Skip to content

Commit 3489790

Browse files
authored
Merge pull request #716 from kwwall/log4j-loose-ends
Log4j loose ends
2 parents e4fc652 + 92239e8 commit 3489790

23 files changed

+89
-98
lines changed

Diff for: documentation/LoggerDesignAndTesting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ The general workflow is:
2222

2323
Logger.info/warn/etc(message) -> forwards to LogBridgelog(logger, esapiLevel, type, message) -> forwards to LogHandler.log(...) -> forwards to slf4j Logger implementation with appropriate level and composed message.
2424

25-
So each of the tests for each of the classes verifies data in -> data out based on the Logging API. The structure for JUL, Log4J, and SLF4J are almost identical. There are a few differences in the interaction with the underlying Logger interactions and expectations. As a result, the tests are also almost full duplications (again accounting for differences in the underlying logging API).
25+
So each of the tests for each of the classes verifies data in -> data out based on the Logging API. The structure for JUL and SLF4J are almost identical. There are a few differences in the interaction with the underlying Logger interactions and expectations. As a result, the tests are also almost full duplications (again accounting for differences in the underlying logging API).
2626

2727
-J

Diff for: pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<version.powermock>2.0.9</version.powermock>
141141
<version.spotbugs>4.7.1</version.spotbugs>
142142
<version.findsecbugs>1.12.0</version.findsecbugs>
143-
<version.spotbugs.maven>4.7.0.0</version.spotbugs.maven>
143+
<version.spotbugs.maven>4.7.1.0</version.spotbugs.maven>
144144
<version.surefire>3.0.0-M7</version.surefire>
145145
<project.java.target>1.8</project.java.target>
146146
<!-- TODO: Be sure to update. Should be date of previous official release -->
@@ -406,7 +406,7 @@
406406
<plugin>
407407
<groupId>org.apache.maven.plugins</groupId>
408408
<artifactId>maven-assembly-plugin</artifactId>
409-
<version>3.4.0</version>
409+
<version>3.4.1</version>
410410
</plugin>
411411
<plugin>
412412
<groupId>org.apache.maven.plugins</groupId>
@@ -538,7 +538,7 @@
538538
<dependency>
539539
<groupId>org.codehaus.mojo</groupId>
540540
<artifactId>extra-enforcer-rules</artifactId>
541-
<version>1.5.1</version>
541+
<version>1.6.0</version>
542542
</dependency>
543543
<dependency>
544544
<groupId>org.codehaus.mojo</groupId>

Diff for: scripts/esapi-release.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ USAGE="Usage: $PROG esapi_svn_dir"
6464
tmpdir="/tmp/$PROG.$RANDOM-$$"
6565
esapi_release_dir="$tmpdir/esapi_release_dir"
6666

67-
# This is the directory under esapi_svn_dir where the log4j and ESAPI
68-
# properties files are located as well as the $esapiConfig/* config files.
67+
# This is the directory under esapi_svn_dir where ESAPI configuration files
68+
# such as ESAPI.properties are located as well as the $esapiConfig/* config files.
6969
# Note that formerly used to be under src/main/resources, but it since
7070
# has been moved because where it was previously was causing problems with
7171
# Sonatype's Nexus. That particular problem may have been resolved, but it
@@ -141,7 +141,7 @@ mkdir $jartmpdir
141141
cd $jartmpdir || exit
142142
jar xf "$jarfile"
143143
rm -fr ${esapiConfig:?}
144-
rm -f properties/* log4j.*
144+
rm -f properties/*
145145
rm -f settings.xml owasp-esapi-dev.jks
146146
# TODO: This part would need some work if we sign or seal the ESAPI jar as
147147
# that creates a special MANIFEST.MF file and other special files and

Diff for: scripts/esapi4java-core-TEMPLATE-release-notes.txt

+1-11
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Issue # GitHub Issue Title
5151
@@@@ NOTE any special notes here. Probably leave this one, but I would suggest noting additions BEFORE this.
5252
[If you have already successfully been using ESAPI 2.2.1.0 or later, you probably can skip this section.]
5353

54-
Since ESAPI 2.2.1.0, the new default ESAPI logger is JUL (java.util.logging packages) and we have deprecated the use of Log4J 1.x because we now support SLF4J and Log4J 1.x is way past its end-of-life. We did not want to make SLF4J the default logger (at least not yet) as we did not want to have the default ESAPI use require additional dependencies. However, SLF4J is likely to be the future choice, at least once we start on ESAPI 3.0. A special shout-out to Jeremiah Stacey for making this possible by re-factoring much of the ESAPI logger code. Note, the straw that broke the proverbial camel's back was the announcement of CVE-2019-17571 (rated Critical), for which there is no fix available and likely will never be.
54+
Since ESAPI 2.2.1.0, the new default ESAPI logger is JUL (java.util.logging packages) and we had deprecated the use of Log4J 1.x because was way past its end-of-life. (Note: As of ESAPI 2.5.0.0, we have officially removed all Log4J 1 dependencies, after it had been deprecated for 2 years as per our deprecation policy.) We did not want to make SLF4J the default logger (at least not yet) as we did not want to have the default ESAPI use require additional dependencies. However, SLF4J is likely to be the future choice, at least once we start on ESAPI 3.0. A special shout-out to Jeremiah Stacey for making this possible by re-factoring much of the ESAPI logger code. Note, the straw that broke the proverbial camel's back was the announcement of CVE-2019-17571 (rated Critical), for which there is no fix available and likely will never be.
5555

5656
However, if you try to juse the new ESAPI 2.2.1.0 or later logging you will notice that you need to change ESAPI.Logger and also possibly provide some other properties as well to get the logging behavior that you desire.
5757

@@ -87,11 +87,6 @@ If you are using JavaLogFactory, you will also want to ensure that you have the
8787
See GitHub issue #560 for additional details.
8888

8989

90-
Related to that aforemented Log4J 1.x CVE and how it affects ESAPI, be sure to read
91-
https://github.com/ESAPI/esapi-java-legacy/blob/develop/documentation/ESAPI-security-bulletin2.pdf
92-
which describes CVE-2019-17571, a deserialization vulnerability in Log4J 1.2.17. ESAPI is *NOT* affected by this (even if you chose to use Log4J 1 as you default ESAPI logger). This security bulletin describes why this CVE is not exploitable as used by ESAPI.
93-
94-
9590
Finally, while ESAPI still supports JDK 7 (even though that too is way past end-of-life), the next ESAPI release will move to JDK 8 as the minimal baseline. (We already use Java 8 for development but still to Java 7 source and runtime compatibility.) We need to do this out of necessity because some of our dependencies are no longer doing updates that support Java 7.
9691

9792
-----------------------------------------------------------------------------
@@ -127,11 +122,6 @@ Another problem is if you run 'mvn test' from the 'cmd' prompt (and possibly Pow
127122

128123
We believe these failures is because the maven-surefire-plugin is by default not forking a new JVM process for each test class. We are looking into this. For now, we have only have observed this behavior on Windows 10. If you see this error, please do NOT report it as a GitHub issue unless you know a fix for it. (And yes, we are aware of '<reuseForks>false</reuseForks>' in the pom for the maven-surefire-plugin, but that causes other tests to fail that we haven't had time to fix.)
129124

130-
131-
Lastly, some SCA services may continue to flag vulnerabilties in ESAPI ${VERSION} related to log4j 1.2.17 (e.g., CVE-2020-9488). We do not believe the way that ESAPI uses log4j in a manner that leads to any exploitable behavior. See the security bulletins
132-
https://github.com/ESAPI/esapi-java-legacy/blob/develop/documentation/ESAPI-security-bulletin2.pdf
133-
for additional details.
134-
135125
-----------------------------------------------------------------------------
136126

137127
Other changes in this release, some of which not tracked via GitHub issues

Diff for: src/examples/java/DisplayEncryptedProperties.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// that were encrypted using ESAPI's EncryptedProperties class.
99
//
1010
// Usage: java -classpath <cp> DisplayEncryptedProperties encryptedPropFileName
11-
// where <cp> is proper classpath, which minimally include esapi.jar & log4j.jar
11+
// where <cp> is proper classpath, which minimally includes the esapi.jar.
1212
public class DisplayEncryptedProperties {
1313

1414
public DisplayEncryptedProperties() {

Diff for: src/examples/java/ESAPILogging.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Purpose: Short code snippet to show how ESAPI logging works.
55
//
66
// Usage: java -classpath <cp> ESAPILogging
7-
// where <cp> is proper classpath, which minimally include esapi.jar & log4j.jar
7+
// where <cp> is proper classpath, which minimally includes the esapi.jar.
88
public class ESAPILogging {
99

1010
public static void main(String[] args) {

Diff for: src/examples/scripts/encryptProperties.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ cd ../java
4949
if [[ "$action" == "-display" ]]
5050
then
5151
set -x
52-
java -Dlog4j.configuration="file:$log4j_properties" \
53-
-Dorg.owasp.esapi.resources="$esapi_resources_test" \
52+
java -Dorg.owasp.esapi.resources="$esapi_resources_test" \
5453
-classpath "$esapi_classpath" \
5554
DisplayEncryptedProperties "$filename"
5655
else
@@ -65,8 +64,7 @@ else
6564
echo
6665
echo "Hit <Enter> to continue..."; read GO
6766
set -x
68-
java -Dlog4j.configuration="file:$log4j_properties" \
69-
-Dorg.owasp.esapi.resources="$esapi_resources_test" \
67+
java -Dorg.owasp.esapi.resources="$esapi_resources_test" \
7068
-classpath "$esapi_classpath" \
7169
org.owasp.esapi.reference.crypto.DefaultEncryptedProperties "$filename" &&
7270
echo "Output of encrypted properties in file: $filename"

Diff for: src/examples/scripts/persistEncryptedData.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ set -x
2323
# Since this is just an illustration, we will use the test ESAPI.properties in
2424
# $esapi_resources_test. That way, it won't matter if the user has neglected
2525
# to run the 'setMasterKey.sh' example before running this one.
26-
java -Dlog4j.configuration="file:$log4j_properties" \
27-
-Dorg.owasp.esapi.resources="$esapi_resources_test" \
28-
-ea -classpath "$esapi_classpath" \
29-
PersistedEncryptedData "$@"
26+
java -Dorg.owasp.esapi.resources="$esapi_resources_test" \
27+
-ea -classpath "$esapi_classpath" \
28+
PersistedEncryptedData "$@"

Diff for: src/examples/scripts/runClass.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ then echo >2&1 "Can't find class file: ${className}.class"
1919
exit 1
2020
fi
2121
echo "Your ESAPI.properties file: ${esapi_resources_test:?}/ESAPI.properties"
22-
echo "Your log4j properties file: ${log4j_properties:?}"
2322
echo
2423
set -x
25-
java -Dlog4j.configuration="file:$log4j_properties" \
26-
-Dorg.owasp.esapi.resources="$esapi_resources_test" \
24+
java -Dorg.owasp.esapi.resources="$esapi_resources_test" \
2725
-classpath "$esapi_classpath" \
2826
${className} "$@"

Diff for: src/examples/scripts/setMasterKey.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ echo
1616
# set -x
1717
# This should use the real ESAPI.properties in $esapi_resources that does
1818
# not yet have Encryptor.MasterKey and Encryptor.MasterSalt yet set.
19-
java -Dlog4j.configuration="file:$log4j_properties" \
20-
-Dorg.owasp.esapi.resources="$esapi_resources" \
19+
java -Dorg.owasp.esapi.resources="$esapi_resources" \
2120
-classpath "$esapi_classpath" \
2221
org.owasp.esapi.reference.crypto.JavaEncryptor "$@"

Diff for: src/examples/scripts/setenv-svn.sh

+5-17
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@
99
# where '$' represents the shell command line prompt.
1010
###########################################################################
1111

12-
# IMPORTANT NOTE: Since you may have multiple (say) log4j jars under
13-
# your Maven2 repository under $HOME/.m2/respository, we
14-
# look for the specific versions that ESAPI was using as of
15-
# ESAPI 2.0_RC10 release on 2010/10/18. If these versions
16-
# changed, they will have to be reflected here.
17-
#
12+
# IMPORTANT NOTE: These dependency versions may need updated. Should match
13+
# what is in ESAPI's pom.xml.
1814
esapi_classpath=".:\
1915
../../../target/classes:\
2016
$(ls ../../../target/esapi-*.jar 2>&- || echo .):\
21-
$(./findjar.sh log4j-1.2.17.jar):\
22-
$(./findjar.sh commons-fileupload-1.3.1.jar):\
23-
$(./findjar.sh servlet-api-2.5.jar)"
17+
$(./findjar.sh commons-fileupload-1.4.jar):\
18+
$(./findjar.sh servlet-api-3.1.0.jar)"
2419

2520
esapi_resources="$(\cd ../../../configuration/esapi >&- 2>&- && pwd)"
2621
esapi_resources_test="$(\cd ../../../src/test/resources/esapi >&- 2>&- && pwd)"
2722

28-
log4j_properties="../../../src/test/resources/log4j.xml"
2923

3024
if [[ ! -r "$esapi_resources"/ESAPI.properties ]]
3125
then echo 2>&1 "setenv-svn.sh: Can't read ESAPI.properties in $esapi_resources"
@@ -37,16 +31,10 @@ then echo 2>&1 "setenv-svn.sh: Can't read ESAPI.properties in $esapi_resources_t
3731
return 1 # Don't use 'exit' here or it will kill their current shell.
3832
fi
3933

40-
if [[ ! -r "$log4j_properties" ]]
41-
then echo 2>&1 "setenv-svn.sh: Can't read log4j.xml: $log4j_properties"
42-
return 1 # Don't use 'exit' here or it will kill their current shell.
43-
fi
44-
4534
echo ############################################################
4635
echo "esapi_resources=$esapi_resources"
4736
echo "esapi_resources_test=$esapi_resources_test"
48-
echo "log4j_properties=$log4j_properties"
4937
echo "esapi_classpath=$esapi_classpath"
5038
echo ############################################################
5139

52-
export esapi_classpath esapi_resources esapi_resources_test log4j_properties
40+
export esapi_classpath esapi_resources esapi_resources_test

Diff for: src/examples/scripts/setenv-zip.sh

+2-10
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
# Here we don't look for the specific versions of the dependent libraries
1313
# since the specific version of the library is delivered as part of the
1414
# ESAPI zip file. In this manner, we do not have to update this if these
15-
# versions change. For the record, at the time of this writing, these were
16-
# log4j-1.2.17.jar, commons-fileupload-1.3.1.jar, and servlet-api-2.5.jar.
15+
# versions change.
1716
esapi_classpath=".:\
1817
$(ls ../../../esapi*.jar):\
19-
$(./findjar.sh -start ../../../libs log4j-*.jar):\
2018
$(./findjar.sh -start ../../../libs commons-fileupload-*.jar):\
2119
$(./findjar.sh -start ../../../libs servlet-api-*.jar)"
2220

2321
esapi_resources="$(\cd ../../../configuration/esapi >&- 2>&- && pwd)"
2422
esapi_resources_test="$(\cd ../../../src/test/resources/esapi >&- 2>&- && pwd)"
2523

26-
log4j_properties="../../../src/test/resources/log4j.xml"
2724

2825
if [[ ! -r "$esapi_resources"/ESAPI.properties ]]
2926
then echo 2>&1 "setenv-svn.sh: Can't read ESAPI.properties in $esapi_resources"
@@ -35,16 +32,11 @@ then echo 2>&1 "setenv-svn.sh: Can't read ESAPI.properties in $esapi_resources_t
3532
return 1 # Don't use 'exit' here or it will kill their current shell.
3633
fi
3734

38-
if [[ ! -r "$log4j_properties" ]]
39-
then echo 2>&1 "setenv-svn.sh: Can't read log4j.xml: $log4j_properties"
40-
return 1 # Don't use 'exit' here or it will kill their current shell.
41-
fi
4235

4336
echo ############################################################
4437
echo "esapi_resources=$esapi_resources"
4538
echo "esapi_resources_test=$esapi_resources_test"
46-
echo "log4j_properties=$log4j_properties"
4739
echo "esapi_classpath=$esapi_classpath"
4840
echo ############################################################
4941

50-
export esapi_classpath esapi_resources esapi_resources_test log4j_properties
42+
export esapi_classpath esapi_resources esapi_resources_test

Diff for: src/main/assembly/dist.xml

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
<outputDirectory>configuration</outputDirectory>
3939
<includes>
4040
<include>esapi/**/*</include>
41-
<include>log4j.dtd</include>
42-
<include>log4j.xml</include>
4341
<include>properties/**/*</include>
4442
</includes>
4543
</fileSet>

0 commit comments

Comments
 (0)