Skip to content

Commit bd325f4

Browse files
authored
add docker scout scan to pipelines (nginx#5759)
1 parent 99d6a03 commit bd325f4

File tree

8 files changed

+82
-20
lines changed

8 files changed

+82
-20
lines changed

.github/workflows/build-base-images.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
name: Build OSS base images
4242
runs-on: ubuntu-22.04
4343
needs: checks
44+
permissions:
45+
contents: read
46+
pull-requests: write # for scout report
4447
strategy:
4548
fail-fast: false
4649
matrix:
@@ -108,6 +111,9 @@ jobs:
108111
name: Build Plus base images
109112
runs-on: ubuntu-22.04
110113
needs: checks
114+
permissions:
115+
contents: read
116+
pull-requests: write # for scout report
111117
strategy:
112118
fail-fast: false
113119
matrix:
@@ -177,6 +183,9 @@ jobs:
177183
name: Build Plus NAP base images
178184
runs-on: ubuntu-22.04
179185
needs: checks
186+
permissions:
187+
contents: read
188+
pull-requests: write # for scout report
180189
strategy:
181190
fail-fast: false
182191
matrix:

.github/workflows/build-oss.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
4848
id-token: write # for OIDC login to GCR
4949
packages: write # for docker/build-push-action to push to GHCR
50+
pull-requests: write # for scout report
51+
outputs:
52+
version: ${{ steps.meta.outputs.version }}
53+
image_digest: ${{ steps.build-push.outputs.digest }}
5054
steps:
5155
- name: Checkout Repository
5256
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
@@ -175,27 +179,46 @@ jobs:
175179
IC_VERSION=${{ inputs.ic-version && inputs.ic-version || steps.meta.outputs.version }}
176180
if: ${{ steps.base_exists.outputs.exists != 'true' || steps.target_exists.outputs.exists != 'true' }}
177181

182+
- name: Make directory for security scan results
183+
run: |
184+
mkdir -p "${{ inputs.image }}-results/"
185+
178186
- name: Run Trivy vulnerability scanner
179187
uses: aquasecurity/trivy-action@595be6a0f6560a0a8fc419ddf630567fc623531d # 0.22.0
180188
continue-on-error: true
181189
with:
182190
image-ref: nginx/nginx-ingress:${{ steps.meta.outputs.version }}
183191
format: "sarif"
184-
output: "trivy-results-${{ inputs.image }}.sarif"
192+
output: "${{ inputs.image }}-results/trivy.sarif"
185193
ignore-unfixed: "true"
186194
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
187195

188-
- name: Upload Trivy scan results to GitHub Security tab
189-
uses: github/codeql-action/upload-sarif@530d4feaa9c62aaab2d250371e2061eb7a172363 # v3.25.9
196+
- name: DockerHub Login for Docker Scount
197+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
198+
with:
199+
username: ${{ secrets.DOCKER_USERNAME }}
200+
password: ${{ secrets.DOCKER_PASSWORD }}
201+
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
202+
203+
- name: Run Docker Scout vulnerability scanner
204+
id: docker-scout
205+
uses: docker/scout-action@5dae9c7571dd0f3de81f5b501240c593c13c3eb6 # v1.9.3
190206
continue-on-error: true
191207
with:
192-
sarif_file: "trivy-results-${{ inputs.image }}.sarif"
208+
command: cves,recommendations
209+
image: ${{ steps.meta.outputs.tags }}
210+
ignore-base: true
211+
only-fixed: true
212+
sarif-file: "${{ inputs.image }}-results/scout.sarif"
213+
write-comment: false
214+
github-token: ${{ secrets.GITHUB_TOKEN }} # to be able to write the comment
215+
summary: true
193216
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
194217

195-
- name: Upload Scan Results
218+
- name: Upload Scan Results to the cache
196219
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
197220
continue-on-error: true
198221
with:
199-
name: "trivy-results-${{ inputs.image }}.sarif"
200-
path: "trivy-results-${{ inputs.image }}.sarif"
201-
if: always()
222+
name: "${{ inputs.image }}-results"
223+
path: "${{ inputs.image }}-results/"
224+
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}

.github/workflows/build-plus.yml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
contents: read # for docker/build-push-action to read repo content
5252
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
5353
id-token: write # for OIDC login to AWS
54+
pull-requests: write # for scout report
5455
runs-on: ubuntu-22.04
5556
steps:
5657
- name: Checkout Repository
@@ -195,8 +196,12 @@ jobs:
195196
${{ contains(inputs.image, 'ubi') && format('"rhel_license={0}"', secrets.RHEL_LICENSE) || '' }}
196197
if: ${{ steps.base_exists.outputs.exists != 'true' || steps.target_exists.outputs.exists != 'true' }}
197198

198-
- name: Extract image name for Trivy
199-
id: trivy-tag
199+
- name: Make directory for security scan results
200+
run: |
201+
mkdir -p "${{ inputs.image }}-results/"
202+
203+
- name: Extract image name for Scans
204+
id: scan-tag
200205
run: |
201206
tag=$(echo $DOCKER_METADATA_OUTPUT_JSON | jq -r '[ .tags[] | select(contains("f5-gcs-7899"))] | .[0]')
202207
echo "tag=$tag" >> $GITHUB_OUTPUT
@@ -206,23 +211,38 @@ jobs:
206211
uses: aquasecurity/trivy-action@595be6a0f6560a0a8fc419ddf630567fc623531d # 0.22.0
207212
continue-on-error: true
208213
with:
209-
image-ref: ${{ steps.trivy-tag.outputs.tag }}
214+
image-ref: ${{ steps.scan-tag.outputs.tag }}
210215
format: "sarif"
211-
output: "trivy-results-${{ inputs.image }}.sarif"
216+
output: "${{ inputs.image }}-results/trivy.sarif"
212217
ignore-unfixed: "true"
213218
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
214219

215-
- name: Upload Trivy scan results to GitHub Security tab
216-
uses: github/codeql-action/upload-sarif@530d4feaa9c62aaab2d250371e2061eb7a172363 # v3.25.9
220+
- name: DockerHub Login for Docker Scount
221+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
222+
with:
223+
username: ${{ secrets.DOCKER_USERNAME }}
224+
password: ${{ secrets.DOCKER_PASSWORD }}
225+
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
226+
227+
- name: Run Docker Scout vulnerability scanner
228+
id: docker-scout
229+
uses: docker/scout-action@5dae9c7571dd0f3de81f5b501240c593c13c3eb6 # v1.9.3
217230
continue-on-error: true
218231
with:
219-
sarif_file: "trivy-results-${{ inputs.image }}.sarif"
232+
command: cves,recommendations
233+
image: ${{ steps.scan-tag.outputs.tag }}
234+
ignore-base: true
235+
only-fixed: true
236+
sarif-file: "${{ inputs.image }}-results/scout.sarif"
237+
write-comment: false
238+
github-token: ${{ secrets.GITHUB_TOKEN }} # to be able to write the comment
239+
summary: true
220240
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}
221241

222242
- name: Upload Scan Results
223243
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
224244
continue-on-error: true
225245
with:
226-
name: "trivy-results-${{ inputs.image }}.sarif"
227-
path: "trivy-results-${{ inputs.image }}.sarif"
228-
if: always()
246+
name: "${{ inputs.image }}-results"
247+
path: "${{ inputs.image }}-results/"
248+
if: ${{ inputs.authenticated && steps.build-push.conclusion == 'success' }}

.github/workflows/cache-update.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
security-events: write
6161
id-token: write
6262
packages: write
63+
pull-requests: write # for scout report
6364
secrets: inherit
6465

6566
build-docker-plus:
@@ -89,6 +90,7 @@ jobs:
8990
contents: read
9091
security-events: write
9192
id-token: write
93+
pull-requests: write # for scout report
9294
secrets: inherit
9395

9496
build-docker-nap:
@@ -161,4 +163,5 @@ jobs:
161163
contents: read
162164
security-events: write
163165
id-token: write
166+
pull-requests: write # for scout report
164167
secrets: inherit

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ jobs:
303303
security-events: write
304304
id-token: write
305305
packages: write
306+
pull-requests: write # for scout report
306307
secrets: inherit
307308

308309
build-docker-plus:
@@ -333,6 +334,7 @@ jobs:
333334
contents: read
334335
security-events: write
335336
id-token: write
337+
pull-requests: write # for scout report
336338
secrets: inherit
337339

338340
build-docker-nap:
@@ -406,6 +408,7 @@ jobs:
406408
contents: read
407409
security-events: write
408410
id-token: write
411+
pull-requests: write # for scout report
409412
secrets: inherit
410413

411414
helm-tests:
@@ -774,5 +777,6 @@ jobs:
774777
actions: read
775778
packages: write # for helm to push to GHCR
776779
security-events: write
780+
pull-requests: write # for scout report
777781
uses: ./.github/workflows/image-promotion.yml
778782
if: ${{ inputs.force && inputs.force || false }}

.github/workflows/image-promotion.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ jobs:
173173
security-events: write
174174
id-token: write
175175
packages: write
176+
pull-requests: write # for scout report
176177
secrets: inherit
177178

178179
build-docker-plus:
@@ -205,6 +206,7 @@ jobs:
205206
security-events: write
206207
id-token: write
207208
packages: write
209+
pull-requests: write # for scout report
208210
secrets: inherit
209211

210212
build-docker-nap:
@@ -280,6 +282,7 @@ jobs:
280282
security-events: write
281283
id-token: write
282284
packages: write
285+
pull-requests: write # for scout report
283286
secrets: inherit
284287

285288
tag-stable:

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FROM ghcr.io/nginxinc/k8s-common:nginx-opentracing-1.27.0-alpine@sha256:5dc5c763
1515
FROM ghcr.io/nginxinc/alpine-fips:0.1.0-alpine3.17@sha256:f00b3f266422feaaac7b733b46903bd19eb1cd1caa6991131576f5f767db76f8 as alpine-fips-3.17
1616
FROM ghcr.io/nginxinc/alpine-fips:0.2.0-alpine3.19@sha256:1744ae3a8e795daf771f3f7df33b83160981545abb1f1597338e2769d06aa1cc as alpine-fips-3.19
1717
FROM redhat/ubi9-minimal@sha256:a7d837b00520a32502ada85ae339e33510cdfdbc8d2ddf460cc838e12ec5fa5a AS ubi-minimal
18-
FROM golang:1.22-alpine@sha256:9bdd5692d39acc3f8d0ea6f81327f87ac6b473dd29a2b6006df362bff48dd1f8 as golang-builder
18+
FROM golang:1.22-alpine@sha256:6522f0ca555a7b14c46a2c9f50b86604a234cdc72452bf6a268cae6461d9000b as golang-builder
1919

2020

2121
############################################# Base image for Alpine #############################################

tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a79
55
# this is here so we can grab the latest version of skopeo and have dependabot keep it up to date
66
FROM quay.io/skopeo/stable:v1.15.1
77

8-
FROM python:3.12@sha256:00389e020fe42a6c74a8f091ce9b28324422d084efdff26eabe93bc4ae9a110b
8+
FROM python:3.12@sha256:4584ea46d313a10e849eb7c5ef36be14773418233516ceaa9e52a8ff7d5e35a5
99

1010
RUN apt-get update \
1111
&& apt-get install -y curl git \

0 commit comments

Comments
 (0)