Skip to content

Commit c2c10e5

Browse files
Support trivy allow lists per image
1 parent 33328d9 commit c2c10e5

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
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 &&

etc/kayobe/trivy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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-2023-31047
15+
16+
###############################################################################
17+
# Dummy variable to allow Ansible to accept this file.
18+
workaround_ansible_issue_8743: yes

tools/scan-images.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ 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[]' $KAYOBE_CONFIG_PATH/trivy.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 \
3847
--quiet \
3948
--exit-code 1 \

0 commit comments

Comments
 (0)