Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

caroalmirola
Copy link

@caroalmirola caroalmirola commented Dec 14, 2020

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

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

@caroalmirola caroalmirola requested a review from a team as a code owner December 14, 2020 15:36
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

@pavel-snyk pavel-snyk reopened this Feb 19, 2021
@@ -79,6 +79,9 @@
@Parameter
private boolean failOnAuthError = false;

@Parameter
private boolean onlyFailFixable = false;
Copy link
Contributor

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.

Comment on lines +300 to +310
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;
}

Copy link
Contributor

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))) {
Copy link
Contributor

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.

Copy link
Contributor

@pavel-snyk pavel-snyk left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants