-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* WINDUPRULE-1018: new ruleset for eap8 log4j removed * fix typo and logic error in rule 00001 * alter ruleset description --------- Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> (cherry picked from commit 4c2e12d) Co-authored-by: Mark Brophy <36955467+m-brophy@users.noreply.github.com>
- Loading branch information
1 parent
79ad740
commit 656723b
Showing
11 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
rules/rules-reviewed/eap8/eap7/log4j-removed.windup.xml
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,147 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="log4j-removed" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<metadata> | ||
<description> | ||
This ruleset provides analysis of Java EE applications that use log4j which is no longer bundled within EAP8 | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" /> | ||
</dependencies> | ||
<sourceTechnology id="eap" versionRange="[6,8)" /> | ||
<targetTechnology id="eap" versionRange="[8,)" /> | ||
</metadata> | ||
<rules> | ||
<rule id="log4j-removed-00001"> | ||
<when> | ||
|
||
<and> | ||
<javaclass references="org.apache.log4j.Logger"> | ||
<location>IMPORT</location> | ||
</javaclass> | ||
<not> | ||
<or> | ||
<file filename="log4j.xml"/> | ||
<file filename="log4j.properties"/> | ||
<file filename="jboss-log4j.xml"/> | ||
</or> | ||
</not> | ||
<not> | ||
<or> | ||
<project> | ||
<artifact groupId="log4j" artifactId="log4j" /> | ||
</project> | ||
<dependency groupId="log4j" artifactId="log4j" /> | ||
<file filename="log4j.jar"/> | ||
</or> | ||
</not> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Log4j version 1 is not longer provided in EAP8" effort="1" category-id="mandatory"> | ||
<message>Log4j usage without configuration files</message> | ||
<link href="https://access.redhat.com/articles/6973120" title="Migration: Apache Log4j version 1 is not longer provided in EAP 8"/> | ||
</hint> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00002"> | ||
<when> | ||
<not> | ||
<or> | ||
<project> | ||
<artifact groupId="log4j" artifactId="log4j" /> | ||
</project> | ||
<dependency groupId="log4j" artifactId="log4j" /> | ||
<file filename="log4j.jar"/> | ||
</or> | ||
</not> | ||
<and> | ||
<javaclass references="org.apache.log4j.Logger"> | ||
<location>IMPORT</location> | ||
</javaclass> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Log4j version 1 is not longer provided in EAP8" effort="1" category-id="mandatory"> | ||
<message>Log4j usage without including `log4j.jar`</message> | ||
<link href="https://access.redhat.com/articles/6973120" title="Migration: Apache Log4j version 1 is not longer provided in EAP 8"/> | ||
</hint> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00003"> | ||
<when> | ||
<not> | ||
<or> | ||
<project> | ||
<artifact groupId="log4j" artifactId="log4j" /> | ||
</project> | ||
<dependency groupId="log4j" artifactId="log4j" /> | ||
<file filename="log4j.jar"/> | ||
</or> | ||
</not> | ||
<and> | ||
<file filename="{config-filename}"/> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Log4j version 1 is not longer provided in EAP8" effort="1" category-id="mandatory"> | ||
<message>Log4j configuration without including `log4j.jar`</message> | ||
<link href="https://access.redhat.com/articles/6973120" title="Migration: Apache Log4j version 1 is not longer provided in EAP 8"/> | ||
</hint> | ||
</perform> | ||
<where param="config-filename"> | ||
<matches pattern="(log4j.xml|log4j.properties|jboss-log4j.xml)"/> | ||
</where> | ||
</rule> | ||
<rule id="log4j-removed-00004"> | ||
<when> | ||
<not> | ||
<or> | ||
<project> | ||
<artifact groupId="log4j" artifactId="log4j" /> | ||
</project> | ||
<dependency groupId="log4j" artifactId="log4j" /> | ||
<file filename="log4j.jar"/> | ||
</or> | ||
</not> | ||
<and> | ||
<filecontent pattern="custom-handler{*}org.apache.log4j.{*}Appender" filename="{*}.xml"/> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Log4j version 1 is not longer provided in EAP8" effort="1" category-id="mandatory"> | ||
<message>Log4j custom-handler using appender</message> | ||
<link href="https://access.redhat.com/articles/6973120" title="Migration: Apache Log4j version 1 is not longer provided in EAP 8"/> | ||
</hint> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00005"> | ||
<when> | ||
<not> | ||
<or> | ||
<project> | ||
<artifact groupId="log4j" artifactId="log4j" /> | ||
</project> | ||
<dependency groupId="log4j" artifactId="log4j" /> | ||
<file filename="log4j.jar"/> | ||
</or> | ||
</not> | ||
<and> | ||
<or> | ||
<filecontent pattern="org.jboss.log4j.logmanager" filename="jboss-deployment-structure.xml"/> | ||
<filecontent pattern="org.jboss.log4j.logmanager" filename="Manifest.MF"/> | ||
</or> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Log4j version 1 is not longer provided in EAP8" effort="1" category-id="mandatory"> | ||
<message>Log4j module dependency declaration</message> | ||
<link href="https://access.redhat.com/articles/6973120" title="Migration: Apache Log4j version 1 is not longer provided in EAP 8"/> | ||
</hint> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
8 changes: 8 additions & 0 deletions
8
rules/rules-reviewed/eap8/eap7/tests/data/log4j-removed-no-config/Test.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,8 @@ | ||
import org.apache.log4j.Logger; | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
Logger logger = new Logger(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
rules/rules-reviewed/eap8/eap7/tests/data/log4j-removed-with-config/Manifest.MF
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 @@ | ||
Dependencies: org.jboss.log4j.logmanager |
8 changes: 8 additions & 0 deletions
8
rules/rules-reviewed/eap8/eap7/tests/data/log4j-removed-with-config/Test.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,8 @@ | ||
import org.apache.log4j.Logger; | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
Logger logger = new Logger(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...es-reviewed/eap8/eap7/tests/data/log4j-removed-with-config/jboss-deployment-structure.xml
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,7 @@ | ||
<jboss-deployment-structure> | ||
<deployment> | ||
<dependencies> | ||
<module name="org.jboss.log4j.logmanager" export="FALSE"/> | ||
</dependencies> | ||
</deployment> | ||
</jboss-deployment-structure> |
Empty file.
Empty file.
Empty file.
19 changes: 19 additions & 0 deletions
19
rules/rules-reviewed/eap8/eap7/tests/data/log4j-removed-with-config/standalone.xml
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,19 @@ | ||
<subsystem xmlns="urn:jboss:domain:logging:1.2"> | ||
<custom-handler name="log4jAppender" class="org.apache.log4j.FileAppender" module="org.apache.log4j"> | ||
<formatter> | ||
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> | ||
</formatter> | ||
<level name="INFO"/> | ||
<properties> | ||
<property name="append" value="true"/> | ||
<property name="file" value="${jboss.server.log.dir}/log4j.log"/> | ||
<property name="immediateFlush" value="true"/> | ||
</properties> | ||
</custom-handler> | ||
<root-logger> | ||
<level name="INFO"/> | ||
<handlers> | ||
<handler name="log4jAppender"/> | ||
</handlers> | ||
</root-logger> | ||
</subsystem> |
24 changes: 24 additions & 0 deletions
24
rules/rules-reviewed/eap8/eap7/tests/log4j-removed-no-config.windup.test.xml
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,24 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="log4j-removed-no-config-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<testDataPath>data/log4j-removed-no-config/</testDataPath> | ||
<rulePath>../log4j-removed.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="log4j-removed-00001-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="Log4j usage without configuration files"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[log4j-removed-00001] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
60 changes: 60 additions & 0 deletions
60
rules/rules-reviewed/eap8/eap7/tests/log4j-removed.windup.test.xml
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,60 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="log4j-removed-with-config-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<testDataPath>data/log4j-removed-with-config/</testDataPath> | ||
<rulePath>../log4j-removed.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="log4j-removed-00002-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="Log4j usage without including `log4j.jar`"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[log4j-removed-00002] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00003-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="3"> | ||
<hint-exists message="Log4j configuration without including `log4j.jar`"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[log4j-removed-00003] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00004-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="Log4j custom-handler using appender"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[log4j-removed-00004] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
<rule id="log4j-removed-00005-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="2"> | ||
<hint-exists message="Log4j module dependency declaration"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[log4j-removed-00005] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |