Repository navigation
chore(mint): log requested and granted token scope #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,14 +51,20 @@ runs: | |
| REPOS_JSON=$(echo "$REPOS" | jq -Rc 'split(",") | map(select(length > 0))') | ||
| BODY=$(jq -nc --arg role "$ROLE" --argjson repos "$REPOS_JSON" \ | ||
| '{role: $role, repos: $repos}') | ||
| TOKEN=$(curl -sSf --retry 5 --retry-delay 5 --retry-all-errors \ | ||
| echo "Requesting token: role=$ROLE repos=$REPOS" | ||
| MINT_RESPONSE=$(curl -sSf --retry 5 --retry-delay 5 --retry-all-errors \ | ||
| -H "Authorization: Bearer $OIDC_TOKEN" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "$BODY" \ | ||
| "${MINT_URL}/v1/token" | jq -r '.token') | ||
| "${MINT_URL}/v1/token") | ||
| TOKEN=$(echo "$MINT_RESPONSE" | jq -r '.token') | ||
| echo "::add-mask::$TOKEN" | ||
| if [[ -z "$TOKEN" || "$TOKEN" == "null" ]]; then | ||
|
Comment on lines
58
to
62
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM — Masking "null" string breaks subsequent logging on mint failure
Suggestion — move validation before the mask: TOKEN=$(echo "$MINT_RESPONSE" | jq -r '.token')
if [[ -z "$TOKEN" || "$TOKEN" == "null" ]]; then
echo "::error::Token mint returned no token for role=$ROLE"
exit 1
fi
echo "::add-mask::$TOKEN"
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Covered in the same commit — token validation now runs before the mask. |
||
| echo "::error::Token mint returned no token for role=$ROLE" | ||
| exit 1 | ||
| fi | ||
| echo "::add-mask::$TOKEN" | ||
| GRANTED_REPOS=$(echo "$MINT_RESPONSE" | jq -r '.granted_repos | if . then map(strings) | join(",") else empty end') | ||
| GRANTED_PERMS=$(echo "$MINT_RESPONSE" | jq -r '.granted_permissions | if . then to_entries | map("\(.key)=\(.value)") | join(",") else empty end') | ||
| REPO_SELECTION=$(echo "$MINT_RESPONSE" | jq -r '.repository_selection // empty') | ||
| echo "Granted scope: repos=${GRANTED_REPOS:-} permissions=${GRANTED_PERMS:-} repo_selection=${REPO_SELECTION:-}" | ||
| echo "token=$TOKEN" >> "$GITHUB_OUTPUT" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MEDIUM —
MINT_RESPONSEvariable holds raw token without maskingMINT_RESPONSEholds the full JSON response (including the plaintext token) and is never masked. WhileTOKENis masked after extraction,MINT_RESPONSEitself persists for the rest of the step. IfACTIONS_STEP_DEBUGis enabled or a future change echoes this variable, the token could leak. Previously the token was piped directly throughjqand never stored in a named variable.Suggestion — add
echo "::add-mask::$MINT_RESPONSE"immediately after the curl, orunset MINT_RESPONSEafter extracting all fields:Flagged by 4/5 review agents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed both in 7aedecc. Masked MINT_RESPONSE right after curl, and moved the null/empty check before the token mask so we never register "null" as a secret.