Skip to content

chore(tools): integrate ratchet for GitHub Actions pinning#19818

Open
janisz wants to merge 2 commits intomasterfrom
pin_actions
Open

chore(tools): integrate ratchet for GitHub Actions pinning#19818
janisz wants to merge 2 commits intomasterfrom
pin_actions

Conversation

@janisz
Copy link
Copy Markdown
Contributor

@janisz janisz commented Apr 3, 2026

Description

Add rachet to lint our workflows and fix pin actions.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

CI

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The ratchet lint command only targets .github/workflows/*.y(a)ml; if you also keep reusable workflows or actions definitions in subdirectories (e.g. .github/workflows/** or .github/actions/**), consider broadening the glob so those files are checked as well.
  • Wiring github-actions-pin-check into the style-slim target means it will run on every style invocation; if that’s heavier or slower than desired for local dev, consider a separate target or a feature flag/variable to make it opt-in outside CI.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The ratchet lint command only targets `.github/workflows/*.y(a)ml`; if you also keep reusable workflows or actions definitions in subdirectories (e.g. `.github/workflows/**` or `.github/actions/**`), consider broadening the glob so those files are checked as well.
- Wiring `github-actions-pin-check` into the `style-slim` target means it will run on every style invocation; if that’s heavier or slower than desired for local dev, consider a separate target or a feature flag/variable to make it opt-in outside CI.

## Individual Comments

### Comment 1
<location path=".github/workflows/style.yaml" line_range="305-312" />
<code_context>
       - name: Check scripts with shellcheck
         run: shellcheck -P SCRIPTDIR -x ./.github/workflows/scripts/*.sh

+  github-actions-pin-check:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v6
+      - uses: ./.github/actions/job-preamble
+        with:
+          gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
+      - uses: actions/setup-go@v6
+        with:
+          go-version-file: go.mod
</code_context>
<issue_to_address>
**🚨 issue (security):** The new pin-check job itself uses tag-based action refs, which may conflict with the intended ratchet policy and cause self-failures.

Because this job runs ratchet with `-format actions`, these `uses: actions/checkout@v6` and `uses: actions/setup-go@v6` lines may be flagged as insufficiently pinned if the policy requires commit SHAs, causing the job to fail on its own workflow. Either pin these actions to specific SHAs (and manage updates via ratchet), or relax the policy to allow major/minor tags for this workflow.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Added validation for GitHub Actions workflow configurations to ensure proper dependency pinning in the CI/CD pipeline.

Walkthrough

A new GitHub Actions workflow validation feature is added using the Ratchet tool to lint and pin GitHub Actions to specific versions. This includes a CI job, Make target, and tool dependencies across workflow configuration and linter tooling files.

Changes

Cohort / File(s) Summary
Workflow & Build Configuration
.github/workflows/style.yaml, Makefile
Added a new CI job github-actions-pin-check that executes a Make target to validate GitHub Actions pinning. Extended the style-slim Make target to include the new check as a prerequisite.
Tool Dependencies
tools/linters/go.mod, tools/linters/tools-import.go
Introduced github.com/sethvargo/ratchet v0.11.4 as a direct Go tool dependency with its transitive dependencies, and added a blank import to the tools manifest file.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes required sections but the main 'Description' section is minimal and contains a typo ('rachet' instead of 'ratchet'). The validation method is only stated as 'CI' without details. Clarify the description with more details about what ratchet does and why it's needed. Fix the typo and provide more context about the validation approach or defer to CI results.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: integrating ratchet tool for GitHub Actions pinning validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pin_actions

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/style.yaml:
- Around line 305-318: The new job github-actions-pin-check was added but not
included in the needs list for slack-on-style-failure, so its failures won't
trigger Slack notifications; update the slack-on-style-failure job's needs array
to include "github-actions-pin-check" (alongside the existing entries) so the
Slack job depends on and runs after the new github-actions-pin-check job.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e69c3485-2245-40a8-90ac-83193bda98d6

📥 Commits

Reviewing files that changed from the base of the PR and between d32cf0a and b20bdf8.

⛔ Files ignored due to path filters (1)
  • tools/linters/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • .github/workflows/style.yaml
  • Makefile
  • tools/linters/go.mod
  • tools/linters/tools-import.go

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.60%. Comparing base (d32cf0a) to head (e58415c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19818   +/-   ##
=======================================
  Coverage   49.60%   49.60%           
=======================================
  Files        2763     2763           
  Lines      208271   208271           
=======================================
  Hits       103309   103309           
  Misses      97294    97294           
  Partials     7668     7668           
Flag Coverage Δ
go-unit-tests 49.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🚀 Build Images Ready

Images are ready for commit e58415c. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.11.x-557-ge58415cb81

janisz and others added 2 commits April 3, 2026 11:31
User request: integrate ratchet tool (github.com/sethvargo/ratchet) into
lint checks to enforce SHA-based pinning of GitHub Actions references.

Changes:
- Added ratchet v0.10.0 to tools/linters module
- Registered ratchet binary in Makefile
- Added github-actions-pin-check target to style-slim
- Added github-actions-pin-check CI job to style workflow

Ratchet will be automatically updated by dependabot (weekly updates of
tools/linters). The check currently fails with 43 unpinned refs, which
is expected until actions are pinned in a follow-up PR.

Partially generated with AI assistance.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Pin all GitHub Actions references to SHA digests and container images
to SHA256 digests to prevent supply chain attacks via compromised or
moved tags. Formatting is preserved - only action/image references are
modified.

Changes:
- 249 GitHub Actions pinned to SHA digests
- 21 container images pinned to SHA256 digests
- 43 files changed, 270 lines modified
- Original version tags preserved in comments

Pinned using custom script based on ratchet v0.11.4 output to preserve
original YAML formatting (no indentation changes).

Partially generated with AI assistance.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@janisz janisz requested a review from davdhacs April 3, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant