Skip to content

Commit

Permalink
Release 3.0.3 fixed bug caused by EPSS changing response format. Bett…
Browse files Browse the repository at this point in the history
…er diagnostic output in exception cases.
  • Loading branch information
EdgewareRoad committed Jun 7, 2024
1 parent 72209fa commit d6481aa
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 3.0.3:

Fixed bug caused by EPSS API changing response format - now ignores new fields
Better diagnostics in exception conditions (separate message for files not found, error trace when EPSS API
generates exception)

Release 3.0.2:

If the scan date is today, TrivySummary now omits the date from the EPSS Query as this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fujitsu.edgewareroad.trivysummary;

public class TrivyScanCouldNotRetrieveEPSSScoresException extends Exception {
public TrivyScanCouldNotRetrieveEPSSScoresException(String message)
public TrivyScanCouldNotRetrieveEPSSScoresException(String message, Exception e)
{
super(message);
super(message, e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public boolean summariseTrivyHistory(String title) throws IOException, TrivyScan
updateEPSSScores(openVulnerabilities, false, epssQueryDate);
openVulnerabilities.prioritiseForRemediation(configuration.getPriorityModel());
} catch (Exception e) {
throw new TrivyScanCouldNotRetrieveEPSSScoresException(String.format("Could not retrieve EPSS scores for open vulnerabilities; Cannot create graph or prioritise vulnerabilities. Please check connectivity to %s or re-run TrivySummary with --offline.", BASE_EPSS_API_URL));
throw new TrivyScanCouldNotRetrieveEPSSScoresException(String.format("Could not retrieve EPSS scores for open vulnerabilities; Cannot create graph or prioritise vulnerabilities. Please check connectivity to %s or re-run TrivySummary with --offline.", BASE_EPSS_API_URL), e);
}
// Now update EPSS scores for closed vulnerabilities.
try {
Expand Down Expand Up @@ -251,7 +251,7 @@ else if (history.getScanHistory().size() == 1)
updateEPSSScores(openVulnerabilities, false, epssQueryDate);
openVulnerabilities.prioritiseForRemediation(configuration.getPriorityModel());
} catch (Exception e) {
throw new TrivyScanCouldNotRetrieveEPSSScoresException(String.format("Could not retrieve EPSS scores for open vulnerabilities; Cannot create graph or prioritise vulnerabilities. Please check connectivity to %s or re-run TrivySummary with --offline.", BASE_EPSS_API_URL));
throw new TrivyScanCouldNotRetrieveEPSSScoresException(String.format("Could not retrieve EPSS scores for open vulnerabilities; Cannot create graph or prioritise vulnerabilities. Please check connectivity to %s or re-run TrivySummary with --offline.", BASE_EPSS_API_URL), e);
}
// Now update EPSS scores for whitelisted vulnerabilities.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -184,14 +185,20 @@ else if (inputFiles.size() == 1)
displayHelp();
this.exitCode = -1;
return;
} catch (FileNotFoundException e) {
output("ERROR: Priority model not found %s", priorityModelPath.toString());
output("");
displayHelp();
this.exitCode = -1;
return;
} catch (IOException e) {
output("ERROR: File IO exception for priority model %s", priorityModelPath.toString());
output("");
displayHelp();
this.exitCode = -1;
return;
}
}
}
}
}

Expand Down Expand Up @@ -222,6 +229,12 @@ else if (inputFiles.size() == 1)
displayHelp();
this.exitCode = -1;
return;
} catch (FileNotFoundException e) {
output("ERROR: Whitelist file not found %s", whiteListFilePath.toString());
output("");
displayHelp();
this.exitCode = -1;
return;
} catch (IOException e) {
output("ERROR: File IO exception for whitelist file %s", whiteListFilePath.toString());
output("");
Expand All @@ -239,6 +252,12 @@ else if (inputFiles.size() == 1)

try {
worker.addTrivyScanFileToHistory(filePath);
} catch (FileNotFoundException e) {
output("ERROR: Could not find input file %s", filePath.toString());
output("");
displayHelp();
this.exitCode = -1;
return;
} catch (IOException e) {
output("ERROR: Could not read input file %s", filePath.toString());
output("");
Expand Down Expand Up @@ -273,6 +292,7 @@ else if (inputFiles.size() == 1)
return;
} catch (TrivyScanCouldNotRetrieveEPSSScoresException e) {
output("ERROR: %s", e.getMessage());
output("Cause of EPSS score retrieval failure: %s: %s", e.getCause().getClass().getName(), e.getCause().getMessage());
this.exitCode = -1;
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.fujitsu.edgewareroad.trivyutils.dto.firstapiv1;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public class EPSSResponse {
@JsonProperty
private String status;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trivysummary.version=3.0.2
trivysummary.version=3.0.3

logging.level.root=ERROR

Expand Down

0 comments on commit d6481aa

Please sign in to comment.