Repository navigation
Expand file tree
/
Copy pathexample-code-analysis.yml.text
More file actions
233 lines (189 loc) · 8.14 KB
/
Copy pathexample-code-analysis.yml.text
File metadata and controls
233 lines (189 loc) · 8.14 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: GHAS Code Scans
# https://github.com/github/codeql-action
on:
push:
branches: [main]
pull_request:
branches: [main]
repository_dispatch:
types: [code-scan]
workflow_dispatch:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: "30 1 * * 0"
jobs:
Dependency-Review:
runs-on: im-ghas-linux
if: github.event_name == 'pull_request'
permissions:
actions: read # only required for workflows in private repositories
contents: read # for actions/checkout fetch code
pull-requests: write # can write to pull requests
security-events: write # required for all workflows
steps:
- name: Checkout Repository
uses: actions/checkout@v3
# https://github.com/actions/dependency-review-action
- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
fail-on-severity: moderate
CodeQL-Scan-csharp:
runs-on: im-ghas-linux # if windows needed im-windows (depending on your needs, you may need to make a custom DYN windows runner based off the im-windows runner)
env:
DOTNET_VERSION: |
6.0
SOLUTION_FILE: ./path/to/solution.sln
DOTNET_INSTALL_DIR: dotnet-install
permissions:
actions: read # only required for workflows in private repositories
contents: read # for actions/checkout fetch code
pull-requests: write # can write to pull requests
security-events: write # required for all workflows
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
env:
DOTNET_INSTALL_DIR: ${{ env.DOTNET_INSTALL_DIR }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
ram: 1536 # Give 1.5 GB ram to CodeQL, 1024 can lead to out of memory issues for some C# repos
# Using additional queries to get more results
# See https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning#using-queries-in-ql-packs
queries: security-and-quality
languages: csharp
- name: Authenticate with GitHub Packages
uses: im-open/authenticate-with-gh-package-registries@v1.0.5
with:
read-pkg-token: ${{ secrets.READ_PKG_TOKEN }} # This is an org-level secret
orgs: "im-platform"
- name: dotnet build
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Release
- name: Perform C# CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: /codeql-scan:csharp
Terraform-Scan:
runs-on: im-ghas-linux
permissions:
actions: read # only required for workflows in private repositories
contents: read # for actions/checkout fetch code
pull-requests: write # can write to pull requests
security-events: write # required for all workflows
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Perform Terraform Scan
# Rules Lookup
# https://aquasecurity.github.io/tfsec/v1.28.1/checks/azure/
uses: aquasecurity/tfsec-sarif-action@v0.1.4
with:
sarif_file: terraform.sarif
- name: Upload Terraform SARIF results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: terraform.sarif
PowerShell-Scan:
runs-on: im-ghas-linux
permissions:
actions: read # only required for workflows in private repositories
contents: read # for actions/checkout fetch code
pull-requests: write # can write to pull requests
security-events: write # required for all workflows
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Perform PowerShell Scan
# Rules URL
# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Rules/README.md
uses: microsoft/psscriptanalyzer-action@v1.1
with:
# Check https://github.com/microsoft/psscriptanalyzer-action for more info about the options.
# The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules.
path: .\
recurse: true
output: powershell.sarif
- name: Upload PowerShell SARIF results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: powershell.sarif
CodeQL-Scan:
strategy:
matrix:
languages: [javascript, python]
runs-on: im-ghas-linux
permissions:
actions: read # only required for workflows in private repositories
contents: read # for actions/checkout fetch code
pull-requests: write # can write to pull requests
security-events: write # required for all workflows
steps:
- name: Checkout repository
uses: actions/checkout@v3
# For JavaScript use filter-sarif action so we can remove results from dist folders
# https://github.com/advanced-security/filter-sarif
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
ram: 1024
# Using additional queries to get more results
# See https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning#using-queries-in-ql-packs
queries: security-and-quality
languages: ${{ matrix.languages }}
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# Perform normal analysis
- name: Perform CodeQL Analysis
if: matrix.languages != 'javascript'
uses: github/codeql-action/analyze@v2
with:
category: /codeql-scan:${{ matrix.languages }}
# For JavaScript run analysis differently so we can ignore directories in the results
- name: Perform JavaScript CodeQL Analysis
if: matrix.languages == 'javascript'
uses: github/codeql-action/analyze@v2
with:
category: /codeql-scan:${{ matrix.languages }}
upload: False
output: sarif-results
- name: Filter JavaScript SARIF Results
if: matrix.languages == 'javascript'
# Information about this tool
# https://github.com/advanced-security/filter-sarif
uses: advanced-security/filter-sarif@09a9626fe5e89584ba5ed115143975bfc59ac6a9
with:
# Remove results under dist directory
patterns: |
-**/dist/**
input: sarif-results/javascript.sarif
output: sarif-results/javascript.sarif
- name: Upload JavaScript SARIF Results
if: matrix.languages == 'javascript'
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: sarif-results/javascript.sarif