Skip to content

Commit abb84f3

Browse files
authored
Merge pull request #144 from wiremock/replace-gosu-with-setpriv
Replace gosu with setpriv to eliminate Go stdlib CVEs and upgrade base deps to avoid further vulns
2 parents e4998c1 + c100031 commit abb84f3

5 files changed

Lines changed: 19 additions & 53 deletions

File tree

.github/workflows/ci-4.x-beta.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ jobs:
7272
working-directory: test/integration-tests
7373
run: mvn -B -ntp package verify --file pom.xml -DargLine="-Dit.wiremock-image=${{ matrix.versions.TAGS[0] }}"
7474

75-
container-image-scan:
76-
uses: ./.github/workflows/container-image-scan.yml
77-
needs: docker-build
78-
with:
79-
image_version: latest
80-
secrets: inherit
75+
- name: Run Snyk to check Docker image for vulnerabilities
76+
uses: snyk/actions/docker@master
77+
env:
78+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
79+
with:
80+
image: ${{ matrix.versions.TAGS[0] }}
81+
command: test
82+
args: --file=${{ matrix.versions.CONTEXT }}/Dockerfile --severity-threshold=high --fail-on=upgradable --org=f310ee2f-5552-444d-84ee-ec8c44c33adb --policy-path=${{ matrix.versions.CONTEXT }}/.snyk

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ jobs:
7272
working-directory: test/integration-tests
7373
run: mvn -B -ntp package verify --file pom.xml -DargLine="-Dit.wiremock-image=${{ matrix.versions.TAGS[0] }}"
7474

75-
container-image-scan:
76-
uses: ./.github/workflows/container-image-scan.yml
77-
needs: docker-build
78-
with:
79-
image_version: latest
80-
secrets: inherit
75+
- name: Run Snyk to check Docker image for vulnerabilities
76+
uses: snyk/actions/docker@master
77+
env:
78+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
79+
with:
80+
image: ${{ matrix.versions.TAGS[0] }}
81+
command: test
82+
args: --file=${{ matrix.versions.CONTEXT }}/Dockerfile --severity-threshold=high --fail-on=upgradable --org=f310ee2f-5552-444d-84ee-ec8c44c33adb --policy-path=${{ matrix.versions.CONTEXT }}/.snyk

Dockerfile

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,9 @@ LABEL maintainer="Rodolphe CHAIGNEAU <rodolphe.chaigneau@gmail.com>"
55

66
ARG WIREMOCK_VERSION=4.0.0-beta.29
77
ENV WIREMOCK_VERSION=$WIREMOCK_VERSION
8-
ENV GOSU_VERSION=1.19
98

109
WORKDIR /home/wiremock
1110

12-
# grab gosu for easy step-down from root
13-
RUN set -eux; \
14-
# save list of currently installed packages for later so we can clean up
15-
savedAptMark="$(apt-mark showmanual)"; \
16-
apt-get update; \
17-
apt-get install -y --no-install-recommends ca-certificates wget; \
18-
if ! command -v gpg; then \
19-
apt-get install -y --no-install-recommends gnupg2 dirmngr; \
20-
elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \
21-
# "This package provides support for HKPS keyservers." (GnuPG 1.x only)
22-
apt-get install -y --no-install-recommends gnupg-curl; \
23-
fi; \
24-
rm -rf /var/lib/apt/lists/*; \
25-
\
26-
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
27-
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
28-
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
29-
\
30-
# verify the signature
31-
export GNUPGHOME="$(mktemp -d)"; \
32-
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
33-
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
34-
command -v gpgconf && gpgconf --kill all || :; \
35-
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
36-
\
37-
# clean up fetch dependencies
38-
apt-mark auto '.*' > /dev/null; \
39-
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
40-
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
41-
\
42-
chmod +x /usr/local/bin/gosu; \
43-
# verify that the binary works
44-
gosu --version; \
45-
gosu nobody true
46-
4711
# grab wiremock standalone jar
4812
RUN mkdir -p /var/wiremock/lib/ \
4913
&& curl https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/$WIREMOCK_VERSION/wiremock-standalone-$WIREMOCK_VERSION.jar \

alpine/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ ENV WIREMOCK_VERSION=$WIREMOCK_VERSION
88

99
WORKDIR /home/wiremock
1010

11-
RUN apk add --update openssl
11+
RUN apk update && apk upgrade
1212

13-
# grab su-exec for easy step-down from root
14-
# and bash
15-
RUN apk add --no-cache 'su-exec>=0.2' bash
13+
RUN apk add --no-cache openssl bash
1614

1715
# grab wiremock standalone jar
1816
RUN mkdir -p /var/wiremock/lib/ \

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fi
1111
if [ "$uid" != "" ]; then
1212
# Change the ownership of /home/wiremock to $uid
1313
chown -R $uid:$uid /home/wiremock
14-
set -- gosu $uid:$uid "$@"
14+
set -- setpriv --reuid=$uid --regid=$uid --init-groups "$@"
1515
fi
1616

1717
exec "$@" $WIREMOCK_OPTIONS

0 commit comments

Comments
 (0)