alopresto commented on a change in pull request #3542: NIFI-6363 Integrates AWS KMS SPP. Refactors SSPP. URL: https://github.com/apache/nifi/pull/3542#discussion_r296353589
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/sensitive/StandardSensitivePropertyProvider.java ########## @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.properties.sensitive; + +import org.apache.nifi.properties.sensitive.aes.AESSensitivePropertyProvider; +import org.apache.nifi.properties.sensitive.aws.kms.AWSKMSSensitivePropertyProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class hides the various SPP subclass construction from clients. + * + */ +public class StandardSensitivePropertyProvider { + private static final Logger logger = LoggerFactory.getLogger(StandardSensitivePropertyProvider.class); + + /** + * Creates a {@link SensitivePropertyProvider} suitable for a given key. + * + * If no provider recognizes a key, this implementation still returns an {@link AESSensitivePropertyProvider} with + * the supplied key. + * + * @param hex provider encryption key + * @param options array of string options + * @return concrete instance of SensitivePropertyProvider + */ + public static SensitivePropertyProvider fromKey(String hex, String... options) { + + String scheme = ""; + if (options.length > 0) { + scheme = options[0]; + } + + if (AWSKMSSensitivePropertyProvider.isProviderFor(hex, options)) { + logger.debug("StandardSensitivePropertyProvider selected specific AWS KMS for key: " + hex + " scheme: " + scheme); Review comment: This was probably for debugging purposes, but we don't want to log the key. For debugging purposes, perhaps a truncated, masked, or hashed version would allow for "uniqueness" tracking across the application without revealing the actual key value. I.e. if this is a key of format `aws-key:arn:1243` which references a key in the KMS, logging that is "ok" but not ideal. If it is the raw hex value of the AES key `0123....`, that is very bad. Hashing that value to a unique identifier would be preferred. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services