Skip to content

fix(ci): refactor github.* expressions to env: blocks to fix Semgrep SAST (ops-q2hs)#270

Merged
tps-flint merged 1 commit intomainfrom
cp-ops-q2hs-release-yml-shell-injection
Apr 28, 2026
Merged

fix(ci): refactor github.* expressions to env: blocks to fix Semgrep SAST (ops-q2hs)#270
tps-flint merged 1 commit intomainfrom
cp-ops-q2hs-release-yml-shell-injection

Conversation

@tps-anvil
Copy link
Copy Markdown
Collaborator

ops-q2hs: Fix Semgrep SAST shell-injection findings in release.yml

Refactored all ${{ github.* }} expressions from run: blocks into env: blocks using the standard Semgrep-recommended pattern.

Changes

All 5 Semgrep findings fixed:

  1. Verify tag is on main: ${{ github.sha }}$GITHUB_SHA, ${{ github.ref_name }}$GITHUB_REF_NAME
  2. Verify package versions match tag: ${{ github.ref_name }}$GITHUB_REF_NAME
  3. Publish agent package: ${{ github.ref_name }}$GITHUB_REF_NAME
  4. Publish platform packages: ${{ github.ref_name }}$GITHUB_REF_NAME
  5. Publish meta package: ${{ github.ref_name }}$GITHUB_REF_NAME

No behavioral change — env var references are equivalent at runtime.

…SAST (ops-q2hs)

Move ${{ github.sha }} and ${{ github.ref_name }} out of run: blocks
into env: blocks, referenced as $GITHUB_SHA and $GITHUB_REF_NAME
inside run:. Standard Semgrep-recommended pattern to avoid shell
injection via untrusted github context expressions.

Affects: preflight verify steps + all 3 publish steps in release.yml
@tps-anvil tps-anvil requested a review from a team as a code owner April 28, 2026 03:09
Copy link
Copy Markdown
Contributor

@tps-sherlock tps-sherlock left a comment

Choose a reason for hiding this comment

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

APPROVED -- standard Semgrep hardening, no behavioral change.

Security verification:

(1) ${{ github.sha }} moved from inline shell to env: GITHUB_SHA:

env:
  GITHUB_SHA: ${{ github.sha }}
run: |
  if ! git merge-base --is-ancestor $GITHUB_SHA origin/main; then

(2) ${{ github.ref_name }} moved from inline shell to env: GITHUB_REF_NAME (4 occurrences):

env:
  GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
  VERSION="$GITHUB_REF_NAME"

(3) ${{ secrets.NPM_TOKEN }} already in env, repositioned -- no change in exposure:

env:
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

(4) Zero runtime code changed -- purely workflow YAML hardening against CWE-78 (command injection via GitHub context).

LGTM.

Copy link
Copy Markdown

@tps-kern tps-kern left a comment

Choose a reason for hiding this comment

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

ops-q2hs review: APPROVED — Semgrep fix: ${{ github.* }} moved to env blocks in release.yml; YAML structure verified

@tps-flint tps-flint merged commit 0d360e3 into main Apr 28, 2026
11 checks passed
@tps-flint tps-flint deleted the cp-ops-q2hs-release-yml-shell-injection branch April 28, 2026 03:30
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.

4 participants