Skip to content

Commit eca493b

Browse files
authored
docs: add provenance flags to CI/CD workflow example in DHI scan page (#24326)
<!--Delete sections as needed --> ## Description Updated the "Build Docker image" step in the GitHub Actions workflow example under "Automate DHI scanning in CI/CD with Docker Scout" to include `--provenance=mode=max`, `--sbom=true`, and `--push` flags. <!-- Tell us what you did and why --> ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent 44f49c3 commit eca493b

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

content/manuals/dhi/how-to/scan.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ lifecycle.
150150

151151
#### Example GitHub Actions workflow
152152

153-
The following is a sample GitHub Actions workflow that builds an image and scans
154-
it using Docker Scout:
153+
The following is a sample GitHub Actions workflow that builds an image, scans it and pushes to the registry only if the scan passes:
155154

156155
```yaml {collapse="true"}
157156
name: DHI Vulnerability Scan
@@ -179,6 +178,16 @@ jobs:
179178
- name: Checkout repository
180179
uses: actions/checkout@v3
181180

181+
- name: Set up Docker with containerd image store
182+
uses: docker/setup-docker-action@v4
183+
with:
184+
daemon-config: |
185+
{
186+
"features": {
187+
"containerd-snapshotter": true
188+
}
189+
}
190+
182191
- name: Set up Docker Buildx
183192
uses: docker/setup-buildx-action@{{% param "setup_buildx_action_version" %}}
184193

@@ -190,7 +199,10 @@ jobs:
190199

191200
- name: Build Docker image
192201
run: |
193-
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHA }} .
202+
docker build \
203+
--provenance=mode=max \
204+
--sbom=true \
205+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHA }} .
194206
195207
- name: Run Docker Scout CVE scan
196208
uses: docker/scout-action@v1
@@ -199,12 +211,31 @@ jobs:
199211
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHA }}
200212
only-severities: critical,high
201213
exit-code: true
214+
215+
- name: Push image
216+
if: success()
217+
run: |
218+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHA }}
219+
202220
```
203221
204222
The `exit-code: true` parameter ensures that the workflow fails if any critical or
205223
high-severity vulnerabilities are detected, preventing the deployment of
206224
insecure images.
207225

226+
> [!NOTE]
227+
>
228+
> The `--provenance=mode=max` and `--sbom=true` flags are required so that
229+
> Docker Scout can trace the DHI base image lineage and correctly apply its
230+
> VEX statements. Enabling the containerd image store via
231+
> `docker/setup-docker-action` allows BuildKit to store attestations locally
232+
> without pushing to a registry first. Without the containerd image store,
233+
> Docker Engine rejects the build with: `Attestation is not supported for the docker driver.
234+
> Switch to a different driver, or turn on the containerd image store, and try again.`
235+
> The `Push image` step runs only if the scan passes, using `if: success()`
236+
> to ensure images are only pushed to the registry when they are free of
237+
> critical or high-severity vulnerabilities.
238+
208239
For more details on using Docker Scout in CI, see [Integrating Docker
209240
Scout with other systems](/manuals/scout/integrations/_index.md).
210241

0 commit comments

Comments
 (0)