[ 
https://issues.apache.org/jira/browse/NIFI-14759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18018160#comment-18018160
 ] 

ASF subversion and git services commented on NIFI-14759:
--------------------------------------------------------

Commit 08e25ae0034c03503de7ff961f706c023659ee0d in nifi's branch 
refs/heads/main from Pierre Villard
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=08e25ae003 ]

NIFI-14759 Handle out-of-order File Entries in NarUnpacker (#10270)

Signed-off-by: David Handermann <[email protected]>

> NarUnpacker fails with NAR file signed with JarSigner
> -----------------------------------------------------
>
>                 Key: NIFI-14759
>                 URL: https://issues.apache.org/jira/browse/NIFI-14759
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 2.2.0
>            Reporter: Timo Harter
>            Assignee: Pierre Villard
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> A previously working NAR file fails to be unpacked by the NarUnpacker on 
> startup after it has been signed with JarSigner (using the 
> maven-jarsigner-plugin) plugin. The following error occurs:
> {code:java}
> java.io.FileNotFoundException: 
> work\nar\extensions\test-nar-2.1.1-SNAPSHOT.nar-unpacked\META-INF\MANIFEST.MF 
> (Das System kann den angegebenen Pfad nicht finden)
>     at java.base/java.io.FileOutputStream.open0(Native Method)
>     at java.base/java.io.FileOutputStream.open(FileOutputStream.java:289)
>     at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:230)
>     at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>     at org.apache.nifi.nar.NarUnpacker.makeFile(NarUnpacker.java:599)
>     at 
> org.apache.nifi.nar.NarUnpacker.unpackIndividualJars(NarUnpacker.java:346)
>     at 
> org.apache.nifi.nar.NarUnpacker.unpackIndividualJars(NarUnpacker.java:323)
>     at org.apache.nifi.nar.NarUnpacker.unpackNar(NarUnpacker.java:296)
>     at org.apache.nifi.nar.NarUnpacker.unpackNars(NarUnpacker.java:156)
>     at org.apache.nifi.nar.NarUnpacker.unpackNars(NarUnpacker.java:85)
>     at org.apache.nifi.nar.NarUnpacker.unpackNars(NarUnpacker.java:80)
>     at org.apache.nifi.nar.NarUnpacker.unpackNars(NarUnpacker.java:72)
>     at org.apache.nifi.runtime.Application.run(Application.java:70)
>     at org.apache.nifi.runtime.Application.run(Application.java:60)
>     at org.apache.nifi.NiFi.main(NiFi.java:42) {code}
> Some analysis shows that the working NAR file has a zipfile structure (order 
> of entries in the file) like this:
> {code:java}
> META-INF/
> META-INF/MANIFEST.MF
> META-INF/bundled-dependencies/
> META-INF/docs/
> META-INF/docs/additional-details/
> ... {code}
> While the NAR file that does not work after signing has an order like this:
> {code:java}
> META-INF/MANIFEST.MF
> META-INF/KEY_5313.SF
> META-INF/KEY_5313.RSA
> META-INF/
> META-INF/DEPENDENCIES
> META-INF/LICENSE
> META-INF/NOTICE
> META-INF/bundled-dependencies/
> META-INF/docs/
> META-INF/docs/additional-details/
> ... {code}
> Notice how the entry for the "META-INF/" directory comes after the entry for 
> "META-INF/MANIFEST.MF". This causes the error in the NarUnpacker code because 
> the META-INF output directory has not been created by the time 
> META-INF/MANIFEST.MF is being unpacked.
> From my understanding, both these structures are valid zip files and other 
> zip related tools do not seem to have an issue with this ordering.
> We fixed this problem for us by unpacking and re-packing the signed NAR file 
> to correct the order of entries, but it would be nice if the NarUnpacker 
> class could be made more tolerant here.
>  
> Steps to reproduce:
> Add a maven-jarsigner-plugin build step to a NAR project and try to deploy 
> the result.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to