You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "pvillard31 (via GitHub)" <gi...@apache.org> on 2024/11/25 14:29:22 UTC
[PR] NIFI-14047 - Add SHA512 of NAR file to published manifest file [nifi-maven]
pvillard31 opened a new pull request, #41:
URL: https://github.com/apache/nifi-maven/pull/41
With this change, we can confirm that the generated XML file will contain the SHA. Example here with GCP NAR:
````
$ xmllint --format nifi-gcp-nar/target/META-INF/docs/extension-manifest.xml
...
<dynamic>false</dynamic>
</property>
</properties>
</extension>
</extensions>
<sha512>d0657970af37192d642978b5468aa47004133143e371008220dfb448534d34c6a3bfd343169d39f36046f6f7cfe6d24407d9ffcc14e6e5c889729692275478ef</sha512>
</extensionManifest>
$ shasum -a 512 ./nifi-gcp-nar/target/nifi-gcp-nar-2.1.0-SNAPSHOT.nar
d0657970af37192d642978b5468aa47004133143e371008220dfb448534d34c6a3bfd343169d39f36046f6f7cfe6d24407d9ffcc14e6e5c889729692275478ef ./nifi-gcp-nar/target/nifi-gcp-nar-2.1.0-SNAPSHOT.nar
````
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-14047 - Add SHA512 of NAR file to published manifest file [nifi-maven]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #41:
URL: https://github.com/apache/nifi-maven/pull/41#discussion_r1860922204
##########
src/main/java/org/apache/nifi/NarMojo.java:
##########
@@ -16,6 +16,7 @@
*/
package org.apache.nifi;
+import org.apache.commons.codec.digest.DigestUtils;
Review Comment:
This appears to be coming through a transitive dependency, and as such, it should be declared explicitly. On the other hand, it may be cleaner to simply use the `MessageDigest` component directly without this utility class.
##########
src/main/java/org/apache/nifi/NarMojo.java:
##########
@@ -1053,6 +1065,29 @@ private void makeNar() throws MojoExecutionException {
final File extensionDocsFile = narResult.getExtensionDocsFile();
if (extensionDocsFile != null && !skipDocGeneration) {
projectHelper.attachArtifact(project, "xml", "nar-extension-manifest", extensionDocsFile);
+ addNarSha512(narFile, extensionDocsFile);
+ }
+ }
+
+ private void addNarSha512(final File narFile, final File extensionDocsFile) {
+ try {
+ final String narSha512 = DigestUtils.sha512Hex(new FileInputStream(narFile));
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Review Comment:
The default settings for DocumentBuilder are not secure and leave it open to external entity vulnerabilities.
##########
src/main/java/org/apache/nifi/NarMojo.java:
##########
@@ -1053,6 +1065,29 @@ private void makeNar() throws MojoExecutionException {
final File extensionDocsFile = narResult.getExtensionDocsFile();
if (extensionDocsFile != null && !skipDocGeneration) {
projectHelper.attachArtifact(project, "xml", "nar-extension-manifest", extensionDocsFile);
+ addNarSha512(narFile, extensionDocsFile);
Review Comment:
This approach of reading the entire manifest and appending the SHA-512 hash seems inefficient. Understanding that introducing the hashing earlier in the process would require some refactoring, did you consider alternative approaches?
##########
src/main/java/org/apache/nifi/NarMojo.java:
##########
@@ -1053,6 +1065,29 @@ private void makeNar() throws MojoExecutionException {
final File extensionDocsFile = narResult.getExtensionDocsFile();
if (extensionDocsFile != null && !skipDocGeneration) {
projectHelper.attachArtifact(project, "xml", "nar-extension-manifest", extensionDocsFile);
+ addNarSha512(narFile, extensionDocsFile);
+ }
+ }
+
+ private void addNarSha512(final File narFile, final File extensionDocsFile) {
+ try {
+ final String narSha512 = DigestUtils.sha512Hex(new FileInputStream(narFile));
Review Comment:
The wrapping `FileInputStream` does not appear necessary, and the method does not close the InputStream, so this approach should be changed.
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-14047 - Add SHA512 of NAR file to published manifest file [nifi-maven]
Posted by "pvillard31 (via GitHub)" <gi...@apache.org>.
pvillard31 commented on PR #41:
URL: https://github.com/apache/nifi-maven/pull/41#issuecomment-2504424706
Thanks for the review David, I'll close the PR for now and consider different alternatives if needed. The manifest file being included into the NAR itself, it might not be the ideal place to have this information because the instance inside of the NAR would not contain the hash.
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-14047 - Add SHA512 of NAR file to published manifest file [nifi-maven]
Posted by "pvillard31 (via GitHub)" <gi...@apache.org>.
pvillard31 closed pull request #41: NIFI-14047 - Add SHA512 of NAR file to published manifest file
URL: https://github.com/apache/nifi-maven/pull/41
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org