Skip to content

Commit f097e0c

Browse files
committed
Merge stackhpc/yoga into stackhpc/zed
2 parents 9be0f1e + 0c07da3 commit f097e0c

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ on:
3434
required: false
3535
default: true
3636
push-dirty:
37-
description: Push scanned images that have vulnerabilities?
37+
description: Push scanned images that have critical vulnerabilities?
3838
type: boolean
3939
required: false
40-
# NOTE(Alex-Welsh): This default should be flipped once we resolve existing failures
41-
default: true
40+
default: false
4241

4342
env:
4443
ANSIBLE_FORCE_COLOR: True
@@ -176,7 +175,7 @@ jobs:
176175
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
177176

178177
- name: Create build logs output directory
179-
run: mkdir image-build-logs
178+
run: mkdir image-build-logs
180179

181180
- name: Build kolla overcloud images
182181
id: build_overcloud_images
@@ -235,9 +234,16 @@ jobs:
235234
run: cp image-build-logs/image-scan-output/clean-images.txt image-build-logs/push-attempt-images.txt
236235
if: inputs.push
237236

237+
# NOTE(seunghun1ee): This always appends dirty images with CVEs severity lower than critical.
238+
# This should be reverted when it's decided to filter high level CVEs as well.
238239
- name: Append dirty images to push list
239240
run: |
240241
cat image-build-logs/image-scan-output/dirty-images.txt >> image-build-logs/push-attempt-images.txt
242+
if: ${{ inputs.push }}
243+
244+
- name: Append images with critical vulnerabilities to push list
245+
run: |
246+
cat image-build-logs/image-scan-output/critical-images.txt >> image-build-logs/push-attempt-images.txt
241247
if: ${{ inputs.push && inputs.push-dirty }}
242248

243249
- name: Push images
@@ -249,7 +255,7 @@ jobs:
249255
250256
while read -r image; do
251257
# Retries!
252-
for i in {1..5}; do
258+
for i in {1..5}; do
253259
if docker push $image; then
254260
echo "Pushed $image"
255261
break
@@ -283,8 +289,15 @@ jobs:
283289
run: if [ $(wc -l < image-build-logs/push-failed-images.txt) -gt 0 ]; then cat image-build-logs/push-failed-images.txt && exit 1; fi
284290
if: ${{ !cancelled() }}
285291

286-
- name: Fail when images failed scanning
287-
run: if [ $(wc -l < image-build-logs/dirty-images.txt) -gt 0 ]; then cat image-build-logs/dirty-images.txt && exit 1; fi
292+
# NOTE(seunghun1ee): Currently we want to mark the job fail only when critical CVEs are detected.
293+
# This can be used again instead of "Fail when critical vulnerabilities are found" when it's
294+
# decided to fail the job on detecting high CVEs as well.
295+
# - name: Fail when images failed scanning
296+
# run: if [ $(wc -l < image-build-logs/image-scan-output/dirty-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/dirty-images.txt && exit 1; fi
297+
# if: ${{ !inputs.push-dirty && !cancelled() }}
298+
299+
- name: Fail when critical vulnerabilities are found
300+
run: if [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/critical-images.txt && exit 1; fi
288301
if: ${{ !inputs.push-dirty && !cancelled() }}
289302

290303
# NOTE(mgoddard): Trigger another CI workflow in the

etc/kayobe/kolla/config/prometheus/system.rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ groups:
2525
description: "Available memory is {{ $value }} GiB."
2626

2727
- alert: LowSwapSpace
28-
expr: (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) < {% endraw %}{{ alertmanager_node_free_swap_warning_threshold_ratio }}{% raw %}
28+
expr: node_memory_SwapTotal_bytes > 0 and (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) < {% endraw %}{{ alertmanager_node_free_swap_warning_threshold_ratio }}{% raw %}
2929
for: 1m
3030
labels:
3131
severity: warning
@@ -34,7 +34,7 @@ groups:
3434
description: "Available swap space is {{ $value | humanizePercentage }}. Running out of swap space causes OOM Kills."
3535

3636
- alert: LowSwapSpace
37-
expr: (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) < {% endraw %}{{ alertmanager_node_free_swap_critical_threshold_ratio }}{% raw %}
37+
expr: node_memory_SwapTotal_bytes > 0 and (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) < {% endraw %}{{ alertmanager_node_free_swap_critical_threshold_ratio }}{% raw %}
3838
for: 1m
3939
labels:
4040
severity: critical

tools/scan-images.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$2" > $1-sca
2727
images=$(grep --invert-match --no-filename ^REPOSITORY $1-scanned-container-images.txt | sed 's/ \+/:/g' | cut -f 1,2 -d:)
2828

2929
# Ensure output files exist
30-
touch image-scan-output/clean-images.txt image-scan-output/dirty-images.txt
30+
touch image-scan-output/clean-images.txt image-scan-output/dirty-images.txt image-scan-output/critical-images.txt
3131

3232
# If Trivy detects no vulnerabilities, add the image name to clean-images.txt.
3333
# If there are vulnerabilities detected, add it to dirty-images.txt and
3434
# generate a csv summary
35+
# If the image contains at least one critical vulnerabilities, add it to
36+
# critical-images.txt
3537
for image in $images; do
3638
filename=$(basename $image | sed 's/:/\./g')
3739
if $(trivy image \
@@ -49,15 +51,13 @@ for image in $images; do
4951
# Add the image to the clean list
5052
echo "${image}" >> image-scan-output/clean-images.txt
5153
else
52-
# Add the image to the dirty list
53-
echo "${image}" >> image-scan-output/dirty-images.txt
54-
54+
5555
# Write a header for the summary CSV
5656
echo '"PkgName","PkgPath","PkgID","VulnerabilityID","FixedVersion","PrimaryURL","Severity"' > image-scan-output/${filename}.summary.csv
5757

5858
# Write the summary CSV data
59-
jq -r '.Results[]
60-
| select(.Vulnerabilities)
59+
jq -r '.Results[]
60+
| select(.Vulnerabilities)
6161
| .Vulnerabilities
6262
# Ignore packages with "kernel" in the PkgName
6363
| map(select(.PkgName | test("kernel") | not ))
@@ -72,8 +72,16 @@ for image in $images; do
7272
.[0].PrimaryURL,
7373
.[0].Severity
7474
]
75-
)
76-
| .[]
75+
)
76+
| .[]
7777
| @csv' image-scan-output/${filename}.json >> image-scan-output/${filename}.summary.csv
78+
79+
if [ $(grep "CRITICAL" image-scan-output/${filename}.summary.csv -c) -gt 0 ]; then
80+
# If the image contains critical vulnerabilities, add the image to critical list
81+
echo "${image}" >> image-scan-output/critical-images.txt
82+
else
83+
# Otherwise, add the image to the dirty list
84+
echo "${image}" >> image-scan-output/dirty-images.txt
85+
fi
7886
fi
7987
done

0 commit comments

Comments
 (0)