module

Noir::OptionsParsing

CLI option parsing: the legacy-alias rewrites, the --set-pvalue / --include / --ai-context target tables, and the helpers that apply them to the options hash.

These were eight top-level defs and five SCREAMING constants leaking into every compilation unit — INCLUDE_TARGETS among them, under a name generic enough to collide. run_options_parser stays top-level: it is the CLI's entry point, same as detect_techs and analysis_endpoints on the scan side.

Constants

INCLUDE_TARGETS = {"path" => "include_path", "techs" => "include_techs", "callee" => "include_callee"}
LEGACY_INCLUDE_TARGETS = {"--include-path" => "include_path", "--include-techs" => "include_techs", "--include-callee" => "include_callee"}
LEGACY_PVALUE_TARGETS = {"--set-pvalue" => "set_pvalue", "--set-pvalue-header" => "set_pvalue_header", "--set-pvalue-cookie" => "set_pvalue_cookie", "--set-pvalue-query" => "set_pvalue_query", "--set-pvalue-form" => "set_pvalue_form", "--set-pvalue-json" => "set_pvalue_json", "--set-pvalue-path" => "set_pvalue_path"}

Silently translate v0 flag spellings to their v1 storage. Keeping the work here (instead of parser.on "--include-path") means the legacy names no longer clutter noir scan -h, while every v0 script keeps working untouched in v1.x.

PVALUE_TYPE_KEYS = {"any" => "set_pvalue", "all" => "set_pvalue", "header" => "set_pvalue_header", "cookie" => "set_pvalue_cookie", "query" => "set_pvalue_query", "form" => "set_pvalue_form", "json" => "set_pvalue_json", "path" => "set_pvalue_path"}

Split TYPE=VAL (or bare VAL → all-types) and route it into the right slot in noir_options. --pvalue may be repeated to set multiple values across different types.

Instance methods

apply_ai_context(noir_options : Hash(String, YAML::Any), spec : String)

--ai-context[=LIST] always enables AI context output. An empty LIST means "every category"; a non-empty LIST narrows the output to the named categories.

Source
apply_include_list(noir_options : Hash(String, YAML::Any), spec : String)
Source
extract_hidden_prompt_flags(noir_options : Hash(String, YAML::Any), reset_seen : Set(String) | Nil = nil) : Array(String)
Source
extract_legacy_aliases(args : Array(String), noir_options : Hash(String, YAML::Any), reset_seen : Set(String) | Nil = nil) : Array(String)
Source
handle_pvalue(noir_options : Hash(String, YAML::Any), spec : String, reset_seen : Set(String) | Nil = nil)
Source
normalize_ai_context_flag(args : Array(String)) : Array(String)
Source
validate_ai_context_features(spec : String, origin : String)

Rejects AI-context bucket names outside the accepted vocabulary. origin names the source in the error so a config-file typo doesn't read as a command-line one.

Source