Repository navigation
test(workspace): run only the programs the service issues - #7
Merged
Merged
Conversation
The stand-in executed whatever argv the caller posted. CodeQL flags that as py/command-line-injection, and it is a fair reading of the code even though the caller is our own test: nothing constrained it. It now runs find, cat and python and refuses anything else with a 403, so a regression that starts shelling out to a new program fails here instead of executing it. The refusal is loud on purpose — a silent fallback would let the test pass without exercising what it meant to. Verified: ruff clean; full suite 2910 passed, 5 skipped, coverage 93.19%. Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodeQL flags
tests/unit/workspace_server.py:65aspy/command-line-injection. It is a fair reading of the code even though the caller is our own test: the stand-in ran whatever argv was posted to it, with nothing constraining what program that was.Fix.
_execnow checksargv[0]againstALLOWED_PROGRAMS—find,cat,python, which are exactly the three the service under test issues (reads inscan_runner.pyanddependency_inventory.py, plus thepython -cinspect step). Anything else raises and the handler answers 403 with the reason.The refusal is deliberate over a silent fallback: a regression that starts shelling out to a new program should fail the test here, not quietly run it.
This is a real constraint, not a suppression — the server can no longer execute an arbitrary program.
Verified locally:
ruff check: clean🤖 Generated with Claude Code