-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to suppress a vulnerability when it is only found as a transitive dependency via the listed dependencies. (WIP, needs further testing) Related to #5686
- Loading branch information
Showing
4 changed files
with
112 additions
and
2 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
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
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
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 |
---|---|---|
|
@@ -85,6 +85,22 @@ public void testCpe() { | |
|
||
} | ||
|
||
/** | ||
* Test of IncludedBy property, of class SuppressionRule. | ||
*/ | ||
@Test | ||
public void testGetIncludedBy() { | ||
SuppressionRule instance = new SuppressionRule(); | ||
List<String> includedBy = new ArrayList<>(); | ||
instance.setIncludedBy(includedBy); | ||
assertFalse(instance.hasIncludedBy()); | ||
instance.addIncludedBy("pkg:maven/com.github.spotbugs/[email protected]"); | ||
assertTrue(instance.hasIncludedBy()); | ||
List<String> result = instance.getIncludedBy(); | ||
assertEquals(includedBy, result); | ||
} | ||
|
||
|
||
/** | ||
* Test of CvssBelow property, of class SuppressionRule. | ||
*/ | ||
|
@@ -130,6 +146,17 @@ public void testCve() { | |
assertEquals(cve, result); | ||
} | ||
|
||
public void testIncludedBy() { | ||
SuppressionRule instance = new SuppressionRule(); | ||
List<String> includedBy = new ArrayList<>(); | ||
instance.setIncludedBy(includedBy); | ||
assertFalse(instance.hasIncludedBy()); | ||
instance.addIncludedBy("pkg:maven/com.github.spotbugs/[email protected]"); | ||
assertTrue(instance.hasIncludedBy()); | ||
List<String> result = instance.getIncludedBy(); | ||
assertEquals(includedBy, result); | ||
} | ||
|
||
/** | ||
* Test of base property, of class SuppressionRule. | ||
*/ | ||
|
@@ -418,6 +445,8 @@ public void testProcess() throws CpeValidationException { | |
dependency.addVulnerableSoftwareIdentifier(cpeId); | ||
String sha1 = dependency.getSha1sum(); | ||
dependency.setSha1sum("384FAA82E193D4E4B0546059CA09572654BC3970"); | ||
dependency.addIncludedBy("pkg:maven/com.github.spotbugs/[email protected]"); | ||
dependency.addIncludedBy("pkg:maven/org.apache.kafka/[email protected]"); | ||
Vulnerability v = createVulnerability(); | ||
dependency.addVulnerability(v); | ||
|
||
|
@@ -454,6 +483,17 @@ public void testProcess() throws CpeValidationException { | |
assertTrue(dependency.getVulnerabilities().isEmpty()); | ||
assertEquals(1, dependency.getSuppressedVulnerabilities().size()); | ||
|
||
//includedBy | ||
dependency.addVulnerability(v); | ||
instance = new SuppressionRule(); | ||
instance.addIncludedBy("pkg:maven/com.github.spotbugs/[email protected]"); | ||
instance.process(dependency); | ||
assertEquals(1, dependency.getVulnerabilities().size()); | ||
instance.addIncludedBy("pkg:maven/org.apache.kafka/[email protected]"); | ||
instance.process(dependency); | ||
assertTrue(dependency.getVulnerabilities().isEmpty()); | ||
assertEquals(1, dependency.getSuppressedVulnerabilities().size()); | ||
|
||
//cpe | ||
instance = new SuppressionRule(); | ||
PropertyType pt = new PropertyType(); | ||
|