-
Notifications
You must be signed in to change notification settings - Fork 3
feat(ci): add and test supply-chain hardening in release workflows #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Test supply chain security | ||
|
|
||
| # Supply-chain gate: asserts that release.yml (and this workflow) never | ||
| # restore the GitHub Actions cache. A workflow that both restores a cache | ||
| # and holds publish credentials is a cache-poisoning target — see | ||
| # https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/ | ||
| # | ||
| # The check (scripts/lint-no-workflow-caching.mjs) requires caching to be | ||
| # disabled *explicitly*, not just left at its default: | ||
| # - `pnpm/action-setup` must set `cache: false` | ||
| # - `actions/setup-node` must set `package-manager-cache: false` | ||
| # - no `cache:` input and no `actions/cache` step anywhere | ||
| # See the "CI/CD Supply-Chain Hardening" section of SECURITY.md. | ||
| # | ||
| # Deliberately minimal: | ||
| # - GitHub-hosted runner (no Blacksmith transparent cache) | ||
| # - contents:read only | ||
| # - no secrets | ||
| # - no caching | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '.github/workflows/release.yml' | ||
| - '.github/workflows/tests-supply-chain.yml' | ||
| - 'scripts/lint-no-workflow-caching.mjs' | ||
| - 'scripts/__tests__/lint-no-workflow-caching.test.mjs' | ||
| - 'scripts/__tests__/fixtures/lint-no-workflow-caching/**' | ||
| pull_request: | ||
| branches: | ||
| - '**' | ||
| paths: | ||
| - '.github/workflows/release.yml' | ||
| - '.github/workflows/tests-supply-chain.yml' | ||
| - 'scripts/lint-no-workflow-caching.mjs' | ||
| - 'scripts/__tests__/lint-no-workflow-caching.test.mjs' | ||
| - 'scripts/__tests__/fixtures/lint-no-workflow-caching/**' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| verify-no-caching-in-release-workflows: | ||
| name: Verify no caching in release workflows | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - uses: pnpm/action-setup@v6 | ||
| name: Install pnpm | ||
| with: | ||
| run_install: false | ||
| # Do not use caching in this cache-testing workflow | ||
| cache: false | ||
|
|
||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22 | ||
| # Do not use caching in this cache-testing workflow | ||
| package-manager-cache: false | ||
|
|
||
| # node-pty's install hook falls back to `node-gyp rebuild` when no | ||
| # linux-x64 prebuild matches. pnpm/action-setup v6 no longer ships | ||
| # node-gyp on PATH, so install it explicitly. | ||
| - name: Install node-gyp | ||
| run: npm install -g node-gyp | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Run lint script self-tests | ||
| run: pnpm run test:scripts | ||
|
|
||
| - name: Verify no caching in release.yml and tests-supply-chain.yml | ||
| run: pnpm run lint:workflow-cache | ||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
scripts/__tests__/fixtures/lint-no-workflow-caching/actions-cache-restore.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Actions Cache Restore | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Restore build cache | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: .turbo | ||
| key: turbo-${{ github.sha }} | ||
| - run: pnpm install --frozen-lockfile |
15 changes: 15 additions & 0 deletions
15
scripts/__tests__/fixtures/lint-no-workflow-caching/actions-cache-save.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Actions Cache Save | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Save build cache | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: .turbo | ||
| key: turbo-${{ github.sha }} | ||
| - run: pnpm install --frozen-lockfile |
15 changes: 15 additions & 0 deletions
15
scripts/__tests__/fixtures/lint-no-workflow-caching/actions-cache.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Actions Cache | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Restore build cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: .turbo | ||
| key: turbo-${{ github.sha }} | ||
| - run: pnpm install --frozen-lockfile |
19 changes: 19 additions & 0 deletions
19
scripts/__tests__/fixtures/lint-no-workflow-caching/clean.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Clean | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: pnpm/action-setup@v6 | ||
| with: | ||
| run_install: false | ||
| cache: false | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22 | ||
| package-manager-cache: false | ||
| - run: pnpm install --frozen-lockfile |
17 changes: 17 additions & 0 deletions
17
scripts/__tests__/fixtures/lint-no-workflow-caching/missing-explicit-false.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Missing Explicit False | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: pnpm/action-setup@v6 | ||
| with: | ||
| run_install: false | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22 | ||
| - run: pnpm install --frozen-lockfile |
13 changes: 13 additions & 0 deletions
13
scripts/__tests__/fixtures/lint-no-workflow-caching/no-actions-cache.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: No Actions Cache | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| # `actions/cache` is named here in prose but never used as a step — | ||
| # the check must only match a real `uses:` reference. | ||
| - name: Note — actions/cache is intentionally avoided | ||
| run: echo "this project does not use actions/cache" |
15 changes: 15 additions & 0 deletions
15
scripts/__tests__/fixtures/lint-no-workflow-caching/setup-node-cache.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Setup Node Cache | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22 | ||
| cache: 'pnpm' | ||
| - run: pnpm install --frozen-lockfile |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Policy enforcement is mutable by the PR under test.
On
pull_request, this workflow checks out PR code and then runspnpm run lint:workflow-cache, so the same PR can weaken the lint script/tests and still pass while reintroducing cache usage. Move this gate to an immutable source (for example: base-branchpull_request_targetpolicy execution, or a pinned reusable workflow/action that is not editable in the same PR).Also applies to: 79-80
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a valid concern, but will be addressed in a follow up PR, by splitting this check out into a re-usable GitHub Action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@auxesis, understood — splitting it into a reusable GitHub Action is a solid approach since the action can be pinned to a ref that the PR cannot modify. Would you like me to open a GitHub issue to track that follow-up work?🧠 Learnings used