Skip to content

Commit 4063f94

Browse files
committed
Add trivy to development environment for vuln scanning
1 parent c82bd29 commit 4063f94

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/s
6868
&& echo "source ~/completions/kubectl.bash" >> ~/.bashrc \
6969
&& echo "alias k=kubectl" >> ~/.bashrc \
7070
&& echo "complete -o default -F __start_kubectl k" >> ~/.bashrc
71+
72+
# Install trivy
73+
RUN mkdir /tmp/trivy \
74+
&& curl -L https://github.com/aquasecurity/trivy/releases/download/v0.19.2/trivy_0.19.2_Linux-64bit.tar.gz | tar xvz -C /tmp/trivy -f - contrib trivy \
75+
&& chmod +x /tmp/trivy/trivy \
76+
&& mv /tmp/trivy/trivy /usr/local/bin/trivy \
77+
&& mkdir -p /trivy/contrib \
78+
&& mv /tmp/trivy/contrib/* /trivy/contrib/
7179

7280
# Clean up
7381
RUN apt-get autoremove -y \

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ IMAGE_MAJOR_VERSION = $(shell echo "$(IMAGE_VERSION)" | cut -d '.' -f1 )
55
IMAGE_MINOR_VERSION = $(shell echo "$(IMAGE_VERSION)" | cut -d '.' -f2 )
66
IMAGE = $(REGISTRY)/$(REPOSITORY)/hello-kubernetes
77

8+
.PHONY: scan-for-vulns
9+
scan-for-vulns:
10+
trivy image --format template --template "@/trivy/contrib/sarif.tpl" $(IMAGE):$(IMAGE_VERSION)
11+
12+
.PHONY: build-images
13+
build-images: build-image-linux
14+
815
.PHONY: build-image-linux
916
build-image-linux:
1017
docker build --no-cache \

0 commit comments

Comments
 (0)