Skip to content

Commit c1eddea

Browse files
authored
ci(iast): update hatch iast envs configuration [backport 2.21] (#12748)
Backport #12740 to 2.21 Removed environment variables from Python commands in `envs.[scenario].scripts` and moved them to `[envs.[scenario].env-vars]`. This improves command readability. Additionally, the internal variable `_DD_IAST_PATCH_MODULES` has been included to prevent potential conflicts observed in other refactors, such as #12639. This PR is a cherry-pick of one of the commits of this PR #12639 ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 3dcb8e4 commit c1eddea

File tree

4 files changed

+92
-39
lines changed

4 files changed

+92
-39
lines changed

hatch.toml

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ checks = [
5757
"suitespec-check",
5858
]
5959
spelling = [
60-
"codespell -I docs/spelling_wordlist.txt --skip='ddwaf.h,*cassettes*,tests/tracer/fixtures/urls.txt' {args:ddtrace/ tests/ releasenotes/ docs/}",
60+
"codespell -I docs/spelling_wordlist.txt --skip='ddwaf.h,*cassettes*,tests/tracer/fixtures/urls.txt,tests/appsec/iast/fixtures/*' {args:ddtrace/ tests/ releasenotes/ docs/}",
6161
]
6262
typing = [
6363
"mypy {args}",
@@ -185,6 +185,9 @@ DD_CIVISIBILITY_AGENTLESS_ENABLED = "1"
185185
DD_CIVISIBILITY_CODE_COVERAGE_ENABLED = "1"
186186
DD_CIVISIBILITY_ITR_ENABLED = "1"
187187
DD_PATCH_MODULES = "unittest:false"
188+
CMAKE_BUILD_PARALLEL_LEVEL = "12"
189+
CARGO_BUILD_JOBS = "12"
190+
DD_FAST_BUILD = "1"
188191

189192
## ASM Django
190193

@@ -198,9 +201,6 @@ dependencies = [
198201
"django{matrix:django}"
199202
]
200203

201-
[envs.appsec_threats_django.env-vars]
202-
CMAKE_BUILD_PARALLEL_LEVEL = "12"
203-
204204
[envs.appsec_threats_django.scripts]
205205
test = [
206206
"uname -a",
@@ -246,9 +246,6 @@ dependencies = [
246246
"flask{matrix:flask}"
247247
]
248248

249-
[envs.appsec_threats_flask.env-vars]
250-
CMAKE_BUILD_PARALLEL_LEVEL = "12"
251-
252249
[envs.appsec_threats_flask.scripts]
253250
test = [
254251
"uname -a",
@@ -299,11 +296,16 @@ dependencies = [
299296
"mysqlclient==2.1.1",
300297
]
301298

299+
[envs.appsec_iast_default.env-vars]
300+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
301+
DD_IAST_REQUEST_SAMPLING = "100"
302+
DD_IAST_DEDUPLICATION_ENABLED = "false"
303+
302304
[envs.appsec_iast_default.scripts]
303305
test = [
304306
"uname -a",
305307
"pip freeze",
306-
"DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest {args:tests/appsec/iast/}",
308+
"python -m pytest --no-ddtrace {args:tests/appsec/iast/}",
307309
]
308310

309311
[[envs.appsec_iast_default.matrix]]
@@ -325,6 +327,11 @@ dependencies = [
325327
"pytest-memray"
326328
]
327329

330+
[envs.appsec_iast_memcheck.env-vars]
331+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
332+
DD_IAST_REQUEST_SAMPLING = "100"
333+
DD_IAST_DEDUPLICATION_ENABLED = "false"
334+
328335
[envs.appsec_iast_memcheck.scripts]
329336
test = [
330337
"uname -a",
@@ -345,6 +352,11 @@ dependencies = [
345352
"clang"
346353
]
347354

355+
[envs.appsec_iast_native.env-vars]
356+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
357+
DD_IAST_REQUEST_SAMPLING = "100"
358+
DD_IAST_DEDUPLICATION_ENABLED = "false"
359+
348360
[envs.appsec_iast_native.scripts]
349361
test = [
350362
"cmake -DCMAKE_BUILD_TYPE=Debug -DPYTHON_EXECUTABLE=python -S ddtrace/appsec/_iast/_taint_tracking -B ddtrace/appsec/_iast/_taint_tracking",
@@ -369,11 +381,16 @@ dependencies = [
369381
"virtualenv-clone"
370382
]
371383

384+
[envs.appsec_iast_packages.env-vars]
385+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
386+
DD_IAST_REQUEST_SAMPLING = "100"
387+
DD_IAST_DEDUPLICATION_ENABLED = "false"
388+
372389
[envs.appsec_iast_packages.scripts]
373390
test = [
374391
"uname -a",
375392
"pip freeze",
376-
"DD_CIVISIBILITY_ITR_ENABLED=0 DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest tests/appsec/iast_packages",
393+
"python -m pytest tests/appsec/iast_packages",
377394
]
378395

379396
[[envs.appsec_iast_packages.matrix]]
@@ -398,11 +415,17 @@ dependencies = [
398415
"aiosqlite",
399416
]
400417

418+
[envs.iast_tdd_propagation.env-vars]
419+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
420+
DD_IAST_REQUEST_SAMPLING = "100"
421+
DD_IAST_DEDUPLICATION_ENABLED = "false"
422+
DD_CIVISIBILITY_ITR_ENABLED = "0"
423+
401424
[envs.iast_tdd_propagation.scripts]
402425
test = [
403426
"uname -a",
404427
"pip freeze",
405-
"DD_CIVISIBILITY_ITR_ENABLED=0 DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest tests/appsec/iast_tdd_propagation",
428+
"python -m pytest tests/appsec/iast_tdd_propagation",
406429
]
407430

408431
[[envs.iast_tdd_propagation.matrix]]
@@ -423,11 +446,18 @@ dependencies = [
423446
"Django{matrix:django}",
424447
]
425448

449+
[envs.appsec_integrations_django.env-vars]
450+
DD_TRACE_AGENT_URL = "http://testagent:9126"
451+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
452+
DD_IAST_REQUEST_SAMPLING = "100"
453+
DD_IAST_DEDUPLICATION_ENABLED = "false"
454+
455+
426456
[envs.appsec_integrations_django.scripts]
427457
test = [
428458
"uname -a",
429459
"pip freeze",
430-
"DD_TRACE_AGENT_URL=\"http://testagent:9126\" DD_CIVISIBILITY_ITR_ENABLED=0 DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest -vvv {args:tests/appsec/integrations/django_tests/}",
460+
"python -m pytest -vvv {args:tests/appsec/integrations/django_tests/}",
431461
]
432462

433463
[[envs.appsec_integrations_django.matrix]]
@@ -455,11 +485,17 @@ dependencies = [
455485
"flask{matrix:flask}",
456486
]
457487

488+
[envs.appsec_integrations_flask.env-vars]
489+
DD_TRACE_AGENT_URL = "http://testagent:9126"
490+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
491+
DD_IAST_REQUEST_SAMPLING = "100"
492+
DD_IAST_DEDUPLICATION_ENABLED = "false"
493+
458494
[envs.appsec_integrations_flask.scripts]
459495
test = [
460496
"uname -a",
461497
"pip freeze",
462-
"DD_TRACE_AGENT_URL=\"http://testagent:9126\" DD_CIVISIBILITY_ITR_ENABLED=0 DD_IAST_ENABLED=true DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest -vvv {args:tests/appsec/integrations/flask_tests/}",
498+
"python -m pytest -vvv {args:tests/appsec/integrations/flask_tests/}",
463499
]
464500

465501
[[envs.appsec_integrations_flask.matrix]]
@@ -506,11 +542,17 @@ dependencies = [
506542
"fastapi{matrix:fastapi}"
507543
]
508544

545+
[envs.appsec_integrations_fastapi.env-vars]
546+
DD_TRACE_AGENT_URL = "http://testagent:9126"
547+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec."
548+
DD_IAST_REQUEST_SAMPLING = "100"
549+
DD_IAST_DEDUPLICATION_ENABLED = "false"
550+
509551
[envs.appsec_integrations_fastapi.scripts]
510552
test = [
511553
"uname -a",
512554
"pip freeze",
513-
"DD_TRACE_AGENT_URL=\"http://testagent:9126\" DD_CIVISIBILITY_ITR_ENABLED=0 DD_IAST_REQUEST_SAMPLING=100 DD_IAST_DEDUPLICATION_ENABLED=false python -m pytest -vvv {args:tests/appsec/integrations/fastapi_tests/}",
555+
"python -m pytest -vvv {args:tests/appsec/integrations/fastapi_tests/}",
514556
]
515557

516558

@@ -529,7 +571,6 @@ fastapi = ["==0.94.1"]
529571
python = ["3.8", "3.10", "3.13"]
530572
fastapi = ["~=0.114.2"]
531573

532-
533574
## ASM FastAPI
534575

535576
[envs.appsec_threats_fastapi]
@@ -544,9 +585,6 @@ dependencies = [
544585
"fastapi{matrix:fastapi}"
545586
]
546587

547-
[envs.appsec_threats_fastapi.env-vars]
548-
CMAKE_BUILD_PARALLEL_LEVEL = "12"
549-
550588
[envs.appsec_threats_fastapi.scripts]
551589
test = [
552590
"uname -a",
@@ -570,10 +608,10 @@ fastapi = ["==0.94.1"]
570608
python = ["3.8", "3.10", "3.13"]
571609
fastapi = ["~=0.114.2"]
572610

573-
## ASM Appsec Aggregated Leak Testing
611+
## ASM IAST Aggregated Leak Testing
574612

575-
[envs.appsec_aggregated_leak_testing]
576-
template = "appsec_aggregated_leak_testing"
613+
[envs.iast_aggregated_leak_testing]
614+
template = "iast_aggregated_leak_testing"
577615
dependencies = [
578616
"pytest",
579617
"pytest-cov",
@@ -587,19 +625,19 @@ dependencies = [
587625

588626
[envs.iast_aggregated_leak_testing.env-vars]
589627
DD_IAST_ENABLED = "true"
590-
_DD_IAST_PATCH_MODULES = "scripts.iast"
628+
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec.,scripts.iast."
629+
DD_FAST_BUILD = "0"
591630

592-
[envs.appsec_aggregated_leak_testing.scripts]
631+
[envs.iast_aggregated_leak_testing.scripts]
593632
test = [
594633
"uname -a",
595634
"pip freeze",
596-
"python -m pytest tests/appsec/iast_aggregated_memcheck/test_aggregated_memleaks.py",
635+
# We use --no-cov due to a pytest-cov problem with eval https://github.com/pytest-dev/pytest-cov/issues/676
636+
"python -m pytest --no-cov tests/appsec/iast_aggregated_memcheck/test_aggregated_memleaks.py",
597637
]
598638

599-
[[envs.appsec_aggregated_leak_testing.matrix]]
600-
python = ["3.10", "3.11", "3.12", "3.13"]
601-
602-
639+
[[envs.iast_aggregated_leak_testing.matrix]]
640+
python = ["3.10", "3.11", "3.12"]
603641

604642
## pytorch profiling test
605643

@@ -617,7 +655,6 @@ dependencies = [
617655
[envs.profiling_pytorch.env-vars]
618656
DD_PROFILING_ENABLED = "true"
619657
DD_PROFILING_PYTORCH_ENABLED = "true"
620-
CMAKE_BUILD_PARALLEL_LEVEL = "12"
621658

622659
[envs.profiling_pytorch.scripts]
623660
test = [
@@ -766,3 +803,4 @@ matrix.tested_pytest_plugin_version.env-vars = [
766803
{ key = "_TESTED_PYTEST_PLUGIN_VERSION", value = "false", if = ["v1"]},
767804
{ key = "_TESTED_PYTEST_PLUGIN_VERSION", value = "true", if = ["v2"]}
768805
]
806+

scripts/gen_gitlab_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def __str__(self) -> str:
5050
if wait_for:
5151
lines.append(" before_script:")
5252
lines.append(f" - !reference [{base}, before_script]")
53-
lines.append(f" - riot -v run -s --pass-env wait -- {' '.join(wait_for)}")
53+
if self.runner == "riot":
54+
lines.append(f" - riot -v run -s --pass-env wait -- {' '.join(wait_for)}")
5455

5556
env = self.env
5657
if not env or "SUITE_NAME" not in env:

tests/appsec/integrations/flask_tests/test_flask_remoteconfig.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def _request_403(client, debug_mode=False, max_retries=40, sleep_time=1):
187187
raise AssertionError("request_403 failed, max_retries=%d, sleep_time=%f" % (max_retries, sleep_time))
188188

189189

190-
@flaky(until=1706677200, reason="TODO(avara1986): We need to migrate testagent to gitlab")
191190
@pytest.mark.skipif(sys.version_info >= (3, 11), reason="Gunicorn is only supported up to 3.10")
192191
def test_load_testing_appsec_ip_blocking_gunicorn_rc_disabled():
193192
token = "test_load_testing_appsec_ip_blocking_gunicorn_rc_disabled_{}".format(str(uuid.uuid4()))
@@ -203,7 +202,6 @@ def test_load_testing_appsec_ip_blocking_gunicorn_rc_disabled():
203202
_unblock_ip(token)
204203

205204

206-
@flaky(until=1706677200, reason="TODO(avara1986): We need to migrate testagent to gitlab")
207205
@pytest.mark.skipif(sys.version_info >= (3, 11), reason="Gunicorn is only supported up to 3.10")
208206
def test_load_testing_appsec_ip_blocking_gunicorn_block():
209207
token = "test_load_testing_appsec_ip_blocking_gunicorn_block_{}".format(str(uuid.uuid4()))
@@ -221,7 +219,6 @@ def test_load_testing_appsec_ip_blocking_gunicorn_block():
221219
_request_200(gunicorn_client)
222220

223221

224-
@flaky(until=1706677200, reason="TODO(avara1986): We need to migrate testagent to gitlab")
225222
@pytest.mark.skipif(list(sys.version_info[:2]) != [3, 10], reason="Run this tests in python 3.10")
226223
def test_load_testing_appsec_ip_blocking_gunicorn_block_and_kill_child_worker():
227224
token = "test_load_testing_appsec_ip_blocking_gunicorn_block_and_kill_child_worker_{}".format(str(uuid.uuid4()))

tests/appsec/suitespec.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,27 @@ suites:
7171
- '@remoteconfig'
7272
retry: 2
7373
runner: hatch
74-
appsec_iast_packages:
75-
parallelism: 4
74+
iast_aggregated_leak_testing:
75+
parallelism: 3
7676
paths:
7777
- '@appsec_iast'
78-
- tests/appsec/iast_packages/*
79-
retry: 2
78+
- tests/appsec/iast_aggregated_memcheck/*
8079
runner: hatch
8180
timeout: 50m
81+
iast_tdd_propagation:
82+
parallelism: 5
83+
paths:
84+
- '@bootstrap'
85+
- '@core'
86+
- '@tracing'
87+
- '@appsec'
88+
- '@appsec_iast'
89+
- '@remoteconfig'
90+
- tests/appsec/iast_tdd_propagation/*
91+
retry: 2
92+
runner: hatch
93+
snapshot: true
94+
timeout: 40m
8295
appsec_integrations_pygoat:
8396
parallelism: 7
8497
paths:
@@ -94,7 +107,7 @@ suites:
94107
runner: riot
95108
snapshot: true
96109
appsec_integrations_flask:
97-
parallelism: 6
110+
parallelism: 17
98111
paths:
99112
- '@bootstrap'
100113
- '@core'
@@ -105,9 +118,11 @@ suites:
105118
- tests/appsec/integrations/flask_tests/*
106119
retry: 2
107120
runner: hatch
108-
timeout: 30m
121+
services:
122+
- testagent
123+
timeout: 40m
109124
appsec_integrations_django:
110-
parallelism: 6
125+
parallelism: 12
111126
paths:
112127
- '@bootstrap'
113128
- '@core'
@@ -118,6 +133,8 @@ suites:
118133
- tests/appsec/integrations/django_tests/*
119134
retry: 2
120135
runner: hatch
136+
services:
137+
- testagent
121138
timeout: 30m
122139
appsec_threats_django:
123140
parallelism: 12

0 commit comments

Comments
 (0)