Skip to content

Commit 8e8de68

Browse files
authored
fix(ci): cves are not closed in code scanning alerts (#892)
* fix(ci): cves are not closed in code scanning alerts * f * f * f * f * f
1 parent 9e58677 commit 8e8de68

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.github/actions/scan-image/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ inputs:
1212
runs:
1313
using: composite
1414
steps:
15+
- name: Get image id
16+
id: image-id
17+
shell: bash
18+
run: |
19+
image_id=$(${{github.action_path}}/image_id.sh '${{ inputs.image-ref }}')
20+
echo "image_id=$image_id" >> $GITHUB_OUTPUT
21+
1522
- name: Scan image
1623
uses: aquasecurity/[email protected]
1724
with:
@@ -35,3 +42,4 @@ runs:
3542
uses: github/codeql-action/upload-sarif@v3
3643
with:
3744
sarif_file: trivy-results.sarif
45+
category: 'image-scan:${{ steps.image-id.outputs.image_id }}'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$#" -ne 1 ] || [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
6+
echo "Usage: $0 <image_id>"
7+
exit 1
8+
fi
9+
10+
image_id="$1"
11+
image_id=$(echo "$image_id" | cut -d'@' -f1) # remove digest
12+
# make sure if there is only one colon it is not the port
13+
if ! echo "$image_id" | rev | cut -d':' -f1 | rev | grep -q '/' ; then
14+
image_id=$(echo "$image_id" | rev | cut -d':' -f2- | rev) # remove tag
15+
fi
16+
17+
echo -n "$image_id"

0 commit comments

Comments
 (0)