Skip to content

Commit e2f228d

Browse files
committed
Verify trivy installation
1 parent 57ea9fa commit e2f228d

22 files changed

Lines changed: 281 additions & 28 deletions

.devcontainer/Dockerfile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
FROM golang:1.26.1-bookworm AS build
2+
ARG TARGETARCH
3+
RUN apt-get update && apt-get install -y \
4+
jq \
5+
&& apt-get clean \
6+
&& rm -rf /var/lib/apt/lists/*
7+
COPY src/base/.devcontainer/scripts/install_cosign.sh /tmp/install_cosign.sh
8+
COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh
9+
RUN INSTALL_DIR=/usr/local/bin /tmp/install_cosign.sh
10+
RUN case "${TARGETARCH}" in \
11+
x86_64|amd64) TRIVY_ARCH=64bit ;; \
12+
aarch64|arm64) TRIVY_ARCH=ARM64 ;; \
13+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
14+
esac \
15+
&& INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh
16+
17+
118
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
219
ARG TARGETARCH
320
ENV TARGETARCH=${TARGETARCH}
@@ -64,11 +81,13 @@ RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \
6481
chmod 755 /usr/share/secrets-scanner && \
6582
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
6683

84+
COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy
85+
6786
USER vscode
6887

69-
ENV PATH="/home/vscode/.asdf/shims/:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"
88+
ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"
7089
RUN \
71-
echo 'PATH="/home/vscode/.asdf/shims/:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \
90+
echo 'PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \
7291
echo '. <(asdf completion bash)' >> ~/.bashrc; \
7392
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
7493
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
@@ -83,8 +102,7 @@ RUN asdf plugin add python; \
83102
asdf plugin add actionlint; \
84103
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \
85104
asdf plugin add trivy https://github.com/zufardhiyaulhaq/asdf-trivy.git; \
86-
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git
87-
105+
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git;
88106

89107
WORKDIR /workspaces/eps-devcontainers
90108
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ 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+
docker build --output=/usr/local/bin/ -f "src/base/.devcontainer/Dockerfile.trivy.${ARCH}" .
69+
env:
70+
ARCH: '${{ matrix.arch }}'
7071
- name: setup node
7172
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
7273
with:

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
2424
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
2525
quality_checks:
26-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
26+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@5ac2707dd9cd60ad127275179495b9c890d74711
2727
needs:
2828
- get_asdf_version
2929
with:
@@ -32,7 +32,7 @@ jobs:
3232
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
3333
tag_release:
3434
needs: [quality_checks, get_asdf_version]
35-
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
35+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@5ac2707dd9cd60ad127275179495b9c890d74711
3636
with:
3737
dry_run: true
3838
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}

.github/workflows/pull_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
dependabot-auto-approve-and-merge:
1010
needs: quality_checks
1111
uses: >-
12-
NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
12+
NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@5ac2707dd9cd60ad127275179495b9c890d74711
1313
secrets:
1414
AUTOMERGE_APP_ID: '${{ secrets.AUTOMERGE_APP_ID }}'
1515
AUTOMERGE_PEM: '${{ secrets.AUTOMERGE_PEM }}'
@@ -32,7 +32,7 @@ jobs:
3232
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
3333
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
3434
quality_checks:
35-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
35+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@5ac2707dd9cd60ad127275179495b9c890d74711
3636
needs:
3737
- get_asdf_version
3838
with:
@@ -41,7 +41,7 @@ jobs:
4141
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
4242
pr_title_format_check:
4343
uses: >-
44-
NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
44+
NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@5ac2707dd9cd60ad127275179495b9c890d74711
4545
get_issue_number:
4646
runs-on: ubuntu-22.04
4747
needs: quality_checks

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
2525
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
2626
quality_checks:
27-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
27+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@5ac2707dd9cd60ad127275179495b9c890d74711
2828
needs:
2929
- get_asdf_version
3030
with:
@@ -33,7 +33,7 @@ jobs:
3333
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
3434
tag_release:
3535
needs: [quality_checks, get_asdf_version]
36-
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
36+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@5ac2707dd9cd60ad127275179495b9c890d74711
3737
with:
3838
dry_run: false
3939
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}

.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 github-login 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-

0 commit comments

Comments
 (0)