fix(workflows): shell step validate() rejects non-string run#3348
Merged
Conversation
ShellStep.validate() only checked that 'run' was present, so run: (null) or a GitHub-Actions-style list validated clean; execute() then str()-coerces the value and invokes it under shell=True, literally running 'None' or "['echo', 'hi']" as a command. Add a type check after the presence check, mirroring the command-step (github#3262) and gate options validation. Expression strings ('{{ ... }}') are strings, so they stay valid. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens workflow shell-step validation to prevent non-string run values (e.g., null, lists, ints) from passing validation and later being coerced to a Python repr that gets executed under shell=True.
Changes:
- Add a type check in
ShellStep.validate()to reject non-strrunvalues with a clear validation error. - Add tests to assert non-string
runis rejected and that normal strings / expression strings are accepted.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/steps/shell/__init__.py |
Enforces run must be a string during validation to prevent executing coerced repr values. |
tests/test_workflows.py |
Adds regression tests covering rejection of non-string run values and acceptance of valid string forms. |
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: 0
- Review effort level: Low
Collaborator
|
Thank you! |
kanfil
added a commit
to tikalk/agentic-sdlc-spec-kit
that referenced
this pull request
Jul 8, 2026
Upstream commits merged (9): - 0151d23 agy honors SPECKIT_INTEGRATION_AGY_EXTRA_ARGS (github#3347) - fb796c2 shell step validate() rejects non-string run (github#3348) - 220e6fc fan-in validate() rejects non-mapping output (github#3349) - 12faf7b workflow run/resume errors to stderr under --json (github#3352) - d5ba062 bundle update uninstalls dropped components (github#3353) - f1a8d8f release 0.12.7, begin 0.12.8.dev0 (github#3398) - 10d4bca guard _sha256 against unreadable managed files (github#3376) - a307894 return None on malformed GHES port (github#3379) - 882e1e9 exit cleanly on malformed IPv6 URLs in add commands (github#3369) Conflict: presets/_commands.py — combined IPv6 try/except + _esc() with fork accent() theming. Assisted-by: OpenCode (model: glm-5.2, autonomous)
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.
Description
ShellStep.validate()only checks thatrunis present:So
run:(null) or a GitHub-Actions-style list validates clean.execute()then does:and invokes that under
shell=True— literally running the Python repr as a command. Reproduced on main @bba473c:validate({'id':'s','run':None})andvalidate({'id':'s','run':['echo','hi']})both return[], and execute then runs'None'/['echo'...(shell error "'None' is not recognized").Fix
Add a type check after the presence check, mirroring the command-step (#3262) and gate-options validation patterns. An expression like
{{ steps.x.output }}is still astr, so expression configs stay valid.Testing
test_validate_rejects_non_string_runparametrized overNone, a list, and an int → all now report'run' must be a string. Fails before (validate returns[]— verified by source-stash), passes after.test_validate_accepts_string_and_expression_run: plain and{{ ... }}strings return[].TestShellStep: 11 passed.uvx ruff checkclean.Note: open PR #3328 also edits this
validate()(addstimeoutvalidation) and theTestShellStepregion — I placed the new checks/tests in distinct spots to minimize any textual conflict; the two changes are independent.AI Disclosure
Found and fixed with Claude Code (Claude Fable 5) under my direction. AI flagged the validate-vs-execute type gap; I reproduced the shell-injection of the repr, verified fail-before/pass-after, and reviewed the diff.