From 9e0eba02bde91cfe259d3f54a7489785076f50ec Mon Sep 17 00:00:00 2001 From: hokching Date: Fri, 7 Jan 2022 17:35:23 +0800 Subject: [PATCH] Update Log4JDetector.java 1. Canonicalize paths in --exclude array 2. Add para dump, mainly for troubleshooting in Windows (without this I will not be able to come out with the exclude argument below (see https://github.com/mergebase/log4j-detector/issues/62#issuecomment-1005549050): java -jar log4j-detector-2021.12.20.jar --verbose --exclude="[\"D:\\\\scan\\\\nf\\\\item\\\\ignore\", \"D:\\\\scan\\\\nf\\\\item\\\\ignore2\"]" d:\scan\nf --- src/main/java/com/mergebase/log4j/Log4JDetector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mergebase/log4j/Log4JDetector.java b/src/main/java/com/mergebase/log4j/Log4JDetector.java index 764e149..8e73c8a 100644 --- a/src/main/java/com/mergebase/log4j/Log4JDetector.java +++ b/src/main/java/com/mergebase/log4j/Log4JDetector.java @@ -101,8 +101,10 @@ public static void main(String[] args) throws IOException { Iterator it = argsList.iterator(); List stdinLines = new ArrayList(); + int argIdx = 0; while (it.hasNext()) { final String argOrig = it.next().trim(); + System.out.println("Arg #" + argIdx++ + ": " + argOrig); if ("--debug".equals(argOrig)) { debug = true; it.remove(); @@ -122,7 +124,9 @@ public static void main(String[] args) throws IOException { List list = (List) o; for (Object obj : list) { if (obj != null) { - excludes.add(String.valueOf(obj)); + + String excl_canon = canonicalize(new File(String.valueOf(obj))).getPath(); + excludes.add(excl_canon); } } }