Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerous ESAPI JUnit test failures when using JDK 9 or later #496

Open
kwwall opened this issue Jun 2, 2019 · 6 comments
Open

Numerous ESAPI JUnit test failures when using JDK 9 or later #496

kwwall opened this issue Jun 2, 2019 · 6 comments

Comments

@kwwall
Copy link
Contributor

kwwall commented Jun 2, 2019

When mvn test is run with JDK 9 or later, there are multiple JUnit test failures. E.g., when using OpenJDK 11, here are the failures:

[ERROR] Tests run: 19, Failures: 0, Errors: 19, Skipped: 0, Time elapsed: 1.818 s <<< FAILURE! - in org.owasp.esapi.filters.SecurityWrapperResponseTest
[ERROR] Tests run: 16, Failures: 0, Errors: 16, Skipped: 0, Time elapsed: 1.939 s <<< FAILURE! - in org.owasp.esapi.reference.DefaultValidaterDateAPITest
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.034 s <<< FAILURE! - in org.owasp.esapi.reference.crypto.EncryptedPropertiesUtilsTest
[ERROR] Tests run: 10, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.062 s <<< FAILURE! - in org.owasp.esapi.reference.crypto.ReferenceEncryptedPropertiesTest
[ERROR] Tests run: 18, Failures: 9, Errors: 9, Skipped: 0, Time elapsed: 2.012 s <<< FAILURE! - in org.owasp.esapi.reference.DefaultValidatorInputStringAPITest
[ERROR] Tests run: 4144, Failures: 0, Errors: 40, Skipped: 0

This problem seems to be related to Java Platform Module System (JPMS) which was first introduced in Java 9. (See the Guice GitHub issue referenced below.)

The first clue about this is the Maven error that appears for any Maven goal and
looks like this (at least for Maven 3.6.0):

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

which @jeremiahjstacey tracked down to Google Guice issue 1133 which has been open since 2017 and is apparently related to JPMS. Maven uses Google Guice, as does Eclipse, so we need to address these issues before Oracle JDK 8 is scheduled for end-of-life (tentatively for end of December, 2020; see https://www.oracle.com/technetwork/java/java-se-support-roadmap.html for details).

@kwwall
Copy link
Contributor Author

kwwall commented Jun 2, 2019

Note: It appears that many of the failing tests were related to Mockito and/or Power Mock which also is likely to be affected by JPMS as well. Currently all tests are passing with OpenJDK 8. At this point it is not clear if ESAPI 2.2.0.0-RC2 or later will work everywhere expected with a JavaEE application server that uses JDK 9 or later though. If you are aware of such situations, please drop us a note here and we may kick up the priority of this. Thanks.

@xeno6696
Copy link
Collaborator

I'm not 100% sure if I've just fixed this for JDK 1.9+ but I fixed it for JDK 1.8:

powermock/powermock#864

Will be doing a PR soon for this issue as well as the new logic for the Referer headers.

@kwwall
Copy link
Contributor Author

kwwall commented Sep 1, 2019 via email

@xeno6696
Copy link
Collaborator

xeno6696 commented Sep 1, 2019

@kwwall @jeremiahjstacey I'm not sure how we want to proceed here. I've essentially silenced our failing tests using @PowermockIgnore, however we have a dependency for when Powermock finally fixes their library.

Do we want to leave this issue open then, since it's not technically fixed?

Also, in every version of maven I still can't get a build to complete even using Java 1.8 because it hangs on dependency check.

@kwwall
Copy link
Contributor Author

kwwall commented Sep 1, 2019 via email

kwwall pushed a commit that referenced this issue Oct 6, 2019
#514)

* Fixed issues #503 by writing a new addReferer method, also temporarily silenced issues related to mocking in #496.

* Additional fix to #503.
@noloader
Copy link
Contributor

noloader commented Jul 21, 2022

@kwwall, @xeno6696,

With PR #730, I was able to build and run the self tests on Java 8 and Java 11. All tests were successful. Java 8 was always Ok, Java 11 was the problem. And that was ESAPI 2.4.0 and 2.5.0. Also see GH #721.

I had a really bad experience with Java 17, however. Too many errors to count due to Reflection abuses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants