@@ -90,6 +90,7 @@ public class Log4JDetector {
90
90
91
91
private static File currentDir = null ;
92
92
private static String currentPath = null ;
93
+ private static boolean printFullPaths = false ;
93
94
94
95
public static void main (String [] args ) throws IOException {
95
96
currentDir = canonicalize (new File ("." ));
@@ -525,12 +526,14 @@ public void close() {
525
526
buf .append ("== 2.12.4 _SAFE_" );
526
527
} else {
527
528
buf .append ("== 2.12.3 _OKAY_" );
529
+ foundHits = true ;
528
530
}
529
531
} else if (isLog4j2_17 ) {
530
532
if (hasJdbcJndiDisabled ) {
531
533
buf .append (">= 2.17.1 _SAFE_" );
532
534
} else {
533
535
buf .append ("== 2.17.0 _OKAY_" );
536
+ foundHits = true ;
534
537
}
535
538
} else if (isLog4j2_16 ) {
536
539
buf .append ("== 2.16.0 _OKAY_" );
@@ -550,6 +553,7 @@ public void close() {
550
553
buf .append ("== 2.3.2 _SAFE_" );
551
554
} else {
552
555
buf .append ("== 2.3.1 _OKAY_" );
556
+ foundHits = true ;
553
557
}
554
558
} else {
555
559
buf .append (">= 2.0-beta9 (< 2.10.0) _VULNERABLE_" );
@@ -576,10 +580,14 @@ public void close() {
576
580
}
577
581
578
582
private static String prepareOutput (String zipPath , StringBuilder buf ) {
579
- if (zipPath .startsWith (currentPath )) {
580
- zipPath = zipPath .substring (currentPath .length ());
581
- if (zipPath .startsWith (File .separator )) {
582
- zipPath = zipPath .substring (1 );
583
+ if (!printFullPaths ) {
584
+ if (zipPath .startsWith (currentPath )) {
585
+ zipPath = zipPath .substring (currentPath .length ());
586
+ if (zipPath .startsWith (File .separator )) {
587
+ zipPath = zipPath .substring (1 );
588
+ }
589
+ } else {
590
+ printFullPaths = true ;
583
591
}
584
592
}
585
593
if (json ) {
@@ -866,12 +874,14 @@ private static void analyze(File f) {
866
874
buf .append ("== 2.12.4 _SAFE_" );
867
875
} else {
868
876
buf .append ("== 2.12.3 _OKAY_" );
877
+ foundHits = true ;
869
878
}
870
879
} else {
871
880
if (hasJdbcJndiDisabled ) {
872
881
buf .append (">= 2.17.1 _SAFE_" );
873
882
} else {
874
883
buf .append ("== 2.17.0 _OKAY_" );
884
+ foundHits = true ;
875
885
}
876
886
}
877
887
} else if (isLog4J_2_15 ) {
@@ -895,6 +905,7 @@ private static void analyze(File f) {
895
905
buf .append ("== 2.3.2 _SAFE_" );
896
906
} else {
897
907
buf .append ("== 2.3.1 _OKAY_" );
908
+ foundHits = true ;
898
909
}
899
910
} else {
900
911
buf .append (">= 2.0-beta9 (< 2.10.0) _VULNERABLE_" );
0 commit comments