Skip to main content

Module utils

Module utils 

Source
Expand description

Shared utilities for rule implementations.

This module contains helper functions and types used across multiple rules, particularly for source code analysis that needs to handle string literals correctly.

Structs§

StringLiteralState
State machine for tracking string literal boundaries across lines.

Constants§

INPUT_SOURCE_PATTERNS
Input source patterns for untrusted data origins. Used by multiple injection rules.
LOG_SINK_PATTERNS
Log sink patterns in MIR (desugarings of print/log macros). Used by both CleartextLoggingRule and LogInjectionRule.

Functions§

collect_sanitized_matches
Collect lines that match any of the given patterns after sanitizing string literals.
command_rule_should_skip
Check if a function should be skipped for command injection rules.
filter_entry
Filter function for WalkDir to skip common non-source directories.
strip_comments
Strip comments from a line of code.
strip_string_literals
Replaces string literal content with spaces while preserving line length.