Skip to main content

Module parser

Module parser 

Source
Expand description

Bash AST parser wrapper around tree-sitter-bash.

Converts tree-sitter’s raw [tree_sitter::Node] graph into a friendlier Node tree that the security analyzer consumes. All offsets are UTF-8 byte offsets and Node::text is sliced directly from the original source so callers never have to manage tree-sitter lifetimes themselves.

Structs§

Node
A node in the bash AST.
SimpleCommand
A simple command with its argv, leading environment assignments, and redirects.

Enums§

RedirectOp
A redirect operator canonical enum.

Constants§

ARGUMENT_KINDS
Kinds that are considered literal words / arguments.
DANGEROUS_KINDS
Named node kinds that represent compound / dynamic shell constructs. If any of these appear in a command, we refuse to extract a static argv.
STRUCTURAL_KINDS
Kinds that wrap multiple commands.

Functions§

is_argument_kind
Returns true if the node kind is an argument-like token.
is_command_kind
Returns true if the node kind is a command name or declaration command.
parse
Parse a bash command string into an AST.
parse_variable_assignment
Simple field-name to value map for a variable_assignment node.
redirect_op_from_kind
Maps a tree-sitter redirect operator kind to its canonical form.