Skip to content

Guard EncryptedProperties store operations due to Java 11 changes (GH #721) #730

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

Closed
wants to merge 0 commits into from

Conversation

noloader
Copy link
Contributor

This check-in guards the EncryptedProperties self test failures due to Java 11 deprecating some write and store operations.

Previously the self test code would perform a write or store operation. This was Ok on Java 8 and 9, but causes an exception on Java 11.

EncryptedPropertiesUtils.storeProperties(encryptedFilePath, props, "<property value>");

This change guards the write and store operations, and skips the test if an UnsupportedOperationException is encountered.

boolean supported = true;
try {
    EncryptedPropertiesUtils.storeProperties(encryptedFilePath, props, "<property value>");
}
catch (UnsupportedOperationException ex) {
    supported = false;
}

if ( supported ) {
    // Continue with self test
}
else {
    // Print message that test was skipped
}

@kwwall
Copy link
Contributor

kwwall commented Jul 27, 2022

@noloader - So, I did the following steps:

$ git clone [email protected]:noloader/esapi-java-legacy.git walton-pr730
$ cd walton-pr730
$ jdk 11   # Alias for a dot script that sets me up to use Java 11
$ mvn compile
$ mvn test

The 'mvn test' resulted in these errors, the same place you are experiencing them. I am running on a fully-patched Linux Mint 19.2, with a 4.15.0-189-generic kernel on x86_64 processor. The significant error output from 'mvn test' was:

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   EncryptedPropertiesUtilsTest.testCreateNew:93 » UnsupportedOperation This method has been removed for security.
[ERROR]   EncryptedPropertiesUtilsTest.testLoadEncryptedAndAdd:165 » UnsupportedOperation This method has been removed for security.
[ERROR]   EncryptedPropertiesUtilsTest.testLoadPlaintextAndEncrypt:131 » UnsupportedOperation This method has been removed for security.
[ERROR]   ReferenceEncryptedPropertiesTest.testStoreLoad:160 » UnsupportedOperation This method has been removed for security.
[INFO] 
[ERROR] Tests run: 4274, Failures: 0, Errors: 4, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

I've attached the Surefire report, but not sure it will help.
org.owasp.esapi.reference.crypto.EncryptedPropertiesUtilsTest.txt
org.owasp.esapi.reference.crypto.ReferenceEncryptedPropertiesTest.txt

@kwwall
Copy link
Contributor

kwwall commented Jul 27, 2022

@noloader - BTW, this now is getting merge conflicts. That may be because I merged PR #720 after you created this PR and that PR was created before this. I presume you would want to keep the 'java 11' stuff.

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

Successfully merging this pull request may close these issues.

2 participants