Skip to content

Commit 5b673ad

Browse files
authored
Chore: [AEA-6413] - Verify trivy installation (#64)
## Summary - Routine Change ### Details - verify trivy installation
1 parent 9833b0d commit 5b673ad

File tree

13 files changed

+128
-16
lines changed

13 files changed

+128
-16
lines changed

.devcontainer/Dockerfile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
FROM alpine:3.23.3 AS build
2+
ARG TARGETARCH
3+
RUN apk add --no-cache cosign bash curl jq
4+
COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh
5+
RUN case "${TARGETARCH}" in \
6+
x86_64|amd64) TRIVY_ARCH=64bit ;; \
7+
aarch64|arm64) TRIVY_ARCH=ARM64 ;; \
8+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
9+
esac \
10+
&& INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh
11+
12+
113
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
214
ARG TARGETARCH
315
ENV TARGETARCH=${TARGETARCH}
@@ -64,11 +76,13 @@ RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \
6476
chmod 755 /usr/share/secrets-scanner && \
6577
curl -L https://raw.githubusercontent.com/NHSDigital/software-engineering-quality-framework/main/tools/nhsd-git-secrets/nhsd-rules-deny.txt -o /usr/share/secrets-scanner/nhsd-rules-deny.txt
6678

79+
COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy
80+
6781
USER vscode
6882

69-
ENV PATH="/home/vscode/.asdf/shims/:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"
83+
ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"
7084
RUN \
71-
echo 'PATH="/home/vscode/.asdf/shims/:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \
85+
echo 'PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \
7286
echo '. <(asdf completion bash)' >> ~/.bashrc; \
7387
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
7488
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
@@ -82,9 +96,7 @@ RUN asdf plugin add python; \
8296
asdf plugin add direnv; \
8397
asdf plugin add actionlint; \
8498
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \
85-
asdf plugin add trivy https://github.com/zufardhiyaulhaq/asdf-trivy.git; \
86-
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git
87-
99+
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git;
88100

89101
WORKDIR /workspaces/eps-devcontainers
90102
COPY .tool-versions /workspaces/eps-devcontainers/.tool-versions

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
1313
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
1414
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind",
15-
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind"
15+
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind",
16+
"source=${env:HOME}${env:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind"
1617
],
1718
"runArgs": [
1819
"--network=host"

.github/workflows/build_all_images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
echo "node_24_languages=$node_24_language_folders"
3434
echo "projects=$project_folders"
3535
} >> "$GITHUB_OUTPUT"
36+
3637
package_base_docker_image:
3738
uses: ./.github/workflows/build_multi_arch_image.yml
3839
with:

.github/workflows/build_multi_arch_image.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ jobs:
6464
with:
6565
fetch-depth: 0
6666
- name: setup trivy
67-
uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514
68-
with:
69-
version: v0.69.3
67+
run: |
68+
mkdir -p "$RUNNER_TEMP/bin"
69+
docker build --output="$RUNNER_TEMP/bin" -f "src/base/.devcontainer/Dockerfile.trivy.${ARCH}" .
70+
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
71+
env:
72+
ARCH: '${{ matrix.arch }}'
7073
- name: setup node
7174
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
7275
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ src/base/.devcontainer/language_versions/
44
.trivyignore_combined.yaml
55
.out/
66
.envrc
7+
.trivy_out/

.tool-versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ shellcheck 0.11.0
55
direnv 2.37.1
66
actionlint 1.7.10
77
ruby 3.3.0
8-
trivy 0.69.3
98
yq 4.52.2

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ guard-%:
1010
exit 1; \
1111
fi
1212

13+
.PHONY: install install-python install-node install-hooks build-base-image build-node-24-image build-node-24-python-3-10-image build-node-24-python-3-12-image build-node-24-python-3-13-image build-node-24-python-3-14-image \
14+
build-eps-storage-terraform-image build-fhir-facade-image build-node-24-python-3-14-golang-1-24-image build-node-24-python-3-14-java-24-image \
15+
build-regression-tests-image build-all build-image build-githubactions-image scan-image scan-image-json shell-image lint test lint-githubactions lint-githubaction-scripts clean
1316
install: install-python install-node install-hooks
1417

1518
install-python:
@@ -129,13 +132,9 @@ test:
129132
lint-githubactions:
130133
actionlint
131134

132-
github-login:
133-
gh auth login --scopes read:packages
134-
135135
lint-githubaction-scripts:
136136
shellcheck .github/scripts/*.sh
137137

138138
clean:
139139
rm -rf .out
140140
find . -type f -name '.trivyignore_combined.yaml' -delete
141-

src/base/.devcontainer/.tool-versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ shellcheck 0.11.0
22
direnv 2.37.1
33
actionlint 1.7.11
44
ruby 3.3.0
5-
trivy 0.69.3
65
yq 4.52.4

src/base/.devcontainer/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
FROM alpine:3.23.3 AS build
2+
ARG TARGETARCH
3+
RUN apk add --no-cache cosign bash curl jq
4+
COPY --chmod=755 scripts/install_trivy.sh /tmp/install_trivy.sh
5+
RUN case "${TARGETARCH}" in \
6+
x86_64|amd64) TRIVY_ARCH=64bit ;; \
7+
aarch64|arm64) TRIVY_ARCH=ARM64 ;; \
8+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
9+
esac \
10+
&& INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh
11+
112
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
213

314
ARG SCRIPTS_DIR=/usr/local/share/eps
@@ -16,6 +27,8 @@ COPY --chmod=755 Mk ${SCRIPTS_DIR}/Mk
1627
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
1728
RUN ./root_install.sh
1829

30+
COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy
31+
1932
COPY --chmod=755 scripts/vscode_install.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/vscode_install.sh
2033
USER vscode
2134
COPY --chown=vscode:vscode .tool-versions.asdf /home/vscode/.tool-versions.asdf
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:3.23.3 AS build
2+
RUN apk add --no-cache cosign bash curl jq
3+
COPY --chmod=755 src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh
4+
RUN INSTALL_DIR=/tmp/trivy/ ARCH=64bit /tmp/install_trivy.sh
5+
6+
FROM scratch
7+
COPY --from=build /tmp/trivy/trivy /
8+
ENTRYPOINT ["/trivy"]

0 commit comments

Comments
 (0)