Skip to content

Github action fixes - #3659

Merged
mandre merged 10 commits into
gophercloud:mainfrom
shiftstack:gha-fixes
Mar 25, 2026
Merged

mandre merged 10 commits into
gophercloud:mainfrom
shiftstack:gha-fixes

Conversation

@mandre

@mandre mandre commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Various fixes for github actions, spotted by zizmor.

Also add a new zizmor github action to scan for potential security risks on workflow changes.

@github-actions github-actions Bot added edit:actions This PR updates GitHub Actions code edit:testinfra This PR updates testing infrastructure code labels Mar 25, 2026
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions github-actions Bot added semver:patch No API change backport-v2 This PR will be backported to v2 labels Mar 25, 2026
@coveralls

coveralls commented Mar 25, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 63.859%. remained the same
when pulling 54ebc36 on shiftstack:gha-fixes
into db6acc1 on gophercloud:main.

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

I'm not entirely sure about the necessity of replacing tags with refs for the github.com/actions/* actions (which is managed by GitHub) or github.com/gophercloud/devstack-action action (which is managed by us) but I guess it is best practice. The rest of this looks sane.

@mandre

mandre commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

I'm not entirely sure about the necessity of replacing tags with refs for the github.com/actions/* actions (which is managed by GitHub) or github.com/gophercloud/devstack-action action (which is managed by us) but I guess it is best practice. The rest of this looks sane.

I agree. If you don't mind, I'll address this in a follow-up tomorrow, and restore the tag based behavior for the actions we consider safe so that dependabot continues updating them.

@mandre
mandre enabled auto-merge March 25, 2026 17:44
@mandre
mandre disabled auto-merge March 25, 2026 20:57
@mandre
mandre enabled auto-merge March 25, 2026 20:57
@mandre
mandre disabled auto-merge March 25, 2026 20:58
@mandre
mandre enabled auto-merge March 25, 2026 20:58
mandre added 10 commits March 25, 2026 21:59
The condition was using separate ${{ }} expressions around an ==
operator, which expands to a non-empty string that always evaluates
to true. Move the comparison inside a single expression so it
evaluates correctly as a boolean.

Reported by zizmor (unsound-condition).
Prevent the GitHub token from being persisted in the git config
after checkout. This avoids potential credential leakage through
artifacts or subsequent steps that don't need repository access.

Reported by zizmor (artipacked).
Apply the principle of least privilege by adding explicit permissions
blocks to every job that was relying on default (overly broad)
permissions. Each job now declares only the permissions it needs.

Reported by zizmor (excessive-permissions).
Replace ${{ env.* }} expressions in shell run blocks with native
shell variable references ($VAR), and pass ${{ github.base_ref }}
through an env variable instead of expanding it directly in a shell
command. This prevents potential code injection through template
expansion.

Reported by zizmor (template-injection).
Pin all third-party action references to their full commit SHA to
prevent supply-chain attacks through tag manipulation. A version
comment is added after each SHA for maintainability.

Reported by zizmor (unpinned-uses).
Add inline zizmor ignore comments for secrets used outside a
dedicated GitHub Environment. Fixing this properly requires
external repository configuration (creating a GitHub Environment)
which cannot be done from code alone.

Reported by zizmor (secrets-outside-env).
The hold job has zero permissions, no secrets access, and no code
checkout, so the privileged pull_request_target trigger is
unnecessary. The merge_group trigger remains as the tamper-proof
gate for the merge queue.

Reported by zizmor (dangerous-triggers).
The pull_request_target trigger is required here to access secrets
for the backport bot token. The workflow is safe: it only runs on
merged PRs (github.event.pull_request.merged guard), does not
checkout or execute any PR code, and uses a dedicated GitHub App
token for creating backport PRs.

Reported by zizmor (dangerous-triggers).
Extract the semver analysis (checkout, rebase, go-apidiff) into a
new semver.yaml workflow triggered by pull_request, which runs in
the unprivileged fork context. The privileged labeling logic stays
in label-pr.yaml as a new semver-label job triggered by workflow_run
on completion of the analysis. PR number and base ref are resolved
via the GitHub API from the workflow_run head SHA.

The edits job (actions/labeler) remains on pull_request_target with
an event_name guard. Both triggers are suppressed with inline
comments: neither job checks out or executes PR code.

Reported by zizmor (dangerous-triggers).
Run zizmor on pushes to master and pull requests that modify
workflow files. Results are uploaded as SARIF to GitHub's
security-events API for code scanning integration.
@mandre
mandre added this pull request to the merge queue Mar 25, 2026
Merged via the queue into gophercloud:main with commit 8d07d46 Mar 25, 2026
66 checks passed
@mandre
mandre deleted the gha-fixes branch March 25, 2026 21:55
@github-actions

Copy link
Copy Markdown

Failed to backport PR to v2 branch. See logs for details.

@mandre

mandre commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

I'm not entirely sure about the necessity of replacing tags with refs for the github.com/actions/* actions (which is managed by GitHub) or github.com/gophercloud/devstack-action action (which is managed by us) but I guess it is best practice. The rest of this looks sane.

I agree. If you don't mind, I'll address this in a follow-up tomorrow, and restore the tag based behavior for the actions we consider safe so that dependabot continues updating them.

@stephenfin I'm confused now, looking at #3654 dependabot still updates the action when it pinned to a SHA rather than version tag.

@stephenfin

Copy link
Copy Markdown
Contributor

I'm not entirely sure about the necessity of replacing tags with refs for the github.com/actions/* actions (which is managed by GitHub) or github.com/gophercloud/devstack-action action (which is managed by us) but I guess it is best practice. The rest of this looks sane.

I agree. If you don't mind, I'll address this in a follow-up tomorrow, and restore the tag based behavior for the actions we consider safe so that dependabot continues updating them.

@stephenfin I'm confused now, looking at #3654 dependabot still updates the action when it pinned to a SHA rather than version tag.

Oh, then let's stick with hashes for everything so. I didn't expect that to work either.

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

Labels

backport-v2 This PR will be backported to v2 edit:actions This PR updates GitHub Actions code edit:testinfra This PR updates testing infrastructure code semver:patch No API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants