-
Notifications
You must be signed in to change notification settings - Fork 9
ci(security): fail the build on a fixable critical in an image (#2018) #2238
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
52fbc12
ci(security): fail the build on a fixable critical in an image (#2018)
Gregory91G b3079f2
ci(security): share the trivy cache and skip secret scanning in the gate
Gregory91G 349195f
Merge branch 'main' into ci/image-critical-gate
Gregory91G b76a4f4
ci(security): check out the repo before the local gate action
Gregory91G File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Image CVE gate | ||
| description: >- | ||
| Scan the push-by-digest blobs of a freshly built image and fail on a fixable | ||
| critical. Runs before the merge job tags them, so a rejected build stays | ||
| unreferenced: no build tag, no :latest, no descriptor bump, no chart. | ||
|
|
||
| inputs: | ||
| image: | ||
| description: Image repository without a tag, e.g. ghcr.io/constructorfabric/insight-toolbox. | ||
| required: true | ||
| registry-username: | ||
| description: Registry user for pulling the digests under scan. | ||
| required: true | ||
| registry-password: | ||
| description: Registry token for pulling the digests under scan. | ||
| required: true | ||
| digests-dir: | ||
| description: Directory holding one empty file per pushed digest, named by the digest. | ||
| default: /tmp/digests | ||
| severity: | ||
| description: Severities that fail the build. | ||
| default: CRITICAL | ||
| trivy-image: | ||
| description: Trivy image, pinned by digest. | ||
| default: aquasec/trivy:0.72.0@sha256:cffe3f5161a47a6823fbd23d985795b3ed72a4c806da4c4df16266c02accdd6f | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - shell: bash | ||
| env: | ||
| IMAGE: ${{ inputs.image }} | ||
| DIGESTS_DIR: ${{ inputs.digests-dir }} | ||
| SEVERITY: ${{ inputs.severity }} | ||
| TRIVY_IMAGE: ${{ inputs.trivy-image }} | ||
| TRIVY_USERNAME: ${{ inputs.registry-username }} | ||
| TRIVY_PASSWORD: ${{ inputs.registry-password }} | ||
| run: | | ||
| set -euo pipefail | ||
| shopt -s nullglob | ||
| digests=("$DIGESTS_DIR"/*) | ||
| if [ ${#digests[@]} -eq 0 ]; then | ||
| echo "::error::no digests in $DIGESTS_DIR — nothing was scanned" | ||
| exit 1 | ||
| fi | ||
| for f in "${digests[@]}"; do | ||
| ref="${IMAGE}@sha256:$(basename "$f")" | ||
| echo "::group::$ref" | ||
| docker run --rm \ | ||
| -e TRIVY_USERNAME -e TRIVY_PASSWORD \ | ||
| -v "$GITHUB_WORKSPACE:/work" -w /work \ | ||
| -v /tmp/trivy-cache:/root/.cache \ | ||
| "$TRIVY_IMAGE" image \ | ||
| --scanners vuln \ | ||
| --severity "$SEVERITY" \ | ||
| --pkg-types os,library \ | ||
| --ignore-unfixed \ | ||
| --exit-code 1 \ | ||
| --no-progress \ | ||
| "$ref" | ||
| echo "::endgroup::" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.