Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/actions/fetch-token/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Fetch GitHub Token from Pool"
description: "Fetches a token from mise-versions token pool"
inputs:
api-secret:
description: "API secret for mise-versions"
required: true
outputs:
token:
description: "The GitHub token"
value: ${{ steps.fetch.outputs.token }}
token-id:
description: "Token ID for rate-limit reporting"
value: ${{ steps.fetch.outputs.token_id }}
runs:
using: "composite"
steps:
- id: fetch
shell: bash
run: |
if [ -z "${{ inputs.api-secret }}" ]; then
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api-secret is being checked for emptiness but is also directly interpolated into the shell script. If the secret contains special characters or shell metacharacters, it could lead to command injection. While GitHub Actions masks secrets in logs, the interpolation pattern could still be exploited. Consider using environment variables instead: set API_SECRET: ${{ inputs.api-secret }} in an env: block at the step level, then reference $API_SECRET in the script.

Copilot uses AI. Check for mistakes.
echo "No API secret provided, skipping token fetch"
exit 0
fi
response=$(curl -sf -H "Authorization: Bearer ${{ inputs.api-secret }}" \
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api-secret is directly interpolated into the curl command. This creates a security risk if the secret contains special characters. Use an environment variable instead to avoid potential command injection and ensure proper shell escaping.

Copilot uses AI. Check for mistakes.
"https://mise-versions.jdx.dev/api/token" || true)
if [ -n "$response" ]; then
token=$(echo "$response" | jq -r '.token')
# Validate token looks like a GitHub token (starts with gh and has reasonable length)
if [[ "$token" =~ ^gh[a-z]_[A-Za-z0-9_]+$ ]] && [ ${#token} -ge 20 ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Token regex rejects fine-grained personal access tokens

The token validation regex ^gh[a-z]_[A-Za-z0-9_]+$ only matches classic GitHub tokens (like ghp_, ghs_, gho_) but rejects fine-grained personal access tokens which use the github_pat_ prefix format. If the token pool contains fine-grained PATs, they would be silently rejected and the workflow would fall back to the default GITHUB_TOKEN, defeating the rate limit distribution purpose.

Fix in Cursor Fix in Web

echo "::add-mask::$token"
echo "token=$token" >> "$GITHUB_OUTPUT"
echo "token_id=$(echo "$response" | jq -r '.token_id')" >> "$GITHUB_OUTPUT"
else
echo "Invalid or missing token in response, skipping"
fi
fi
8 changes: 8 additions & 0 deletions .github/workflows/registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ jobs:
tranche: ${{ fromJson(needs.list-changed-tools.outputs.tools == '' && '[0,1,2,3,4,5,6,7]' || '[0]') }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Fetch token from pool
id: token
uses: ./.github/actions/fetch-token
with:
api-secret: ${{ secrets.MISE_VERSIONS_API_SECRET }}
- name: Set GITHUB_TOKEN from pool
if: steps.token.outputs.token
run: echo "GITHUB_TOKEN=${{ steps.token.outputs.token }}" >> "$GITHUB_ENV"
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing the token directly to GITHUB_ENV could expose it in the environment. While GitHub Actions should handle this, consider whether this approach maintains the same security guarantees as using secrets context. The token should ideally be masked before being written to the environment file.

Copilot uses AI. Check for mistakes.
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: mise
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Fetch token from pool
id: token
uses: ./.github/actions/fetch-token
with:
api-secret: ${{ secrets.MISE_VERSIONS_API_SECRET }}
- name: Set GITHUB_TOKEN from pool
if: steps.token.outputs.token
run: echo "GITHUB_TOKEN=${{ steps.token.outputs.token }}" >> "$GITHUB_ENV"
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing the token directly to GITHUB_ENV could expose it in the environment. While GitHub Actions should handle this, consider whether this approach maintains the same security guarantees as using secrets context. The token should ideally be masked before being written to the environment file.

Copilot uses AI. Check for mistakes.
- name: Install build and test dependencies
run: |
sudo apt-get update
Expand Down
Loading