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

[Trivy] Support for properties #3369

Closed
2 tasks done
fnxpt opened this issue Jan 10, 2024 · 6 comments · Fixed by #3620
Closed
2 tasks done

[Trivy] Support for properties #3369

fnxpt opened this issue Jan 10, 2024 · 6 comments · Fixed by #3620
Labels
enhancement New feature or request integration/trivy Related to the Trivy integration
Milestone

Comments

@fnxpt
Copy link

fnxpt commented Jan 10, 2024

Current Behavior

Currently when scanning with trivy analyser we are not able to pass properties from sbom since they are not stored

Proposed Behavior

As soon as #2560 is fixed we can use these properties in #3251

Checklist

@fnxpt fnxpt added the enhancement New feature or request label Jan 10, 2024
@nscuro nscuro mentioned this issue Jan 18, 2024
2 tasks
@nscuro
Copy link
Member

nscuro commented Feb 25, 2024

@fnxpt Did you do some testing by chance as per what properties specifically need to be provided?

I added an integration test here that documents the current state of things:

/**
* This test documents the case where Trivy is unable to correlate a package with vulnerabilities
* in its database, unless additional properties are provided. When including libc6 in an SBOM,
* Trivy adds metadata to the component, which among other things includes alternative package names.
* <p>
* Here's an excerpt of the properties included:
* <pre>
* "properties": [
* {
* "name": "aquasecurity:trivy:LayerDiffID",
* "value": "sha256:256d88da41857db513b95b50ba9a9b28491b58c954e25477d5dad8abb465430b"
* },
* {
* "name": "aquasecurity:trivy:LayerDigest",
* "value": "sha256:43f89b94cd7df92a2f7e565b8fb1b7f502eff2cd225508cbd7ea2d36a9a3a601"
* },
* {
* "name": "aquasecurity:trivy:PkgID",
* "value": "[email protected]"
* },
* {
* "name": "aquasecurity:trivy:PkgType",
* "value": "ubuntu"
* },
* {
* "name": "aquasecurity:trivy:SrcName",
* "value": "glibc"
* },
* {
* "name": "aquasecurity:trivy:SrcRelease",
* "value": "0ubuntu3.4"
* },
* {
* "name": "aquasecurity:trivy:SrcVersion",
* "value": "2.35"
* }
* ]
* </pre>
* <p>
* To reproduce, run:
* <pre>
* docker run -it --rm aquasec/trivy image --format cyclonedx registry.hub.knime.com/knime/knime-full:r-5.1.2-433
* </pre>
*
* @see <a href="https://github.com/DependencyTrack/dependency-track/issues/2560">Add support for CycloneDX component properties</a>
* @see <a href="https://github.com/DependencyTrack/dependency-track/issues/3369">Support component properties with Trivy</a>
*/
@Test
public void testWithUnrecognizedPackageName() {
final var project = new Project();
project.setName("acme-app");
qm.persist(project);
final var componentA = new Component();
componentA.setProject(project);
componentA.setName("libc6");
componentA.setVersion("2.35-0ubuntu3.4");
componentA.setClassifier(Classifier.LIBRARY);
componentA.setPurl("pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-22.04");
qm.persist(componentA);
final var analysisEvent = new TrivyAnalysisEvent(List.of(componentA));
new TrivyAnalysisTask().inform(analysisEvent);
assertThat(qm.getAllVulnerabilities(componentA)).isEmpty();
}

I played around with sending the listed properties to Trivy, but even when I send them all, I don't get any vulnerabilities.

@nscuro nscuro added the integration/trivy Related to the Trivy integration label Feb 25, 2024
@fnxpt
Copy link
Author

fnxpt commented Feb 26, 2024

Im not passing the properties yet... the test I did was simple sending it manually to trivy

@nscuro
Copy link
Member

nscuro commented Feb 26, 2024

Yes I meant manual testing.

When I tested yesterday I modified the code accordingly.

@fnxpt
Copy link
Author

fnxpt commented Feb 26, 2024

I need to double check it... not sure if I will be able to do it today, but for sure tomorrow

@nscuro
Copy link
Member

nscuro commented Feb 26, 2024

Thanks, but no need to sweat it.

I was hoping to close this gap before the 4.11 release. Adding support for component properties isn't that much work. There is a pending PR from a contributor that brings us 80% there. So if we can proof that forwarding properties works as expected, I can add this capability.

nscuro added a commit to nscuro/dependency-track that referenced this issue Feb 26, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Mar 2, 2024
@nscuro nscuro added this to the 4.11 milestone Mar 3, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Mar 4, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Mar 16, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Mar 26, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Apr 1, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Apr 8, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Apr 14, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Apr 14, 2024
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request integration/trivy Related to the Trivy integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants