docker / docker/scout-action

Binary download is unauthenticated, so it hits the 60/hour anonymous rate limit and 403s

Open Beginner friendly
#116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
141
Forks
53
PR merge metrics
No merged PRs in 30d

Description

What happens

Intermittently, the action fails before scanning anything:

Downloading asset: docker-scout-action_linux_amd64 (179.2 MB)
##[error]Unexpected HTTP response: 403

No image is scanned and no finding is reported, so the job goes red for a reason unrelated to the code under test. A re-run usually clears it.

Why

In src/index.js, downloadRelease() builds an authenticated client and then does not use it for the download:

const octokit = github.getOctokit(core.getInput('github-token'))   // authenticated

release = await octokit.rest.repos.getReleaseByTag({ ... })        // authenticated

await tc.downloadTool(asset.url, binary, undefined, {              // <-- auth: undefined
    accept: 'application/octet-stream',
})

The third parameter of @actions/tool-cache's downloadTool is auth. It is undefined, so the asset is fetched anonymously from api.github.com, which puts it on the 60-requests-per-hour-per-IP budget:

$ curl -sI -H "Accept: application/octet-stream" \
    https://api.github.com/repos/docker/scout-action/releases/assets/493034676
HTTP/2 302
x-ratelimit-limit: 60
x-ratelimit-resource: core

Authenticated, that limit is 5,000/hour. GitHub-hosted runners come from a shared address pool, so the anonymous budget is spent collectively by everyone using this action — which is consistent with the failures being bursty and with a re-run (a different runner) succeeding.

It also means retrying inside the same job does not help: the retry runs from the same address against the same exhausted budget.

Suggested fix

Pass the token the action already accepts (github-token, default ${{ github.token }}):

const token = core.getInput('github-token')
await tc.downloadTool(asset.url, binary, `token ${token}`, {
    accept: 'application/octet-stream',
})
Version

docker/scout-action@v1.24.0 (pinned by digest, 7c6b6c3f7844478ace1ffd4e7aef649053d1f87d), ubuntu-24.04 runners.

Happy to open a PR if that would be useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/index.js at downloadRelease(), then inspect how the authenticated client and github-token input are used around tc.downloadTool. Confirm the release asset download uses the existing token and that the action no longer fails with the reported anonymous-rate-limit 403 before scanning.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, javascript
Domain
ci-cd
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.