Skip to content

Commit 638792c

Browse files
committed
fix(analyzer): preserve bounded native shell-decoder matching
Signed-off-by: yashrajbasav <[email protected]>
1 parent 6e39d4e commit 638792c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎docs/ANALYSIS_RESOURCE_BOUNDS.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ searches remain outside it. The anti-refusal schema-field helper uses a linear
351351
whitespace prefix so its benign-context check cannot backtrack quadratically.
352352

353353
Audited command/option patterns use a linear, command-segment search that preserves
354-
unbounded command spans and the original greedy matches. Memory poisoning's
354+
unbounded command spans and the original greedy matches. The SC3 shell-decoder
355+
rules keep their native matcher: their literals, stages and options already have
356+
explicit length/count bounds and atomic or possessive ambiguous groups. Memory poisoning's
355357
2–20-character repetition rule uses Python's native engine: failed candidates
356358
examine at most 20 copies, and successful candidates consume the repeated run.
357359
The variable shell-flag rule also retains Python’s native backreference semantics.

‎src/skillspector/nodes/analyzers/static_patterns_supply_chain.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,8 +2282,13 @@ def line_number(start: int) -> int:
22822282
if has_shell_decoder:
22832283
sc3_patterns = sc3_patterns + SC3_SHELL_PATTERNS
22842284
for pattern, confidence in sc3_patterns:
2285+
# Shell-decoder rules already bound every stage/literal and use atomic
2286+
# or possessive ambiguous groups. Keep their audited native matcher;
2287+
# the interruptible engine adds enough cost to reject dense input.
22852288
matches = (
2286-
static_runner.iter_paragraph_matches
2289+
re.finditer
2290+
if (pattern, confidence) in SC3_SHELL_PATTERNS
2291+
else static_runner.iter_paragraph_matches
22872292
if (pattern, confidence) in SC3_PROSE_PATTERNS
22882293
else static_runner.iter_pattern_matches
22892294
)

0 commit comments

Comments
 (0)