ravinarayansingh commented on code in PR #6367: URL: https://github.com/apache/nifi/pull/6367#discussion_r964094986
########## nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java: ########## @@ -419,14 +420,21 @@ public void onTrigger(ProcessContext context, final ProcessSession session) thro } return 0; }); - for ( final PropertyDescriptor descriptor : propertyDescriptors) { - args.add(context.getProperty(descriptor.getName()).evaluateAttributeExpressions(inputFlowFile).getValue()); + for (final PropertyDescriptor descriptor : propertyDescriptors) { + if (descriptor.isSensitive()) { + String value = context.getProperty(descriptor.getName()).evaluateAttributeExpressions(inputFlowFile).getValue(); + String maskedValue = IntStream.rangeClosed(0, value.length()).mapToObj(i -> "*").collect(Collectors.joining()); Review Comment: @exceptionfactory i have made the required changes an buid and it's working fine but writing unit test fail because some sensitive true is not reflecting when run the unittest ``` @Test public void testExecuteJarWithSensitiveDynamicPropArgs() throws Exception { File exJar = new File("src/test/resources/ExecuteCommand/TestSuccess.jar"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); String jarPath = exJar.getAbsolutePath(); String sensitiveValue="sensitiveTest"; exJar.setExecutable(true); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); controller.enqueue(dummy.toPath()); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.ARGUMENTS_STRATEGY, ExecuteStreamCommand.DYNAMIC_PROPERTY_ARGUMENTS_STRATEGY.getValue()); PropertyDescriptor dynamicProp1 = new PropertyDescriptor.Builder() .dynamic(true) .name("command.argument.1") .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .build(); controller.setProperty(dynamicProp1, "-jar"); PropertyDescriptor dynamicProp2 = new PropertyDescriptor.Builder() .dynamic(true) .name("command.argument.2") .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .build(); controller.setProperty(dynamicProp2, jarPath); PropertyDescriptor dynamicProp3 = new PropertyDescriptor.Builder() .dynamic(true) .name("command.argument.3") .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .sensitive(true) .build(); controller.setProperty(dynamicProp3, sensitiveValue); controller.run(1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); MockFlowFile outputFlowFile = flowFiles.get(0); byte[] byteArray = outputFlowFile.toByteArray(); String result = new String(byteArray); assertTrue(Pattern.compile("Test was a success\r?\n").matcher(result).find()); assertEquals("0", outputFlowFile.getAttribute("execution.status")); assertEquals("java", outputFlowFile.getAttribute("execution.command")); String commandArgs = outputFlowFile.getAttribute("execution.command.args"); assertEquals("-jar", commandArgs.substring(0, 4).trim()); assertEquals("********",new StringBuilder(commandArgs).reverse().substring(0,8)); String attribute = outputFlowFile.getAttribute("execution.command.args"); String expected = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ExecuteCommand" + File.separator + "TestSuccess.jar"; assertEquals(expected, attribute.substring(attribute.length() - expected.length())); MockFlowFile originalFlowFile = controller.getFlowFilesForRelationship(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP).get(0); assertEquals(outputFlowFile.getAttribute("execution.status"), originalFlowFile.getAttribute("execution.status")); assertEquals(outputFlowFile.getAttribute("execution.command"), originalFlowFile.getAttribute("execution.command")); assertEquals(outputFlowFile.getAttribute("execution.command.args"), originalFlowFile.getAttribute("execution.command.args")); } ``` -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org