Skip to content

fix(ci): validate the dispatched version and send it with --raw-field - #1731

Open
skritosss wants to merge 1 commit into
generative-computing:mainfrom
skritosss:patch-1
Open

skritosss wants to merge 1 commit into
generative-computing:mainfrom
skritosss:patch-1

Conversation

@skritosss

Copy link
Copy Markdown

Pull Request

Issue

Fixes #1722

Description

The two changes proposed in #1722, applied to .github/workflows/dispatch-to-contribs.yml:

  • Resolve version rejects anything that is not X.Y.Z with an ::error:: before it is written to $GITHUB_OUTPUT, so a manual workflow_dispatch input with a newline cannot add step outputs.
  • Dispatch to mellea-contribs uses --raw-field instead of --field, so a value starting with @ is sent as text and never read as a file from the runner. Both values are plain strings, so the payload contributors receive is unchanged.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

The run steps use the default bash shell on ubuntu-latest, so [[ =~ ]] works. I checked the regex in bash: 0.9.0 and 1.2.3 pass; 1.2.3\nfoo=bar, @/etc/passwd, 0.9.0rc1 and v0.9.0 are rejected. zizmor reports no findings on the file. The workflow itself only runs on a release, so I could not run it from a fork.

Attribution

  • AI coding assistants used (Claude)

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

Reject a version that is not X.Y.Z before it is written to $GITHUB_OUTPUT,
and send the dispatch payload with gh's --raw-field so a value starting
with @ is never read as a file.

Fixes generative-computing#1722

Assisted-by: Claude

Signed-off-by: Alex Shuvalov <shuv.aleksandr@icloud.com>
@skritosss
skritosss requested a review from a team as a code owner October 13, 2026 16:26
@github-actions github-actions Bot added the bug Something isn't working label Oct 13, 2026

@planetf1 planetf1 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.

Verified both changes against the issue:

  • Ran the regex in bash: 0.9.0 and 1.2.3 are accepted; 1.2.3rc1, v0.9.0, @/etc/passwd, 1.2.3\nfoo=bar, 1.2.3.4, empty and trailing-space values are all rejected. The newline injection and @-prefixed file paths from #1722 are both closed off before the value reaches $GITHUB_OUTPUT or the dispatch call.
  • gh api --help confirms -F/--field is the typed flag that reads @<path> values from disk, while -f/--raw-field sends the literal string. Both values here are plain strings, so the payload mellea-contribs receives is unchanged.
  • zizmor reports no findings on the modified workflow.

The run steps use the default bash shell on ubuntu-latest, so [[ =~ ]] is fine.

@markstur markstur 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.

See inline. The injection problem was fixed, but also introduced in the error handling.

VERSION="${GITHUB_REF#refs/tags/v}"
fi
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version '${VERSION}'; expected X.Y.Z"

@markstur markstur Oct 22, 2026 •

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.

The new ::error:: message interpolates the raw unvalidated VERSION. A dispatch with a version input containing \n::stop-commands::t fails the regex (good) but the echo then emits the raw multi-line value, and the runner parses those lines as workflow commands. Same injection class the PR exists to close, relocated. Fix: echo a quoted/escaped form or just "Invalid version; expected X.Y.Z" without the value.

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.

@skritosss please take a look at the injection problem with the new error message

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: harden dispatch-to-contribs.yml: validate version and use --raw-field

3 participants