Skip to content

harden: remove shell parameter from run_command()#3716

Merged
mnriem merged 1 commit into
github:mainfrom
mnriem:mnriem-fix-harden-run-command-shell
Jul 24, 2026
Merged

harden: remove shell parameter from run_command()#3716
mnriem merged 1 commit into
github:mainfrom
mnriem:mnriem-fix-harden-run-command-shell

Conversation

@mnriem

@mnriem mnriem commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

run_command() in src/specify_cli/_utils.py enforces a list[str] argv contract and always runs with shell=False. The shell parameter it exposed served no functional purpose — shell=True was 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 ValueError guard) so shell=False is 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 the shell parameter and the ValueError guard from run_command(); update the docstring to document the argv-list contract.
  • tests/test_utils.py: the regression test now asserts shell is absent from the signature and that passing shell= raises TypeError.

Notes

  • No call sites used shell= — the only reference in the repo was the test.
  • Full test suite passes (5074 passed, 6 skipped).

Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous)

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
Copilot AI review requested due to automatic review settings July 24, 2026 14:07
@mnriem mnriem self-assigned this Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/specify_cli/_utils.py
@mnriem
mnriem merged commit 1631c0a into github:main Jul 24, 2026
14 checks passed
@mnriem
mnriem deleted the mnriem-fix-harden-run-command-shell branch July 24, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants