forked from DependencyTrack/dependency-track
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Trivy IT to use OS component and properties
Relates to DependencyTrack#3369 Signed-off-by: nscuro <[email protected]>
- Loading branch information
Showing
1 changed file
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
package org.dependencytrack.tasks.scanners; | ||
|
||
import alpine.model.IConfigProperty; | ||
import alpine.security.crypto.DataEncryption; | ||
import org.dependencytrack.PersistenceCapableTest; | ||
import org.dependencytrack.event.TrivyAnalysisEvent; | ||
|
@@ -177,19 +178,30 @@ 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)); | ||
|
||
final var osComponent = new Component(); | ||
osComponent.setProject(project); | ||
osComponent.setName("ubuntu"); | ||
osComponent.setVersion("22.04"); | ||
osComponent.setClassifier(Classifier.OPERATING_SYSTEM); | ||
qm.persist(osComponent); | ||
|
||
final var component = new Component(); | ||
component.setProject(project); | ||
component.setName("libc6"); | ||
component.setVersion("2.35-0ubuntu3.4"); | ||
component.setClassifier(Classifier.LIBRARY); | ||
component.setPurl("pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-22.04"); | ||
qm.persist(component); | ||
|
||
qm.createComponentProperty(component, "aquasecurity:trivy", "SrcName", "glibc", IConfigProperty.PropertyType.STRING, null); | ||
qm.createComponentProperty(component, "aquasecurity:trivy", "SrcVersion", "2.35", IConfigProperty.PropertyType.STRING, null); | ||
qm.createComponentProperty(component, "aquasecurity:trivy", "SrcRelease", "0ubuntu3.4", IConfigProperty.PropertyType.STRING, null); | ||
|
||
final var analysisEvent = new TrivyAnalysisEvent(List.of(osComponent, component)); | ||
new TrivyAnalysisTask().inform(analysisEvent); | ||
|
||
assertThat(qm.getAllVulnerabilities(componentA)).isEmpty(); | ||
assertThat(qm.getAllVulnerabilities(component)).isEmpty(); | ||
} | ||
|
||
} |