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

Fixes logpresso/CVE-2021-44228-Scanner#273 #278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}
}