Skip to content

ci: Refine workflow linting (strict zizmor, workflow_run guard) - #58

Merged
jeffjensen merged 3 commits into
mainfrom
ci/workflow-linting-refinements
Sep 10, 2026
Merged

ci: Refine workflow linting (strict zizmor, workflow_run guard)#58
jeffjensen merged 3 commits into
mainfrom
ci/workflow-linting-refinements

Conversation

@jeffjensen

@jeffjensen jeffjensen commented Sep 10, 2026

Copy link
Copy Markdown
Member

Brings the workflow linting up to the same shape the four database-audits /
java-service-archetype repos landed on after their review rounds.

ci: Run zizmor with --strict-collection

The zizmor-action wrapper has no way to pass --strict-collection, so a
malformed collected file (a broken dependabot.yml, an action.yml) is warned
about and skipped rather than failing the job. Run the pinned tool directly
(pipx run zizmor==1.30.1, pipx is preinstalled on ubuntu-latest).

ci: Pin the workflow_run deploy jobs to the tested commit

Deploy Snapshot and the docs publish checked out the default branch, so a commit
landing on main between a green build and the queued workflow_run job could
be deployed/published untested. Check out workflow_run.head_sha (the commit
that passed) and guard the job with
head_repository.full_name == github.repository so a fork branch named main
still can't reach it.

ci(coderabbit): Enable the zizmor tool and note workflow linting

Turn on CodeRabbit's built-in zizmor integration and extend the .github/**
path instruction to cover it and the Lint workflows job.

Both linters pass clean locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YA7TRsrNp1TPrHn1KD6vnJ

Summary by Sourcery

Harden workflow validation and workflow_run job safety to prevent untested or fork-controlled code from being deployed or published.

Bug Fixes:

  • Ensure workflow_run deployment and documentation publishing jobs only process successful runs from this repository and use the appropriate tested commit context.

Enhancements:

  • Strengthen workflow linting by running zizmor in strict collection mode and enable zizmor reviews in CodeRabbit.

CI:

  • Update workflow security review guidance and enforce strict zizmor validation in the workflow lint job.

Summary by CodeRabbit

  • Security

    • Strengthened workflow security checks, including stricter validation of workflow configuration and action usage.
    • Restricted automated workflow processing to runs originating from the same repository.
  • Bug Fixes

    • Documentation and snapshot deployments now build from the exact commit that triggered them, preventing mismatched or outdated content from being published.
  • Chores

    • Updated workflow security guidance and tooling configuration to support more consistent automated checks.

Drop the zizmor-action wrapper and run the pinned tool directly, so
--strict-collection fails the job on a malformed collected file (an
action.yml, dependabot.yml) instead of warning and skipping it. pipx
is preinstalled on ubuntu-latest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YA7TRsrNp1TPrHn1KD6vnJ
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR tightens CI workflow security and linting by running pinned zizmor directly with strict collection enabled, adding CodeRabbit zizmor coverage, and pinning workflow_run deployment and documentation jobs to the successful triggering commit while rejecting fork-originated runs.

Sequence diagram for guarded workflow_run deployment

sequenceDiagram
    participant Build as Build any branch
    participant Deploy as Deploy Snapshot
    participant GitHub as GitHub repository

    Build->>GitHub: complete(conclusion, head_sha, head_repository)
    GitHub->>Deploy: workflow_run event
    alt conclusion == success and head_repository.full_name == github.repository
        Deploy->>GitHub: checkout(head_sha)
        Deploy->>Deploy: deploy snapshot
    else unsuccessful or fork-originated run
        Deploy-->>GitHub: skip job
    end
Loading

Sequence diagram for guarded workflow_run documentation publish

sequenceDiagram
    participant Build as Build any branch
    participant Publish as Build site
    participant GitHub as GitHub repository

    Build->>GitHub: complete(conclusion, head_sha, head_repository)
    GitHub->>Publish: workflow_run event
    alt successful same-repository run
        Publish->>GitHub: checkout(head_sha)
        Publish->>Publish: publish documentation
    else unsuccessful or fork-originated run
        Publish-->>GitHub: skip workflow_run job
    end
Loading

Flow diagram for strict workflow linting

flowchart LR
    Files[.github workflows and collected files] --> Zizmor[pipx run zizmor==1.30.1]
    Zizmor --> Strict[--strict-collection]
    Strict --> Result{Lint passes?}
    Result -->|yes| CI[Blocking Lint workflows job]
    Result -->|no| Fail[Fail CI]
Loading

File-Level Changes

Change Details Files
Make workflow linting fail on malformed collected configuration while preserving pinned, security-focused zizmor checks.
  • Replace the zizmor action wrapper with pinned direct execution via pipx.
  • Enable strict collection and GitHub-formatted annotations while retaining regular persona and full .github collection.
  • Document zizmor as a blocking workflow lint and enable its CodeRabbit integration.
.github/workflows/lint-workflows.yml
.coderabbit.yml
Ensure workflow_run deployments and documentation publishes use only successful, trusted repository commits.
  • Require successful triggering runs to originate from the current repository.
  • Check out workflow_run.head_sha instead of the default branch for workflow_run executions.
  • Retain the event-specific checkout fallback for direct publish workflow runs and update safety rationale.
.github/workflows/deploy-snapshot.yml
.github/workflows/publish-docs.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

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f5f32259-a2e1-44b6-b23c-5e693403fc2c

📥 Commits

Reviewing files that changed from the base of the PR and between 6fa238d and a8d817c.

📒 Files selected for processing (1)
  • .github/workflows/publish-docs.yml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 705d90f0-87fb-4835-99ec-a36698c811f0

📥 Commits

Reviewing files that changed from the base of the PR and between 4031509 and 6fa238d.

📒 Files selected for processing (4)
  • .coderabbit.yml
  • .github/workflows/deploy-snapshot.yml
  • .github/workflows/lint-workflows.yml
  • .github/workflows/publish-docs.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The workflows now restrict workflow_run processing to runs from the same repository and checkout their exact commits. Workflow linting now runs pinned zizmor directly with strict collection. CodeRabbit configuration documents the zizmor policy and enables the tool.

Changes

Workflow security and lint enforcement

Layer / File(s) Summary
workflow_run repository and commit validation
.github/workflows/deploy-snapshot.yml, .github/workflows/publish-docs.yml
The workflows require successful runs from the same repository and check out the triggering run's head_sha.
zizmor policy and strict lint execution
.coderabbit.yml, .github/workflows/lint-workflows.yml
The configuration documents zizmor policy and enables the tool. The lint job runs zizmor==1.30.1 through pipx with strict collection and GitHub output.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 6fa23

Deployment and documentation publishing now run only against validated same-repository commits, and workflow linting is stricter. No actionable current-head risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: stricter zizmor workflow linting and workflow_run safeguards.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/workflow-linting-refinements

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

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

@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/publish-docs.yml" line_range="44" />
<code_context>
     steps:
     - uses: actions/checkout@v7
       with:
+        ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
         persist-credentials: false
     - uses: ./.github/actions/jdk-setup
</code_context>
<issue_to_address>
**issue (broader_impact):** When the `workflow_run` is for `Record Dependabot update in changes.xml`, checkout uses that workflow's `head_sha`, which is the commit that triggered the pull-request-closed workflow rather than the new commit that the workflow appends to and pushes on `main`. The docs job therefore publishes a site from the pre-changelog or PR commit and omits the changelog update (and can publish code that was not merged).

**Triggers:** When the `Record Dependabot update in changes.xml` workflow completes for a merged Dependabot pull request.

**Suggested fix:** Use the repository's resulting default-branch commit for the Dependabot workflow_run case, or restrict the `head_sha` checkout behavior to `Build any branch` runs and resolve the post-update `main` commit explicitly.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the workflow_run condition and checkout ref define which repository and commit are trusted for deployment and documentation publishing. If either is wrong, an untrusted or unintended commit could be executed or published before a revert can undo the resulting deployment or publication.

Blocking findings: .github/workflows/publish-docs.yml:44


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .github/workflows/publish-docs.yml Outdated
@jeffjensen
jeffjensen force-pushed the ci/workflow-linting-refinements branch from 6fa238d to 8491a20 Compare September 10, 2026 22:29
jeffjensen and others added 2 commits September 10, 2026 17:30
Deploy Snapshot and the docs-publish build-site job run in the
workflow_run context with a read/write token. Guard both with
`head_repository.full_name == github.repository` so a fork branch named
`main` cannot reach them (the branches filter alone does not exclude a
fork whose branch happens to be named `main`).

Deploy Snapshot additionally checks out `workflow_run.head_sha` -- the
exact commit that passed CI -- instead of the default branch, so a
commit landing on main after the green build cannot be deployed
untested (the deploy skips tests). The docs publish keeps its
default-branch checkout: it is also triggered by "Record Dependabot
update in changes.xml", whose head_sha predates the changelog commit
that workflow pushes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YA7TRsrNp1TPrHn1KD6vnJ
Turn on CodeRabbit's zizmor integration alongside actionlint so it picks
up .github/zizmor.yml, and extend the .github/** path instruction so
prose review defers workflow syntax and security findings to actionlint
and zizmor and does not re-raise the deliberate `# zizmor: ignore`
suppressions, tag-pinned first-party actions, or workspace-relative
action syntax.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YA7TRsrNp1TPrHn1KD6vnJ
@jeffjensen
jeffjensen force-pushed the ci/workflow-linting-refinements branch from 8491a20 to a8d817c Compare September 10, 2026 22:30
@jeffjensen
jeffjensen merged commit 5076aa8 into main Sep 10, 2026
6 checks passed
@jeffjensen
jeffjensen deleted the ci/workflow-linting-refinements branch September 10, 2026 22:31
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.

1 participant