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

Feat: Support Trivy status filtering #844

Merged

Conversation

inFocus7
Copy link
Contributor

@inFocus7 inFocus7 commented Aug 29, 2023

What this PR does / why we need it:
Adds ability to filter by image vulnerability status through a new field ignoredStatuses in components.scanner.config.
https://aquasecurity.github.io/trivy/v0.44/docs/configuration/filtering/#by-status

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #821

Special notes for your reviewer:
Still needs to be (manually) end-to-end tested. Have only "verified" it works based on logic and the small test for the config, but have not done any manual verification.

Manual Verification Steps

Install Eraser with updated scanner

  1. kind create cluster
  2. make docker-build-trivy-scanner TRIVY_SCANNER_IMG=eraser-trivy-scanner:dev
  3. kind load docker-image eraser-trivy-scanner:dev
  4. helm upgrade --install eraser charts/eraser --values override.yaml (seen below)

Test Eraser with vulnerable image

  1. docker pull docker.io/library/alpine:3.7.3 (pulling vulnerable image)
  2. docker exec -ti kind-control-plane bash
  3. crictl images (in the bash)
  4. kind load docker-image alpine:3.7.3
    • Repeat this while updating the override.yaml and doing helm upgrade --install eraser charts/eraser --values override.yaml to see it taking effect.
    • When fixed is an ignored status, the image does not get deleted. When we don't ignore it, it gets deleted (as expected). That alpine image only has a single CRITICAL - fixed vuln.

override.yaml

runtimeConfig:
  manager:
    scheduling:
      repeatInterval: "1s"
  components:
    collector:
      enabled: true
      image:
        tag: "v1.2.1"
    scanner:
      enabled: true
      image:
        repo: "docker.io/library/eraser-trivy-scanner"
        tag: "dev"
      config: |
         cacheDir: /var/lib/trivy
         dbRepo: ghcr.io/aquasecurity/trivy-db
         deleteFailedImages: false
         deleteEOLImages: false
         vulnerabilities:
           ignoreUnfixed: false
           types:
             - os
             - library
           securityChecks:
             - vuln
           severities:
             - CRITICAL
           ignoredStatuses:
             - fixed
    remover:
      image:
        tag: "v1.2.1"

deploy:
  image:
    repo: ghcr.io/eraser-dev/eraser-manager
    pullPolicy: IfNotPresent
    tag: "v1.2.1"

Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
@inFocus7 inFocus7 force-pushed the feat/support-trivy-status-filtering branch from 7896ebf to 27aea68 Compare August 30, 2023 03:27
@salaxander
Copy link
Contributor

@inFocus7 Thank you for the contribution! :)

charts/eraser/values.yaml Outdated Show resolved Hide resolved
deploy/eraser.yaml Outdated Show resolved Hide resolved
@sozercan sozercan requested a review from pmengelbert August 30, 2023 21:49
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
@inFocus7 inFocus7 marked this pull request as ready for review August 30, 2023 21:59
@ashnamehrotra
Copy link
Contributor

Looks like helm pull secret test was failing due to PodTemplate not found error which we fixed recently. Tests pass after rebase.

Copy link
Contributor

@ashnamehrotra ashnamehrotra left a comment

Choose a reason for hiding this comment

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

LGTM after rebase

@inFocus7
Copy link
Contributor Author

@ashnamehrotra Thanks! It looks like some checks failed, not sure if they were flakes though

@ashnamehrotra
Copy link
Contributor

@inFocus7 I think they may be flakes. I cannot re-run the failed tests, would you be able to do that again so we can check?

@sozercan
Copy link
Member

@inFocus7 I can't seem to re-run tests either, checking if closing and re-opening resolves this

@sozercan sozercan closed this Nov 28, 2023
@sozercan sozercan reopened this Nov 28, 2023
@inFocus7
Copy link
Contributor Author

inFocus7 commented Nov 28, 2023

@sozercan @ashnamehrotra Thanks all!

So looks like they were flakes, theres just two failing checks now.

  1. Trivy fails due to CVE in kubernetes, requiring an upgrade.
  2. Linting fails due to dot imports in controller/suite_test.go.
    • Unsure if this is a new check failure, although the dot imports have existed for months/years.
    • Should I update the test to use the named imports (gomega.<...>, ginkgo.<...>?

@ashnamehrotra
Copy link
Contributor

@inFocus7 made those changes in #917! Once that is merged we should be good to rebase. There are still vulns in the trivy binary which we can ignore for now since we cannot fix those.

@ashnamehrotra ashnamehrotra merged commit 8fbd155 into eraser-dev:main Nov 29, 2023
170 of 171 checks passed
@inFocus7
Copy link
Contributor Author

🥳

ashnamehrotra pushed a commit to ashnamehrotra/eraser that referenced this pull request Jan 25, 2024
Signed-off-by: Fabian Gonzalez <fabiangonz98@gmail.com>
Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
Signed-off-by: ashnamehrotra <ashnamehrotra@gmail.com>
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.

support for trivy status
4 participants