mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
core/tools: only value-taking options may swallow the program
The wrapper option table listed flags as if they consumed the next token, so the program behind them was skipped: `exec -c git -c init.defaultBranch=main init` resolved to `init` and the policy denied it as a denylisted basename, while `exec -c rm -rf /`, `command -p rm -rf /` and `command -v rm` hid `rm` from the denylist completely and `exec -c python -c …` lost the interpreter review. Drop the entries that take no value — `exec -c`/`-l`, the whole `command` entry, `pkexec --disable-internal-agent`, `su -p`, and `xargs -e` (its argument is optional, and the jammed form needs no entry) — so the resolved program is the one that really runs.
This commit is contained in:
@@ -136,6 +136,14 @@ def test_wrappers_reach_the_interpreter() -> None:
|
||||
assert "$(command)" in reason
|
||||
|
||||
|
||||
def test_value_free_flags_do_not_hide_the_interpreter() -> None:
|
||||
"""``exec -c`` takes no value, so the interpreter behind it is still reviewed."""
|
||||
reason = classify_danger("run_argv", {"argv": ["exec", "-c", "python", "-c", "print(1)"]})
|
||||
assert reason is not None
|
||||
assert "interpreter 'python'" in reason
|
||||
assert "print(1)" in reason
|
||||
|
||||
|
||||
def test_only_the_interpreter_dash_c_becomes_a_placeholder() -> None:
|
||||
reason = classify_danger("run_argv", {"argv": ["ionice", "-c", "2", "python", "-c", "print(1)"]})
|
||||
assert reason is not None
|
||||
|
||||
Reference in New Issue
Block a user