-
Notifications
You must be signed in to change notification settings - Fork 18
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
Setup trivy scanning #27
Open
eswdd
wants to merge
10
commits into
master
Choose a base branch
from
eswdd-patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ac358ac
Setup trivy scanning
eswdd 9430dd3
Add trivy scanning whenever doing docker build
eswdd 58a2d80
Delete docker.yaml
eswdd e360baf
Create docker.yaml
eswdd 91dc847
Delete trivy.yml
eswdd 30daa36
Update docker.yaml
eswdd 9fc631c
Update docker.yaml
eswdd 2c69f99
Update docker.yaml
eswdd 992d4f8
Update docker.yaml
eswdd 025d2d2
Try running docker push on branch
eswdd 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 |
---|---|---|
|
@@ -8,6 +8,9 @@ on: | |
|
||
tags: | ||
- v* | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ master ] | ||
|
||
env: | ||
IMAGE_NAME: thanos-remote-read | ||
|
@@ -21,17 +24,22 @@ jobs: | |
|
||
- name: Build image | ||
run: docker build -t image . | ||
|
||
- name: Sanitize repo slug | ||
uses: actions/github-script@v4 | ||
id: github_id | ||
with: | ||
result-encoding: string | ||
script: return 'docker.pkg.github.com/${{ github.repository }}/${{ env.IMAGE_NAME }}'.toLowerCase() | ||
|
||
- name: Log into registry | ||
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | ||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | ||
|
||
- name: Push image | ||
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
GITHUB_ID="docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME" | ||
GITHUB_ID="${{ steps.github_id.outputs.result }}" | ||
DOCKERHUB_ID="gresearchdev/$IMAGE_NAME" | ||
|
||
# Change all uppercase to lowercase for github | ||
|
@@ -58,3 +66,18 @@ jobs: | |
docker tag image $DOCKERHUB_ID:latest | ||
docker push $DOCKERHUB_ID:latest | ||
fi | ||
|
||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@2a2157eb22c08c9a1fac99263430307b8d1bc7a2 | ||
with: | ||
image-ref: '${{ steps.github_id.outputs.result }}:${{ github.sha }}' | ||
format: 'template' | ||
template: '@/contrib/sarif.tpl' | ||
output: 'trivy-results.sarif' | ||
severity: 'CRITICAL,HIGH' | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v1 | ||
with: | ||
sarif_file: 'trivy-results.sarif' | ||
Comment on lines
+71
to
+83
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. We may want to scan the image before we push it, to avoid pushing known vulnerable images. In that case, we may want to refactor further, by using the proper image name straight for building, instead of |
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.
I think we should use the latest version of this action