From 0946521274b6aa4dd27b9f7aee7911253b640723 Mon Sep 17 00:00:00 2001 From: yashrajbasav Date: Wed, 9 Sep 2026 15:43:40 +0530 Subject: [PATCH] fix: preserve partial coverage for runtime printf paths Signed-off-by: yashrajbasav --- .../analyzers/static_patterns_tool_misuse.py | 8 ++++++++ .../analyzers/test_security_reconstruction.py | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/skillspector/nodes/analyzers/static_patterns_tool_misuse.py b/src/skillspector/nodes/analyzers/static_patterns_tool_misuse.py index 874e191e4b..ce6a4bb505 100644 --- a/src/skillspector/nodes/analyzers/static_patterns_tool_misuse.py +++ b/src/skillspector/nodes/analyzers/static_patterns_tool_misuse.py @@ -708,6 +708,14 @@ def _consume_printf_invocation( # invocation or wrapper word. Its basename is not deterministic. return True, False command = word.casefold().rsplit("/", 1)[-1] + if _RUNTIME_SHELL_PARAMETER_SENTINEL in word and command in { + "printf", + "command", + "builtin", + "env", + }: + # A known basename does not make a runtime-selected executable exact. + return True, False if command == "printf": return True, True if command == "command": diff --git a/tests/nodes/analyzers/test_security_reconstruction.py b/tests/nodes/analyzers/test_security_reconstruction.py index 44ee565858..cf9a12a7b4 100644 --- a/tests/nodes/analyzers/test_security_reconstruction.py +++ b/tests/nodes/analyzers/test_security_reconstruction.py @@ -1664,15 +1664,32 @@ def test_long_quoted_command_path_still_detects_destructive_basename() -> None: [ "$(printf $FORMAT) -rf /", "$(printf ${FORMAT}) -rf /", + "$($BIN/printf echo) -rf /", + "$(${BIN}/printf echo) -rf /", + '$("$BIN/printf" echo) -rf /', + "$($BIN/env printf echo) -rf /", + "$($BIN/command printf echo) -rf /", + "$($BIN/builtin printf echo) -rf /", '`"${TOOL:-$(printf rm ' + " " * 300 + ')}"` -rf /', ], - ids=["runtime-format", "braced-runtime-format", "nested-parameter-reconstruction"], + ids=[ + "runtime-format", + "braced-runtime-format", + "runtime-path", + "braced-runtime-path", + "quoted-runtime-path", + "runtime-env-path", + "runtime-command-path", + "runtime-builtin-path", + "nested-parameter-reconstruction", + ], ) def test_runtime_printf_arguments_and_nested_reconstruction_stay_partial(content: str) -> None: result = static_runner.run_static_patterns_with_ledger( {"components": ["SKILL.md"], "file_cache": {"SKILL.md": content}}, [tm_module] ) + assert result["inspection_ledger"][0]["outcome"] is LedgerOutcome.PARTIAL assert result["inspection_ledger"][0]["reason_code"] is LedgerReason.STATIC_PARSE_LIMIT