fix: wrap bare secret-name tokens in setup-cli step - #189
Merged
Merged
Conversation
A manifest that sets release_token (or state_token, or a notify token) to a
bare secret name such as CASCADE_STATE_TOKEN caused the generator to emit that
name verbatim into the Setup CLI step (token: CASCADE_STATE_TOKEN). The setup-cli
action then ran gh release download with GH_TOKEN set to the literal string,
which GitHub rejected with 401 Bad credentials.
Normalize token values in GetReleaseToken, GetStateToken, and NotifyConfig.GetToken:
a full ${{ ... }} expression passes through, an unwrapped context form (secrets.X,
vars.X) is wrapped, and a bare name is treated as a secret. The Setup CLI download
targets a public release, so the wrapped expression resolves correctly.
Adds unit coverage for the normalizer and the token getters, a generator
regression test asserting no emitted token is a bare identifier, and an e2e
scenario exercising a bare release_token.
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.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.
Problem
A manifest that sets
release_token(orstate_token, or a notify token) to a bare secret name likeCASCADE_STATE_TOKENmade the generator emit that name verbatim into the Setup CLI step:The setup-cli action then runs
gh release downloadwithGH_TOKENset to the literal stringCASCADE_STATE_TOKEN, which GitHub rejects with401 Bad credentials. Repos with a barerelease_token(e.g. cascade-example-primary) fail; repos that omit it fall back to${{ secrets.GITHUB_TOKEN }}and work.Root cause
internal/config/types.go:GetReleaseToken,GetStateToken, andNotifyConfig.GetTokenreturned a configured value verbatim, assuming it was always a full${{ ... }}expression. Therelease_tokenfield is documented as a 'GitHub secret name', so an operator-written bare name was passed straight through. No wrapper was ever stripped; the bare name was simply never wrapped.Fix
Add
normalizeTokenExpression: a full${{ ... }}expression passes through, an unwrapped context form (secrets.X,vars.X) is wrapped, and a bare name is treated as a secret (${{ secrets.NAME }}). The Setup CLI download targets a public release, so the wrapped expression resolves. Wired into all three token getters.Verification
normalizeTokenExpressionand the three getters.release_token) now emitstoken: ${{ secrets.CASCADE_STATE_TOKEN }}, and a guard asserts no emittedtoken:/GH_TOKEN:line is a bare identifier. Default (norelease_token) still emits${{ secrets.GITHUB_TOKEN }}.orchestrate/22-release-token-bare-secret-name.yaml.go build ./... && go test ./...(1375 pass) andgolangci-lint run ./...green; e2e module builds and vets clean.state_token, norelease_token).