Skip to content
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

Fix rate limiting issue in Trivy workflow scan #23634

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

sgress454
Copy link
Contributor

This PR updates the way that the Trivy scan workflow downloads the vulnerability database. Previously, it would download the database from the Github container registry (ghcr.io) by default. This caused issues where the request for the file would get a "too many requests" error response, seemingly due to ever user of Trivy being lumped together for the purpose of rate limiting. Now, we're instructing Trivy to download the dbs from their own public ECR. We're also authenticating with AWS first, so that we get our own quota.

This PR also updates the version of the Github checkout action to avoid a warning about it not being designed for Node 20:

The following actions use a deprecated Node.js version and will be forced to run on node20: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c, aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/

I tested this by pushing the branch up and triggering the workflow manually. Only time will tell if it really solves the rate limit issue, since we run this pretty infrequently.

Comment on lines +25 to +28
env:
AWS_REGION: us-east-2
AWS_IAM_ROLE: arn:aws:iam::160035666661:role/github-actions-role

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for use in aws-actions/configure-aws-credentials

Comment on lines +58 to +59
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See aquasecurity/trivy-db#440. Pulling from these may become the default in future Trivy versions, at which point we could back this out and let them drive again.

@sgress454 sgress454 linked an issue Nov 7, 2024 that may be closed by this pull request
Copy link
Member

@lukeheath lukeheath left a comment

Choose a reason for hiding this comment

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

💖 This is great, thank you!

@lukeheath lukeheath merged commit 1551157 into main Nov 7, 2024
3 checks passed
@lukeheath lukeheath deleted the 23605-fix-trivy-rate-limiting branch November 7, 2024 21:06
lucasmrod added a commit that referenced this pull request Nov 12, 2024
Exactly same fix as #23634.

PS: Thanks @sgress454!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Trivy vulnerability scan workflow is no longer completing
2 participants