Skip to content

ci: add Harden-Runner audit step to all existing workflows - #326

Merged
robotrocketscience merged 6 commits into
mainfrom
ci/harden-runner-expansion
Apr 30, 2026
Merged

ci: add Harden-Runner audit step to all existing workflows#326
robotrocketscience merged 6 commits into
mainfrom
ci/harden-runner-expansion

Conversation

@yoshi280

@yoshi280 yoshi280 commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds step-security/harden-runner@v2 (audit mode) as the first step of every job in every existing workflow. Pairs with #325 which ships the same step in newly-added workflows.

Workflow Jobs covered
ci.yml pytest
staging-gate.yml secrets-scan, pattern-scan, history-scan, release-docs-check, commit-msg-prefix, pr-body-issue-link
publish.yml publish (highest value — id-token: write + PyPI OIDC)
post-release-docs-issue.yml open-sweep-issue
release-drafter.yml update_release_draft
stale.yml stale
auto-rebase-open-prs.yml rebase (contents: write, force-pushes to PRs)

Audit mode only — no behavior change. Captures the egress baseline so a future block-mode promotion can reject unexpected outbound traffic from a compromised action.

Test plan

  • CI passes on this PR
  • After merge: every workflow run shows a harden-runner step at the top of each job
  • After ~2 weeks of normal traffic: review egress baselines at app.stepsecurity.io and consider promoting high-risk workflows (publish, auto-rebase) to block mode

Follow-up

Promotion to block mode is deliberately deferred. Audit-only first.

Summary by Sourcery

CI:

  • Enable step-security/harden-runner@v2 in audit mode at the start of every job across all GitHub Actions workflows to baseline egress traffic.

Summary by CodeRabbit

  • Chores
    • Added runner hardening across CI/CD and repository workflows to strengthen execution environment; egress policy set to "audit" for the new hardening step, applied consistently before workflow actions.

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robotrocketscience has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 18 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd666de4-984f-4f7d-866b-203481bf786f

📥 Commits

Reviewing files that changed from the base of the PR and between 9650bd6 and 6353181.

📒 Files selected for processing (7)
  • .github/workflows/auto-rebase-open-prs.yml
  • .github/workflows/ci.yml
  • .github/workflows/post-release-docs-issue.yml
  • .github/workflows/publish.yml
  • .github/workflows/release-drafter.yml
  • .github/workflows/staging-gate.yml
  • .github/workflows/stale.yml
📝 Walkthrough

Walkthrough

Adds step-security/harden-runner@v2 with egress-policy: audit as the first step to several GitHub Actions workflows, inserting runner hardening prior to repository checkout across CI, publishing, release, stale, rebase, post-release, and staging-gate jobs.

Changes

Cohort / File(s) Summary
General Workflows
.github/workflows/auto-rebase-open-prs.yml, .github/workflows/ci.yml, .github/workflows/post-release-docs-issue.yml, .github/workflows/publish.yml, .github/workflows/release-drafter.yml, .github/workflows/stale.yml
Prepended step-security/harden-runner@v2 step with egress-policy: audit as the first action in each job, placed before actions/checkout and existing steps.
Staging Gate Jobs
.github/workflows/staging-gate.yml
Inserted the same hardening step (step-security/harden-runner@v2, egress-policy: audit) at the start of multiple jobs (secrets-scan, pattern-scan, history-scan, release-docs-check, commit-msg-prefix, pr-body-issue-link).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding Harden-Runner audit steps across all existing workflows. It is specific, clear, and directly reflects the changeset.
Description check ✅ Passed The description includes a clear summary with a structured table of affected workflows/jobs, a detailed test plan with checkboxes, follow-up notes, and Sourcery summary. However, the Type of change and Verification checkboxes from the template are not explicitly addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/harden-runner-expansion

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 57 minutes and 18 seconds.

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

@sourcery-ai

sourcery-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds the step-security/harden-runner@v2 action in audit mode as the first step of every job across all existing GitHub Actions workflows to capture egress baselines without changing current behavior.

Sequence diagram for GitHub Actions job execution with HardenRunner audit step

sequenceDiagram
  actor Developer
  participant GitHubActions
  participant JobRunner
  participant HardenRunner as HardenRunner_step_security_harden_runner_v2
  participant Checkout as Action_actions_checkout
  participant OtherAction as Other_job_steps
  participant StepSecurityService
  participant ExternalService

  Developer->>GitHubActions: Push commit or open pull_request
  GitHubActions->>GitHubActions: Select workflow and job
  GitHubActions->>JobRunner: Start job on ubuntu_latest

  JobRunner->>HardenRunner: Execute with egress_policy_audit
  HardenRunner->>JobRunner: Configure egress monitoring
  HardenRunner->>StepSecurityService: Send initial job metadata

  JobRunner->>Checkout: Run checkout action
  Checkout->>ExternalService: Fetch repository contents
  ExternalService-->>Checkout: Repository data

  JobRunner->>OtherAction: Run subsequent job steps
  OtherAction->>ExternalService: Make outbound network calls
  ExternalService-->>OtherAction: Responses

  HardenRunner->>StepSecurityService: Report observed egress traffic
  JobRunner->>GitHubActions: Complete job without blocking egress
Loading

File-Level Changes

Change Details Files
Introduce step-security/harden-runner@v2 (egress-policy: audit) as the first step in all existing GitHub Actions jobs to baseline outbound traffic.
  • Prepend a harden-runner step with egress-policy: audit to each job in staging-gate workflows (secrets-scan, pattern-scan, history-scan, release-docs-check, commit-msg-prefix, pr-body-issue-link).
  • Prepend a harden-runner step with egress-policy: audit to the rebase job in the auto-rebase-open-prs workflow.
  • Prepend a harden-runner step with egress-policy: audit to the pytest matrix job in the main CI workflow.
  • Prepend a harden-runner step with egress-policy: audit to the open-sweep-issue job in the post-release-docs-issue workflow.
  • Prepend a harden-runner step with egress-policy: audit to the publish job in the publish workflow.
  • Prepend a harden-runner step with egress-policy: audit to the update_release_draft job in the release-drafter workflow.
  • Prepend a harden-runner step with egress-policy: audit to the stale job in the stale workflow.
.github/workflows/staging-gate.yml
.github/workflows/auto-rebase-open-prs.yml
.github/workflows/ci.yml
.github/workflows/post-release-docs-issue.yml
.github/workflows/publish.yml
.github/workflows/release-drafter.yml
.github/workflows/stale.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/staging-gate.yml" line_range="20-22" />
<code_context>
   rebase:
     runs-on: ubuntu-latest
     steps:
+      - uses: step-security/harden-runner@v2
+        with:
+          egress-policy: audit
       - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
         with:
</code_context>
<issue_to_address>
**🚨 issue (security):** Consider pinning step-security/harden-runner to a specific commit SHA instead of the v2 tag.

A floating tag like `@v2` can change without any updates here, undermining the supply-chain hardening you’re adding. Please pin `step-security/harden-runner` to a specific commit SHA for deterministic behavior and apply that consistently in all workflows touched by this PR.
</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.

Comment thread .github/workflows/staging-gate.yml Outdated
@github-actions
github-actions Bot force-pushed the ci/harden-runner-expansion branch from 8aa5c98 to b05acbe Compare April 30, 2026 21:52

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 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/auto-rebase-open-prs.yml:
- Around line 29-31: Replace the loose version tag for the GitHub Action
"step-security/harden-runner@v2" with a pinned commit SHA while preserving the
version tag as a trailing comment; specifically, update the action reference in
the workflow to use "step-security/harden-runner@<COMMIT_SHA>" and add a comment
like "# v2" after the line, keeping the existing "with: egress-policy: audit"
block unchanged so the action is pinned but human-readable.

In @.github/workflows/ci.yml:
- Around line 21-23: Replace the mutable action reference "uses:
step-security/harden-runner@v2" with a SHA-pinned reference to the specific
commit (e.g., "uses: step-security/harden-runner@<COMMIT_SHA>") and append the
human-readable tag as a trailing comment for traceability (e.g., "# v2"). Update
the workflow entry where "step-security/harden-runner@v2" appears so CI uses the
full commit SHA instead of the mutable tag.

In @.github/workflows/post-release-docs-issue.yml:
- Around line 15-17: The GitHub Actions usage of step-security/harden-runner is
tag-pinned ("step-security/harden-runner@v2"); update that reference to the full
commit SHA (e.g., "step-security/harden-runner@<COMMIT_SHA>") and keep the
version tag as a trailing comment (e.g., "# v2.x.y") so the workflow uses a
fixed commit while still documenting the intended version; modify the uses line
where "step-security/harden-runner@v2" appears in the workflow file accordingly.

In @.github/workflows/publish.yml:
- Around line 18-20: Replace the mutable action reference
"step-security/harden-runner@v2" with a specific commit SHA (e.g.
"step-security/harden-runner@<COMMIT_SHA>") and append a trailing comment
containing the original version tag (e.g. "# v2.x.y"); update the uses entry in
the workflow where "step-security/harden-runner@v2" appears and keep the
existing inputs like "egress-policy: audit" unchanged.

In @.github/workflows/release-drafter.yml:
- Around line 18-20: Replace the floating tag "step-security/harden-runner@v2"
with an immutable commit pin (the repo@<commit-sha>) and retain the
human-readable version as a trailing comment (e.g. " # v2.x.y") so the workflow
step uses the exact commit while still documenting the version; update the
action reference in the workflow step where "step-security/harden-runner@v2"
appears and add the corresponding commit SHA and version comment.

In @.github/workflows/staging-gate.yml:
- Around line 20-22: The workflow uses mutable action refs—replace all six
occurrences of step-security/harden-runner@v2 with pinned commit SHAs in the
format step-security/harden-runner@<commit-sha> # v2.x.y (e.g.,
a235c7d7def8a53dbc7bed9e20bf6a94b87d2e8d) so each harden-runner usage is
immutable; while editing, also pin other third-party actions such as
actions/checkout@v4 and gitleaks/gitleaks-action@v2 to their specific commit
SHAs and add a trailing comment with the corresponding semantic version for
clarity.

In @.github/workflows/stale.yml:
- Around line 16-18: Replace the floating tag in the uses entry for
step-security/harden-runner (the line containing "uses:
step-security/harden-runner@v2") with a specific commit SHA and append the
original version tag as a trailing comment (e.g., "uses:
step-security/harden-runner@<commit-sha> # v2") so the action is pinned to an
exact revision while preserving the human-readable version in a comment; keep
the existing "with: egress-policy: audit" block unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aba4bc50-3d03-412e-897b-52c1a021b775

📥 Commits

Reviewing files that changed from the base of the PR and between 515c4ff and b05acbe.

📒 Files selected for processing (7)
  • .github/workflows/auto-rebase-open-prs.yml
  • .github/workflows/ci.yml
  • .github/workflows/post-release-docs-issue.yml
  • .github/workflows/publish.yml
  • .github/workflows/release-drafter.yml
  • .github/workflows/staging-gate.yml
  • .github/workflows/stale.yml

Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/post-release-docs-issue.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/release-drafter.yml Outdated
Comment thread .github/workflows/staging-gate.yml Outdated
Comment thread .github/workflows/stale.yml Outdated
Pre-step on every job emits an egress baseline to StepSecurity for
review before promoting to block mode. No behavior change at audit
level.

ci.yml: pytest job.
staging-gate.yml: secrets-scan, pattern-scan, history-scan,
release-docs-check, commit-msg-prefix, pr-body-issue-link.
Highest-value placement: publish runs with id-token: write and contacts
the PyPI Trusted Publishing OIDC endpoint. Audit-mode egress baseline
captures the legitimate publish path so a future block-mode promotion
can reject any unexpected outbound traffic from a compromised action.
post-release-docs-issue.yml, release-drafter.yml, stale.yml each get
the audit-mode egress baseline. Completes Harden-Runner coverage
across the .github/workflows/ tree.
Closes Harden-Runner coverage. This workflow runs with contents: write
and force-pushes to open PR branches, so an egress baseline here is
load-bearing for future block-mode promotion.
Four atomic commits adding step-security/harden-runner@v2 (audit mode)
as the first step of every job in every existing workflow. Pairs with
the new workflows on ci/devtools-bundle which already include it.

Verification:
- coverage: 7/7 workflows (1 ci, 6 staging-gate jobs, 1 publish, 1
  post-release-docs-issue, 1 release-drafter, 1 stale, 1 auto-rebase)
- mode: audit only — no egress blocking, baseline collection only
- behavior change: none until promoted to block mode

Blockers (require user decision before merge):
- [user] confirm app.stepsecurity.io account exists or accept that
  baselines are visible only in workflow-run logs until then

Open questions:
- Promotion to block mode is a follow-up after baselines stabilize
  (~2 weeks of normal traffic)

Rollback:
- git revert 21b6500..HEAD (or delete branch before merge)
@robotrocketscience
robotrocketscience force-pushed the ci/harden-runner-expansion branch from b05acbe to 9650bd6 Compare April 30, 2026 21:56
Replaces tag-pin with commit SHA per repo convention (other third-party
actions in these files are SHA-pinned). Resolves sourcery + coderabbit
findings on PR #326.
@robotrocketscience
robotrocketscience merged commit 6353181 into main Apr 30, 2026
10 checks passed
@robotrocketscience
robotrocketscience deleted the ci/harden-runner-expansion branch April 30, 2026 22:01
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.

2 participants