Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
19 changes: 18 additions & 1 deletion tests/nodes/analyzers/test_security_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down