Skip to content

Commit 30f6d29

Browse files
chore: CI for scanning vulnerabilities (#43)
1 parent 43e01ab commit 30f6d29

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/CI_pull.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI_pull
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
Vulnerability-test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Run Trivy vulnerability scanner in repo mode
18+
uses: aquasecurity/trivy-action@master
19+
with:
20+
scan-type: "fs"
21+
ignore-unfixed: true
22+
format: "table"
23+
output: "Trivy-table"
24+
severity: "LOW,MEDIUM,HIGH,CRITICAL"
25+
exit-code: "1"
26+
27+
- if: failure()
28+
uses: actions/github-script@v5
29+
with:
30+
script: |
31+
var data = require('fs').readFileSync("Trivy-table").toString();
32+
Trivyresult=""
33+
Trivyresult=Trivyresult.concat("```",data,"```");
34+
github.rest.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: `
39+
# Vulnerability Found!
40+
${Trivyresult}
41+
`
42+
})

.github/workflows/CI_push.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI_push
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
12+
Upload-result:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Run Trivy vulnerability scanner in repo mode
19+
uses: aquasecurity/trivy-action@master
20+
with:
21+
scan-type: 'fs'
22+
ignore-unfixed: true
23+
format: 'template'
24+
output: 'trivy-results.sarif'
25+
template: '@/contrib/sarif.tpl'
26+
severity: 'LOW,MEDIUM,HIGH,CRITICAL'
27+
28+
- name: Upload Trivy scan results to GitHub Security-tab
29+
uses: github/codeql-action/upload-sarif@v1
30+
with:
31+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)