forked from microsoft/msticpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
254 lines (254 loc) · 8.84 KB
/
azure-pipelines.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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# Variable 'keys.ipstack_auth' was defined in the Variables tab
# Variable 'keys.maxmind_auth' was defined in the Variables tab
# Variable 'PIP_CACHE_DIR' was defined in the Variables tab
# Variable 'python.version' was defined in the Variables tab
# Cron Schedules have been converted using UTC Time Zone and may need to be updated for your location
# Multi-job configuration must be converted to matrix strategy: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#multi-job-configuration
trigger:
branches:
include:
- main
batch: True
pr:
branches:
include:
- main
- release/*
schedules:
- cron: 0 4 * * 1
branches:
include:
- main
always: true
name: $(date:yyyyMMdd)$(rev:.r)
resources:
repositories:
- repository: self
type: git
ref: main
variables:
- name: prSource
${{ if variables['System.PullRequest.IsFork'] }}:
value: fork
${{ if not(variables['System.PullRequest.IsFork']) }}:
value: internal
stages:
- stage: PythonTests
displayName: Python build and tests
variables:
# This is run explicity so does not need to be auto-injected
skipComponentGovernanceDetection: true
jobs:
- job: InstallAndTestPackage
strategy:
matrix:
linux:
imageName: "ubuntu-latest"
python.version: '3.8'
mac:
imageName: "macos-latest"
python.version: '3.8'
windows-py36:
imageName: "windows-latest"
python.version: '3.8'
maxParallel: 4
pool:
vmImage: $(imageName)
steps:
# Add an alias for Windows python=>python3
- script: alias python='python3' pip='pip3'
condition: in(variables['imageName'], 'ubuntu-latest', 'macos-latest')
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'
inputs:
versionSpec: '$(python.version)'
- task: Cache@2
displayName: Cache pip packages
continueOnError: True
inputs:
key: python | "$(Agent.OS)"
path: $(PIP_CACHE_DIR)
restoreKeys: python
- script: |
python -m pip install --upgrade pip wheel setuptools==56.0.0
python -m pip install -r requirements-all.txt
python -m pip install -e .
displayName: 'Install package and dependencies'
- script: |
python -m pip install sphinx readthedocs-sphinx-ext>=2.1.4 sphinx-rtd-theme>=1.0.0
python -m pip install -r $(Build.SourcesDirectory)/docs/requirements.txt
make html
env:
SPHINX_NOGEN: "true"
workingDirectory: docs
condition: eq(variables.imageName, 'windows-latest')
displayName: 'Sphinx Read the Docs build'
- script: |
mkdir ~/.msticpy
mkdir ~/.msticpy/mordor
cp $(Build.SourcesDirectory)/tests/testdata/geolite/GeoLite2-City.mmdb ~/.msticpy
touch ~/.msticpy/GeoLite2-City.mmdb
cp -r $(Build.SourcesDirectory)/tests/testdata/mordor/* ~/.msticpy/mordor
touch ~/.msticpy/mordor/mitre_tact_cache.pkl
touch ~/.msticpy/mordor/mitre_tech_cache.pkl
touch ~/.msticpy/mordor/mordor_cache.pkl
condition: ne(variables.imageName, 'windows-latest')
displayName: 'Prepare test dummy data - Linux'
- script: |
mkdir %USERPROFILE%\.msticpy
mkdir %USERPROFILE%\.msticpy\mordor
copy /Y $(Build.SourcesDirectory)\tests\testdata\geolite\GeoLite2-City.mmdb %USERPROFILE%\.msticpy
copy /Y $(Build.SourcesDirectory)\tests\testdata\mordor\* %USERPROFILE%\.msticpy\mordor
condition: eq(variables.imageName, 'windows-latest')
displayName: 'Prepare test dummy data - Windows'
- script: |
echo MSTICPYCONFIG: $(Build.SourcesDirectory)/tests/msticpyconfig-test.yaml
echo Env $MSTICPYCONFIG or %MSTICPYCONFIG%
echo Build source: $(prSource)
echo Env $MSTICPY_BUILD_SOURCE or %MSTICPY_BUILD_SOURCE%
python -m pip install -r requirements-dev.txt
python -m pip install "pandas>=1.3.0"
python -m pip install seaborn
pytest tests --junitxml=junit/test-$(variables.imageName)-$(variables.python.version)-results.xml -n auto --cov=msticpy --cov-report=xml
displayName: pytest
env:
MSTICPYCONFIG: $(Build.SourcesDirectory)/tests/msticpyconfig-test.yaml
MAXMIND_AUTH: $(keys.maxmind_auth)
IPSTACK_AUTH: $(keys.ipstack_auth)
MSTICPY_TEST_NOSKIP: 1
MSTICPY_BUILD_SOURCE: $(prSource)
condition: succeededOrFailed()
continueOnError: true
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '**/*-results.xml'
testRunTitle: 'Python $(python.version)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov'
- stage: SecurityChecks
# Pipeline
displayName: Azure pipeline, security and component governance tools
dependsOn:
- PythonTests
# - PythonLinters
variables:
# This is run explicitly, so does not need to be auto-injected
skipComponentGovernanceDetection: true
jobs:
- job: SecurityTests
# Credscan must be run on Windows
pool:
vmImage: windows-latest
python.version: '3.8'
steps:
- task: CredScan@2
displayName: 'Run CredScan'
inputs:
toolMajorVersion: V2
debugMode: false
suppressionsFile: $(Build.SourcesDirectory)\.ci_config\credscan.json
continueOnError: true
condition: succeededOrFailed()
- task: AutoApplicability@1
inputs:
ExternalRelease: true
displayName: 'Run AutoApplicability'
- task: PoliCheck@1
displayName: 'Run PoliCheck'
inputs:
SOMEnabled: true
optionsUEPATH: $(Build.SourcesDirectory)\.ci_config\UserExclusion.xml
- task: VulnerabilityAssessment@0
displayName: 'Run Vulnerability Assessment'
- task: ComponentGovernanceComponentDetection@0
inputs:
scanType: 'Register'
verbosity: 'Verbose'
alertWarningLevel: 'High'
displayName: 'Component Detection'
- task: AntiMalware@3
inputs:
InputType: 'Basic'
ScanType: 'CustomScan'
FileDirPath: '$(Build.StagingDirectory)'
EnableServices: true
SupportLogOnError: false
TreatSignatureUpdateFailureAs: 'Warning'
SignatureFreshness: 'UpToDate'
TreatStaleSignatureAs: 'Error'
continueOnError: true
condition: succeededOrFailed()
- task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@1
displayName: 'Create Security Analysis Report'
inputs:
CredScan: true
PoliCheck: true
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs'
inputs:
AllTools: false
AntiMalware: true
APIScan: false
BinSkim: false
CodesignValidation: false
FortifySCA: false
FxCop: false
ModernCop: false
MSRD: false
RoslynAnalyzers: false
SDLNativeRules: false
Semmle: false
TSLint: false
WebScout: false
- task: notice@0
displayName: NOTICE File Generator
# This fails for external forks
condition: not(variables['System.PullRequest.IsFork'])
- task: PostAnalysis@1
displayName: Post Analysis
inputs:
CredScan: true
PoliCheck: true
- task: dependency-check-build-task@5
displayName: 'OWASP Dependency Check'
inputs:
projectName: msticpy
scanPath: '$(Build.SourcesDirectory)'
format: HTML,JUNIT
suppressionPath: '$(Build.SourcesDirectory)'
continueOnError: true
condition: succeededOrFailed()
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '**/*-results.xml'
testRunTitle: 'Python $(python.version)'
- stage: CreatePythonPackage
displayName: Create msticpy distribution package and publish msticpy artifact
variables:
# This is run explicitly so does not need to be auto-injected
skipComponentGovernanceDetection: true
dependsOn:
- SecurityChecks
condition: succeeded('SecurityChecks')
jobs:
- job: CreateDistPackage
pool:
vmImage: windows-latest
variables:
python.version: '$(python.version)'
steps:
- script: 'pip install --upgrade setuptools==56.0.0 wheel'
displayName: 'Install setuptools'
- script: 'python setup.py sdist bdist_wheel'
displayName: 'Build sdist and wheel'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: msticpy'
inputs:
PathtoPublish: dist
ArtifactName: msticpy