Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: scan images with docker scout #5184

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented Jul 23, 2024

Adds an extra job for buildkit and frontend workflows to scan images with Docker Scout to report vulnerabilities.

Runs scout cves command and output a SARIF report that will be uploaded to GitHub Code scanning so we have these issues reported in the Security tab.

Example can be seen here for moby/buildkit:master: https://github.com/crazy-max/.github/security/code-scanning

image

@@ -189,6 +190,35 @@ jobs:
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scout:
runs-on: ubuntu-24.04
if: ${{ github.ref == 'refs/heads/master' }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only want to scan when merged on default branch

Copy link
Collaborator

@thompson-shaun thompson-shaun Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to cover maintenance branches as well (e.g., v0.16)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as follow-up if possible. I need to check how GitHub code scanning handles multiple refs within Security tab.

Copy link
Member Author

@crazy-max crazy-max Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompson-shaun Seems affected branches are correctly reported in security tab:

image

So I guess we could scan for release branches as follow-up.

Comment on lines +202 to +212
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Scout
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have liked to run scout on PR but docker login is required by the tool.

-
name: Scout
id: scout
uses: crazy-max/.github/.github/actions/docker-scout@7ea918c968b43fbee013e94ef2dde3e76af5f5a1
Copy link
Member Author

@crazy-max crazy-max Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using the official https://github.com/docker/scout-action for now as it takes at least one minute to fetch it because of the repo size: 5.7GB! https://api.github.com/repos/docker/scout-action (size: 5790458)

Binaries for each supported arch are in the working tree: https://github.com/docker/scout-action/tree/main/dist. Around 64MB each so ~384MB to be fetched for each run.

So for now I've created a composite action that downloads scout from https://hub.docker.com/r/docker/scout-cli for current platform. More info: https://github.com/crazy-max/.github/blob/main/.github/actions/docker-scout/action.yml

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max merged commit a3999ae into moby:master Aug 6, 2024
77 checks passed
@crazy-max crazy-max deleted the scout-scan branch August 6, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants