-
Notifications
You must be signed in to change notification settings - Fork 15
162 lines (161 loc) · 6.26 KB
/
codeql-analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Note, the base of this comes from an autogenerated file from CodeQL
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: CodeQL security analysis
on:
workflow_call:
jobs:
analyzeExcludingWarnings:
name: Analyze add-on excluding warnings
runs-on: windows-latest
permissions:
actions: read
contents: read
security-events: write
issues: write
strategy:
fail-fast: false
matrix:
python-version: [ 3.11 ]
language: ['python']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download add-on
uses: actions/download-artifact@v4
with:
name: addon
- name: Unzip add-on
run: |
Copy-Item addon.nvda-addon addon.zip
Expand-Archive addon.zip
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config-excluding-warnings.yml
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
output: results
- name: Download add-on metadata
uses: actions/download-artifact@v4
with:
name: addonMetadata
- name: Set security analysis status
id: setSecurityAnalysisStatus
uses: actions/github-script@v7
with:
script: |
const setSecurityAnalysisStatus = require('./.github/workflows/securityAnalysis.js')
const path = 'results/${{ matrix.language }}.sarif'
setSecurityAnalysisStatus({core}, path)
- name: Upload results
id: uploadResults
if: failure()
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.language }}
path: results/*.sarif
overwrite: true
- name: Upload manual approval
id: uploadManualApproval
if: failure()
uses: actions/upload-artifact@v4
with:
name: manualApproval
path: reviewedAddons.json
overwrite: true
- name: Warn if analysis fails
if: failure()
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
Security analysis has failed for this add-on.
You can open this link and [download artifacts containing the results of the analysis](${{ steps.uploadResults.outputs.artifact-url }}).
Unzip artifacts and open the .sarif file in your preferred editor.
For example, you can use [Microsoft's Sarif web based reader](https://microsoft.github.io/sarif-web-component).
NV Access will determine whether or not the detection should prevent the add-on from being accepted.
Please review the warnings and consider fixing this in the add-on.
If you can provide more context on the failure in the submission, please do.
See the [submission guide](https://github.com/nvaccess/addon-datastore/blob/master/docs/submitters/submissionGuide.md) for more details.
analyze:
name: Analyze add-on
needs: analyzeExcludingWarnings
continue-on-error: true
runs-on: windows-latest
permissions:
actions: read
security-events: write
issues: write
strategy:
fail-fast: false
matrix:
python-version: [ 3.11 ]
language: ['javascript', 'python']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download add-on
uses: actions/download-artifact@v4
with:
name: addon
- name: Unzip add-on
run: |
Copy-Item addon.nvda-addon addon.zip
Expand-Archive addon.zip
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
output: results
- name: Download add-on metadata
uses: actions/download-artifact@v4
with:
name: addonMetadata
- name: Set security analysis status
id: setSecurityAnalysisStatus
uses: actions/github-script@v7
with:
script: |
const setSecurityAnalysisStatus = require('./.github/workflows/securityAnalysis.js')
const path = 'results/${{ matrix.language }}.sarif'
setSecurityAnalysisStatus({core}, path)
- name: Upload results
id: uploadResults
if: failure()
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.language }}
path: results/*.sarif
overwrite: true
- name: Warn if analysis fails
if: failure()
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
Security analysis has reported warnings for this add-on.
This won't prevent its acceptance to the store, but you may want to review warnings to improve the quality of your code for future versions.
You can open this link and [download artifacts containing the results of the analysis](${{ steps.uploadResults.outputs.artifact-url }}).
Unzip artifacts and open the .sarif file in your preferred editor.
For example, you can use [Microsoft's Sarif web based reader](https://microsoft.github.io/sarif-web-component).