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: return proper image digest #2310

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

d-mankowski-synerise
Copy link
Contributor

@d-mankowski-synerise d-mankowski-synerise commented Nov 10, 2024

Trivy Operator incorrectly reported imageID as image digest.

Fixes #2259

Description

Related issues

Remove this section if you don't have related PRs.

Checklist

  • [ x] I've read the guidelines for contributing to this repository.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Trivy Operator incorrectly reported imageID as image digest.

Fixes aquasecurity#2259
@github-actions github-actions bot added the bug label Nov 10, 2024
// - image ID (this is what is visible in 'docker image ls command')
// Execute docker image ls --digests --no-trunc <image> to see both digest and ID.
// See https://stackoverflow.com/questions/56364643/whats-the-difference-between-a-docker-images-image-id-and-its-digest
var imageDigest = strings.Split(reports.Metadata.RepoDigests[0], "@")[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

@d-mankowski-synerise any reason to strip the sha256@ prefix?

Copy link
Contributor Author

@d-mankowski-synerise d-mankowski-synerise Nov 12, 2024

Choose a reason for hiding this comment

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

copying from the issue you raised:

    "RepoDigests": [
      "<registry>/<image repo>@sha256:cf3e3b3a98edde46eac58d4745a2467b9da2bc49a11191565a893ffac38034a3"
    ],

so it is not stripping sha256 prefix, but <registry>/<repo>@ part

Copy link
Contributor

Choose a reason for hiding this comment

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

ohh, right! mixed up the delimiters 👍🏼

@@ -5,7 +5,10 @@
"Family": "alpine",
"Name": "3.10.2",
"EOSL": true
}
},
"RepoDigests": [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really sure why RepoDigests and other parameters are not included in this report (which, I assume, is the output of trivy i --format json alpine:3.10.2)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, looks like the fixture is incomplete, might have been generated with an older version of Trivy?

@dkulchinsky
Copy link
Contributor

looks like a bunch of tests need to be updated to account for the image digest: https://github.com/aquasecurity/trivy-operator/actions/runs/11804608055/job/32885192536?pr=2310

should be fairly simple to fix

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

Successfully merging this pull request may close these issues.

Vulnerability Report's report.artifact.digest field is the artifact's image_id not digest
2 participants