File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : " [Push] Build dev"
22
33on :
4+ push :
5+ branches :
6+ - master
7+ paths-ignore :
8+ - ' .github/**'
9+ - ' src/VERSION'
10+ - ' docs/**'
411 workflow_dispatch :
5- repository_dispatch :
6- types : [master_push]
712
813env :
914 SLACK_WEBHOOK_URL : ${{secrets.SLACK_WEBHOOK_URL}}
5863 fields : repo,workflow,job
5964 author_name : Github Action Slack
6065
66+ scan :
67+ needs : docker
68+ runs-on : ubuntu-20.04
69+ steps :
70+ - name : Run Trivy vulnerability scanner
71+ id : trivy-scan
72+ uses : aquasecurity/trivy-action@master
73+ with :
74+ image-ref : pyengine/${{ github.event.repository.name }}:${{ env.VERSION }}
75+ format : ' sarif'
76+ output : ' trivy-results.sarif'
77+ ignore-unfixed : true
78+ vuln-type : ' os,library'
79+ severity : ' CRITICAL,HIGH'
80+
81+ - name : Upload Trivy scan results to GitHub Security tab
82+ uses : github/codeql-action/upload-sarif@v2
83+ with :
84+ sarif_file : ' trivy-results.sarif'
85+
86+ - name : Count vulnerabilities
87+ id : vulnerabilities
88+ run : |
89+ count=$(jq '.runs[].results[].ruleId' ./trivy-results.sarif | wc -c)
90+ echo "result_count=$count" >> $GITHUB_OUTPUT
91+ echo "$count"
92+
93+ - name : slack
94+ if : ${{ steps.vulnerabilities.outputs.result_count != 0 }}
95+ uses : 8398a7/action-slack@v3
96+ with :
97+ status : custom
98+ fields : workflowRun
99+ custom_payload : |
100+ {
101+ "blocks": [
102+ {
103+ "type": "section",
104+ "text": {
105+ "type": "mrkdwn",
106+ "text": ":warning: Image vulnerability detected"
107+ }
108+ },
109+ {
110+ "type": "section",
111+ "fields": [
112+ {
113+ "type": "mrkdwn",
114+ "text": "*Image:*\n$pyengine/${{ github.event.repository.name }}:${{ env.VERSION }}"
115+ },
116+ {
117+ "type": "mrkdwn",
118+ "text": "*Repo name:*\n${{ github.repository }}"
119+ }
120+ ]
121+ },
122+ {
123+ "type": "actions",
124+ "elements": [
125+ {
126+ "type": "button",
127+ "text": {
128+ "type": "plain_text",
129+ "emoji": true,
130+ "text": "View Detail"
131+ },
132+ "style": "danger",
133+ "url": "https://github.com/${{ github.repository }}/security/code-scanning"
134+ }
135+ ]
136+ }
137+ ]
138+ }
139+ env :
140+ SLACK_WEBHOOK_URL : ${{secrets.VULNERABILITY_SLACK_WEBHOOK_URL}}
141+
61142 notification :
62143 runs-on : ubuntu-latest
63144 needs : docker
You can’t perform that action at this time.
0 commit comments