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

Add Registry Mirrors to Trivy #673

Merged
merged 2 commits into from
Sep 13, 2021
Merged

Conversation

shaardie
Copy link
Contributor

This patch adds the option to use mirrors for the docker registries in trivy.
This way it is possible to download the images from self-hosted mirrors instead
of e.g. index.docker.io. This has some benefits, like not being hit by download
restrictions.

I tried to also add this new Feature to the docs and I also wrote unit tests for it.

In the contributing guidelines is mentioned that for every PR there should also be a issue, but when generating a new issue of kind feature request, I am redirected to the discussion. So I skipped creating an issue for this, but I can do it afterwards, if necessary. For now I will point to the already existing discussion #260.

This patch adds the option to use mirrors for the docker registries in trivy.
This way it is possible to download the images from self-hosted mirrors instead
of e.g. index.docker.io. This has some benefits, like not being hit by download
restrictions.
@codecov
Copy link

codecov bot commented Sep 8, 2021

Codecov Report

Merging #673 (5c95364) into main (91e65c8) will decrease coverage by 0.46%.
The diff coverage is 79.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #673      +/-   ##
==========================================
- Coverage   66.20%   65.73%   -0.47%     
==========================================
  Files          58       58              
  Lines        5903     6170     +267     
==========================================
+ Hits         3908     4056     +148     
- Misses       1617     1714      +97     
- Partials      378      400      +22     
Impacted Files Coverage Δ
pkg/plugin/trivy/plugin.go 82.71% <79.31%> (+0.08%) ⬆️
pkg/kube/object.go 56.66% <0.00%> (-11.55%) ⬇️
pkg/configauditreport/scanner.go 59.74% <0.00%> (-3.90%) ⬇️
pkg/configauditreport/builder.go 81.03% <0.00%> (-3.64%) ⬇️
pkg/operator/predicate/predicate.go 87.67% <0.00%> (-3.51%) ⬇️
pkg/operator/controller/plugins_config.go 45.45% <0.00%> (-2.55%) ⬇️
pkg/kube/logs.go 35.84% <0.00%> (-2.16%) ⬇️
pkg/cmd/installer.go 46.21% <0.00%> (-1.13%) ⬇️
pkg/plugin/conftest/plugin.go 81.00% <0.00%> (-0.60%) ⬇️
pkg/kubehunter/scanner.go 75.71% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91e65c8...5c95364. Read the comment docs.

Copy link
Contributor

@danielpacak danielpacak left a comment

Choose a reason for hiding this comment

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

👋 Thank you for working on this enhancement @shaardie . I believe it can be useful. Please check my comments and questions before we merge the code.

docs/integrations/vulnerability-scanners/trivy.md Outdated Show resolved Hide resolved
pkg/plugin/trivy/plugin.go Outdated Show resolved Hide resolved
pkg/plugin/trivy/plugin_test.go Outdated Show resolved Hide resolved
docs/integrations/vulnerability-scanners/trivy.md Outdated Show resolved Hide resolved
pkg/plugin/trivy/plugin.go Outdated Show resolved Hide resolved
pkg/plugin/trivy/plugin.go Outdated Show resolved Hide resolved
* Use a single configuration key to describe the registry as well as the
  mirror.
* More meaningful error inspection in tests.
* Use github.com/google/go-containerregistry to parse image reference.
Copy link
Contributor

@danielpacak danielpacak left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @shaardie for reworking this PR and great contribution 🚀

@danielpacak danielpacak merged commit c68ad51 into aquasecurity:main Sep 13, 2021
@danielpacak danielpacak added this to the Release v0.12.0 milestone Sep 13, 2021
py-go added a commit to py-go/starboard that referenced this pull request Sep 29, 2021
This patch adds the option to use image digest for the container scanning in Trivy.
trivy --skip-update --cache-dir /var/lib/trivyx --format json <container imageID/Digest>
@travisghansen
Copy link

Is this a client-side setting or server-side setting? How would I utilize it running outside of k8s? Thanks in advance for examples!

@chen-keinan
Copy link
Contributor

@travisghansen if you'll update it on the starboard-trivy-config it will work for you with client as well

@travisghansen
Copy link

How would I configure it for basic cli usage (in a client server setup). I will add to starboard but I also run trivy in CI where I’d prefer to use local mirrors to keep the traffic down. I just don’t see cli arg that correspond for using it in that fashion so I’m trying to figure out what those helm values are really doing.

@chen-keinan
Copy link
Contributor

@travisghansen you should update the configmap directly via kubctl patch command , in this case

@travisghansen
Copy link

travisghansen commented Nov 13, 2022

For me when using via CI, k8s is not involved at all (neither server nor client). I’m trying to figure out what the requirements are to configure it without any k8s-isms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants