20
20
# JavaScript, and others. The findings are reported in the repo's code-scanning
21
21
# results page, https://github.com/quantumlib/REPO/security/code-scanning/.
22
22
#
23
- # The OSV project provides a GA workflow that you can reference as a step with
23
+ # Note: the OSV project provides a workflow you can reference as a step with
24
24
# uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml.
25
25
# Unfortunately, that workflow hardcodes some behaviors (such as uploading the
26
- # SARIF file to the workflow Actions tab, which we rarely need ). The workflow
27
- # below is basically a heavily modified version of theirs.
26
+ # SARIF file to the workflow Actions tab, which we have never needed ). The
27
+ # workflow in this file is basically a heavily modified version of theirs.
28
28
#
29
29
# For more OSV scanner examples and options, including how to ignore specific
30
30
# vulnerabilities, see https://google.github.io/osv-scanner/github-action/.
31
31
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
32
33
- name : OSV code scan
34
- run-name : Run OSV vulnerability scanner ${{inputs.reason}}
33
+ name : OSV known vulnerabilities scanner
34
+ run-name : Run OSV (open-source vulnerabilities) scanner ${{inputs.reason}}
35
35
36
36
on :
37
37
pull_request :
45
45
types :
46
46
- checks_requested
47
47
48
- # Allow manual invocation.
49
- workflow_dispatch :
50
-
51
- # Allow calling from nightly.yaml.
48
+ # Allow calling from other workflows.
52
49
workflow_call :
53
50
inputs :
54
51
reason :
52
+ description : ' Append text to workflow run name:'
55
53
type : string
54
+ debug :
55
+ description : ' Run with debugging options'
56
+ type : boolean
57
+ default : false
58
+
59
+ # Allow manual invocation.
60
+ workflow_dispatch :
61
+ inputs :
62
+ debug :
63
+ description : ' Run with debugging options'
64
+ type : boolean
65
+ default : true
56
66
57
- # Declare default permissions as read only.
67
+ # Declare default workflow permissions as read only.
58
68
permissions : read-all
59
69
70
+ concurrency :
71
+ # Cancel any previously-started but still active runs on the same branch.
72
+ cancel-in-progress : true
73
+ group : ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
74
+
60
75
jobs :
61
76
osv-scan :
77
+ if : github.repository_owner == 'quantumlib'
62
78
name : Run OSV scanner
63
79
runs-on : ubuntu-24.04
64
80
timeout-minutes : 15
69
85
security-events : write
70
86
# Needed to upload SARIF file to CodeQL.
71
87
contents : read
88
+ env :
89
+ # Setting Bash SHELLOPTS here takes effect for all shell commands below.
90
+ SHELLOPTS : ${{inputs.debug && 'xtrace' || '' }}
72
91
steps :
73
92
- name : Check out a copy of the git repository
74
- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
93
+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
75
94
with :
76
95
fetch-depth : 0
77
96
@@ -82,10 +101,11 @@ jobs:
82
101
83
102
- name : Run OSV scanner on existing code
84
103
# yamllint disable rule:line-length
85
- uses : google/osv-scanner-action/osv-scanner-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
104
+ uses : google/osv-scanner-action/osv-scanner-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
86
105
continue-on-error : true
87
106
with :
88
107
scan-args : |-
108
+ --include-git-root
89
109
--format=json
90
110
--output=old-results.json
91
111
--recursive
@@ -99,18 +119,19 @@ jobs:
99
119
100
120
- name : Run OSV scanner on new code
101
121
# yamllint disable rule:line-length
102
- uses : google/osv-scanner-action/osv-scanner-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
122
+ uses : google/osv-scanner-action/osv-scanner-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
103
123
continue-on-error : true
104
124
with :
105
125
scan-args : |-
126
+ --include-git-root
106
127
--format=json
107
128
--output=new-results.json
108
129
--recursive
109
130
./
110
131
111
132
- name : Run the OSV scanner reporter
112
133
# yamllint disable rule:line-length
113
- uses : google/osv-scanner-action/osv-reporter-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
134
+ uses : google/osv-scanner-action/osv-reporter-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
114
135
with :
115
136
scan-args : |-
116
137
--output=osv-results.sarif
@@ -122,10 +143,18 @@ jobs:
122
143
- name : Upload results to the repository's code-scanning results dashboard
123
144
id : upload_artifact
124
145
# yamllint disable rule:line-length
125
- uses : github/codeql-action/upload-sarif@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.10
146
+ uses : github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
126
147
with :
127
148
sarif_file : osv-results.sarif
128
149
150
+ - if : github.event.inputs.debug == true
151
+ name : Upload results as artifacts to the workflow Summary page
152
+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
153
+ with :
154
+ name : SARIF file
155
+ path : results.sarif
156
+ retention-days : 5
157
+
129
158
- name : Error troubleshooter
130
159
if : ${{always() && steps.upload_artifact.outcome == 'failure'}}
131
160
run : echo '::error::Artifact upload failed. Check the workflow logs.'
0 commit comments