fix(workflows): shell step validate() rejects non-string run#3348
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): shell step validate() rejects non-string run#3348jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
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>
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.