Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Printed versions of secure versions - also in given Files
Refactoring report creation

"Copyright © 2021 Atruvia AG <[email protected]>"
  • Loading branch information
ChKemper committed Feb 15, 2022
1 parent 35c37dd commit ac82bf2
Showing 1 changed file with 18 additions and 29 deletions.
47 changes: 18 additions & 29 deletions src/main/java/com/logpresso/scanner/Detector.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,11 @@ public void addErrorReport(File jarFile, String error) {
if (errorReports.size() < 100000)
errorReports.add(entry);

// invoke listeners
for (LogListener listener : logListeners) {
try {
listener.onError(entry);
} catch (Throwable t) {
// listener should not throw any exception
if (config.isDebug())
t.printStackTrace();
}
}
addReport(jarFile, entry);
}

private void addReport(File jarFile, List<String> pathChain, String product, String version, String cve, boolean mitigated,
boolean potential) {
List<ReportEntry> entries = fileReports.get(jarFile);
if (entries == null) {
entries = new ArrayList<ReportEntry>();
fileReports.put(jarFile, entries);
}

Status status = Status.VULNERABLE;
if (mitigated)
Expand All @@ -632,18 +618,7 @@ else if (potential)
status = Status.POTENTIALLY_VULNERABLE;

ReportEntry entry = new ReportEntry(jarFile, StringUtils.toString(pathChain), product, version, cve, status);
entries.add(entry);

// invoke listeners
for (LogListener listener : logListeners) {
try {
listener.onDetect(entry);
} catch (Throwable t) {
// listener should not throw any exception
if (config.isDebug())
t.printStackTrace();
}
}
addReport(jarFile, entry);
}

private void reportError(File jarFile, String msg) {
Expand All @@ -652,12 +627,26 @@ private void reportError(File jarFile, String msg) {
}

private void addSafeReport(File jarFile, List<String> pathChain, String product, String version) {
ReportEntry entry = new ReportEntry(jarFile, StringUtils.toString(pathChain), product, version);
addReport(jarFile, entry);
}

private void addReport(File jarFile, ReportEntry reportEntry) {
List<ReportEntry> entries = fileReports.get(jarFile);
if (entries == null) {
entries = new ArrayList<ReportEntry>();
fileReports.put(jarFile, entries);
}
ReportEntry entry = new ReportEntry(jarFile, StringUtils.toString(pathChain), product, version);
entries.add(entry);
entries.add(reportEntry);
// invoke listeners
for (LogListener listener : logListeners) {
try {
listener.onDetect(reportEntry);
} catch (Throwable t) {
// listener should not throw any exception
if (config.isDebug())
t.printStackTrace();
}
}
}
}

0 comments on commit ac82bf2

Please sign in to comment.