harden: remove shell parameter from run_command()#3716
Merged
Conversation
run_command() enforces a list[str] argv contract, so a shell parameter served no purpose beyond keeping an unnecessary shell-injection surface that a future refactor could re-enable. Remove the parameter (and its now-dead ValueError guard) so shell=False is the only possible behavior. Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74a1bd02-f6cd-412a-b5a8-a7767a5e058d
Contributor
There was a problem hiding this comment.
Pull request overview
Removes run_command()’s shell parameter to enforce shell-free execution through its signature.
Changes:
- Removes the parameter and runtime guard.
- Adds regression coverage for rejecting
shell=.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/_utils.py |
Simplifies run_command() and documents its argv contract. |
tests/test_utils.py |
Verifies the new signature and TypeError behavior. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
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.
Summary
run_command()insrc/specify_cli/_utils.pyenforces alist[str]argv contract and always runs withshell=False. Theshellparameter it exposed served no functional purpose —shell=Truewas already rejected at runtime — but it left an unnecessary shell-injection surface that a future refactor could accidentally re-enable.This removes the parameter (and its now-dead
ValueErrorguard) soshell=Falseis the only possible behavior, enforcing the intended design at the signature level rather than guarding it at runtime.Changes
src/specify_cli/_utils.py: drop theshellparameter and theValueErrorguard fromrun_command(); update the docstring to document the argv-list contract.tests/test_utils.py: the regression test now assertsshellis absent from the signature and that passingshell=raisesTypeError.Notes
shell=— the only reference in the repo was the test.Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous)