-
Notifications
You must be signed in to change notification settings - Fork 19
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
[ISSUE 435] Fix vulnerability checks #452
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d6cc9b4
Give names to vuln scans
daphnegold 73130f2
There's no way this will work
daphnegold e558999
Try out using ECR
daphnegold 215d7ac
Try cache
daphnegold 89323a2
Don't need checkout
daphnegold c4ad1dc
Cleanup
daphnegold 63801cf
Try without latest tag
daphnegold 102e517
Does this fix the tag?
daphnegold e075fb8
Update comment
daphnegold 8600988
Enable buildx caching to actually speed build times using caching layers
daphnegold 341befb
Need to load image in buildx command
daphnegold 9a72e0e
Rename
daphnegold c07a116
Add cache-hit to skip builds entirely with same sha
daphnegold 57fc56b
It was trying to save docker image when it wasn't rebuilt, only do th…
daphnegold 1ff7e81
Output for image name wasn't getting set if build step was skipped be…
daphnegold 6bf9c8d
Skip cache attempt on cache-hit
daphnegold 18c5eb0
Switch out --cache-to and --cache-from to use gha
daphnegold 1446f12
Add test comment
daphnegold 56ce23d
Revert "Add test comment"
daphnegold 5309040
Revert "Switch out --cache-to and --cache-from to use gha"
daphnegold 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 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
# GitHub Actions CI workflow that runs vulnerability scans on the application's Docker image | ||
# to ensure images built are secure before they are deployed. | ||
|
||
# NOTE: The workflow isn't able to pass the docker image between jobs, so each builds the image. | ||
# A future PR will pass the image between the scans to reduce overhead and increase speed | ||
name: CI Vulnerability Scans | ||
|
||
on: | ||
|
@@ -28,6 +26,7 @@ env: | |
|
||
jobs: | ||
hadolint-scan: | ||
name: Hadolint Scan | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -47,25 +46,80 @@ jobs: | |
run: | | ||
cat hadolint-results.txt >> $GITHUB_STEP_SUMMARY | ||
|
||
trivy-scan: | ||
build-and-cache: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.shared-output.outputs.image }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build and tag Docker image for scanning | ||
id: build-image | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@master | ||
|
||
- name: Cache Docker layers | ||
id: cache-buildx | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
|
||
- name: Ensure Buildx cache exists | ||
run: | | ||
mkdir -p /tmp/.buildx-cache | ||
|
||
- name: Set shared outputs | ||
id: shared-output | ||
run: | | ||
make APP_NAME=${{ env.APP_NAME }} release-build | ||
IMAGE_NAME=$(make APP_NAME=${{env.APP_NAME}} release-image-name) | ||
IMAGE_TAG=$(make release-image-tag) | ||
echo "image=$IMAGE_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
|
||
- name: Build and tag Docker image for scanning | ||
# If there's an exact match in cache, skip build entirely | ||
if: steps.cache-buildx.outputs.cache-hit != 'true' | ||
run: | | ||
make APP_NAME=${{ env.APP_NAME }} release-build | ||
|
||
- name: Save Docker image | ||
if: steps.cache-buildx.outputs.cache-hit != 'true' | ||
run: | | ||
docker save ${{ steps.shared-output.outputs.image }} > /tmp/docker-image.tar | ||
|
||
- name: Cache Docker image | ||
if: steps.cache-buildx.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: /tmp/docker-image.tar | ||
key: ${{ runner.os }}-docker-image-${{ github.sha }} | ||
|
||
trivy-scan: | ||
name: Trivy Scan | ||
runs-on: ubuntu-latest | ||
needs: build-and-cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Restore cached Docker image | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: /tmp/docker-image.tar | ||
key: ${{ runner.os }}-docker-image-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-docker-image- | ||
|
||
- name: Load cached Docker image | ||
run: | | ||
docker load < /tmp/docker-image.tar | ||
|
||
- name: Run Trivy vulnerability scan | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
scan-type: image | ||
image-ref: ${{ steps.build-image.outputs.image }} | ||
image-ref: ${{ needs.build-and-cache.outputs.image }} | ||
format: table | ||
exit-code: 1 | ||
ignore-unfixed: true | ||
|
@@ -78,23 +132,29 @@ jobs: | |
echo "View results in GitHub Action logs" >> $GITHUB_STEP_SUMMARY | ||
|
||
anchore-scan: | ||
name: Anchore Scan | ||
runs-on: ubuntu-latest | ||
needs: build-and-cache | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build and tag Docker image for scanning | ||
id: build-image | ||
- name: Restore cached Docker image | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: /tmp/docker-image.tar | ||
key: ${{ runner.os }}-docker-image-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-docker-image- | ||
|
||
- name: Load cached Docker image | ||
run: | | ||
make APP_NAME=${{ env.APP_NAME }} release-build | ||
IMAGE_NAME=$(make APP_NAME=${{ env.APP_NAME }} release-image-name) | ||
IMAGE_TAG=$(make release-image-tag) | ||
echo "image=$IMAGE_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
docker load < /tmp/docker-image.tar | ||
|
||
- name: Run Anchore vulnerability scan | ||
uses: anchore/scan-action@v3 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
image: ${{ needs.build-and-cache.outputs.image }} | ||
output-format: table | ||
|
||
- name: Save output to workflow summary | ||
|
@@ -103,18 +163,24 @@ jobs: | |
echo "View results in GitHub Action logs" >> $GITHUB_STEP_SUMMARY | ||
|
||
dockle-scan: | ||
name: Dockle Scan | ||
runs-on: ubuntu-latest | ||
needs: build-and-cache | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build and tag Docker image for scanning | ||
id: build-image | ||
- name: Restore cached Docker image | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: /tmp/docker-image.tar | ||
key: ${{ runner.os }}-docker-image-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-docker-image- | ||
|
||
- name: Load cached Docker image | ||
run: | | ||
make APP_NAME=${{ env.APP_NAME }} release-build | ||
IMAGE_NAME=$(make APP_NAME=${{ env.APP_NAME }} release-image-name) | ||
IMAGE_TAG=$(make release-image-tag) | ||
echo "image=$IMAGE_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
docker load < /tmp/docker-image.tar | ||
|
||
# Dockle doesn't allow you to have an ignore file for the DOCKLE_ACCEPT_FILES | ||
# variable, this will save the variable in this file to env for Dockle | ||
|
@@ -127,7 +193,7 @@ jobs: | |
- name: Run Dockle container linter | ||
uses: erzz/[email protected] | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
image: ${{ needs.build-and-cache.outputs.image }} | ||
exit-code: "1" | ||
failure-threshold: WARN | ||
accept-filenames: ${{ env.DOCKLE_ACCEPT_FILES }} | ||
|
This file contains 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!