Skip to content

Commit 06aa99e

Browse files
kwwalljeremiahjstacey
authored andcommitted
Prepare 2.2.0.0-RC3 (ESAPI#497)
* ESAPI release notes * Prep for 2.2.0.0-RC3 releases. Update to 5.0.0 of Dependency Check. * Updates to prepare for 2.2.0.0 release. * Updates to prepare for 2.2.0.0 release. * Change 'import org.apache.commons.beanutils.*' to 'import org.apache.commons.beanutils.LazyDynaMap'. * Fix lead-in documentation and add static setCache(boolean) method to allow disabling class and method cache. Also, reduced initial size of case. No way we would ever need it that big. * Add testObjectFactoryCache() test. Fixed testMakeCipher() test so we could actually tell if it failed. * Removed empty initial comment line. * Added larger-than-life warning that this is a TEST VERSION and not to use it.
1 parent ff9fd96 commit 06aa99e

12 files changed

+240
-33
lines changed

CONTRIBUTING-TO-ESAPI.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Required Software:
4141
We use Maven for building. Maven 3.1 or later is required. You also need
4242
JDK 7 or later. (We generally use JDK 8, but compile ESAPI only to require
4343
JDK 7, which means our code can't yet use any features exclusive to Java 8
44-
or later.)
44+
or later.) [Note: If you use JDK 9 or later, there will be multiple
45+
failures when you try to run 'mvn test' as well as some general warnings.
46+
See ESAPI GitHub issue #496 for details.]
4547

4648
Building ESAPI:
4749
https://www.owasp.org/index.php/ESAPI-Building briefly discusses how to
@@ -73,10 +75,13 @@ Steps to work with ESAPI:
7375
git checkout -b issue-#
7476
4. Work on the GitHub issue on this newly created issue-# branch.
7577
5. Make sure everything builds correctly and all the JUnit tests pass
76-
('mvn test'). [Note: On occasion, there may be a failure in
77-
AuthenticatorTest.testGetCurrentUser(). If there is, run 'mvn test'
78-
again. It seems to be sporadic and it is hypothesized that it is
79-
related to some sort of race condition in the JUnit tests.]
78+
('mvn test'). [Note: There are some known issues with test failures if
79+
your are running under Windows and your local ESAPI Git repo located
80+
anywhere other than the C: drive, where the test
81+
ValidatorTest.testIsValidDirectoryPath() fails. Also, if you are using
82+
JDK 7 on Mac-OS, there is one know test failure in
83+
SecurityProviderLoaderTest.testWithBouncyCastle(). That same test works
84+
with JDK 8.]
8085
6. If you have added any dependencies, please also run
8186
mvn org.owasp:dependency-check-maven:check
8287
to run OWASP Dependency-Check and look at the generated report
@@ -98,6 +103,7 @@ Steps to work with ESAPI:
98103
$ git merge issue-444
99104

100105
In theory, you can do all this 'git' magic from Eclipse and presumably other
101-
IDEs like NetBeans or IntelliJ). From Eclipse, it is right-click on the
102-
project and then select 'Team' to do the commits, etc. If you choose that
103-
route, you're pretty much on your own because none of us use that.
106+
IDEs like Oracle NetBeans or IntelliJ IDEA). From Eclipse, it is right-click
107+
on the project and then select 'Team' to do the commits, etc. If you choose that
108+
route, you're pretty much on your own because none of us use that for Git
109+
interactions.

documentation/ESAPI-release-steps.odt

162 KB
Binary file not shown.

documentation/esapi4java-core-2.2.0.0-release-notes.txt

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Executive Summary: Important Things to Note for this Release
1616
* Known vulnerabilities still not addressed:
1717
- There is this critical CVE in log4j 2.x before 2.8.2: CVE-2017-5645. It is a Java deserialization vulnerability that can lead to arbitrary remote code execution. Some private vulnerability databases claim that this same vulnerability is present in log4j 1.x even though the CVE itself does not claim that. However, examination of this CVE shows that the vulnerability is associated with implementations of TcpSocketServer and UdpSocketServer, which implement fully functional socket servers that can be used to listen on network connections and record log events sent to server from various client applications. For ESAPI to be vulnerable to that, first someone would have to have an implementation of wone of those servers running and secondly, they would have to change ESAPI's log4j.xml configuration file so that it uses log4j's SocketAppender rather than the default ConsoleAppender that ESAPI's default deployment uses. Thus even if this vulnerability were present in log4j 1.x, ESAPI's use of ConsoleAppender makes it a non-issue.
1818
- There is a known and unpatched vulnerability in the SLF4J Extensions that some vulnerability scanners may pick up and associate with ESAPI's use of slf4j-api-1.7.25.jar. (Note that OWASP Dependency Check does NOT flag this vulnerability [CVE-2018-8088], but others may.) According to NVD, this vulnerability is associated with "org.slf4j.ext.EventData in the slf4j-ext module in QOS.CH SLF4J before 1.8.0-beta2". Fortunately, I have confirmed that this Java deserialization does not impact ESAPI. First off, the default configuration of ESAPI.properties does not use SLF4J, but even if an application should choose to use it, ESAPI does not include the slf4j-ext jar and it has been confirmed that the vulnerable class (org.slf4j.ext.EventData) is not included in the slf4j-api jar that ESAPI does. Unfortunately, this CVE is not patched in the latest SLF4J packages, so even if we were to update it to latest version (currently 1.80-beta2, as of 12/31/2018), any scanners that associate ESAPI with CVE-2018-8088 would still have this false positive. But the important thing to ESAPI users is to know that if this CVE is identified for ESAPI, that it is a false positive.
19+
- There is a recently discovered issue (see https://app.snyk.io/vuln/SNYK-JAVA-COMMONSBEANUTILS-30077) that is related to CVE-2014-0114 that is a Java deserialization issue in Apache Commons BeanUtils 1.9.3 that can lead to remote command execution attacks. This had been fixed in 1.9.2, but apparently they missed a place where the fix was needed. A GitHub commit (https://github.com/apache/commons-beanutils/pull/7/commits/2780a77600e6428b730e3a5197b7c5baf1c4cca0) has been made to mster branch of the BeanUtils repo, but thus far, no official patch has been released. ESAPI only uses BeanUtils in its AccessController (specifically, DynaBeanACRParameter class), where it has a dependency on org.apache.commons.beanutils.LazyDynaMap. Based on the BeanUtils commit, the fix was in org.apache.commons.beanutils2.PropertyUtilsBean. Based on a cursory examination, the ESAPI team does not believe that this vulnerability reported by Snyk is exploitable given that manner that it is used within ESAPI, or if it is, it is not externally exploitable based on the default access control rules that are provided with ESAPI. However, the ESAPI team will be watching for an official patch to Apache Commons BeanUtils and we will release a patched version of ESAPI as patch point release once a patch is officially available in Maven Central.
1920
- Otherwise, ESAPI 2.2.0.0 addresses all know CVEs except for CVE-2013-5960 (which I have fixed in a private BitBucket repo, but getting it to be backward compatible is proving to be more difficult than anticipated.) Besides, if you want to use encryption in Java, I'd highly recommend using Google Tink, which is much more fully featured than ESAPI. (Tink allows key rotation, storing keys in various cloud HSMs, etc.)
2021

2122

@@ -30,9 +31,9 @@ ESAPI 2.1.0.1 release:
3031

3132
ESAPI 2.2.0.0 release:
3233
194 source files
33-
4140 JUnit tests!!!!!
34+
4145 JUnit tests!!!!!
3435

35-
That's 2593 NEW tests!!!
36+
That's 2598 NEW tests since the 2.1.0.1 release!!!
3637

3738
GitHub Issues fixed in this release
3839
[i.e., since 2.1.0.1 release on 2016-Feb-05]
@@ -85,6 +86,7 @@ Issue # GitHub Issue Title
8586
301 encodeForHTMLAttribute escapes the forward slash
8687
302 HTMLEntityCodec#decode incorrectly decodes upper-case accented letters as their lower-case counterparts
8788
303 HTMLEntityCodec destroys 32-bit CJK (Chinese, Japanese and Korean) characters
89+
304 encodeForCSS breaks color values
8890
305 ClassCastException when using ESAPI logger
8991
307 Issue with decodeFromURL method in the DefaultEncoder
9092
308 AuthenticatedUser isCredentialsNonExpired() have todo comment, but default return false;
@@ -150,9 +152,11 @@ Issue # GitHub Issue Title
150152
471 Bump ESAPI release # to 2.2.0.0
151153
476 DefaultValidator.getValidInput implementation ignores 'canonicalize' method parameter
152154
478 Remove obsolete references to Google Code in pom.xml and any other release prep
155+
482 ESAPI 2.2.0.0 release date?
153156
483 More miscellaneous prep work for ESAPI 2.2.0.0 release
154157
485 Update Maven dependency check plugin to 5.0.0-M2
155-
158+
492 Release candidates on maven central
159+
493 wrong regex validation
156160

157161
-----------------------------------------------------------------------------
158162

@@ -305,25 +309,58 @@ List of all PRs closed since 2.1.0.1 (2016-Feb-05) -
305309
#472 by jeremiahjstacey was merged on Jan 21, 2019 -- Issue #31 MySQLCodec Updates
306310
#475 by jeremiahjstacey was merged on Jan 27, 2019 -- Issue #188 resolution proof: Test updates
307311
#477 by jeremiajjstacey was merged on Feb 02, 2019 -- $476 DefaultValidator.getValidInput uses canonicalize method argument
312+
#487 by kwwall was merged on Apr 29, 2019 -- Master branch updates for ESAPI-2.2.0.0-RC2
313+
#490 by hellyguo was closed on May 12, 2019 -- enhance: cache class and method to avoid reading each time
314+
#491 by hellyguo was merged on May 27, 2019 -- enhance: improve the performance of ObjFactory
315+
308316

309-
List of contributors of *merged* PRs, listed (rather naively) by # or merged PRs:
317+
List of contributors of *merged* PRs, listed (rather naively) by # of merged PRs:
310318
# merged PRs GitHub ID
311319
-------------------------
312320
19 xeno6696
313321
10 jeremiahjstacey
314-
8 kwwall
322+
9 kwwall
315323
2 artfullyContrived
316324
2 augustd
317325
2 JoelRabinovitch
318326
1 drm2
327+
1 hellyguo
319328
1 jackycct
320329
1 mickilous
321330
1 NiklasMehner
322331
1 simon0117
323332
1 sunnypav
324333

325-
326-
Thanks you all for your time and effort to ESAPI and making it a better project.
334+
Developer Activity Report (Changes between release 2.1.0.1 and 2.2.0.0, i.e., between 2015-02-05 and 2019-06-09 <UPDATE>)
335+
As created by 'mvn site', however this data was slighty edited to remove email ids replace them with GitHub ids when those were known, or with the developer name.
336+
Sorted first by # of commits and then by developer id / name..
337+
338+
Developer Total commits Total Number
339+
of Files Changed
340+
=====================================================
341+
kwwall 362 351
342+
xeno6696 64 82
343+
jeremiahjstacey 55 68
344+
davewichers 7 49
345+
Anthony Musyoki 4 2
346+
Kad DEMBELE 4 2
347+
augustd 3 7
348+
drmyersii 2 2
349+
JoelRabinovitch 2 4
350+
Ben Sleek 1 1
351+
chrisisbeef 1 5
352+
hellyguo 1 3
353+
Jackycct 1 2
354+
mickilous 1 2
355+
NiklasMehner 1 2
356+
Pavan Kumar 1 1
357+
simon0117 1 3
358+
taringamberini 1 1
359+
=====================================================
360+
Totals: 512 399 (unique files changed)
361+
362+
363+
Thanks you all for your time and effort to ESAPI and making it a better project. And if I've missed any, my apologies; let me know and I will correct it.
327364

328365
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
329366
Appendix: Dependency Updates (as reflected in pom.xml)

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.owasp.esapi</groupId>
55
<artifactId>esapi</artifactId>
6-
<version>2.2.0.0-RC3-SNAPSHOT</version>
6+
<version>2.2.0.0-RC3</version>
77
<packaging>jar</packaging>
88

99
<distributionManagement>
@@ -698,7 +698,7 @@
698698
<plugin>
699699
<groupId>org.owasp</groupId>
700700
<artifactId>dependency-check-maven</artifactId>
701-
<version>5.0.0-M2</version>
701+
<version>5.0.0</version>
702702
<configuration>
703703
<failBuildOnCVSS>5.9</failBuildOnCVSS>
704704
<suppressionFile>./suppressions.xml</suppressionFile>

src/main/java/org/owasp/esapi/reference/accesscontrol/DynaBeanACRParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Date;
66
import java.util.Iterator;
77

8-
import org.apache.commons.beanutils.*;
8+
import org.apache.commons.beanutils.LazyDynaMap;
99
import org.owasp.esapi.reference.accesscontrol.policyloader.PolicyParameters;
1010

1111
/**

src/main/java/org/owasp/esapi/util/ObjFactory.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
* ...
3131
* // Typically these would be populated from some Java properties file
3232
* String barName = "com.example.foo.Bar";
33-
* String beerBrand = "com.example.brewery.Guiness";
33+
* String beerBrand = "com.example.brewery.Guinness";
3434
* ...
3535
* DrinkingEstablishment bar = ObjFactory.make(barName, "DrinkingEstablishment");
3636
* Beer beer = ObjFactory.make(beerBrand, "Beer");
37-
* bar.drink(beer); // Drink a Guiness beer at the foo Bar. :)
37+
* bar.drink(beer); // Drink a Guinness beer at the foo Bar. :)
3838
* ...
3939
* </pre>
4040
* </p><p>
@@ -45,10 +45,11 @@
4545
*/
4646
public class ObjFactory {
4747

48-
private static final int CACHE_INITIAL_CAPACITY = 4096;
48+
private static final int CACHE_INITIAL_CAPACITY = 32;
4949
private static final float CACHE_LOAD_FACTOR = 0.75F;
5050
private static final ConcurrentHashMap<String,Class<?>> CLASSES_CACHE = new ConcurrentHashMap<>(CACHE_INITIAL_CAPACITY, CACHE_LOAD_FACTOR);
5151
private static final ConcurrentHashMap<String,MethodWrappedInfo> METHODS_CACHE = new ConcurrentHashMap<>(CACHE_INITIAL_CAPACITY, CACHE_LOAD_FACTOR);
52+
private static boolean cacheEnabled = true;
5253

5354
/**
5455
* Create an object based on the <code>className</code> parameter.
@@ -130,6 +131,18 @@ public static <T> T make(String className, String typeName) throws Configuration
130131
// DISCUSS: Should we also catch ExceptionInInitializerError here? See Google Issue #61 comments.
131132
}
132133

134+
/**
135+
* Control whether cache for classes and method names should be enabled or disabled. Initial state is enabled.
136+
* Ordinally, you are not expected to want to / have to call this method. It's major purpose is a "just-in-case"
137+
* something goes wrong is some weird context where multiple ESAPI jars are loaded into a give application and something
138+
* goes wrong, etc. A secondary purpose is it allows us to easily disable the cache so we can measure its time savings.
139+
*
140+
* @param enable true - enable cache; false - disable cache
141+
*/
142+
public static void setCache(boolean enable) {
143+
cacheEnabled = enable;
144+
}
145+
133146
/**
134147
* Load the class in cache, or load by the classloader and cache it
135148
*
@@ -139,11 +152,11 @@ public static <T> T make(String className, String typeName) throws Configuration
139152
*/
140153
private static Class<?> loadClassByStringName(String className) throws ClassNotFoundException {
141154
Class<?> clazz;
142-
if (CLASSES_CACHE.containsKey(className)) {
155+
if (cacheEnabled && CLASSES_CACHE.containsKey(className)) {
143156
clazz = CLASSES_CACHE.get(className);
144157
} else {
145158
clazz = Class.forName(className);
146-
CLASSES_CACHE.putIfAbsent(className, clazz);
159+
if ( cacheEnabled ) CLASSES_CACHE.putIfAbsent(className, clazz);
147160
}
148161
return clazz;
149162
}
@@ -177,15 +190,15 @@ private static Method findSingletonCreateMethod(String className, Class<?> theCl
177190
private static MethodWrappedInfo loadMethodByStringName(String className, Class<?> theClass) throws NoSuchMethodException {
178191
String methodName = className + "getInstance";
179192
MethodWrappedInfo methodInfo;
180-
if (METHODS_CACHE.containsKey(methodName)) {
193+
if (cacheEnabled && METHODS_CACHE.containsKey(methodName)) {
181194
methodInfo = METHODS_CACHE.get(methodName);
182195
} else {
183196
Method method = theClass.getMethod("getInstance");
184197
boolean staticMethod = Modifier.isStatic(method.getModifiers());
185198
ConfigurationException nonStaticEx = staticMethod ? null :
186199
new ConfigurationException("Class [" + className + "] contains a non-static getInstance method.");
187200
methodInfo = new MethodWrappedInfo(method, staticMethod, nonStaticEx);
188-
METHODS_CACHE.putIfAbsent(methodName, methodInfo);
201+
if ( cacheEnabled ) METHODS_CACHE.putIfAbsent(methodName, methodInfo);
189202
}
190203
return methodInfo;
191204
}

src/test/java/org/owasp/esapi/util/ObjFactoryTest.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,44 @@ public void testMakeCipher() throws ConfigurationException {
183183
String className = "javax.crypto.spec.SecretKeySpec";
184184
javax.crypto.spec.SecretKeySpec skeySpec =
185185
(SecretKeySpec) ObjFactory.make(className, "SecretKeySpec");
186-
assertTrue( skeySpec != null );
186+
// Should not get to here. Exception is expected.
187187
} catch(ConfigurationException ex) {
188188
Throwable cause = ex.getCause();
189189
assertTrue( cause instanceof InstantiationException);
190190
}
191191
}
192+
193+
/** Test cache. Create 100k JavaEncryptor instances with cache enabled (the
194+
* default), and then create 100k instances with cache disabled. Time each.
195+
* The cached version should save some time.
196+
*/
197+
public void testObjFactoryCache() throws Exception {
198+
final int reps = 100000;
199+
System.out.println("testObjFactoryCache: " + reps + " iterations.");
200+
org.owasp.esapi.reference.crypto.JavaEncryptor je = null;
201+
String clz = "org.owasp.esapi.reference.crypto.JavaEncryptor";
202+
203+
long startCacheEnabled = System.nanoTime();
204+
for ( int i = 0; i < reps; i++ ) {
205+
je = (org.owasp.esapi.reference.crypto.JavaEncryptor) ObjFactory.make(clz, "JavaEncryptor");
206+
assertNotNull( je );
207+
}
208+
long stopCacheEnabled = System.nanoTime();
209+
210+
ObjFactory.setCache( false ); // Disable cache
211+
212+
long startCacheDisabled = System.nanoTime();
213+
for ( int i = 0; i < reps; i++ ) {
214+
je = (org.owasp.esapi.reference.crypto.JavaEncryptor) ObjFactory.make(clz, "JavaEncryptor");
215+
assertNotNull( je );
216+
}
217+
long stopCacheDisabled = System.nanoTime();
218+
219+
long durationEnabled = stopCacheEnabled - startCacheEnabled;
220+
long durationDisabled = stopCacheDisabled - startCacheDisabled;
221+
System.out.println("testObjFactoryCache: Time with cache ENABLED (nanosec): " + durationEnabled );
222+
System.out.println("testObjFactoryCache: Time with cache DISABLED (nanosec): " + durationDisabled );
223+
224+
assertTrue( durationEnabled < durationDisabled );
225+
}
192226
}

src/test/resources/esapi/ESAPI-CommaValidatorFileChecker.properties

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1-
#
21
# OWASP Enterprise Security API (ESAPI) Properties file -- TEST Version
2+
#############################################################################
3+
#
4+
# WARNING WARNING WARNING WARNING WARNING WARNING
5+
#
6+
# ####### # #
7+
# # ###### #### ##### # # ###### ##### ####
8+
# # # # # # # # # # #
9+
# # ##### #### # # # ##### # # ####
10+
# # # # # # # # ##### #
11+
# # # # # # # # # # # # #
12+
# # ###### #### # # ###### # # ####
13+
#
14+
# This is NOT the version of ESAPI.properties that you are looking for.
15+
# Do NOT use this for your production applications!!!!!
16+
#
17+
# That is over in the 'configuration/esapi/ESAPI.properties' file. You
18+
# should retrieve THAT version from the official GitHub report from
19+
# https://github.com/ESAPI/esapi-java-legacy/blob/develop/configuration/esapi/ESAPI.properties
20+
# but make sure that you select it from the 'master' branch (which will
21+
# correspond to the latest official ESAPI relase). Sorry for the
22+
# inconvenience. We are trying to figure out how to get it to the official
23+
# "esapi-<releaseVersion>-sources.jar fiel available from Maven Central, but
24+
# in the meantime, you will have to get it from GitHub.
25+
#
26+
# PLEASE do not base your production use of ESAPI on this TEST version of
27+
# ESAPI.properties as this test version has been dummed down in several places
28+
# for JUnit testing.
29+
#
30+
# You have been warned.
31+
#
32+
#############################################################################
333
#
434
# This file is part of the Open Web Application Security Project (OWASP)
535
# Enterprise Security API (ESAPI) project. For details, please see

0 commit comments

Comments
 (0)