Skip to main content

Module shell_scan

Module shell_scan 

Source
Expand description

Shell-aware command normalization: reduce a command to a scannable form before pattern matching.

Structs§

ShellScan
Words of each simple command plus the bodies of command substitutions.

Functions§

has_dangerous_structure
True when the command’s structure (argv, pipelines, evaluated substitutions) is dangerous regardless of the literal text: recursive root deletes, remote payloads fed to a shell, or eval of a fetched script.
scan_shell
Split input into simple commands (quote-aware) and command-substitution bodies.
scannable_command
Reduce command to a form where quoting, wrappers and nested shell payloads no longer hide the executable text. The result may span several lines: the unquoted original followed by each recursively normalized executed payload.
segment_consumes_shell_stdin
True when the simple command reads its script from stdin (bash -s, sh -, /dev/stdin, …), including through wrapper binaries such as sudo or env -S.
shell_pipelines
Pipelines of the input, each as its segment strings (only pipelines with 2+ stages).