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

NIFI-5481 Additional Sensitive Property Providers #3672

Closed
wants to merge 21 commits into from

Conversation

natural
Copy link
Contributor

@natural natural commented Aug 26, 2019

Description of PR

The code in this change-set provides the following:

This PR replaces #3542.

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? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not squash or use --force when pushing to allow for clean monitoring of changes.

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?
  • 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.

Copy link
Contributor

@alopresto alopresto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed code dealing directly with SPP implementations; have not reviewed ConfigEncryptTool or core loading production code.

* @return integer value such that upper >= value >= lower
*/
public static int getRandomInt(int lower, int upper) {
int value = random.nextInt(upper);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a construct of random.nextInt(upper - lower) + lower; which avoids the while() loop.

String keyPassword; // and that key has a random password, too
}

private static final String[] keyAlgos = {"RSA", "DSA", "ECDSA", "AES"};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the wrapped SPP in the KeyStoreSensitivePropertyProvider is AESSensitivePropertyProvider, I am confused about what actually happens when an RSA, DSA, or ECDSA key is retrieved from the keystore and used -- if it's just raw key bytes, the lengths still shouldn't match the 128, 192, or 256 bit expected key lengths.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enforce a validation check on line 104 of KeyStoreSensitivePropertyProvider which ensures the returned SecretKey from the keystore is an AES key (.secretKey.getAlgorithm()).


@Before
public void setUpTest() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
final byte[] keyBytes = new byte[32];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail on systems that do not have the unlimited strength crypto jurisdiction policies installed. As more people move to 1.8 112+ we will be ok, but some users are still on 1.8 prior. Recommend using 16 byte / 128 bit key length.

}
}

// These tests show we can use an AWS KMS key to encrypt/decrypt property values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy/paste error on comment.

mkdir -p /runtime

openssl genrsa -out /runtime/root.key 4096
openssl req -x509 -new -nodes -sha256 -days 1024 -subj "/C=US/ST=AK/O=Data in Motion/CN=localhost" -key /runtime/root.key -out /runtime/root.crt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "Data in Motion" to "Apache NiFi" on these two lines.

@@ -353,14 +353,13 @@ private static String loadFormattedKey(String[] args) {
if (parsedArgs.contains(KEY_FILE_FLAG)) {
key = getKeyFromKeyFileAndPrune(parsedArgs);
// Format the key (check hex validity and remove spaces)
key = formatHexKey(key);

// key = formatHexKey(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented lines if not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks for catching that.

Copy link
Contributor

@pvillard31 pvillard31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a very quick look on the GCP part of the code and left a comment. Will try to find some time to test it.

@@ -1720,9 +1720,9 @@ For each Node, the minimum properties to configure are as follows:
thread pool will never have fewer than this number of threads. It will grow as needed up to the maximum value set by the `nifi.cluster.node.protocol.max.threads`
property.
** `nifi.cluster.node.protocol.max.threads` - The maximum number of threads that should be used to communicate with other nodes in the cluster. This property
defaults to `50`. A thread pool is used for replication requests to all nodes, and the thread pool will have a "core" size that is configured by the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert all the unnecessary changes on the documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, yeah. I would blame my tools if I could. Thanks for the catch.

@natural natural changed the title NIFI-6363 Additional Sensitive Property Providers NIFI-5481 Additional Sensitive Property Providers Sep 5, 2019
@natural
Copy link
Contributor Author

natural commented Dec 4, 2019

Resubmitting in #3916.

@natural natural closed this Dec 4, 2019
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.

3 participants