Repository navigation
ci: harden Actions and Dependabot supply chain (SHA pins, automerge binding, cooldown, feed OIDC, cache split, digest promotion) - #1729
Merged
Conversation
- Pin every action in the hand-written workflows to a full commit SHA with a version comment (incl. reproducible-containers/buildkit-cache-dance v3.4.0 = 5422eac0), so sha_pinning_required can be enabled. - Dependabot auto-merge: require the PR author, actor and triggering actor to be dependabot[bot]; refuse if the live head moved; approve with commit_id and enable auto-merge with --match-head-commit for the triggering SHA; drop unused GITHUB_TOKEN write scopes. - Dependabot: 3-day cooldown (7 for majors) on nuget, npm and github-actions; ContentFeedNuget and EssentialCSharp.Shared.Models exempt. - Private feed: optional Entra OIDC auth (azure/login + Azure DevOps access token) when vars.AZURE_DEVOPS_FEED_CLIENT_ID is set on BuildAndUploadImage; AZURE_DEVOPS_PAT stays as the fallback. Setup in docs/nuget-feed-oidc.md. - Caches: credentialed builds use *-feed- keys, PR/CodeQL builds use *-public- keys with no fallback, so main's private-feed NuGet and BuildKit caches are no longer restored into PR builds. - Promotion: deploy-development records the pushed manifest digest (and checks the dev tag matches), deploys dev by digest, and deploy-production imports dev@digest and fails unless prod holds that exact manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Hardens the CI/CD supply chain, following the Tier B leads (3, 4 and 5) and the CI hardening notes from the 2026-11 security audit. This PR changes workflow and Dependabot files only; it changes no repository, org or Azure settings.
What changed
1. SHA-pinned actions. Every
uses:in the hand-written workflows is now pinned to a full commit SHA, with a# vX.Y.Zcomment that Dependabot keeps up to date. That includesreproducible-containers/buildkit-cache-dance→5422eac04292c961a382e0f584ea0f03ad9da723 # v3.4.0, the same commit@v3resolved to. The gh-aw*.lock.ymlfiles were already pinned and are unchanged. Once this PR merges,sha_pinning_requiredcan be turned on.2. Dependabot auto-merge (
Automerge-ContentNugetFeed.yml). Every update still auto-merges, as intended, with these new conditions:github.actorandgithub.triggering_actormust all bedependabot[bot], and the head must be in this repository. A re-run by someone else no longer runs the job.commit_id = pull_request.head.sha. Auto-merge is enabled with--match-head-commitfor that SHA, whichghsends asexpectedHeadOid.GITHUB_TOKENdrops tocontents: read. Every privileged call already usedBOT_PAT.3. Dependabot cooldown (
dependabot.yml): 3 days onnuget,npmandgithub-actions, and 7 days for major versions onnugetandnpm(github-actionsaccepts onlydefault-days).ContentFeedNugetandEssentialCSharp.Shared.Modelsare exempt: they share$(ToolingPackagesVersion)and carry book content. Security updates bypass cooldown.4. Private-feed auth through OIDC, keeping the PAT as fallback (
build-and-test).BuildAndUploadImageenvironment has the variableAZURE_DEVOPS_FEED_CLIENT_ID, the job:azure/login(OIDC,allow-no-subscriptions);az account get-access-token --resource 499b84ac-…;nuget_configsecret.AZURE_DEVOPS_PAT, exactly as before.Private feed auth mode: oidc|pat.setup-dotnet'ssource-url, which wrote the token to../nuget.configand left it there for the whole job. The job now writes~/.nuget/NuGet/NuGet.Config, the same credentials-only file the Dockerfile already uses, and deletes it right after restore.id-token: write.scripts/nuget/get-feed-token.sh. Setup steps are under the manual follow-ups below.AZURE_DEVOPS_FEED_CLIENT_IDvariable; the next run uses the PAT.5. Caches split by trust.
build-and-test,copilot-setup-steps) use*-nuget-feed-andbuildkit-cache-feed-keys.*-nuget-public-andbuildkit-cache-public-keys, and their restore-keys don't fall back to anything else.buildkit-cache-<hash>andLinux-nuget-entries stop being used.6. Promotion by digest.
deploy-developmentreads the manifest digest it just pushed from the local image'sRepoDigests. It fails if the dev ACR:shatag doesn't point to that digest.image-digest, and runs the dev migration and dev deploy by@digest.deploy-productionrunsaz acr import --source <dev>/essentialcsharpweb@<digest>and fails unless prod:shapoints to that exact digest.Verification
actionlint1.7.7 (with shellcheck) reports nothing on any changed workflow. The one remaining note is a pre-existing SC2086 info in the unchangedCleanupCaches.yml. This PR also removes a pre-existing SC2086 in the old prod import step.get-feed-token.sh. I ran the PAT path locally: a missing token and an unknown mode both exit 1.build-and-test,deploy-*and the automerge job don't run on this PR. They run on push tomainor a Dependabot PR. Watch the firstmainrun after merging, especially:Build and test (Ubuntu): feed restore through the user-level config;Push Image to Dev Container Registry: digest capture;Import image from dev ACR to prod ACR: import by digest.Manual follow-ups for the owner (not changed here)
Turn on OIDC for the feed:
intelliTectAzure DevOps org is connected to. Done:ecs-web-nuget-feed-reader-identity.https://token.actions.githubusercontent.com, subjectrepo:IntelliTect/EssentialCSharp.Web:environment:BuildAndUploadImageand audienceapi://AzureADTokenExchange.AZURE_TENANT_ID, change the workflow'stenant-id.EssentialCSharpfeed.AZURE_DEVOPS_FEED_CLIENT_IDonBuildAndUploadImage. The firstmainrun after merge will use OIDC.mainrun logsPrivate feed auth mode: oidcand passes, remove the PAT fallback. Then move the remaining PAT users: Dependabot'snuget-azure-artifactsregistry (Dependabot supports Azure OIDC withtenant-id/client-id) and thecopilotenvironment. Finally deleteAZURE_DEVOPS_PATand revoke the PAT.GitHub settings to consider:
sha_pinning_required: enable it under repository Actions settings (allowed actions) now that every workflow is pinned.Development(andBuildAndUploadImage) tomain. Today any branch can get the dev identity, which holds registry-wide AcrPush. Consider the same forIntelliTect/try'sDevelopmentenvironment, whose identity also has AcrPush onecsdevacr.require_last_push_approvaland/ordismiss_stale_reviews_on_push, so a push after the bot's approval needs a fresh approval. This is the server-side backstop for the automerge pinning.Azure settings to consider:
writeEnabled=false(az acr repository update --write-enabled false) on releasedessentialcsharpwebmanifests inecsprodacr, and optionally on promoted digests inecsdevacr. Also review whether the registry-wide AcrPush grants on the dev ACR are all needed. Basic SKU has no repository-scoped permissions.Small follow-up found along the way: in
scripts/nuget/emit-creds-config.sh,xml_escapemis-escapes<,>and"on bash 5.2 and later, because&in a${var//pat/rep}replacement now inserts the matched text. PATs and Entra JWTs never contain those characters, so this has no effect today. The fix is to escape&in the replacement strings.🤖 Generated with Claude Code