MikeThomsen commented on a change in pull request #4572:
URL: https://github.com/apache/nifi/pull/4572#discussion_r500573830



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UnpackContent.java
##########
@@ -145,6 +150,15 @@
             .addValidator(StandardValidators.REGULAR_EXPRESSION_VALIDATOR)
             .build();
 
+    public static final PropertyDescriptor PASSWORD = new 
PropertyDescriptor.Builder()
+            .name("Password")
+            .displayName("Password")
+            .description("Password used for decrypting archive entries. 
Supports Zip files encrypted with ZipCrypto or AES")
+            .required(false)
+            .sensitive(true)
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)

Review comment:
       Should have expression language support. Preferably on the 
flowfile-level.

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UnpackContent.java
##########
@@ -200,7 +215,13 @@ public void onScheduled(ProcessContext context) throws 
ProcessException {
         if (fileFilter == null) {
             fileFilter = 
Pattern.compile(context.getProperty(FILE_FILTER).getValue());
             tarUnpacker = new TarUnpacker(fileFilter);
-            zipUnpacker = new ZipUnpacker(fileFilter);
+
+            char[] password = null;
+            final PropertyValue passwordProperty = 
context.getProperty(PASSWORD);

Review comment:
       If/when you add EL support, you'd need to add 
`evaluateExpressionLanguage` here.

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java
##########
@@ -221,6 +226,32 @@ public void testInvalidZip() throws IOException {
         }
     }
 
+    @Test
+    public void testZipEncryptionZipStandard() throws IOException {
+        runZipEncryptionMethod(EncryptionMethod.ZIP_STANDARD);
+    }
+
+    @Test
+    public void testZipEncryptionAes() throws IOException {
+        runZipEncryptionMethod(EncryptionMethod.AES);
+    }
+
+    @Test
+    public void testZipEncryptionNoPasswordConfigured() throws IOException {
+        final TestRunner runner = TestRunners.newTestRunner(new 
UnpackContent());
+        runner.setProperty(UnpackContent.PACKAGING_FORMAT, 
UnpackContent.PackageFormat.ZIP_FORMAT.toString());
+
+        final String password = String.class.getSimpleName();
+        final char[] streamPassword = password.toCharArray();
+        final String contents = TestRunner.class.getCanonicalName();
+
+        final byte[] zipEncrypted = createZipEncrypted(EncryptionMethod.AES, 
streamPassword, contents);

Review comment:
       Would be good to have a test method where you use something like 
DES/Triple DES to prove the error handling on unsupported algorithms.




----------------------------------------------------------------
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:
[email protected]


Reply via email to