-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.logpresso.scanner; | ||
|
||
public interface DeleteTargetChecker { | ||
boolean isTarget(String entryPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/logpresso/scanner/Log4j2DeleteTargetChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.logpresso.scanner; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class Log4j2DeleteTargetChecker implements DeleteTargetChecker { | ||
|
||
private static final String JNDI_LOOKUP_CLASS_PATH = "org/apache/logging/log4j/core/lookup/JndiLookup.class"; | ||
private boolean includeLog4j1; | ||
private Set<String> targets; | ||
|
||
public Log4j2DeleteTargetChecker(boolean includeLog4j1) { | ||
this.includeLog4j1 = includeLog4j1; | ||
|
||
targets = new HashSet<String>(); | ||
if (includeLog4j1) { | ||
targets.add("org/apache/log4j/jdbc/JDBCAppender.class"); | ||
for (String name : Arrays.asList("SocketServer.class", "JMSAppender.class", "SMTPAppender$1.class", | ||
"SMTPAppender.class", "JMSSink.class")) | ||
targets.add("org/apache/log4j/net/" + name); | ||
} | ||
|
||
targets.add(JNDI_LOOKUP_CLASS_PATH); | ||
|
||
} | ||
|
||
@Override | ||
public boolean isTarget(String entryPath) { | ||
if (targets.contains(entryPath)) | ||
return true; | ||
|
||
return includeLog4j1 && entryPath.startsWith("org/apache/log4j/chainsaw/"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters