You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by alopresto <gi...@git.apache.org> on 2017/08/25 19:29:13 UTC
[GitHub] nifi pull request #2108: NIFI-3116 Remove Jasypt
GitHub user alopresto opened a pull request:
https://github.com/apache/nifi/pull/2108
NIFI-3116 Remove Jasypt
I removed the Jasypt library (still present w/ `test` scope for backwards-compatibility testing). I re-implemented the relevant logic using Java cryptographic primitives. This will make unit testing much easier, reduce our attack surface because we no longer depend on an un-maintained library, and allows for more reasonable security decisions that are not obfuscated by the library.
I added unit tests (some ignored as I will build out additional functionality, but this is sufficient for removal of the library), but manual verification is important. To do this:
1. Create a flow with processors that store sensitive values (a sample flow [here](https://gist.github.com/alopresto/28e748358455e93bfc774556ba820b6e) encrypts and then decrypts text -- both components store a key value).
1. Stop NiFi
1. Use the `encrypt-config` tool to migrate the `flow.xml.gz` to use a new `nifi.sensitive.props.key` (and be sure to update the value in `nifi.properties` as well).
1. Note that the flow provided above already uses the `...key` *newpassword*, so enter something different if using that flow
1. This command is operating on a copied flow definition, be sure to point at your actual `flow.xml.gz`
```
./bin/encrypt-config.sh -n ../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties -f ~/Workspace/scratch/encrypt.xml.gz -g ~/Workspace/scratch/encrypt_changed.xml.gz -v -x -s newpassword
```
1. Verify that the `nifi.properties` file has a new `nifi.sensitive.props.key` value. `more conf/nifi.properties | grep '\''sensitive\|assw\|key\|trust'\''`
1. Start NiFi.
1. Verify that the flow still works.
---------
Thank you for submitting a contribution to Apache NiFi.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/alopresto/nifi NIFI-3116
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/2108.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2108
----
commit 84c631c005269ad0b9297714f21e813169e7bfb1
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-15T19:33:19Z
NIFI-3116 Added initial regression test for StringEncryptor to ensure continued functionality during removal of Jasypt.
commit ae0c54178fd5d857947d0c06902e3e24a1f2efc0
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-16T17:10:15Z
NIFI-3116 Added external compatibility regression test for StringEncryptor to ensure continued functionality during removal of Jasypt.
Documents custom salt lengths and iteration counts for each encryption method.
commit 875d3d434b95bdd71503b9fc1fadee3a06decd64
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-16T17:56:04Z
NIFI-3116 Cleaned up test.
commit 86f0921eee5ed6a5d31a714488278374ae22ac39
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-16T18:04:10Z
NIFI-3116 Added (ignored) failing tests for keyed encryption (Jasypt does not support keyed encryption).
commit 98163625b69a48482203c3ddaeb5291151f444b0
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-16T18:51:03Z
NIFI-3116 Added failing test for non-final class.
Changed StringEncryptor to non-final class and added protected default constructor.
commit 5c967d4f0bc6a1fb482dc66427722bd8f92432ff
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-22T04:39:57Z
NIFI-3116 Added failing test for initialization status.
Added utility methods in CipherUtility.
commit 4bbdb0c3f03afebed50c6456ff7b5a38ec1d64b1
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-22T06:30:44Z
NIFI-3116 Moved PBE cipher providers (and tests) from nifi-standard-processors to nifi-security-utils module.
commit 926d152f2f2127035bd0f91e27267547df83dd5f
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-23T23:37:41Z
NIFI-3116 Implemented PBE and keyed encryption/decryption logic.
Added unit tests.
commit 5efcd3b6ae03438f04fa20441b9699d5912f74cc
Author: Andy LoPresto <al...@apache.org>
Date: 2017-08-25T19:12:25Z
NIFI-3116 Removed Jasypt dependency from production scope (kept in test scope for backward compatibility tests).
Fixed checkstyle issues.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] nifi pull request #2108: NIFI-3116 Remove Jasypt
Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2108#discussion_r141081928
--- Diff: nifi-commons/nifi-security-utils/pom.xml ---
@@ -68,6 +68,9 @@
<configuration>
<excludes combine.children="append">
<exclude>src/test/resources/xxe_template.xml</exclude>
+ <!-- This file is copied from https://github.com/jeremyh/jBCrypt
+because the binary is compiled for Java 8 and we must support Java 7 -->
--- End diff --
@alopresto we no longer need to support Java 7. We can remove this. Not saying this for this review but is worth resolving later.
---
[GitHub] nifi pull request #2108: NIFI-3116 Remove Jasypt
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2108#discussion_r141117483
--- Diff: nifi-commons/nifi-security-utils/pom.xml ---
@@ -68,6 +68,9 @@
<configuration>
<excludes combine.children="append">
<exclude>src/test/resources/xxe_template.xml</exclude>
+ <!-- This file is copied from https://github.com/jeremyh/jBCrypt
+because the binary is compiled for Java 8 and we must support Java 7 -->
--- End diff --
Yeah I had the same thought but did not want to delay this PR any more. Will open a Jira for this.
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:
https://github.com/apache/nifi/pull/2108
@alopresto just wanted to ping and see if you forgot to push? I've got some cycles to test/review it again for a bit if you have it. If not no problem.
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the issue:
https://github.com/apache/nifi/pull/2108
I rebased against master and am resolving the issues Joe identified above. Should have a new push shortly.
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:
https://github.com/apache/nifi/pull/2108
@alopresto test failures
Tests run: 10, Failures: 0, Errors: 3, Skipped: 4, Time elapsed: 1.727 sec <<< FAILURE! - in org.apache.nifi.encrypt.StringEncryptorTest
testPBEncryptionShouldBeInternallyConsistent(org.apache.nifi.encrypt.StringEncryptorTest) Time elapsed: 0.046 sec <<< ERROR!
org.apache.nifi.encrypt.EncryptionException: org.apache.nifi.encrypt.EncryptionException: Could not encrypt sensitive value
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.init(Cipher.java:1393)
at javax.crypto.Cipher.init(Cipher.java:1327)
at org.apache.nifi.security.util.crypto.OpenSSLPKCS5CipherProvider.getInitializedCipher(OpenSSLPKCS5CipherProvider.java:127)
at org.apache.nifi.security.util.crypto.NiFiLegacyCipherProvider.getCipher(NiFiLegacyCipherProvider.java:62)
at org.apache.nifi.encrypt.StringEncryptor.encryptPBE(StringEncryptor.java:309)
at org.apache.nifi.encrypt.StringEncryptor.encrypt(StringEncryptor.java:278)
at org.apache.nifi.encrypt.StringEncryptor$encrypt$0.call(Unknown Source)
at org.apache.nifi.encrypt.StringEncryptorTest.testPBEncryptionShouldBeInternallyConsistent(StringEncryptorTest.groovy:140)
testPBEncryptionShouldBeExternallyConsistent(org.apache.nifi.encrypt.StringEncryptorTest) Time elapsed: 0.014 sec <<< ERROR!
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.init(Cipher.java:1393)
at javax.crypto.Cipher.init(Cipher.java:1327)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:192)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at org.apache.nifi.encrypt.StringEncryptorTest.generatePBECipher(StringEncryptorTest.groovy:115)
testPBEncryptionShouldBeConsistentWithLegacyEncryption(org.apache.nifi.encrypt.StringEncryptorTest) Time elapsed: 1.631 sec <<< ERROR!
org.jasypt.exceptions.EncryptionOperationNotPossibleException: Encryption raised an exception. A possible cause is you are using strong encryption algorithms and you have not installed the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files in this Java Virtual Machine
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.handleInvalidKeyException(StandardPBEByteEncryptor.java:1073)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.encrypt(StandardPBEByteEncryptor.java:924)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.encrypt(StandardPBEStringEncryptor.java:642)
at org.jasypt.encryption.StringEncryptor$encrypt.call(Unknown Source)
at org.apache.nifi.encrypt.StringEncryptorTest.testPBEncryptionShouldBeConsistentWithLegacyEncryption(StringEncryptorTest.groovy:228)
---
[GitHub] nifi pull request #2108: NIFI-3116 Remove Jasypt
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/nifi/pull/2108
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the issue:
https://github.com/apache/nifi/pull/2108
You should see output like this when running the commands above:
```
hw12203:...assembly/target/nifi-toolkit-1.4.0-SNAPSHOT-bin/nifi-toolkit-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 266782s @ 12:05:17 $ ./bin/encrypt-config.sh -n ../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties -f ~/Workspace/scratch/encrypt.xml.gz -g ~/Workspace/scratch/encrypt_changed.xml.gz -v -x -s newpassword
2017/08/25 12:08:05 WARN [main] org.apache.nifi.properties.ConfigEncryptionTool: The source nifi.properties and destination nifi.properties are identical [../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties] so the original will be overwritten
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: Handling encryption of flow.xml.gz
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: bootstrap.conf: null
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (src) nifi.properties: ../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (dest) nifi.properties: ../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (src) login-identity-providers.xml: null
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (dest) login-identity-providers.xml: null
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (src) flow.xml.gz: /Users/alopresto/Workspace/scratch/encrypt.xml.gz
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: (dest) flow.xml.gz: /Users/alopresto/Workspace/scratch/encrypt_changed.xml.gz
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.NiFiPropertiesLoader: Loaded 135 properties from /Users/alopresto/Workspace/nifi/nifi-toolkit/nifi-toolkit-assembly/target/nifi-toolkit-1.4.0-SNAPSHOT-bin/nifi-toolkit-1.4.0-SNAPSHOT/../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.NiFiPropertiesLoader: Loaded 135 properties from /Users/alopresto/Workspace/nifi/nifi-toolkit/nifi-toolkit-assembly/target/nifi-toolkit-1.4.0-SNAPSHOT-bin/nifi-toolkit-1.4.0-SNAPSHOT/../../../../../nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT/conf/nifi.properties
2017/08/25 12:08:05 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: Loaded NiFiProperties instance with 135 properties
2017/08/25 12:08:06 INFO [main] org.apache.nifi.properties.ConfigEncryptionTool: Decrypted and re-encrypted 4 elements for flow.xml.gz
hw12203:...assembly/target/nifi-toolkit-1.4.0-SNAPSHOT-bin/nifi-toolkit-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 266952s @ 12:08:07 $
hw12203:...space/nifi/nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 266344s @ 11:57:59 $ cp conf/flow.xml.gz ~/Workspace/scratch/encrypt.xml.gz
hw12203:...space/nifi/nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 266371s @ 11:58:27 $ cp ~/Workspace/scratch/encrypt_changed.xml.gz conf/flow.xml.gz
hw12203:...space/nifi/nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 267004s @ 12:08:59 $ npw
nifi.provenance.repository.encryption.key.provider.implementation=
nifi.provenance.repository.encryption.key.provider.location=
nifi.provenance.repository.encryption.key.id=
nifi.provenance.repository.encryption.key=
nifi.sensitive.props.key=newpassword
nifi.sensitive.props.key.protected=
nifi.sensitive.props.algorithm=PBEWITHMD5AND256BITAES-CBC-OPENSSL
nifi.sensitive.props.provider=BC
nifi.sensitive.props.additional.keys=
nifi.security.keystore=
nifi.security.keystoreType=
nifi.security.keystorePasswd=
nifi.security.keyPasswd=
nifi.security.truststore=
nifi.security.truststoreType=
nifi.security.truststorePasswd=
nifi.kerberos.service.keytab.location=
nifi.kerberos.spnego.keytab.location=
hw12203:...space/nifi/nifi-assembly/target/nifi-1.4.0-SNAPSHOT-bin/nifi-1.4.0-SNAPSHOT (NIFI-3116) alopresto
🔓 267009s @ 12:09:04 $
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:
https://github.com/apache/nifi/pull/2108
I have verified that when building an older nifi flow with sensitive properties I can bring it into the new non-jasypted nifi. So that is great.
I found Jasypt L&N entries in the following
- nifi-assembly/NOTICE This should be removed. I realize you still have it for test but our assembly notice wont need it for test cases since we're not bundling those binary deps in that case.
-nifi-nar-bundles/nifi-framework-nar/NOTICE Can be removed from here now too
If you can please rebase to resolve the conflict, address the test failures for environments like mine which do not have unlimited JCE installed, and fix these L&N i think we're in good shape.
Thanks
---
[GitHub] nifi issue #2108: NIFI-3116 Remove Jasypt
Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:
https://github.com/apache/nifi/pull/2108
@alopresto i've verified full clean build w/contrib check. Have ensured that old flow and new flow works with sensitive values including use of tool to change sensitive key passphrase and that still working on the new version as well as before. So backward compatibility appears strong.
---