mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
build: verify Maven distribution checksums (#4751)
* build: verify Maven distribution checksums Pin distributionSha256Sum in the Maven wrapper so mvnw rejects a tampered download, and check Apache's published SHA-512 before extracting Maven in Dockerfile.native. * build: require unzip when the Maven wrapper checksum is pinned Without unzip, mvnw downloads the .tar.gz distribution and checks it against the .zip checksum, reporting a possibly compromised download. Stop with a clear message instead.
This commit is contained in:
1 parent
123941dd03
commit
02eb4e7297
3 files changed
+8
-1
No files matched your search
+1
@@ -1,3 +1,4 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
|
||||
distributionSha256Sum=5af3b743dd8b876b5c45da33b676251e5f1687712644abb4ee519ca56e1d89ce
|
||||
@@ -4,7 +4,11 @@ USER root
|
||||
WORKDIR /app
|
||||
|
||||
# Install Maven 3.9.x (system Maven is too old for Quarkus 3.31)
|
||||
RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.tar.gz | tar xz -C /opt \
|
||||
# The SHA-512 is Apache's published checksum for apache-maven-3.9.12-bin.tar.gz.
|
||||
RUN curl -fsSL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.tar.gz \
|
||||
&& echo "0a1be79f02466533fc1a80abbef8796e4f737c46c6574ede5658b110899942a94db634477dfd3745501c80aef9aac0d4f841d38574373f7e2d24cce89d694f70 /tmp/maven.tar.gz" | sha512sum -c - \
|
||||
&& tar xzf /tmp/maven.tar.gz -C /opt \
|
||||
&& rm /tmp/maven.tar.gz \
|
||||
&& ln -sf /opt/apache-maven-3.9.12/bin/mvn /usr/local/bin/mvn
|
||||
|
||||
COPY pom.xml .
|
||||
|
||||
@@ -177,6 +177,8 @@ verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
# distributionSha256Sum is the checksum of the .zip, so the .tar.gz fallback cannot be verified
|
||||
[ -z "${distributionSha256Sum-}" ] || die "unzip is required to install Maven because distributionSha256Sum is set in maven-wrapper.properties. Please install unzip."
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user