fgerlits commented on code in PR #2204:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2204#discussion_r3480343302


##########
encrypt-config/PropertiesFileEncryptor.cpp:
##########
@@ -15,33 +15,51 @@
  * limitations under the License.
  */
 
-#include "ConfigFileEncryptor.h"
+#include "PropertiesFileEncryptor.h"
 
 #include <iostream>
 #include <optional>
 #include <string>
 
+#include "properties/Configuration.h"
+#include "properties/Properties.h"
 #include "utils/StringUtils.h"
 
-namespace org::apache::nifi::minifi::encrypt_config {
-
+namespace {
 bool isEncrypted(const std::optional<std::string>& encryption_type) {
   return encryption_type && !encryption_type->empty() && *encryption_type  != 
"plaintext";
 }
+}  // namespace
+
+namespace org::apache::nifi::minifi::encrypt_config {
+
+std::vector<std::string> getSensitiveProperties(const std::filesystem::path& 
properties_file_path) {
+  auto minifi_properties = 
PropertiesImpl{PropertiesImpl::PersistTo::MultipleFiles, "MiNiFi properties"};
+  minifi_properties.loadConfigureFile(properties_file_path);
+
+  auto sensitive_properties = 
Configuration::getSensitiveProperties([&minifi_properties](const std::string& 
property_name) {
+    return minifi_properties.getString(property_name);
+  });
+  const auto not_found = [&minifi_properties](const std::string& 
property_name) { return 
!minifi_properties.getString(property_name).has_value(); };
+  const auto new_end = std::remove_if(sensitive_properties.begin(), 
sensitive_properties.end(), not_found);
+  sensitive_properties.erase(new_end, sensitive_properties.end());

Review Comment:
   yes, good idea -- I have changed it to `erase_if` in 
31040a053be4da11fd69f832d6cafa8a7257530f



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to