class

Analyzer::Swift::Cli

Inherits CliEndpointSupport < Analyzer < FileHelper < Reference < Object

Surfaces the command-line attack surface of Swift programs as cli:// endpoints: one endpoint per (sub)command with named options (param_type "flag"), positional arguments ("argument") and consumed environment variables ("env"). Covers swift-argument-parser plus builtin CommandLine.arguments / ProcessInfo.environment / getenv.

Line-scan analyzer (Go/Ruby/Rust CLI house style) merging endpoints by URL. Subclasses Analyzer directly (SwiftEngine#analyze_file is abstract) and reuses SwiftEngine.swift_test_path? to skip tests.

Constants

ARGS_IDX = /\bCommandLine\.arguments\s*\[\s*(\d+)\s*\]/
ARGUMENT_WRAP = /@Argument\b/
COMMAND_NAME = /\bcommandName:\s*"([^"]+)"/
CUSTOM_LONG = /name:\s*\.(?:customLong|long)\s*\(\s*"([^"]+)"/
GETENV = /\bgetenv\s*\(\s*"([^"]+)"/
OPTION_FLAG = /@(?:Option|Flag)\b/
PARSABLE_STRUCT = /\b(?:struct|enum|class)\s+(\w+)\s*:\s*[^\{]*\b(?:Async)?ParsableCommand\b/
PROC_ENV = /ProcessInfo(?:\.processInfo|\(\))?\.environment\s*\[\s*"([^"]+)"\s*\]/
SUBCOMMANDS_KEY = /\bsubcommands:/
VAR_DECL = /\bvar\s+(\w+)/
WEB_FRAMEWORK_RE = /\bimport\s+(?:Vapor|Hummingbird\w*|Kitura\w*)\b|\bapp\.environment\b/

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

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.

Source