ci: add zizmor pre-commit hook and harden GitHub Actions workflows#40
Open
ci: add zizmor pre-commit hook and harden GitHub Actions workflows#40
Conversation
Add `zizmor` (GitHub Actions security linter) as a pre-commit hook to catch workflow security issues during development. Pin all GitHub Actions and pre-commit hooks to commit SHAs for supply chain security. Add `persist-credentials: false` to `actions/checkout` steps to prevent credential leakage through artifacts. Suppress `unpinned-images` for the Testing Farm container (we always want latest) and `secrets-outside-env` (overkill for this repo). Assisted-by: Claude Code Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
Reviewer's GuideThis PR hardens CI by pinning all GitHub Actions and pre-commit hooks to immutable commit SHAs, introduces zizmor-based security linting for workflows, and adds explicit suppressions and settings needed to keep existing container behavior while satisfying the new linting rules. Flow diagram for pre-commit and workflow security linting with zizmorflowchart LR
A[Developer edits workflows and scripts] --> B[git commit]
B --> C[pre-commit runs]
subgraph Pre_commit_hooks
C1[Shellcheck_py]
C2[Pre_commit_hooks]
C3[Gitleaks]
C4[Markdownlint_cli]
C5[Codespell]
C6[Zizmor_pre_commit lints GitHub_Actions_workflows]
end
C --> C1
C --> C2
C --> C3
C --> C4
C --> C5
C --> C6
C1 --> D{All hooks pass?}
C2 --> D
C3 --> D
C4 --> D
C5 --> D
C6 --> D
D -- No --> E[Developer fixes issues and recommits]
D -- Yes --> F[Push to GitHub]
F --> G[GitHub Actions workflows run with pinned action SHAs]
subgraph Zizmor_suppressions_in_CI
H1[Testing_Farm_container image latest with ignore_unpinned_images]
H2[Secrets in env with ignore_secrets_outside_env]
end
G --> H1
G --> H2
G --> I[Workflows complete with hardened security configuration]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- For the
zizmorsuppressions in the container workflow (unpinned-imagesandsecrets-outside-env), consider expanding the inline comments to briefly explain the rationale (e.g., needinglatestfor Testing Farm CLI and why env-based secrets are acceptable here) so future changes don’t accidentally remove or misuse these ignores.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- For the `zizmor` suppressions in the container workflow (`unpinned-images` and `secrets-outside-env`), consider expanding the inline comments to briefly explain the rationale (e.g., needing `latest` for Testing Farm CLI and why env-based secrets are acceptable here) so future changes don’t accidentally remove or misuse these ignores.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Add `environment: build` to the container build job so secrets are scoped to a dedicated GitHub environment instead of being accessible repo-wide. This addresses the `secrets-outside-env` zizmor finding properly rather than suppressing it. Also expand the `unpinned-images` suppression comment with rationale. Assisted-by: Claude Code Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.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.
Summary
zizmoras a pre-commit hook to lint GitHub Actions workflows for security issuesactions/checkout,actions/setup-python,peaceiris/actions-gh-pages,peter-evans/create-pull-request) to commit SHAsshellcheck-py,pre-commit-hooks,gitleaks,markdownlint-cli,codespell,zizmor-pre-commit) to commit SHAspersist-credentials: falsetoactions/checkoutsteps inmkdocs.ymlandrefresh-build-fmf.ymlunpinned-imagesfor the Testing Farm container (always want latest)secrets-outside-envfor repository secrets (GitHub environments are overkill here)container.yml.j2template to match generatedcontainer.ymlsuppressionsAssisted-by: Claude Code
Summary by Sourcery
Harden CI and GitHub Actions security by pinning dependencies and adding workflow linting.
New Features:
Enhancements: