@@ -108,68 +108,7 @@ jobs:
108
108
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
109
109
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
110
110
111
- - name : Download image
112
- run : |
113
- . venv/bin/activate
114
- sudo mkdir /mnt/images
115
- sudo chmod 777 /mnt/images
116
- openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-id }}"
117
- openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
118
-
119
- - name : Set up QEMU
120
- uses : docker/setup-qemu-action@v3
121
-
122
- - name : install libguestfs
123
- run : |
124
- sudo apt -y update
125
- sudo apt -y install libguestfs-tools
126
-
127
- - name : mkdir for mount
128
- run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
129
-
130
- - name : mount qcow2 file
131
- run : sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
132
-
133
- - name : Run Trivy vulnerability scanner
134
- uses :
aquasecurity/[email protected]
135
- with :
136
- scan-type : fs
137
- scan-ref : " ${{ steps.manifest.outputs.image-name }}"
138
- scanners : " vuln"
139
- format : sarif
140
- output : " ${{ steps.manifest.outputs.image-name }}.sarif"
141
- # turn off secret scanning to speed things up
142
- env :
143
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
144
-
145
- - name : Upload Trivy scan results to GitHub Security tab
146
- uses : github/codeql-action/upload-sarif@v3
147
- with :
148
- sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
149
- category : " ${{ matrix.os_version }}-${{ matrix.build }}"
150
-
151
- - name : Fail if scan has CRITICAL vulnerabilities
152
- uses :
aquasecurity/[email protected]
153
- with :
154
- scan-type : fs
155
- scan-ref : " ${{ steps.manifest.outputs.image-name }}"
156
- scanners : " vuln"
157
- format : table
158
- exit-code : ' 1'
159
- severity : ' CRITICAL'
160
- ignore-unfixed : true
161
- env :
162
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
163
-
164
- - name : Delete new image if Trivy scan fails
165
- if : failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
166
- run : |
167
- . venv/bin/activate
168
- echo "Deleting new image due to critical vulnerabilities or scan failure ..."
169
- openstack image delete "${{ steps.manifest.outputs.image-id }}"
170
-
171
111
- name : Delete old latest image
172
- if : success() # Runs only if Trivy scan passed
173
112
run : |
174
113
. venv/bin/activate
175
114
IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
0 commit comments