Analyzer::Ruby::Cli
Inherits CliEndpointSupport < Analyzer::Ruby::RubyEngine < Analyzer < FileHelper < Reference < Object
Surfaces the command-line attack surface of Ruby programs as cli://
endpoints: one endpoint per (sub)command, with named options
(param_type "flag"), positional arguments ("argument") and consumed
environment variables ("env"). Covers stdlib OptionParser / ARGV plus
Thor, GLI, Slop, TTY::Option, the commander gem, Optimist, Clamp and
dry-cli.
Line-scan analyzer (house style for non-tree-sitter Ruby adapters), merging endpoints by URL across files.
Constants
builtin argv / env.
GLI / commander gem command blocks + flags.
Clamp: class Foo < Clamp::Command with option/parameter DSL and
optional nested subcommand "name", "desc" do ... end blocks. The DSL
call's first argument (the switch name or an array of switch names)
must appear immediately after option + whitespace — a (?=["'\[])
lookahead — so an unrelated local/instance variable assignment like
option = default? ? "--json" : "--text" cannot masquerade as the
DSL call just because a dash-prefixed quoted string appears somewhere
later on the line. Mirrors CLAMP_PARAMETER, which already requires the
quote directly after the keyword.
cli_evidence? runs once per .rb file and OR-ed four String#includes?
scans as a standalone boolean gate. Folded into one precompiled union
so the literal-marker half of the gate costs a single PCRE2 match
instead of up to four naive substring scans.
cli_evidence? is the gate every .rb in the tree passes through,
and it OR-ed seven separate whole-file scans. One union is the same
predicate in a single pass; the individual patterns are still needed
below, where each one sets its own flag.
Program-name hints.
Instance methods only: def self.exit_on_failure? (standard Thor
boilerplate) is a class method, never a command, so the name must be
followed by an argument list, whitespace or end-of-line — not ..
dry-cli: class Build < Dry::CLI::Command with option/argument
DSL; each subclass is its own (sub)command. DRY_CLI_MARKER (unanchored)
is for whole-content evidence checks; DRY_CLI_CLASS (line-anchored, to
capture indent) is for the per-line scan — ^ in Crystal only matches
the very start of a multi-line string, not after every \n.
Optimist: opt :name, "desc", type: :string — a flat parser (no
subcommand DSL), gated on the block-opening call so a bare local
variable/method named opt elsewhere doesn't false-positive.
OptionParser: opts.on("-p", "--port PORT") — prefer the long name.
Slop: o.string '-p', '--port'.
Thor DSL.
TTY::Option DSL (only when no Thor class is present, to avoid clashing
with Thor's option).
Web frameworks: their ENV reads are config, not a CLI surface.
Class methods
Instance methods
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.