Skip to content

Commit 7d4a28f

Browse files
Support trivy allow lists per image
1 parent 8c55e94 commit 7d4a28f

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

.github/workflows/stackhpc-container-image-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ jobs:
145145
run: |
146146
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.49.0
147147
148+
- name: Install yq
149+
run: |
150+
curl -sL https://github.com/mikefarah/yq/releases/download/v4.42.1/yq_linux_amd64.tar.gz | tar xz && sudo mv yq_linux_amd64 /usr/bin/yq
151+
148152
- name: Install Kayobe
149153
run: |
150154
mkdir -p venvs &&
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
###############################################################################
3+
# Trivy allowed vulnerabilities list
4+
5+
# Example allowed vulnerabilities file setup
6+
#
7+
# keystone_allowed_vulnerabilities:
8+
# - CVE-2022-2447
9+
#
10+
# barbican-api_allowed_vulnerabilities:
11+
# - CVE-2023-31047
12+
13+
horizon_allowed_vulnerabilities:
14+
- CVE-2022-28346
15+
- CVE-2022-28347
16+
- CVE-2022-34265
17+
- CVE-2023-31047
18+
19+
###############################################################################
20+
# Dummy variable to allow Ansible to accept this file.
21+
workaround_ansible_issue_8743: yes

tools/scan-images.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ touch image-scan-output/clean-images.txt image-scan-output/dirty-images.txt
3434
# generate a csv summary
3535
for image in $images; do
3636
filename=$(basename $image | sed 's/:/\./g')
37+
imagename=$(echo $filename | cut -d "." -f 1)
38+
vulnerabilities=$(yq .$imagename'_allowed_vulnerabilities[]' src/kayobe-config/etc/kayobe/trivy/allowed-vulnerabilities.yml)
39+
rc=$?
40+
rm .trivyignore && touch .trivyignore
41+
for vulnerability in $vulnerabilities; do
42+
if [ $rc -eq 0 ]; then
43+
echo $vulnerability >> .trivyignore;
44+
fi
45+
done
3746
if $(trivy image \
38-
--quiet \
47+
--debug \
3948
--exit-code 1 \
4049
--scanners vuln \
4150
--format json \
42-
--severity HIGH,CRITICAL \
51+
--severity CRITICAL \
4352
--output image-scan-output/${filename}.json \
44-
--ignore-unfixed \
4553
$image); then
4654
# Clean up the output file for any images with no vulnerabilities
4755
rm -f image-scan-output/${filename}.json

0 commit comments

Comments
 (0)