Repository navigation
ci: harden GitHub Actions supply chain and token permissions - #319
Merged
Merged
Conversation
Pin all external GitHub Actions references across every workflow to verified 40-character commit SHAs with inline tag comments and disable persisted checkout credentials. Set explicit empty top-level permissions across all workflows and assign minimal per-job permissions so switching repository defaults to read-only with pull request approval disabled remains safe. Isolate contents: write and Cloudflare R2 secrets away from pnpm build and validation jobs in build.yml and release.yml, and isolate issues: write in dependencies.yml. Remove runtime pnpm dlx npm-check-updates, runtime pnpm add -D package installs (vitest/jsdom/@vitest/ui/c8 in dependencies.yml and eslint-plugin-complexity in quality.yml), and automated GITHUB_TOKEN pull request creation. Split dependencies.yml into read-only scheduled checks plus manual workflow_dispatch patch preparation verified with the repository's declared test and type-check commands, and fix pnpm list JSON parsing in dependency-analysis. Add a source regression test guarding action SHA pinning, explicit permissions, runtime package installs, and release-chain privilege separation. Refs: rustfs/backlog#1187
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
Description
Harden all GitHub Actions workflows in
rustfs/consoleto reduce the CI/CD supply-chain attack surface and prepare the repository for least-privilege default workflow token settings (default_workflow_permissions: readandcan_approve_pull_request_reviews: false):uses:action across all 5 workflows (.github/workflows/build.yml,dependencies.yml,quality.yml,release.yml,test.yml) to its verified 40-character commit SHA with inline semantic version comments, and setpersist-credentials: falseon allactions/checkoutsteps.permissions: {}on every workflow and declare minimal per-job permissions so read-only jobs never receive write tokens.pnpmexecution: splitbuild.ymlintobuild(contents: read, no R2 secrets),upload-r2(permissions: {}, downloads build artifacts only), andupload-release-asset(contents: write,releaseevents only, nopnpm); scopecontents: writeinrelease.ymlsolely tocreate-release(nopnpm); remove unusedpages: write/id-token: writepermissions frombuild.yml.env:variables with version format validation to prevent shell or script expression injection..github/workflows/dependencies.ymland.github/workflows/quality.yml: remove unpinned runtimepnpm dlx npm-check-updates, runtimepnpm add -D vitest jsdom @vitest/ui c8, unused runtimepnpm add -D eslint-plugin-complexity, and automatedGITHUB_TOKENPR creation (peter-evans/create-pull-request). Scheduled dependency runs are now strictly read-only (security-audit,check-updates,dependency-analysis) with isolatedreport-security-issue(issues: write, nopnpm), while manualworkflow_dispatchruns (patch/latest, defaulting tocheck-only) prepare and verify updates with pinnedpnpm,pnpm run test:run, andpnpm run type-check, uploading a reviewabledependency-update-patchartifact instead of mutating repository branches. Also fixespnpm list --depth=0 --jsonarray parsing independency-analysisand preventspipefailSIGPIPE when truncating diff previews.tests/lib/workflow-supply-chain-source.test.jsto guard SHA pinning, explicit permissions, absence of runtimepnpm dlx/pnpm addand auto-PR bots, and build/release privilege separation.Type of Change
Testing
Commands run locally against the final commit:
All 7 unique external action pins were verified against live GitHub API tag refs (peeling annotated tags to their target commit SHAs). Local Prettier verification confirmed all 6 touched files conform to
.prettierrc. Fullpnpm run lint,pnpm run test:run,pnpm run format:check, andpnpm run buildare delegated to the PR CI workflows (TestsandCode Quality).Checklist
Related Issues
Refs: rustfs/backlog#1187
Screenshots (if applicable)
N/A
Additional Notes
build.ymlnow passes built zip archives betweenbuildand the isolatedupload-r2/upload-release-assetjobs via a short-livedconsole-publish-artifactsworkflow artifact (retention-days: 1), while preserving the existingrustfs-console-latest.zipdefault artifact upload.dependencies.ymlno longer opens automated PRs on schedule; maintainers triggerworkflow_dispatchwithpatchorlatestto generate a verifieddependency-update-patchartifact.main, repository Actions workflow defaults can safely be tightened todefault_workflow_permissions: "read"andcan_approve_pull_request_reviews: falsewithout breaking builds, releases, tests, or security alerts.read, restore explicit job permissions before reverting).