Skip to content

Commit 0f46b5f

Browse files
committed
Add --repo-base-url option
1 parent f8d0ed2 commit 0f46b5f

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ Docker container to verify jars PGP signatures.
1111
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/10079/badge)](https://bestpractices.coreinfrastructure.org/projects/10079)
1212
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/leplusorg/docker-pgp-verify-jar/badge)](https://securityscorecards.dev/viewer/?uri=github.com/leplusorg/docker-pgp-verify-jar)
1313

14+
## Goal and limitations
15+
16+
The goal of this docker container image is to provide an easy way to
17+
verify jar files signatures. Currently it can only verify files that
18+
it downloads from a Maven repository that doesn't require
19+
authentication and that use a certificate issues by a trusted public
20+
CA.
21+
22+
This image has the benefit of being platform-agnostic and it
23+
doesn't rely on Maven or Java. But if your goal is to validate
24+
signatures for your project dependencies at build time and/or runtime,
25+
there are Maven plugins (e.g.
26+
[Verify PGP signatures](https://www.simplify4u.org/pgpverify-maven-plugin/)).
27+
Gradle even has this feature
28+
(out-of-the-box)[https://docs.gradle.org/current/userguide/dependency_verification.html].
29+
1430
## Examples
1531

1632
Assuming that you want to see the signature of a jar with coordinates 'org.leplus:ristretto:1.0.0':

pgp-verify-jar/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apk -U upgrade \
1919
apk -u list ; \
2020
exit 1 ; \
2121
fi \
22+
&& apk cache clean \
2223
&& rm -rf /var/cache/apk/*
2324

2425
# create gpg directory to prevent keyboxd to automagically start, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150

pgp-verify-jar/pgp-verify-jar.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ Options:
1111
1212
-h display this help and exit
1313
-v, --verification-mode MODE use the corresponding verification mode
14-
(online or offline). Default is online.
14+
(online or offline). In online mode, keys
15+
are downloaded from a keyserver. In offline
16+
mode, keys are read from local key store.
17+
Default is online.
18+
-r, --repo-base-url URL use the provided URL to fecth signature
19+
files. Default is https://repo1.maven.org/maven2.
1520
-k, --keyserver SERVER use the provided keyserver for online
1621
operations. Default is keyserver.ubuntu.com.
1722
-b, --bootstrap-online-keys KEYS download from the keyserver the keys with
@@ -75,6 +80,25 @@ while :; do
7580
--verification-mode=)
7681
die 'ERROR: "--verification-mode" requires an option argument.'
7782
;;
83+
-r | --repo-base-url)
84+
if [ -z ${2+x} ]; then
85+
REPO_BASE_URL=${2}
86+
shift
87+
else
88+
die 'ERROR: "--repo-base-url" requires an option argument.'
89+
fi
90+
;;
91+
--repo-base-url=?*)
92+
if [ "${1#*=}" ]; then
93+
REPO_BASE_URL=${1#*=}
94+
shift
95+
else
96+
die 'ERROR: "--repo-base-url" requires an option argument.'
97+
fi
98+
;;
99+
--repo-base-url=)
100+
die 'ERROR: "--repo-base-url" requires an option argument.'
101+
;;
78102
-k | --keyserver)
79103
if [ -z ${2+x} ]; then
80104
KEYSERVER=${2}
@@ -145,6 +169,10 @@ while :; do
145169
esac
146170
done
147171

172+
if [ -z ${REPO_BASE_URL+x} ]; then
173+
REPO_BASE_URL='https://repo1.maven.org/maven2'
174+
fi
175+
148176
if [ -z ${VERIFICATION_MODE+x} ]; then
149177
VERIFICATION_MODE='online'
150178
fi
@@ -192,8 +220,8 @@ for artifact in "${@}"; do
192220
else
193221
artifactClassifierSuffix="-${coordinates[3]}"
194222
fi
195-
artifactUrl="https://repo1.maven.org/maven2/${groupId//\.//}/${artifactId}/${artifactVersion}/${artifactId}-${artifactVersion}${artifactClassifierSuffix}.${artifactExtension}"
196223
artifactFile="${artifactId}-${artifactVersion}${artifactClassifierSuffix}.${artifactExtension}"
224+
artifactUrl="${REPO_BASE_URL}/${groupId//\.//}/${artifactId}/${artifactVersion}/${artifactFile}"
197225
signatureUrl="${artifactUrl}.asc"
198226
signatureFile="${artifactFile}.asc"
199227
\echo Downloading "${artifactUrl}"

0 commit comments

Comments
 (0)