Skip to content

Commit 6b8d1ce

Browse files
anthony-nhsCopilot
andauthored
Chore: [AEA-0000] - verify installs (#96)
## Summary - Routine Change ### Details - install zizmor from github release and verify it - install zizmor in base image - increase version of zizmor - verify installation of third party tools rather than rely on asdf or downloading from github --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7ff1d37 commit 6b8d1ce

32 files changed

Lines changed: 721 additions & 140 deletions

.github/workflows/build_all_images.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
3838
build_tool_images:
3939
# build common tool images with a lower scoped github token
40-
# as it uses a 3rd party docker image with github cli installed to verify attestation of tflint binary
41-
# and we dont want to make a high scoped token available to that image
42-
# token needs attestation read so it can verify attestation of tflint binary
40+
# as it uses a 3rd party docker image with github cli installed to verify attestation of binaries downloaded from github
41+
# and we don't want to make a high scoped token available to that image
42+
# token needs attestation read so it can verify attestation of binaries
4343
name: Build tool images for on ${{ matrix.arch }}
4444
runs-on: '${{ matrix.runner }}'
4545
strategy:
@@ -59,23 +59,14 @@ jobs:
5959
with:
6060
fetch-depth: 0
6161
persist-credentials: false
62-
- name: build_grype
62+
- name: build_tools
6363
run: |
64-
make build-grype
64+
make build-tools
6565
docker save "local_grype:latest" -o grype_image.tar
66-
- name: build_syft
67-
run: |
68-
make build-syft
6966
docker save "local_syft:latest" -o syft_image.tar
70-
- name: build_grant
71-
run: |
72-
make build-grant
7367
docker save "local_grant:latest" -o grant_image.tar
74-
75-
- name: build_tflint
76-
run: |
77-
make build-tflint
7868
docker save "local_tflint:latest" -o tflint_image.tar
69+
docker save "local_zizmor:latest" -o zizmor_image.tar
7970
env:
8071
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8172

@@ -88,6 +79,7 @@ jobs:
8879
syft_image.tar
8980
grant_image.tar
9081
tflint_image.tar
82+
zizmor_image.tar
9183
package_base_docker_image:
9284
uses: ./.github/workflows/build_multi_arch_image.yml
9385
permissions:

.grype.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ ignore:
3535
- vulnerability: CVE-2026-32283
3636
- vulnerability: CVE-2026-32281
3737
- vulnerability: CVE-2026-33810
38+
- vulnerability: CVE-2026-6100
39+
- vulnerability: CVE-2026-4786
3840
# node_24 vulnerabilities
3941
- vulnerability: GHSA-c2c7-rcm5-vvqj
4042
- vulnerability: GHSA-7r86-cg39-jmmj

Makefile

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ guard-%:
1313
.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 \
1414
build-eps-storage-terraform-image build-eps-data-extract-image build-fhir-facade-image build-node-24-python-3-14-golang-1-24-image build-node-24-python-3-14-java-24-image \
1515
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 \
16-
build-syft build-grype build-grant build-tflint
16+
build-syft build-grype build-grant build-tflint build-tools build-zizmor
1717
install: install-python install-node install-hooks
1818

1919
install-python:
@@ -89,14 +89,35 @@ build-tflint:
8989
@if docker image inspect local_tflint:latest >/dev/null 2>&1; then \
9090
echo "Image local_tflint:latest already exists. Skipping build."; \
9191
else \
92+
if [ -z "$$GITHUB_TOKEN" ]; then \
93+
echo "GITHUB_TOKEN environment variable not set. Please set it by running 'make github-login' and setting GITHUB_TOKEN to the value of 'gh auth token'."; \
94+
exit 1; \
95+
fi; \
9296
docker buildx build \
9397
--secret id=GH_TOKEN,env=GITHUB_TOKEN \
94-
-f src/projects/eps-storage-terraform/.devcontainer/Dockerfile.tflint \
98+
-f src/base/.devcontainer/Dockerfile.tflint \
9599
--tag local_tflint:latest \
96-
src/projects/eps-storage-terraform/.devcontainer/; \
100+
src/base/.devcontainer/; \
97101
fi
98102

99-
build-image: build-syft build-grype build-grant build-tflint guard-CONTAINER_NAME guard-BASE_VERSION_TAG guard-BASE_FOLDER guard-IMAGE_TAG
103+
build-zizmor:
104+
@if docker image inspect local_zizmor:latest >/dev/null 2>&1; then \
105+
echo "Image local_zizmor:latest already exists. Skipping build."; \
106+
else \
107+
if [ -z "$$GITHUB_TOKEN" ]; then \
108+
echo "GITHUB_TOKEN environment variable not set. Please set it by running 'make github-login' and setting GITHUB_TOKEN to the value of 'gh auth token'."; \
109+
exit 1; \
110+
fi; \
111+
docker buildx build \
112+
--secret id=GH_TOKEN,env=GITHUB_TOKEN \
113+
-f src/base/.devcontainer/Dockerfile.zizmor \
114+
--tag local_zizmor:latest \
115+
src/base/.devcontainer/; \
116+
fi
117+
118+
build-tools: build-syft build-grype build-grant build-tflint build-zizmor
119+
120+
build-image: build-tools guard-CONTAINER_NAME guard-BASE_VERSION_TAG guard-BASE_FOLDER guard-IMAGE_TAG
100121
workspace_folder="$${CONTAINER_NAME}"; \
101122
case "$${CONTAINER_NAME}" in \
102123
eps_*) workspace_folder="$$(printf '%s' "$${CONTAINER_NAME}" | tr '_' '-')" ;; \
@@ -149,6 +170,18 @@ lint-githubaction-scripts:
149170

150171
clean:
151172
rm -rf .out
173+
docker image rm local_syft:latest || true
174+
docker image rm local_grype:latest || true
175+
docker image rm local_grant:latest || true
176+
docker image rm local_tflint:latest || true
177+
docker image rm local_zizmor:latest || true
178+
179+
deep-clean: clean
180+
rm -rf .venv
181+
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
182+
poetry env remove --all
183+
docker images --format "{{.Repository}}:{{.Tag}}" | grep ":local-build" | xargs -r docker rmi -f
184+
152185

153186
%:
154187
@$(MAKE) -f /usr/local/share/eps/Mk/common.mk $@

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ The base image contains
3333
- asdf
3434
- aws cli
3535
- aws sam cli
36+
- gitleaks
37+
- shellcheck
38+
- direnv
39+
- yq
40+
- zizmor
41+
- grype
42+
- syft
43+
- grant
3644

3745
It installs the following dev container features
3846
- docker outside of docker
@@ -41,14 +49,10 @@ The base image contains
4149
As the vscode user the following also happens
4250

4351
asdf install and setup for these so they are available globally as vscode user
44-
- shellcheck
45-
- direnv
4652
- actionlint
4753
- ruby (for GitHub Pages)
48-
- yq
4954

5055
Install and setup git-secrets.
51-
Install [zizmor](https://github.com/zizmorcore/zizmor).
5256

5357
# Using the images
5458
## Project setup
@@ -176,7 +180,7 @@ Check targets (`check.mk`)
176180
- `cfn-guard-cdk` - validates `cdk.out` against cfn-guard rulesets and writes outputs to `.cfn_guard_out/`
177181
- `cfn-guard-terraform` - validates `terraform_plans` against cfn-guard rulesets and writes outputs to `.cfn_guard_out/`
178182
- `actionlint` - runs actionlint against GitHub Actions
179-
- `secret-scan` - runs git-secrets (including scanning history) against the repository
183+
- `secret-scan` - runs git-secrets or gitleaks (including scanning history) against the repository
180184
- `guard-<ENVIRONMENT_VARIABLE>` - checks if an environment variable is set and errors if it is not
181185
- `zizmor` - runs [zizmor](https://github.com/zizmorcore/zizmor) in the local directory to check github workflows and actions
182186
- `syft-generate-sbom` - uses syft to generate an sbom in cyclonedx-json format. This *does not* include dev dependencies. Outputs file to .sbom/sbom.cdx.json.
@@ -369,7 +373,7 @@ CONTAINER_NAME=base \
369373

370374
# Cleaning up unused container images
371375

372-
There is a script to delete unused container images. This runs on every merge to main and deletes pull request images, and on a weekly schedule it deletes images created by CI.
376+
There is a script to delete unused container images on GitHub. This runs on every merge to main and deletes pull request images, and on a weekly schedule it deletes images created by CI.
373377
You can run it manually using the following. Using the `dry-run` flag just shows what would be deleted
374378

375379
```
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
shellcheck 0.11.0
2-
direnv 2.37.1
31
actionlint 1.7.12
42
ruby 3.3.0
5-
yq 4.52.5

src/base/.devcontainer/.tool-versions.asdf

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/base/.devcontainer/Dockerfile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
FROM local_syft:latest AS syft-build
22
FROM local_grype:latest AS grype-build
33
FROM local_grant:latest AS grant-build
4+
FROM local_zizmor:latest AS zizmor-build
45
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
56

67
ARG SCRIPTS_DIR=/usr/local/share/eps
78
ARG CONTAINER_NAME
89
ARG IMAGE_TAG
910
ARG TARGETARCH
11+
ARG SAM_VERSION="v1.158.0"
12+
ARG ASDF_VERSION="v0.18.1"
13+
ARG GITLEAKS_VERSION="8.30.1"
14+
ARG CFN_GUARD_VERSION="3.2.0"
15+
ARG SHELLCHECK_VERSION="v0.11.0"
16+
ARG DIRENV_VERSION="v2.37.1"
17+
ARG YQ_VERSION="v4.52.5"
1018

1119
ENV SCRIPTS_DIR=${SCRIPTS_DIR}
1220
ENV CONTAINER_NAME=${CONTAINER_NAME}
1321
ENV TARGETARCH=${TARGETARCH}
22+
ENV SAM_VERSION=${SAM_VERSION}
23+
ENV ASDF_VERSION=${ASDF_VERSION}
24+
ENV GITLEAKS_VERSION=${GITLEAKS_VERSION}
25+
ENV CFN_GUARD_VERSION=${CFN_GUARD_VERSION}
26+
ENV SHELLCHECK_VERSION=${SHELLCHECK_VERSION}
27+
ENV DIRENV_VERSION=${DIRENV_VERSION}
28+
ENV YQ_VERSION=${YQ_VERSION}
1429

15-
COPY .tool-versions.asdf ${SCRIPTS_DIR}/${CONTAINER_NAME}/.tool-versions.asdf
1630
COPY --chmod=755 scripts/lifecycle/*.sh ${SCRIPTS_DIR}/
1731
COPY --chmod=755 scripts/root_install.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/root_install.sh
32+
COPY --chmod=755 scripts/install_aws_sam_cli.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_aws_sam_cli.sh
33+
COPY --chmod=755 scripts/install_asdf.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_asdf.sh
34+
COPY --chmod=755 scripts/install_gitleaks.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_gitleaks.sh
35+
COPY --chmod=755 scripts/install_cfn_guard.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_cfn_guard.sh
36+
COPY --chmod=755 scripts/install_shellcheck.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_shellcheck.sh
37+
COPY --chmod=755 scripts/install_direnv.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_direnv.sh
38+
COPY --chmod=755 scripts/install_yq.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_yq.sh
1839
COPY --chmod=755 Mk ${SCRIPTS_DIR}/Mk
1940

2041
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
@@ -23,10 +44,9 @@ RUN ./root_install.sh
2344
COPY --from=syft-build /syft /usr/local/bin/syft
2445
COPY --from=grype-build /grype /usr/local/bin/grype
2546
COPY --from=grant-build /grant /usr/local/bin/grant
26-
47+
COPY --from=zizmor-build /zizmor /usr/local/bin/zizmor
2748
COPY --chmod=755 scripts/vscode_install.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/vscode_install.sh
2849
USER vscode
29-
COPY --chown=vscode:vscode .tool-versions.asdf /home/vscode/.tool-versions.asdf
3050
COPY --chown=vscode:vscode .tool-versions /home/vscode/.tool-versions
3151
COPY --chown=vscode:vscode .grant.yaml /home/vscode/.grant.yaml
3252

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM serversideup/github-cli:2.89.0 AS build
2+
ARG TARGETARCH
3+
ARG TFLINT_VERSION="v0.61.0"
4+
COPY --chmod=755 scripts/install_github_release.sh /tmp/install_github_release.sh
5+
RUN --mount=type=secret,id=GH_TOKEN,env=GH_TOKEN \
6+
case "${TARGETARCH}" in \
7+
x86_64|amd64) DOWNLOAD_BINARY=tflint_linux_amd64.zip ;; \
8+
aarch64|arm64) DOWNLOAD_BINARY=tflint_linux_arm64.zip ;; \
9+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
10+
esac \
11+
&& INSTALL_DIR=/tmp/tflint/ \
12+
ARCH="${TARGETARCH}" \
13+
VERSION="${TFLINT_VERSION}" \
14+
GITHUB_REPO="terraform-linters/tflint" \
15+
TOOL="tflint" \
16+
DOWNLOAD_BINARY="${DOWNLOAD_BINARY}" \
17+
VERIFY_BINARY_ATTESTATION="false" \
18+
VERIFY_CHECKSUM="true" \
19+
COMPRESSION="zip" \
20+
/tmp/install_github_release.sh
21+
22+
FROM scratch
23+
COPY --from=build /tmp/tflint/tflint /tflint
24+
ENTRYPOINT ["/tflint"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM serversideup/github-cli:2.89.0 AS build
2+
ARG TARGETARCH
3+
ARG ZIZMOR_VERSION="v1.24.1"
4+
COPY --chmod=755 scripts/install_github_release.sh /tmp/install_github_release.sh
5+
RUN --mount=type=secret,id=GH_TOKEN,env=GH_TOKEN \
6+
case "${TARGETARCH}" in \
7+
x86_64|amd64) DOWNLOAD_BINARY=zizmor-x86_64-unknown-linux-gnu.tar.gz ;; \
8+
aarch64|arm64) DOWNLOAD_BINARY=zizmor-aarch64-unknown-linux-gnu.tar.gz ;; \
9+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
10+
esac \
11+
&& INSTALL_DIR=/tmp/zizmor/ \
12+
ARCH="${TARGETARCH}" \
13+
VERSION="${ZIZMOR_VERSION}" \
14+
GITHUB_REPO="zizmorcore/zizmor" \
15+
TOOL="zizmor" \
16+
DOWNLOAD_BINARY="${DOWNLOAD_BINARY}" \
17+
VERIFY_BINARY_ATTESTATION="true" \
18+
VERIFY_CHECKSUM="false" \
19+
COMPRESSION="tar.gz" \
20+
/tmp/install_github_release.sh
21+
22+
FROM scratch
23+
COPY --from=build /tmp/zizmor/zizmor /zizmor
24+
ENTRYPOINT ["/zizmor"]

src/base/.devcontainer/Mk/check.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ actionlint:
8484
actionlint
8585

8686
secret-scan:
87-
git-secrets --scan-history .
87+
@if [ -f .gitallowed ]; then \
88+
git-secrets --scan-history .; \
89+
else \
90+
gitleaks -v --redact git; \
91+
fi
8892

8993
guard-%:
9094
@ if [ "${${*}}" = "" ]; then \

0 commit comments

Comments
 (0)