Skip to content

ci: GitHub Actions workflow security cleanup - #484

Merged
lawrence-forooghian merged 4 commits into
mainfrom
worktree-fixup-workflows
May 27, 2026
Merged

ci: GitHub Actions workflow security cleanup#484
lawrence-forooghian merged 4 commits into
mainfrom
worktree-fixup-workflows

Conversation

@emptyhammond

@emptyhammond emptyhammond commented May 26, 2026

Copy link
Copy Markdown
Contributor

Routine hygiene pass over the GitHub Actions workflow in this repo, addressing findings from a workflow security audit. Changes are split into four commits, one per finding type:

  • Disable credential persistence on actions/checkout steps so the default GITHUB_TOKEN is not left in the local git config after checkout.
  • Scope each job's permissions explicitly: top-level permissions: {}, with each job granted only the GITHUB_TOKEN scopes it actually needs.
  • Move workflow-context expansions (${{ matrix.platform }}, step outputs) out of run: shell source and into env: bindings.
  • Pin all third-party actions to commit SHAs (with the tag preserved as a comment) so an upstream tag move can't silently change what runs in CI.

No behavioural changes intended — the workflow runs the same checks against the same inputs.

Summary by CodeRabbit

  • Chores
    • Updated continuous integration workflow configuration to enhance security and build stability through dependency pinning and explicit permission controls.

Review Change Stack

Replaces tag-based references (@v4, @v1, etc.) with the corresponding
commit SHAs, with the original version retained as a trailing comment.

Identified by a workflow security audit. Pinning to SHAs prevents a
compromised tag from silently introducing a new action version on the
next run.
Sets a workflow-level permissions: {} default and grants each job only
contents: read (the minimum required for actions/checkout). The
check-documentation job retains its existing deployments / id-token
scopes; the all-checks-completed job needs nothing, so {} is explicit.

Identified by a workflow security audit. Previously the workflow
inherited the default GITHUB_TOKEN scopes, which include write access
to several APIs that no job here uses.
Adds persist-credentials: false to every actions/checkout step. The
workflow does not need to push back to the repo or carry the token
beyond checkout, so persisting the credential in .git/config only
widens the window in which a later step could read it.

Identified by a workflow security audit.
Replaces inline ${{ ... }} expansions inside shell run blocks with env
bindings that the script then reads as "$VAR". The expression syntax
substitutes text directly into the shell command before it executes,
so a crafted value could escape the intended argument; env vars are
treated as data by the shell.

Identified by a workflow security audit. The current sources of these
values (build matrix and a trusted action's output) are not
attacker-controlled today, but the env-var idiom is robust if that
changes.
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02298d6e-8941-4a81-8864-2d15069d1c70

📥 Commits

Reviewing files that changed from the base of the PR and between 79ed990 and 2732c65.

📒 Files selected for processing (1)
  • .github/workflows/check.yaml

Walkthrough

The workflow hardening adds explicit job-level permissions (mostly contents: read) and pins all third-party actions to commit SHAs for security. Xcode matrix build jobs refactor platform specification from direct matrix.platform interpolation to a step-level PLATFORM environment variable. The documentation job adjusts DocC generation to pass the hosting base path via environment variable.

Changes

GitHub Actions Workflow Hardening and Platform Configuration

Layer / File(s) Summary
Core job permissions and action pinning
.github/workflows/check.yaml
Lint, spec-coverage, generate-matrices, and SPM build jobs add explicit read-only permissions and pin actions/checkout and maxim-lobanov/setup-xcode to commit SHAs with checkout configured to skip credential persistence.
Xcode matrix jobs with platform variable refactoring
.github/workflows/check.yaml
Build-and-test-xcode, build-release-configuration-xcode, and check-example-app jobs add permissions and pin actions, then refactor swift run commands to set and reference a PLATFORM step environment variable instead of directly interpolating matrix.platform.
Documentation job hardening and DocC generation update
.github/workflows/check.yaml
Check-documentation job adds permissions and pins checkout/setup-xcode/upload actions, then adjusts the DocC generation step to compute HOSTING_BASE_PATH via environment variable and quote the resulting value in swift package generate-documentation.
Final marker job permissions
.github/workflows/check.yaml
All-checks-completed job receives explicit empty permissions declaration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Workflows hardened, actions pinned with care,
Platform variables float through the GitHub air,
Permissions explicit, credentials locked tight,
Documentation builds with environment light! ✨

🚥 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 'ci: GitHub Actions workflow security cleanup' directly and accurately summarizes the main changes: security-focused updates to GitHub Actions workflows including action pinning, permission scoping, and credential handling.
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 worktree-fixup-workflows

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 and usage tips.

@lawrence-forooghian

Copy link
Copy Markdown
Contributor

@emptyhammond I suspect this was opened during that GitHub Actions outage, can you trigger CI again please?

@emptyhammond

Copy link
Copy Markdown
Contributor Author

@emptyhammond I suspect this was opened during that GitHub Actions outage, can you trigger CI again please?

Done @lawrence-forooghian - still one failure, which I'll check

@lawrence-forooghian

Copy link
Copy Markdown
Contributor

That failure is unrelated, merging

@lawrence-forooghian
lawrence-forooghian merged commit d2e9070 into main May 27, 2026
32 of 49 checks passed
@lawrence-forooghian
lawrence-forooghian deleted the worktree-fixup-workflows branch May 27, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants