-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add daily vulnerability scan #100
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d6436ab
add daily-vul-scan.yml
R-HNF 20d232b
add tested workflow and trivy result template
R-HNF e772bd5
fix badge link
R-HNF a49cd04
add branch parameter to badge link
R-HNF cda4144
move template file
R-HNF dec98bb
change workflow trigger to cron
R-HNF 91e13dc
fix link
R-HNF 83f321c
fix job name
R-HNF ab8f154
fix template
R-HNF 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{ $d := dict "CRITICAL" "🔴" "HIGH" "🟠" "MEDIUM" "🟡" "UNKNOWN" "🟤" }} | ||
|
||
{{- range . -}} | ||
## {{ .Target }} | ||
|
||
### {{ .Type }} | ||
|
||
{{ if .Vulnerabilities -}} | ||
| Title | Severity | CVE | Package Name | Installed Version | Fixed Version | References | | ||
| :--: | :--: | :--: | :--: | :--: | :--: | :-- | | ||
{{- range .Vulnerabilities }} | ||
| {{ .Title -}} | ||
| {{ get $d .Vulnerability.Severity }}{{ .Vulnerability.Severity -}} | ||
| {{ .VulnerabilityID -}} | ||
| {{ .PkgName -}} | ||
| {{ .InstalledVersion -}} | ||
| {{ .FixedVersion -}} | ||
| {{ range $ref := .Vulnerability.References -}}- {{ $ref }}<br>{{- end -}} | ||
| | ||
{{- end }} | ||
|
||
{{ else -}} | ||
_No vulnerabilities found_ | ||
|
||
{{ end }} | ||
|
||
{{- end }} |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: daily vulnerability scan | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
env: | ||
IMAGE_NAME: zozo-gatling-operator | ||
TRIVY_RESULTS_MARKDOWN: trivy-results.md | ||
|
||
permissions: | ||
contents: read | ||
issues: write | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: ./go.mod | ||
cache: true | ||
|
||
- name: Go modules sync | ||
run: go mod tidy | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build an image from Dockerfile | ||
run: | | ||
make docker-build IMG="${{ env.IMAGE_NAME }}:${{ github.sha }}" | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
scan-type: image | ||
image-ref: "${{ env.IMAGE_NAME }}:${{ github.sha }}" | ||
exit-code: 1 | ||
ignore-unfixed: true | ||
vuln-type: os,library | ||
severity: HIGH,CRITICAL | ||
timeout: 10m0s | ||
scanners: vuln,secret,config | ||
format: template | ||
template: "@.github/ISSUE_TEMPLATE/trivy-results.tpl" | ||
output: ${{ env.TRIVY_RESULTS_MARKDOWN }} | ||
|
||
- name: Insert YAML front matter into the results markdown | ||
if: always() | ||
run: | | ||
sed -i '1i\ | ||
---\ | ||
title: "[DO NOT CHANGE] Security Alert"\ | ||
labels: "trivy, vulnerability"\ | ||
---\ | ||
' "${{ env.TRIVY_RESULTS_MARKDOWN }}" | ||
|
||
- name: Create or update the trivy results issue | ||
uses: JasonEtco/create-an-issue@v2 | ||
if: always() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
filename: ${{ env.TRIVY_RESULTS_MARKDOWN }} | ||
update_existing: true | ||
search_existing: open |
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
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.
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 feel the job should be separated more as not only building here.
Such as scanning and making an issue.
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.
As you suggested, it seemed like a good idea to separate the jobs.
However, upon consideration of the following points, I concluded that processing the trivy results within the same job would be more efficient than writing them out as a string and sharing across different jobs.
aquasecurity/trivy-action@master
is specified by file.JasonEtco/create-an-issue@v2
isfilename
.Consequently, I decided to only change the job name, instead of separating the jobs.
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.
OK, I understand it's tough to separate jobs.