-
Notifications
You must be signed in to change notification settings - Fork 47
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
Filter fixable #94
base: main
Are you sure you want to change the base?
Filter fixable #94
Conversation
Carolina Almirola seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@@ -79,6 +79,9 @@ | |||
@Parameter | |||
private boolean failOnAuthError = false; | |||
|
|||
@Parameter | |||
private boolean onlyFailFixable = false; |
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.
@caroalmirola, let's keep parameter naming consistent (failOnSeverity, failOnAuthError).
How about failOnFixableOnly
.
private boolean isIssueFixable(JSONObject vuln) { | ||
boolean upgradable = | ||
(vuln.get("isUpgradable") != null && (boolean) vuln.get("isUpgradable")); | ||
boolean fixable = false; | ||
if (vuln.get("fixedIn") != null) { | ||
JSONArray fixedIn = (JSONArray) vuln.get("fixedIn"); | ||
fixable = (!fixedIn.isEmpty()); | ||
} | ||
return upgradable || fixable; | ||
} | ||
|
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.
An issue is fixable if it can be eliminated with an upgrade ("isUpgradable") or patch ("isPatchable").
|
||
Iterator<JSONObject> iterator = vulns.iterator(); | ||
while (iterator.hasNext()) { | ||
JSONObject vuln = iterator.next(); | ||
vulnIdSet.add((String)vuln.get("id")); | ||
Integer severityInt = severityMap.get(vuln.get("severity")); | ||
if(severityInt != null && severityInt > highestSeverity) { | ||
highestSeverity = severityInt; | ||
if (!onlyFailFixable || (onlyFailFixable && isIssueFixable(vuln))) { |
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 statement can be simplified. Atm second onlyFailFixable
is always true
.
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.
👋 @caroalmirola , please take a look on my comments
What does this PR do?
Adds configuration flag for only failing on non-fixable issues. That is, don't fail if the only issues that pass the severity threshold do not have a fix.
Initialize highestSeverity to Integer.MIN_VALUE in processVulns(). Previously, in the case that user defined failOnSeverity to low (or left it to default=low) and no vulnerabilities met the threshold, this would always fail.
Where should the reviewer start?
Logic added in SnykTest processVulns() to handle non-fixable issues.
How should this be manually tested?
By executing the plugin with the configuration flag onlyFailFixable set to true.
Any background context you want to provide?
N/A
What are the relevant tickets?
N/A
Screenshots
N/A
Additional questions
N/A