-
Notifications
You must be signed in to change notification settings - Fork 39
192 lines (163 loc) · 6.79 KB
/
codescanner.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
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
name: Codescanner
on:
push:
branches:
- 'master'
- 'devel'
- 'min-devel'
- 'min'
- 'code-scanner_wf'
jobs:
bandit:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Bandit Scan
uses: shundor/python-bandit-scan@9cc5aa4a006482b8a7f91134412df6772dbda22c
with: # optional arguments
# exit with 0, even with results found
exit_zero: true # optional, default is DEFAULT
# Github token of the repository (automatically created by Github)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information.
# File or directory to run bandit on
# path: # optional, default is .
# Report only issues of a given severity level or higher. Can be LOW, MEDIUM or HIGH. Default is UNDEFINED (everything)
# level: # optional, default is UNDEFINED
# Report only issues of a given confidence level or higher. Can be LOW, MEDIUM or HIGH. Default is UNDEFINED (everything)
# confidence: # optional, default is UNDEFINED
# comma-separated list of paths (glob patterns supported) to exclude from scan (note that these are in addition to the excluded paths provided in the config file) (default: .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg)
# excluded_paths: # optional, default is DEFAULT
# comma-separated list of test IDs to skip
# skips: # optional, default is DEFAULT
# path to a .bandit file that supplies command line arguments
# ini_path: # optional, default is DEFAULT
codecov:
name: Codecov Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Install components
run: |
sudo DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
libkrb5-dev \
python3-gssapi \
- name: Generate coverage report
run: |
python -m pip install --upgrade pip
pip install lxml beautifulsoup4 html5lib
pip install pytest
pip install pytest-cov impacket
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install components
run: |
sudo DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
libkrb5-dev \
python3-gssapi \
- name: Install pytest coverage and any other packages
run: |
python -m pip install --upgrade pip
pip install pytest coverage impacket
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: run coverage
run: |
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: github.event_name == 'pull_request'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
# Autobuild attempts to build any compiled languages (C/C++, C#, 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.
# 📚 https://git.io/JvXDl
# ✏️ 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: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
# ossarscan:
# name: OSSAR-Scan
# # OSSAR runs on windows-latest.
# # ubuntu-latest and macos-latest support coming soon
# runs-on: windows-latest
# steps:
# # Checkout your code repository to scan
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
# fetch-depth: 2
# # If this run was triggered by a pull request event, then checkout
# # the head of the pull request instead of the merge commit.
# - run: git checkout HEAD^2
# if: ${{ github.event_name == 'pull_request' }}
# # Ensure a compatible version of dotnet is installed.
# # The [Microsoft Security Code Analysis CLI](https://aka.ms/mscadocs) is built with dotnet v3.1.201.
# # A version greater than or equal to v3.1.201 of dotnet must be installed on the agent in order to run this action.
# # Remote agents already have a compatible version of dotnet installed and this step may be skipped.
# # For local agents, ensure dotnet version 3.1.201 or later is installed by including this action:
# # - name: Install .NET
# # uses: actions/setup-dotnet@v1
# # with:
# # dotnet-version: '3.1.x'
# # Run open source static analysis tools
# - name: Run OSSAR
# uses: github/ossar-action@v1
# id: ossar
# # Upload results to the Security tab
# - name: Upload OSSAR results
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: ${{ steps.ossar.outputs.sarifFile }}