forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.pre-commit-config_template.yaml
378 lines (363 loc) · 12 KB
/
.pre-commit-config_template.yaml
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
exclude: .devcontainer/|.vscode|Pipfile.lock|.gitlab/ci/|.circleci/|docs
files: ''
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-json
- id: check-yaml
- id: check-ast
min_py_version: '3.7'
- id: check-merge-conflict
- id: debug-statements
language_version: python3
min_py_version: '3.7'
- id: name-tests-test
min_py_version: '3.7'
files: .+_test.py$
- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
hooks:
- id: poetry-check
args:
- --lock
files: ^pyproject.toml$
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.2
hooks:
- id: pycln
min_py_version: '3.7'
args:
- --all
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
hooks:
- id: ruff
parallel: false
min_py_version: '3.7'
args:
- --fix
args:nightly:
- --config=nightly_ruff.toml
args:ci:
- --config=nightly_ruff.toml
args:docker_autoupdate:
- --config=nightly_ruff.toml
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
exclude_support_level:ci:
- community
exclude_support_level:nightly:
- community
skip:nightly: true
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
min_py_version: '3.7'
args:
- --ignore-missing-imports
- --check-untyped-defs
- --show-error-codes
- --follow-imports=silent
- --allow-redefinition
exclude: test_data|tests_data|.venv|.*_test.py$|infrastructure_tests|.vulture_whitelist.py|demistomock.py|Templates|conftest.py|Utils/download_packs_and_docker_images.py
language: system
entry: mypy
- repo: local
hooks:
- id: xsoar-lint
name: xsoar-lint
description: Run xsoar-linter on the code in content packs
entry: demisto-sdk xsoar-lint
files: ^Packs\/.*\.py$
exclude: _test\.py|\.vulture_whitelist\.py|test_data|tests_data|TestData
require_serial: true
language: system
# skip nightly since we don't care about warnings in nightly
skip:nightly: true
skip:docker_autoupdate: true
- id: pylint-in-docker
name: pylint-in-docker
description: Run pylint on the code in content packs
docker_image:nightly: native:ga,native:maintenance,from-yml,native:candidate
docker_image:ci: native:ga,from-yml,native:dev,native:maintenance
docker_image:native: native:ga,from-yml,native:dev,native:maintenance
docker_image: from-yml
entry: pylint
files: Packs\/.*\.py$
exclude: _test\.py|.vulture_whitelist\.py|test_data
args:
- --ignore=demistomock.py,CommonServerPython.py,CommonServerUserPython.py,conftest.py,.venv
- -E
- --disable=bad-option-value,unsubscriptable-object
- -d duplicate-string-formatting-argument
- "--msg-template='{path}:{line}:{column}: {msg_id} {obj}: {msg}'"
- --generated-members=requests.packages.urllib3,requests.codes.ok
config_file_arg:
arg_name: --rcfile
file_name: .pylintrc
skip:commit: true
pass_docker_extra_args:ci: --rm=false
pass_docker_extra_args:nightly: --rm=false
- id: mypy-in-docker
name: mypy-in-docker
copy_files:
- Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
- Tests/demistomock/demistomock.py
description: Run mypy on the code in content packs
docker_image:nightly: native:ga,native:maintenance,from-yml,native:candidate
docker_image:native: native:ga,from-yml,native:dev,native:maintenance
docker_image:ci: native:ga,from-yml,native:dev,native:maintenance
docker_image: from-yml
entry: mypy
files: Packs\/.*\.py$
exclude: test_data|tests_data|.venv|.*_test.py$|infrastructure_tests|.vulture_whitelist.py|demistomock.py|Templates|conftest.py|Utils/download_packs_and_docker_images.py
min_py_version: '3.7'
args:
- --check-untyped-defs
- --show-error-codes
- --allow-redefinition
- --cache-dir=/tmp/.mypy_cache
- --implicit-optional
pass_docker_extra_args:ci: --rm=false
pass_docker_extra_args:nightly: --rm=false
skip: true # skip until the https://github.com/demisto/demisto-sdk/pull/4468 will merge
- id: pytest-in-docker
name: pytest-in-docker
description: Run pytest on the code in content packs
docker_image:nightly: native:ga,native:maintenance,from-yml,native:candidate
docker_image:ci: native:ga,from-yml,native:dev,native:maintenance
docker_image:native: native:ga,from-yml,native:dev,native:maintenance
docker_image: from-yml
entry: python
language: docker
files: Packs\/.*_test\.py$
# The exclude list includes the list of all integration/scripts which require network for testing
exclude: test_data|Packs/Base/Scripts/CommonServerPython/CommonServerPython_test.py|Packs/Base/Scripts/SanePdfReport/SanePdfReport_test.py|Packs/Base/Scripts/CheckDockerImageAvailable/CheckDockerImageAvailable_test.py|Packs/CommonScripts/Scripts/Ping/Ping_test.py|Packs/CommonScripts/Scripts/GetDockerImageLatestTag/GetDockerImageLatestTag_test.py|Packs/CommonScripts/Scripts/GetDuplicatesMlv2/GetDuplicatesMlv2_test.py|Packs/CommonScripts/Scripts/DockerHardeningCheck/DockerHardeningCheck_test.py|Packs/rasterize/Integrations/rasterize/rasterize_test.py|Packs/Slack/Integrations/Slack/Slack_test.py|Packs/SymantecDLP/Integrations/SymantecDLP/SymantecDLP_test.py|Packs/WebFileRepository/Integrations/WebFileRepository/WebFileRepository_test.py|Packs/Whois/Integrations/Whois/Whois_test.py
env:
COVERAGE_FILE: /src/.pre-commit/coverage/.coverage
args:
- /src/Tests/scripts/script_runner.py
- coverage
- run
- -p
- --source=.
- -m
- pytest
- -v
- --override-ini='asyncio_mode=auto'
- --rootdir=/src
- --junitxml=/src/.pre-commit/pytest-junit/.report_pytest.xml
- --color=yes
- --files
args:docker_autoupdate:
- /src/Tests/scripts/script_runner.py
- pytest
- -v
- --override-ini='asyncio_mode=auto'
- --rootdir=/src
- --junitxml=/src/.pre-commit/pytest-junit/.report_pytest.xml
- --color=yes
- --files
copy_files:
- Tests/scripts/dev_envs/pytest/conftest.py
skip:commit: true
pass_docker_extra_args:ci: --rm=false --network=none
pass_docker_extra_args:nightly: --rm=false --network=none
pass_docker_extra_args: --network=none
- id: pytest-network-in-docker
name: pytest-network-in-docker
description: Run pytest with network enabled on the code in content packs
docker_image:nightly: native:ga,native:maintenance,from-yml,native:candidate
docker_image:ci: native:ga,from-yml,native:dev,native:maintenance
docker_image:native: native:ga,from-yml,native:dev,native:maintenance
docker_image: from-yml
entry: coverage
language: docker
files: Packs/Base/Scripts/CommonServerPython/CommonServerPython_test.py|Packs/Base/Scripts/SanePdfReport/SanePdfReport_test.py|Packs/Base/Scripts/CheckDockerImageAvailable/CheckDockerImageAvailable_test.py|Packs/CommonScripts/Scripts/Ping/Ping_test.py|Packs/CommonScripts/Scripts/GetDockerImageLatestTag/GetDockerImageLatestTag_test.py|Packs/CommonScripts/Scripts/GetDuplicatesMlv2/GetDuplicatesMlv2_test.py|Packs/CommonScripts/Scripts/DockerHardeningCheck/DockerHardeningCheck_test.py|Packs/rasterize/Integrations/rasterize/rasterize_test.py|Packs/Slack/Integrations/Slack/Slack_test.py|Packs/SymantecDLP/Integrations/SymantecDLP/SymantecDLP_test.py|Packs/WebFileRepository/Integrations/WebFileRepository/WebFileRepository_test.py|Packs/Whois/Integrations/Whois/Whois_test.py
env:
COVERAGE_FILE: /src/.pre-commit/coverage/.coverage
args:
- run
- -p
- --source=.
- -m
- pytest
- -v
- --override-ini='asyncio_mode=auto'
- --rootdir=/src
- --junitxml=/src/.pre-commit/pytest-junit/.report_pytest.xml
- --color=yes
copy_files:
- Tests/scripts/dev_envs/pytest/conftest.py
skip:commit: true
run_isolated: true
pass_docker_extra_args:ci: --rm=false
pass_docker_extra_args:nightly: --rm=false
- id: validate-deleted-files
name: validate-deleted-files
entry: validate-deleted-files
language: system
require_serial: true
pass_filenames: false
skip:nightly: true
args:
- Packs
- Tests
- Utils
- id: validate-content-paths
name: validate-content-paths
entry: validate-content-path
language: system
require_serial: true
args:
- validate
- --skip-depth-one-folder
- --skip-integration-script-file-name
- --skip-markdown
- --skip-suffix
- id: validate-conf-json
name: validate-conf-json
description: validate conf.json
files: Tests/conf.json
skip:commit: true
skip:nightly: true
entry: validate-conf-json
pass_filenames: false
language: system
- id: pwsh-test-in-docker
name: pwsh-test-in-docker
description: Run powershell tests
entry: pwsh
args:
- -Command
- Invoke-Pester
- -Output
- Detailed
- -CI
- -Path
files: .Tests.ps1$
copy_files:
- Packs/Base/Scripts/CommonServerPowerShell/CommonServerPowerShell.ps1
- Tests/demistomock/demistomock.ps1
run_isolated: true
pass_docker_extra_args:ci: --rm=false --network=none
pass_docker_extra_args:nightly: --rm=false --network=none
pass_docker_extra_args: --network=none
skip:commit: true
- id: pwsh-analyze-in-docker
name: pwsh-analyze-in-docker
description: Run powershell analyze
entry: pwsh
args:
- -Command
- Invoke-ScriptAnalyzer
- -EnableExit
- -Severity
- Error
- -Path
files: .ps1$
exclude: .Tests.ps1$|test_data
copy_files:
- Packs/Base/Scripts/CommonServerPowerShell/CommonServerPowerShell.ps1
- Tests/demistomock/demistomock.ps1
run_isolated: true
skip:commit: true
pass_docker_extra_args:ci: --rm=false --network=none
pass_docker_extra_args:nightly: --rm=false --network=none
pass_docker_extra_args: --network=none
- id: validate
name: validate
description: validate content
entry: demisto-sdk validate
args:
- --skip-pack-dependencies
- --config-path=validation_config.toml
args:packwise:
- --skip-pack-dependencies
- --config-path=validation_config.toml
- --ignore=DO106
- --ignore=CJ105
pass_filenames: false
language: system
require_serial: true
skip:commit: true
skip:nightly: true
skip:docker_autoupdate: true
- id: format
name: format
description: Format non-code files, to comply with XSOAR standards.
entry: demisto-sdk format
args:
- -ud
- -n
- --no-validate
language: system
pass_filenames: false
require_serial: true
skip:docker_autoupdate: true
- id: secrets
name: secrets
description: Check for secrets in files.
entry: demisto-sdk secrets
args:
- --ignore-entropy
pass_filenames: false
language: system
skip:nightly: true
- id: merge-pytest-reports
name: merge-pytest-reports
entry: merge-pytest-reports
language: system
require_serial: true
pass_filenames: false
needs:
- pytest-in-docker
- id: coverage-pytest-analyze
name: coverage-pytest-analyze
entry: demisto-sdk coverage-analyze
description: Running demisto-sdk coverage-analyze and showing a coverage report.
language: system
pass_filenames: false
args:
- -i
- .coverage
- --report-dir
- coverage_report
- --report-type
- all
- --previous-coverage-report-url
- https://storage.googleapis.com/marketplace-dist-dev/code-coverage-reports/coverage-min.json
args:nightly:
- -i
- .coverage
- --report-dir
- coverage_report
- --report-type
- all
- --allowed-coverage-degradation-percentage
- '100'
needs:
- pytest-in-docker
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.6.0
hooks:
- id: sourcery
config_file: .sourcery.yaml
args:
- --no-summary
- --diff
- git diff HEAD
- --fix
args:nightly:
- --no-summary
- --diff
- git diff HEAD
args:ci:
- --no-summary
- --diff
- git diff HEAD
skip: true