-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: Update registry fallbacks #7679
feat: Update registry fallbacks #7679
Conversation
We should document how to authenticate with ECR. Otherwise, ECR Public has only 500 GB free tier for anonymous users. Also, it's calculated by IP address. I suppose we'll run out of the free tier on CI service as it shares IP addresses. |
I'm worried about adding Instead of adding |
We read the docs but... having to authenticate to aws would be a breaking change 🥹 |
hello @nvuillam |
Yes - I wanted to add more info on this topic. Added fa03189 |
c4d3c8d
to
fa03189
Compare
docs/docs/configuration/db.md
Outdated
Please see more info on how to authenticate with ECR [auth-ecr] and GHCR [auth-ghcr]. | ||
|
||
#### Caching DBs | ||
Trivy DB and Trivy Java DB are published every 24 hours. If you are running Trivy scans more often than this, you can significantly benefit from caching the DBs on each run and updating them as needed. |
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.
24 hours is incorrect.
We publish trivy-db every 6 hours, but update interval is 24 hours.
for trivy-java-db: publish every 24 hours, update interval is 3 days.
I'm also leaning toward this approach. I'm afraid that users downloading container images from ECR Public (e.g., Kubernetes cluster) may suddenly reach rate limits due to Trivy DB and be unable to deploy, etc. Of course, it is best if users can continue to use DBs as before without being aware of it, but the implicit use of ECR Public may have other negative effects. We should be careful about the use of ECR Public. If users explicitly set this up, they will understand these trade-offs. |
Yes but the same can be said for GHCR today.
I added some docs here. Ultimately we can reach rate limits even with authenticated use of container registries. The fallback to using a secondary registry only mitigates the risk up to an extent. |
The rate limits in GHCR are on the organization, not the user, unlike ECR Public. In other words, heavy use of GHCR may make aquasecurity images unavailable, but not other images. Users may not be able to use Trivy, but they will be able to pull any other images except aquasecurity. |
It should also be improved once this PR is merged: aquasecurity/trivy#7679
checks bundle also needs ecr. env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db
TRIVY_CHECKS_BUNDLE_REPOSITORY: public.ecr.aws/aquasecurity/trivy-checks |
The |
thanks for the good idea. |
@simar7 |
Any updates here? |
|
I see 8 incorrect mentions of |
pkg/javadb/client.go
Outdated
@@ -29,6 +29,9 @@ const ( | |||
var ( | |||
// GitHub Container Registry | |||
DefaultGHCRRepository = fmt.Sprintf("%s:%d", "ghcr.io/aquasecurity/trivy-java-db", SchemaVersion) | |||
|
|||
// AWS ECR | |||
DefaultECRRepository = fmt.Sprintf("%s:%d", "public.ecr.aws/aquasecurity/trivy-db", SchemaVersion) |
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.
DefaultECRRepository = fmt.Sprintf("%s:%d", "public.ecr.aws/aquasecurity/trivy-db", SchemaVersion) | |
DefaultECRRepository = fmt.Sprintf("%s:%d", "public.ecr.aws/aquasecurity/trivy-java-db", SchemaVersion) |
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.
Thanks @benji78 !
pkg/remote/remote.go
Outdated
token := registry.GetToken(ctx, domain, option) | ||
if !lo.IsEmpty(token) { | ||
opts = append(opts, remote.WithAuth(&token)) | ||
// The default trivy-db and trivy-java-db repositories are public. |
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.
If I understand correctly, there is no chance that mirror.gcr.io
requires authentication. We should skip mirror.gcr.io
here.
if domain != gcrURLDomain && !strings.HasSuffix(domain, gcrURLSuffix) && !strings.HasSuffix(domain, garURLSuffix) { |
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.
yeah, you're probably right, I didn't think about it
Changed in 99e96bb
docs/docs/configuration/db.md
Outdated
|
||
#### Authenticated use of Registries | ||
By authenticating with the registries that Trivy hosts its DBs on can significantly increase the limit for users. For Amazon ECR, the details for rate limits can be found [ecr-limits]. | ||
For GitHub GHCR, the rate limits can be found [ghcr-limits] |
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.
It's not correct. GHCR doesn't respect the GitHub token now.
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.
But some users wrote that GH token helps them.
Do you think that for GHCR it makes no difference at all whether the user is authorized or not when downloading the image?
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.
But some users wrote that GH token helps them.
Trivy has a bug that doesn't reflect GITHUB_TOKEN
now, so I'm sure those users luckily didn't see rate limit errors.
I saw the same rate limit error when I set the token, so I believe it has no effect on GHCR. If we confirm it helps, we can add it back.
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.
Got it!
Removed info about GHCR in c18a511
pkg/javadb/client.go
Outdated
@@ -29,6 +29,9 @@ const ( | |||
var ( | |||
// GitHub Container Registry | |||
DefaultGHCRRepository = fmt.Sprintf("%s:%d", "ghcr.io/aquasecurity/trivy-java-db", SchemaVersion) | |||
|
|||
// GHC mirrors |
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.
nit
// GHC mirrors | |
// GCR mirrors |
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.
thanks! fixed in 272b1a0
#### Authenticated use of Registries | ||
By authenticating with the registries that Trivy hosts its DBs on can significantly increase the limit for users. For Amazon ECR, the details for rate limits can be found [ecr-limits]. | ||
|
||
Please see more info on how to authenticate with ECR [auth-ecr]. |
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.
Is Amazon ECR still relevant here if it has been replaced by GCR?
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.
We still push trivy-db and trivy-java-db into ECR.
So this is still relevant for users using ECR.
|
||
#### Caching DBs | ||
Trivy DB and Trivy Java DB are published every 6 hours and 24 hours, respectively. If you are running Trivy scans more often than this, you can significantly benefit from caching the DBs on each run and updating them as needed. | ||
Once example of this can be seen in Trivy Action, where with caching multiple CI invocations can be performed with a single download of the DBs. More on info Trivy Action caching can be found [trivy-action-cache]. |
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.
There is an extra c
in Once
which should be One example of this …
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.
Thanks! We will fix that in another PR.
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.
@aqua-bot backport release/v0.57 |
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
Backport PR created: #7944 |
Description
Adds public
mirror.gcr.io
registry as a fallback for both vuln-db and java-db.Issues
mirror.gcr.io
as default DB repository #7938Related PRs
Checklist