Skip to content

Commit d148c9c

Browse files
committed
test(analyzer): keep new shell rules on interruptible matching
Signed-off-by: yashrajbasav <[email protected]>
1 parent 9510cf6 commit d148c9c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎tests/nodes/analyzers/test_static_patterns.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,3 +3184,21 @@ def test_nontrivial_short_paragraphs_remain_bounded(length):
31843184
started = perf_counter()
31853185
assert list(static_runner.iter_paragraph_matches(r"never\s+refuse", content)) == []
31863186
assert perf_counter() - started < 2
3187+
3188+
3189+
def test_new_shell_decoder_rules_default_to_interruptible_matching(monkeypatch):
3190+
from skillspector.nodes.analyzers import static_patterns_supply_chain as module
3191+
3192+
pattern = "new-shell-rule"
3193+
reached = []
3194+
original = static_runner.iter_pattern_matches
3195+
3196+
def capture(candidate, *args, **kwargs):
3197+
if candidate == pattern:
3198+
reached.append(candidate)
3199+
yield from original(candidate, *args, **kwargs)
3200+
3201+
monkeypatch.setattr(module, "SC3_SHELL_PATTERNS", [*module.SC3_SHELL_PATTERNS, (pattern, 0.9)])
3202+
monkeypatch.setattr(static_runner, "iter_pattern_matches", capture)
3203+
module.analyze("base64 -d new-shell-rule", "install.sh", "shell")
3204+
assert reached == [pattern]

0 commit comments

Comments
 (0)