feat: Add a flag to fail when one or more suppression rules are not used#7244
Merged
jeremylong merged 15 commits intodependency-check:mainfrom Dec 20, 2024
ftiercelin:main
Merged
feat: Add a flag to fail when one or more suppression rules are not used#7244jeremylong merged 15 commits intodependency-check:mainfrom ftiercelin:main
jeremylong merged 15 commits intodependency-check:mainfrom
ftiercelin:main
Conversation
…red by NvdCveClientBuilder#withLastModifiedFilter replace minusDays(-120) with plusDays(120) when calculating end date for increased legibility
fix indentation
add a flag to fail when one or more suppression rules are not used
Contributor
Author
|
to demonstrate the functionality: <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>DemoProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DemoProject</name>
<description>DemoProject</description>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>... version ...</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>11.1.2-SNAPSHOT</version>
<configuration>
<failBuildOnUnusedSuppressionRule> ... flag ...</failBuildOnUnusedSuppressionRule>
<skipProvidedScope>true</skipProvidedScope>
<skipTestScope>true</skipTestScope>
<failOnError>true</failOnError>
<suppressionFile>src/owasp.suppression.xml</suppressionFile>
<nvdApiKey> ... api key ...</nvdApiKey>
<autoUpdate>false</autoUpdate>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>and this suppression file listing a CVE for org.json version 20230618: <?xml version="1.0" encoding="UTF-8"?>
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
<suppress>
<notes><![CDATA[
file name: json-20230618.jar
]]></notes>
<packageUrl regex="true">^pkg:maven/org\.json/json@.*$</packageUrl>
<vulnerabilityName>CVE-2023-5072</vulnerabilityName>
</suppress>
</suppressions>Setting the version of the JSON library and the value of the flag, running each time
without the
|
Collaborator
|
Thank you for the work here! Haven't looked at the detail - but this would be great/useful! :-) |
jeremylong
requested changes
Dec 16, 2024
Collaborator
jeremylong
left a comment
There was a problem hiding this comment.
Can you please add this to the CLI as well, so that if there are unused suppression rules it will return a positive, non-zero error code?
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue
#7165
Description of Change
add a flag,
failBuildOnUnusedSuppressionRule, which will cause the build to fail if there are unused suppression rules.Have test cases been added to cover the new functionality?
yes, a new test class was created: org.owasp.dependencycheck.analyzer.UnusedSuppressionRuleAnalyzerTest