You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by apsaltis <gi...@git.apache.org> on 2018/05/20 07:15:05 UTC

[GitHub] nifi pull request #2725: NIFI-4988 Changed to handle an invalid ZIP file

GitHub user apsaltis opened a pull request:

    https://github.com/apache/nifi/pull/2725

    NIFI-4988 Changed to handle an invalid ZIP file

    Changed the exception handling so that an invalid ZIP file is handled. When an invalid zip is processed, the exception is an IllegalArgumentException which was not being handled and thus the session was being rollbacked. 
    
    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [X ] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [X ] 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.
    
    - [X ] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [ X] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ X] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [X ] Have you written or updated unit tests to verify your changes?
    - [N/A ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [N/A ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [N/A ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [N/A ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [N/A ] 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.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apsaltis/nifi NIFI-4988

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2725.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2725
    
----
commit bca63409d0fb37df715c3095a926a00bb88ba151
Author: Andrew Psaltis <ap...@...>
Date:   2018-05-20T07:10:39Z

    NIFI-4988 Changed the exception handling so that an invliad ZIP is handled. When an invalid zip is processed, the exception is an IllegalArgumentException which was not being handled and thus the session was being rollbacked.

----


---

[GitHub] nifi issue #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:

    https://github.com/apache/nifi/pull/2725
  
    @markap14 i think often RAT can detect something is a binary file and not subject to having a license header.  It can't hurt to add the exclusion but i think it is normal that rat isn't unhappy about it.


---

[GitHub] nifi issue #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:

    https://github.com/apache/nifi/pull/2725
  
    also possible that I am totally full of it.  One of these, possibly both, are true.


---

[GitHub] nifi pull request #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi/pull/2725


---

[GitHub] nifi pull request #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2725#discussion_r189647485
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java ---
    @@ -168,6 +168,39 @@ public void testZip() throws IOException {
                 flowFile.assertContentEquals(path.toFile());
             }
         }
    +    @Test
    +    public void testInvalidZip() throws IOException {
    +        final TestRunner unpackRunner = TestRunners.newTestRunner(new UnpackContent());
    +        final TestRunner autoUnpackRunner = TestRunners.newTestRunner(new UnpackContent());
    +        unpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.PackageFormat.ZIP_FORMAT.toString());
    +        autoUnpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.PackageFormat.AUTO_DETECT_FORMAT.toString());
    +        unpackRunner.enqueue(dataPath.resolve("invalid_data.zip"));
    +        unpackRunner.enqueue(dataPath.resolve("invalid_data.zip"));
    +        Map<String, String> attributes = new HashMap<>(1);
    +        attributes.put("mime.type", "application/zip");
    +        autoUnpackRunner.enqueue(dataPath.resolve("invalid_data.zip"), attributes);
    +        autoUnpackRunner.enqueue(dataPath.resolve("invalid_data.zip"), attributes);
    +        unpackRunner.run(2);
    +        autoUnpackRunner.run(2);
    +
    +        unpackRunner.assertTransferCount(UnpackContent.REL_FAILURE, 2);
    +        unpackRunner.assertTransferCount(UnpackContent.REL_ORIGINAL, 0);
    +        unpackRunner.assertTransferCount(UnpackContent.REL_SUCCESS, 0);
    +
    +        autoUnpackRunner.assertTransferCount(UnpackContent.REL_FAILURE, 2);
    +        autoUnpackRunner.assertTransferCount(UnpackContent.REL_ORIGINAL, 0);
    +        autoUnpackRunner.assertTransferCount(UnpackContent.REL_SUCCESS, 0);
    +
    +        final List<MockFlowFile> unpacked = unpackRunner.getFlowFilesForRelationship(UnpackContent.REL_FAILURE);
    +        for (final MockFlowFile flowFile : unpacked) {
    +            final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key());
    +           // final String folder = flowFile.getAttribute(CoreAttributes.PATH.key());
    --- End diff --
    
    Can probably remove this line.


---

[GitHub] nifi issue #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on the issue:

    https://github.com/apache/nifi/pull/2725
  
    I think I'm missing something obvious... but the PR adds a new file, invalid_data.zip but it doesn't add it to the RAT exclusions in the pom.xml... yet, it still pass the contrib-check. I'm not sure why.


---

[GitHub] nifi issue #2725: NIFI-4988 Changed to handle an invalid ZIP file

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on the issue:

    https://github.com/apache/nifi/pull/2725
  
    Ah, ok, I didn't realize that @joewitt  - I thought it had to always be excluded. There are probably a handful of well-known magic headers or something then. Good to know!


---