fix(ci): mint self-mutation token from a workflow pinned to main (2/2) - #868
Open
darccio wants to merge 1 commit into
Open
fix(ci): mint self-mutation token from a workflow pinned to main (2/2)#868darccio wants to merge 1 commit into
darccio wants to merge 1 commit into
Conversation
Completes the fix started in #866, restoring the self-mutation job that has been permission-denied on every pull request since #846. #846 constrained the dd-octo-sts policy to validate.yml@refs/heads/main, which is unsatisfiable: for pull_request events GitHub runs workflows from the PR merge ref, so job_workflow_ref is always validate.yml@refs/pull/<N>/merge. Relaxing the policy to accept merge refs would reintroduce what #846 set out to prevent, since a pull request can rewrite validate.yml and mint the contents: write token from its own code. Instead, validate.yml now calls the self-mutation workflow added in #866, pinned at @main. job_workflow_ref resolves to the *called* reusable workflow, so the claim becomes self-mutation.yml@refs/heads/main -- a ref no pull request can influence -- and the policy asserts that. The same-repo/maintainer_can_modify guard moved into the called workflow so it lives in trusted code, and the workflow takes no inputs: the push target is derived from the pull_request event context so an untrusted caller cannot redirect it. ratchet:exclude and an allowlist entry are required because this one reference is intentionally a branch ref rather than a SHA.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Step 2 of 2. Stacked on #866 — do not merge until #866 lands on
main.Why this depends on #866
validate.ymlnow calls.github/workflows/self-mutation.ymlviauses: DataDog/orchestrion/.github/workflows/self-mutation.yml@main. That@mainreference is resolved by GitHub against the actual tip ofmainin this repo — not against this PR's base branch, not against the merge commit being tested. Until #866 merges,maindoesn't have that file, so this PR's own CI will fail to load (the same zero-jobs, instant-failure symptom documented on #866: run 30830039834). That's expected, not a regression — stacking this PR on #866's branch only makes the diff clean for review; it doesn't change how@mainresolves.Once #866 merges, this PR's base will auto-retarget to
mainand its CI should go green.What this does
self-mutationjob invalidate.ymlbecomesuses: DataDog/orchestrion/.github/workflows/self-mutation.yml@maininstead of an inline job, moving the token-minting into the trusted reusable workflow added in fix(ci): add trusted self-mutation reusable workflow (1/2) #866.job_workflow_refin.github/chainguard/self.github.validate.self-mutation.sts.yamlnow targetsself-mutation.yml@refs/heads/maininstead ofvalidate.yml@refs/heads/main(the latter being the unsatisfiable pattern from fix: narrow validate STS policy #846 — see fix(ci): add trusted self-mutation reusable workflow (1/2) #866 for the full history).GitHub Workflow Linters' SHA-pin allowlist gainsDataDog/orchestrion, and theuses:line gets# ratchet:exclude, since this one reference is intentionally a branch ref rather than a SHA.Test plan
actionlintclean locallymain(post-fix(ci): add trusted self-mutation reusable workflow (1/2) #866), confirmGitHub Workflow Linterspasses and a PR with a generator diff successfully mints the token and pushes (nopermission denied)