anton-vinogradov commented on code in PR #13330:
URL: https://github.com/apache/ignite/pull/13330#discussion_r3530189833


##########
modules/extdata/uri/pom.xml:
##########
@@ -253,9 +253,14 @@
 
                                 <sleep seconds="2" />

Review Comment:
   This `<sleep seconds="2"/>` (and the one in the `.gar` section below) only 
existed to make the old timestamp-based `<touch>` + `<zip update="yes">` trick 
work. With the unpack/replace/repack approach nothing depends on timestamps 
anymore, so both sleeps can be removed — saves 4 seconds on every build of this 
module.



##########
modules/extdata/uri/pom.xml:
##########
@@ -253,9 +253,14 @@
 
                                 <sleep seconds="2" />
 
-                                <touch 
file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
 />
-
-                                <zip 
destfile="${basedir}/target/file/${bad-signed.jar}" 
basedir="${basedir}/target/classes/" 
includes="org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
 update="yes" />
+                                <!-- Unpack, replace corrupted entry with 
correct class, repack to break signature -->
+                                <unzip 
src="${basedir}/target/file/${bad-signed.jar}" 
dest="${basedir}/target/file_tmp/zipfix" />
+                                <copy 
file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
+                                      
todir="${basedir}/target/file_tmp/zipfix/org/apache/ignite/spi/deployment/uri/tasks/"
+                                      overwrite="yes" />
+                                <delete 
file="${basedir}/target/file/${bad-signed.jar}" />
+                                <zip 
destfile="${basedir}/target/file/${bad-signed.jar}" 
basedir="${basedir}/target/file_tmp/zipfix" />

Review Comment:
   `<zip>` writes entries in directory-scan order, so `META-INF/MANIFEST.MF` is 
no longer guaranteed to be the first entry. The test still passes because 
`GridUriDeploymentJarVerifier` uses `JarFile`, which looks the manifest up by 
name — but any `JarInputStream`-based reader (including the verifier's 
`verify(InputStream, ...)` overloads) would see such a jar as having no 
manifest at all and treat it as unsigned rather than badly signed.
   
   Cheap insurance is to repack with the `<jar>` task, which always puts the 
manifest first:
   ```xml
   <jar destfile="${basedir}/target/file/${bad-signed.jar}"
        basedir="${basedir}/target/file_tmp/zipfix"
        manifest="${basedir}/target/file_tmp/zipfix/META-INF/MANIFEST.MF" />
   ```
   (Ant merges its own `Ant-Version`/`Created-By` attributes into the main 
section, which changes the manifest digest — but that only breaks the signature 
further, which is exactly what this artifact is for.)



##########
modules/extdata/uri/pom.xml:
##########
@@ -253,9 +253,14 @@
 
                                 <sleep seconds="2" />
 
-                                <touch 
file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
 />
-
-                                <zip 
destfile="${basedir}/target/file/${bad-signed.jar}" 
basedir="${basedir}/target/classes/" 
includes="org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
 update="yes" />
+                                <!-- Unpack, replace corrupted entry with 
correct class, repack to break signature -->
+                                <unzip 
src="${basedir}/target/file/${bad-signed.jar}" 
dest="${basedir}/target/file_tmp/zipfix" />
+                                <copy 
file="${basedir}/target/classes/org/apache/ignite/spi/deployment/uri/tasks/GridUriDeploymentTestWithNameTask11.class"
+                                      
todir="${basedir}/target/file_tmp/zipfix/org/apache/ignite/spi/deployment/uri/tasks/"
+                                      overwrite="yes" />
+                                <delete 
file="${basedir}/target/file/${bad-signed.jar}" />
+                                <zip 
destfile="${basedir}/target/file/${bad-signed.jar}" 
basedir="${basedir}/target/file_tmp/zipfix" />
+                                <delete 
dir="${basedir}/target/file_tmp/zipfix" />

Review Comment:
   Nit: this `<delete dir=".../zipfix"/>` is redundant — the very next step 
deletes its parent `${basedir}/target/file_tmp/`.



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