Repository navigation
fix: stop purview-release declaring permissions its callers cannot grant - #38
Merged
Merged
Conversation
The workflow-level permissions block added with trusted publishing broke every caller at parse time: GitHub validates a reusable workflow's permissions against the caller statically, before any input is read, and grants id-token as none by default whatever the repository's default-token setting. Callers failed with "is only allowed 'id-token: none'" whether or not they used trusted-publishing, and whether or not they declared a permissions block of their own. A block there could never have helped. A reusable workflow cannot elevate its caller, so it grants nothing, and it can only fail runs rather than reduce them. Remove it and let the jobs inherit the caller's token, as they did before. Callers now grant what the feature they use needs: contents: write to tag and release, packages: write for GitHub Packages, id-token: write for trusted publishing. Every documented caller snippet is updated to match, including the trusted publishing example, which granted contents and id-token but not packages. WorkflowParityTests gains two guards: the workflow must declare no permissions block at any level, and every documented caller block must grant the full set.
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.
The break
purview-release.ymldeclared a workflow-levelpermissions:block when trusted publishing was wired up in 1c1a6c9. That fails every caller at parse time:GitHub validates a reusable workflow's permissions against the caller statically, before any input is read, and grants
id-tokenasnoneby default however permissive the repository's default token is. Sotrusted-publishing: falsedid not help, and neither did having nopermissions:block in the caller.The fix
Remove the block. A reusable workflow can never elevate its caller, so it granted nothing; all it added was a ceiling that can fail runs but never reduce them. Jobs inherit the caller's token again, as before.
Callers grant what the feature they use needs:
contents: writepackages: writeid-token: writetrusted-publishing: trueAlso in here
README.md,docs/wiki/Release-Flow.md,docs/wiki/Getting-Started.md,skills/purview-build-adoption/SKILL.md. The trusted publishing example grantedcontentsandid-tokenbut notpackages, so an opted-in repository following it would publish to nuget.org and then fail on the mirror push.SECURITY.mdgains a Commitments entry stating the reusable workflows do not cap the caller's token, and why a block there could only fail runs.AGENTS.mdrecords the invariant next to the existing concurrency andrelease-branchrules.WorkflowParityTestsgainsReleaseWorkflow_DeclaresNoPermissionsBlock(catches job-level blocks too) and a data-driven check that every documented caller block grants the full set, with a "guards the guard" test in the style of the existing one..editorconfigversion marker corrected to the actual SDK version, 1.1.0.No version bump: this touches workflows, docs and tests only, no shipping tool code. Consumers pick it up from
@mainon merge.Verification
dotnet build -c Release --warnaserrorclean,just testgreen (92 + 436 + 9, zero failures),just lint-checkandjust lint-yamlclean.