You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mcpx(affected-tests): --run executes shell syntax from changed paths #5649
affected-tests.py --run executes shell commands containing Git-reported paths without quoting them. The script collects changed and untracked paths at pkgs/mcpx/scripts/affected-tests.py:366-371, interpolates .go paths and package directories into command strings at :399-404 and :412-414, then runs each string with subprocess.run(..., shell=True) at :605-608. The repo-level mcpx-test-affected recipe exposes the --run argument (root.just:187-191).
A controlled scratch-repository probe confirmed arbitrary shell syntax in a space-free untracked .go filename executed during --run and created a marker file. The probe ran outside the laptop checkout. Current selector tests explicitly use the dry-run seam and never --run (pkgs/mcpx/scripts/tests/test_affected_untracked.py:12-19,85-99).
Why it matters
A developer running the documented affected-test command with --run against an untrusted branch can execute commands from a crafted filename. This turns a local test-selection convenience into a shell-execution boundary.
Suggested fix
Keep Git paths as structured values (prefer NUL-delimited Git output), build argument vectors for gofmt, go vet, and go test, and use cwd= rather than shell cd strings. Add a scratch-repo regression test with shell metacharacters in a filename and assert that no marker command runs.
Triage evidence (2026-11-05, fresh read of current main via gh api):
pkgs/mcpx/scripts/affected-tests.py is 614 lines at current main; the --run loop still executes with subprocess.run(cmd, cwd=root, shell=True) (line 608).
Commands are built as strings interpolating Git-reported paths unquoted: the gofmt -l command joins pkgs/mcpx/{p} paths with spaces, and go vet / go test commands interpolate package directories via pkg_arg() — a crafted path containing shell syntax reaches the shell unchanged.
No open PR fixes this path (PR fix(mcpx): include untracked contents in affected-tests (#3320) #4398 covered untracked-file contents, a different change), and no live fix task existed — enqueued task 10479 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:5649).
Fix path (as scoped on the issue): keep Git paths structured (NUL-delimited output), argv vectors for gofmt/go vet/go test, cwd= instead of shell cd, plus a scratch-repo regression test with shell metacharacters in a filename asserting no marker executes.
Fix: PR fix(mcpx): affected-tests --run executes argv, never a shell (#5649) #8672 merged 2026-11-11T12:45Z (merge commit 147aef2) — affected-tests.py no longer builds shell strings from Git-reported paths. Collection is NUL-delimited (git ls-files -z / git diff --name-only -z); every tier command carries an argv vector + explicit cwd and --run executes argv with no shell (no shell=True remains). Dry-run display strings are byte-identical for ordinary paths, so the existing selector tests and the mcpx-test-affected recipe are unaffected.
Review: Codex round 1 found three real gaps, all fixed in 0f2a00d and re-reviewed clean — the new suite is wired into the Go-equipped unit job in mcpx-test.yml and registered as mcpx.scripts.affected-run-injection; run() decodes subprocess output with surrogateescape so non-UTF-8 filename bytes can't crash the selector; the space-in-filename test now asserts the whole path appears in the executed commands (it could pass vacuously before).
Tests: new test_affected_run_injection.py drives the real selector with --run in a scratch repo — $(touch…) and ;touch… filenames create no marker, a spaced filename stays one path. Full pkgs/mcpx/scripts/tests discover green (23 tests) pre-merge.
Activity
developing-today commentedon Nov 4, 2026
CODE-1407
dezren39 commentedon Nov 5, 2026
🤖 Agent note · done
Triage evidence (2026-11-05, fresh read of current main via
gh api):pkgs/mcpx/scripts/affected-tests.pyis 614 lines at current main; the--runloop still executes withsubprocess.run(cmd, cwd=root, shell=True)(line 608).gofmt -lcommand joinspkgs/mcpx/{p}paths with spaces, andgo vet/go testcommands interpolate package directories viapkg_arg()— a crafted path containing shell syntax reaches the shell unchanged.repo-health:v1:fix:developing-today/code:issue:5649).cwd=instead of shellcd, plus a scratch-repo regression test with shell metacharacters in a filename asserting no marker executes.developing-today commentedon Nov 5, 2026
🤖 Agent note · handed off
149 remaining items
fix(mcpx): wire run-injection suite into CI; surrogateescape git outp…
Merge pull request #8672 from developing-today/queue/10479-5649-affec…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (task 10479, lane code-d)
affected-tests.pyno longer builds shell strings from Git-reported paths. Collection is NUL-delimited (git ls-files -z/git diff --name-only -z); every tier command carries an argv vector + explicit cwd and--runexecutes argv with no shell (noshell=Trueremains). Dry-run display strings are byte-identical for ordinary paths, so the existing selector tests and themcpx-test-affectedrecipe are unaffected.mcpx-test.ymland registered asmcpx.scripts.affected-run-injection;run()decodes subprocess output with surrogateescape so non-UTF-8 filename bytes can't crash the selector; the space-in-filename test now asserts the whole path appears in the executed commands (it could pass vacuously before).test_affected_run_injection.pydrives the real selector with--runin a scratch repo —$(touch…)and;touch…filenames create no marker, a spaced filename stays one path. Fullpkgs/mcpx/scripts/testsdiscover green (23 tests) pre-merge.