From 5d5a0a56e459f76aa2fcd58147cbe604c57ac82d Mon Sep 17 00:00:00 2001 From: xeraph Date: Tue, 21 Dec 2021 21:44:48 +0900 Subject: [PATCH] Fixed csv report formatting, v2.5.1 --- README.md | 16 ++++++++-------- pom.xml | 2 +- .../com/logpresso/scanner/Log4j2Scanner.java | 2 +- .../java/com/logpresso/scanner/ReportEntry.java | 6 +++--- .../com/logpresso/scanner/ReportGenerator.java | 5 ++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6b432ce..adf07ea 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ log4j2-scan is a single binary command-line tool for CVE-2021-44228 vulnerability scanning and mitigation patch. It also supports nested JAR file scanning and patch. It also detects CVE-2021-45046 (log4j 2.15.0), CVE-2021-45105 (log4j 2.16.0), CVE-2021-4104 (log4j 1.x), and CVE-2021-42550 (logback 0.9-1.2.7) vulnerabilities. ### Download -* [log4j2-scan 2.5.0 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0-win64.7z) -* [log4j2-scan 2.5.0 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0-win64.zip) +* [log4j2-scan 2.5.1 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1-win64.7z) +* [log4j2-scan 2.5.1 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1-win64.zip) * If you get `VCRUNTIME140.dll not found` error, install [Visual C++ Redistributable](https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170). * If native executable doesn't work, use the JAR instead. 32bit is not supported. * 7zip is available from www.7zip.org, and is open source and free. -* [log4j2-scan 2.5.0 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0-linux.tar.gz) -* [log4j2-scan 2.5.0 (Linux aarch64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0-linux-aarch64.tar.gz) +* [log4j2-scan 2.5.1 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1-linux.tar.gz) +* [log4j2-scan 2.5.1 (Linux aarch64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1-linux-aarch64.tar.gz) * If native executable doesn't work, use the JAR instead. 32bit is not supported. -* [log4j2-scan 2.5.0 (Mac OS)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0-darwin.tar.gz) -* [log4j2-scan 2.5.0 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.0/logpresso-log4j2-scan-2.5.0.jar) +* [log4j2-scan 2.5.1 (Mac OS)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1-darwin.tar.gz) +* [log4j2-scan 2.5.1 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.5.1/logpresso-log4j2-scan-2.5.1.jar) ### Build * [How to build Native Image](https://github.com/logpresso/CVE-2021-44228-Scanner/wiki/FAQ#how-to-build-native-image) @@ -22,7 +22,7 @@ Just run log4j2-scan.exe or log4j2-scan with target directory path. The logpress Usage ``` -Logpresso CVE-2021-44228 Vulnerability Scanner 2.5.0 (2021-12-21) +Logpresso CVE-2021-44228 Vulnerability Scanner 2.5.1 (2021-12-21) Usage: log4j2-scan [--scan-log4j1] [--fix] target_path1 target_path2 -f [config_file_path] @@ -93,7 +93,7 @@ On Linux ``` On UNIX (AIX, Solaris, and so on) ``` -java -jar logpresso-log4j2-scan-2.5.0.jar [--fix] target_path +java -jar logpresso-log4j2-scan-2.5.1.jar [--fix] target_path ``` If you add `--fix` option, this program will copy vulnerable original JAR file to .bak file, and create new JAR file without `org/apache/logging/log4j/core/lookup/JndiLookup.class` entry. All .bak files are archived into the single zip file which is named by `log4j2_scan_backup_yyyyMMdd_HHmmss.zip`, then deleted safely. In most environments, JNDI lookup feature will not be used. However, you must use this option at your own risk. You can easily restore original vulnerable JAR files using `--restore` option. diff --git a/pom.xml b/pom.xml index 9aaad75..b7b47c4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.logpresso log4j2-scanner - 2.5.0 + 2.5.1 jar Logpresso Log4j2 Scanner diff --git a/src/main/java/com/logpresso/scanner/Log4j2Scanner.java b/src/main/java/com/logpresso/scanner/Log4j2Scanner.java index ca91ec9..808f120 100644 --- a/src/main/java/com/logpresso/scanner/Log4j2Scanner.java +++ b/src/main/java/com/logpresso/scanner/Log4j2Scanner.java @@ -23,7 +23,7 @@ import com.logpresso.scanner.utils.ZipUtils; public class Log4j2Scanner { - public static final String VERSION = "2.5.0"; + public static final String VERSION = "2.5.1"; public static final String RELEASE_DATE = "2021-12-21"; public static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner " + VERSION + " (" + RELEASE_DATE + ")"; diff --git a/src/main/java/com/logpresso/scanner/ReportEntry.java b/src/main/java/com/logpresso/scanner/ReportEntry.java index 0f60fce..25cd4db 100644 --- a/src/main/java/com/logpresso/scanner/ReportEntry.java +++ b/src/main/java/com/logpresso/scanner/ReportEntry.java @@ -89,9 +89,9 @@ public String getJsonLine(String hostname) { df.format(reportTime), hostname, escapedPath, escapedEntry, product, version, cve, status, fixed); } - public String getCsvLine() { + public String getCsvLine(String hostname) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return String.format("\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"%n", path.getAbsolutePath(), entry, product, - version, cve, status, fixed ? "FIXED" : "", df.format(reportTime)); + return String.format("\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"%n", hostname, path.getAbsolutePath(), + entry, product, version, cve, status, fixed ? "FIXED" : "", df.format(reportTime)); } } diff --git a/src/main/java/com/logpresso/scanner/ReportGenerator.java b/src/main/java/com/logpresso/scanner/ReportGenerator.java index 1cea664..a207401 100644 --- a/src/main/java/com/logpresso/scanner/ReportGenerator.java +++ b/src/main/java/com/logpresso/scanner/ReportGenerator.java @@ -118,7 +118,7 @@ private static File generateReportFileName(Configuration config, Metrics metrics private static void writeCsvReport(Configuration config, Map> fileReports, FileOutputStream csvStream) throws IOException, UnsupportedEncodingException { - String header = String.format("Hostname,Path,Entry,Product,Version,CVE,Status,Fixed,Detected at%n"); + String header = String.format("\"Hostname\",\"Path\",\"Entry\",\"Product\",\"Version\",\"CVE\",\"Status\",\"Fixed\",\"Detected at\"%n"); csvStream.write(header.getBytes("utf-8")); String hostname = getHostname(config.isDebug()); @@ -127,8 +127,7 @@ private static void writeCsvReport(Configuration config, Map