-
Notifications
You must be signed in to change notification settings - Fork 123
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
New feature: Exempt vulnerabilities for single archives (digests) #319
Conversation
To be tested: (De)serialization of |
f4a21c2
to
06d7ef1
Compare
rest-backend/src/main/java/com/sap/psr/vulas/backend/rest/HubIntegrationController.java
Show resolved
Hide resolved
"modifiedBy": null, | ||
"cvssDisplayString": "7.5 (v2.0)" | ||
}, | ||
"constructList": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about how this test file was created but I think it comes from running the code as in the serialization of the vulnerableDependency the View to be used was missing and thus the constructList was serialized even if we never did it as it's not required by the client at this step.
shared/src/main/java/com/sap/psr/vulas/shared/json/model/ExemptionBug.java
Outdated
Show resolved
Hide resolved
shared/src/main/java/com/sap/psr/vulas/shared/json/model/ExemptionScope.java
Outdated
Show resolved
Hide resolved
shared/src/main/java/com/sap/psr/vulas/shared/json/model/ExemptionUnassessed.java
Show resolved
Hide resolved
} | ||
|
||
// Deprecated format | ||
final String[] bugs = _cfg.getStringArray(DEPRECATED_CFG_PREFIX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this step old exemptions existing in the db are not kept into account as their key does not contain the prefix vulas. and thus doesn't match DEPRECATED_CFG_PREFIX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a mismatch between old config keys where the prefix vulas. was removed and the new ones. As a result exemptions saved with older clients are not considered. This would also impact the way exemptions are read from Configuration objects vs the Map.
I also added a test to show that the digest/reasons values returned passing from the Map are different than those obtained via the Configuration objects
I can also do the changes but first I want to agree on the prefix.
Still something is not working as expected as the JSON from the test system contains the following (but JUnit tests are successfully checking that the content is correct) "exemption": { This happens when separators are not escaped to be part of the key (https://commons.apache.org/proper/commons-configuration/javadocs/v1.10/apidocs/index.html?org/apache/commons/configuration/PropertiesConfiguration.html) Also, to double check that vulas:report only exempts a certain CVE for the specified digest. |
|
||
// New setting | ||
if(_map.containsKey(CFG)) { | ||
final String[] scopes = _map.get(DEPRECATED_CFG).split(","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be final String[] scopes = _map.get(CFG).split(",");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I just pushed it.
…essment-tool into exempt-vuln-digest
} | ||
else { | ||
is_exempted = is_exempted && | ||
(purl.getNamespace()==null || libid.getMvnGroup().equals(purl.getNamespace())) && // No purl.namespace || purl.namespace==libid.mvnGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we allow exemptions for library ids whose namespace (aka mvn group) is not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package URLs for Python packages will not have a namespace. Alternatively, we can consider the type, but such if-else conditions would not be nice either. Moreover, I do not know whether the prg. language can be easily determined at this point in time.
if(lib.startsWith("pkg:")) { | ||
try { | ||
final PackageURL purl = new PackageURL(lib); | ||
if(purl.getName()==null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is linked to the previous comment, why not requiring that also the namespace is not null?
…for maven and pypi)
…ffectedLibraries from exemptions
…of a merge conflict
Until release 3.1.6, vulnerabilities could be exempted by combining the configuration settings
vulas.report.exceptionExcludeBugs
andvulas.report.exceptionExcludeBugs.<ID>
, whereby the former enumerates all vulnerability identifiers that should not cause a build exception, and the latter was used to provide a corresponding reason for every identifier<ID>
, e.g.,The feature implemented with this PR simplifies and extends exemptions: First, the enumeration is not required any longer. Second, the exemption can be done for single archives (by specifying their digest) or all archives (by using
*
)The following example exempts
ABC
, no matter the affected library (indicated by the wildcard*
), andXYZ
for the archives with digest123
and456
.Moreover, the configuration used to exempt entire scopes changes to
vulas.report.exemptScope
.TODO
s