From 9cc23b1bfb6ec3d3c6ff1f468811445400f2ac97 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 29 Oct 2026 14:08:26 +0100 Subject: [PATCH 01/17] Add Python Lambda SCA reachability fixtures --- docs/understand/weblogs/end-to-end_weblog.md | 2 ++ manifests/python_lambda.yml | 2 +- tests/appsec/test_sca_reachability.py | 6 +++++ .../docker/python_lambda/function/handler.py | 22 +++++++++++++++++++ .../python_lambda/function/requirements.txt | 4 ++-- .../scripts/libraries_and_scenarios_rules.yml | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/understand/weblogs/end-to-end_weblog.md b/docs/understand/weblogs/end-to-end_weblog.md index 6a33d3f613e..6cb2658262d 100644 --- a/docs/understand/weblogs/end-to-end_weblog.md +++ b/docs/understand/weblogs/end-to-end_weblog.md @@ -903,6 +903,8 @@ first occurrence is reported in the `reached` array. The Java Lambda weblogs also implement both SCA endpoints, using Junrar 7.5.5 kept as a separate JAR. The vulnerable class is preloaded during handler initialization. +The Python Lambda weblogs implement both SCA endpoints with requests 2.31.0. They call `Session.send` from two distinct handlers against a closed loopback port, so no external service is required. + ### GET /log/library This endpoint facilitates logging a message using a logging library. It is primarily designed for testing log injection functionality. Weblog apps must log using JSON format. diff --git a/manifests/python_lambda.yml b/manifests/python_lambda.yml index aa4fed2a8bf..d8d8e6397c4 100644 --- a/manifests/python_lambda.yml +++ b/manifests/python_lambda.yml @@ -284,7 +284,7 @@ manifest: tests/appsec/test_reports.py::Test_Info: v7.112.0 tests/appsec/test_reports.py::Test_RequestHeaders: v7.112.0 tests/appsec/test_reports.py::Test_StatusCode: v7.112.0 - tests/appsec/test_sca_reachability.py: incomplete_test_app (Lambda SCA dependency fixtures and vulnerable-call endpoints are not implemented) + tests/appsec/test_sca_reachability.py: missing_feature (requires Lambda SCA reachability support in dd-trace-py and datadog-lambda-python) tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules: v8.113.0 tests/appsec/test_traces.py::Test_AppSecEventSpanTags: v7.112.0 tests/appsec/test_traces.py::Test_AppSecEventSpanTags::test_header_collection: bug (APPSEC-58202) diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index aef5a54ef42..b2287c63b0e 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -33,6 +33,12 @@ "path": "com.datadoghq.system_tests.springboot.ScaReachability", "symbol": "junrarHit", }, + "python_lambda": { + "cve_id": ["CVE-2024-35195", "GHSA-652x-xj99-gmcc"], + "vulnerable_dep": "requests", + "path": "handler.py", + "symbol": "sca_requests_vulnerable_call", + }, "java_lambda": { "cve_id": ["GHSA-hf5p-q87m-crj7"], "vulnerable_dep": "junrar", diff --git a/utils/build/docker/python_lambda/function/handler.py b/utils/build/docker/python_lambda/function/handler.py index d507f927a20..7227da81760 100644 --- a/utils/build/docker/python_lambda/function/handler.py +++ b/utils/build/docker/python_lambda/function/handler.py @@ -47,6 +47,28 @@ _TRACK_CUSTOM_APPSEC_EVENT_NAME = "system_tests_appsec_event" +@app.get("/sca/vulnerable-call") +def sca_requests_vulnerable_call() -> str: + """Call the vulnerable Session.send target without an external dependency.""" + with requests.Session() as session: + try: + session.send(requests.Request("GET", "http://127.0.0.1:1").prepare(), timeout=1) + except requests.exceptions.ConnectionError: + pass + return "OK" + + +@app.get("/sca/vulnerable-call-alt") +def sca_requests_vulnerable_call_alt() -> str: + """Use a distinct caller for the same target to check first-hit deduplication.""" + with requests.Session() as session: + try: + session.send(requests.Request("GET", "http://127.0.0.1:1").prepare(), timeout=1) + except requests.exceptions.ConnectionError: + pass + return "OK" + + def version_info(): return { "status": "ok", diff --git a/utils/build/docker/python_lambda/function/requirements.txt b/utils/build/docker/python_lambda/function/requirements.txt index b3abb7c5aee..f13f7fc198c 100644 --- a/utils/build/docker/python_lambda/function/requirements.txt +++ b/utils/build/docker/python_lambda/function/requirements.txt @@ -1,3 +1,3 @@ aws-lambda-powertools==3.17.0 -requests==2.32.5 -xmltodict==1.0.2 \ No newline at end of file +requests==2.31.0 +xmltodict==1.0.2 diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 76e21e362e2..012047c4e77 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -681,7 +681,7 @@ patterns: tests/appsec/test_sca_reachability.py: scenario_groups: null - libraries: [java, java_lambda, python] + libraries: [java, java_lambda, python, python_lambda] ################################# Default rules ################################ # The rules in this section are only applied if no other rule is applicable. From 8e94c6497603cbc12b1cc42d89d0b60a16d8ff84 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 29 Oct 2026 14:32:22 +0100 Subject: [PATCH 02/17] Use a synthetic advisory for Python Lambda SCA tests --- docs/understand/weblogs/end-to-end_weblog.md | 2 -- tests/appsec/sca_python_lambda.json | 10 ++++++++++ tests/appsec/test_sca_reachability.py | 2 +- utils/_context/_scenarios/aws_lambda.py | 9 +++++++++ utils/build/docker/python_lambda/function/handler.py | 2 +- .../docker/python_lambda/function/requirements.txt | 4 ++-- utils/scripts/libraries_and_scenarios_rules.yml | 5 +++++ 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 tests/appsec/sca_python_lambda.json diff --git a/docs/understand/weblogs/end-to-end_weblog.md b/docs/understand/weblogs/end-to-end_weblog.md index 6cb2658262d..6a33d3f613e 100644 --- a/docs/understand/weblogs/end-to-end_weblog.md +++ b/docs/understand/weblogs/end-to-end_weblog.md @@ -903,8 +903,6 @@ first occurrence is reported in the `reached` array. The Java Lambda weblogs also implement both SCA endpoints, using Junrar 7.5.5 kept as a separate JAR. The vulnerable class is preloaded during handler initialization. -The Python Lambda weblogs implement both SCA endpoints with requests 2.31.0. They call `Session.send` from two distinct handlers against a closed loopback port, so no external service is required. - ### GET /log/library This endpoint facilitates logging a message using a logging library. It is primarily designed for testing log injection functionality. Weblog apps must log using JSON format. diff --git a/tests/appsec/sca_python_lambda.json b/tests/appsec/sca_python_lambda.json new file mode 100644 index 00000000000..81ebe582fd5 --- /dev/null +++ b/tests/appsec/sca_python_lambda.json @@ -0,0 +1,10 @@ +{ + "targets": [ + { + "id": "system-tests-python-lambda-sca", + "dependency_name": "requests", + "package_versions": [">=0"], + "targets": ["requests.sessions:Session.send"] + } + ] +} diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index b2287c63b0e..04c5f29494e 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -34,7 +34,7 @@ "symbol": "junrarHit", }, "python_lambda": { - "cve_id": ["CVE-2024-35195", "GHSA-652x-xj99-gmcc"], + "cve_id": ["system-tests-python-lambda-sca"], "vulnerable_dep": "requests", "path": "handler.py", "symbol": "sca_requests_vulnerable_call", diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index bf15d58df09..92a9be0433a 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -250,6 +250,15 @@ def __init__(self) -> None: scenario_groups=[scenario_groups.appsec, scenario_groups.appsec_lambda], ) + def configure(self, config: pytest.Config) -> None: + super().configure(config) + if self.lambda_weblog.image.labels.get("system-tests-library") == "python_lambda": + # Inject a synthetic advisory without coupling requests upgrades to a real CVE. + self.lambda_weblog.volumes["./tests/appsec/sca_python_lambda.json"] = { + "bind": "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json", + "mode": "ro", + } + class AppsecLambdaRasp(_LambdaScenario): """Enable APPSEC RASP""" diff --git a/utils/build/docker/python_lambda/function/handler.py b/utils/build/docker/python_lambda/function/handler.py index 7227da81760..875f4be39e4 100644 --- a/utils/build/docker/python_lambda/function/handler.py +++ b/utils/build/docker/python_lambda/function/handler.py @@ -49,7 +49,7 @@ @app.get("/sca/vulnerable-call") def sca_requests_vulnerable_call() -> str: - """Call the vulnerable Session.send target without an external dependency.""" + """Exercise the synthetic advisory's Session.send target.""" with requests.Session() as session: try: session.send(requests.Request("GET", "http://127.0.0.1:1").prepare(), timeout=1) diff --git a/utils/build/docker/python_lambda/function/requirements.txt b/utils/build/docker/python_lambda/function/requirements.txt index f13f7fc198c..b3abb7c5aee 100644 --- a/utils/build/docker/python_lambda/function/requirements.txt +++ b/utils/build/docker/python_lambda/function/requirements.txt @@ -1,3 +1,3 @@ aws-lambda-powertools==3.17.0 -requests==2.31.0 -xmltodict==1.0.2 +requests==2.32.5 +xmltodict==1.0.2 \ No newline at end of file diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 012047c4e77..7577fe3f797 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -683,6 +683,11 @@ patterns: scenario_groups: null libraries: [java, java_lambda, python, python_lambda] + tests/appsec/sca_python_lambda.json: + scenario_groups: null + scenarios: [APPSEC_LAMBDA_SCA] + libraries: python_lambda + ################################# Default rules ################################ # The rules in this section are only applied if no other rule is applicable. # They are considered safe to override in previous rules. They should match a From d9f5947dcf58cc593242ac2f5392638e76fe5969 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 29 Oct 2026 14:44:49 +0100 Subject: [PATCH 03/17] Share SCA advisory fixtures across languages --- tests/appsec/sca_advisories.json | 34 +++++++++++++++++++ tests/appsec/sca_python_lambda.json | 10 ------ tests/appsec/test_sca_reachability.py | 2 +- utils/_context/_scenarios/aws_lambda.py | 12 +++++-- .../scripts/libraries_and_scenarios_rules.yml | 2 +- 5 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 tests/appsec/sca_advisories.json delete mode 100644 tests/appsec/sca_python_lambda.json diff --git a/tests/appsec/sca_advisories.json b/tests/appsec/sca_advisories.json new file mode 100644 index 00000000000..3c9d0fdc82e --- /dev/null +++ b/tests/appsec/sca_advisories.json @@ -0,0 +1,34 @@ +{ + "python": { + "targets": [ + { + "id": "system-tests-sca", + "dependency_name": "requests", + "package_versions": [ + ">=0" + ], + "targets": [ + "requests.sessions:Session.send" + ] + } + ] + }, + "java": { + "version": 1, + "entries": [ + { + "vuln_id": "system-tests-sca", + "artifact": "com.github.junrar:junrar", + "version_ranges": [ + ">=0" + ], + "symbols": [ + { + "class": "com/github/junrar/LocalFolderExtractor", + "method": "createDirectory" + } + ] + } + ] + } +} diff --git a/tests/appsec/sca_python_lambda.json b/tests/appsec/sca_python_lambda.json deleted file mode 100644 index 81ebe582fd5..00000000000 --- a/tests/appsec/sca_python_lambda.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "targets": [ - { - "id": "system-tests-python-lambda-sca", - "dependency_name": "requests", - "package_versions": [">=0"], - "targets": ["requests.sessions:Session.send"] - } - ] -} diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index 04c5f29494e..e494e3eddfc 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -34,7 +34,7 @@ "symbol": "junrarHit", }, "python_lambda": { - "cve_id": ["system-tests-python-lambda-sca"], + "cve_id": ["system-tests-sca"], "vulnerable_dep": "requests", "path": "handler.py", "symbol": "sca_requests_vulnerable_call", diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 92a9be0433a..26c37fb3e73 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -1,3 +1,6 @@ +import json +from pathlib import Path + import pytest from utils import interfaces from utils.interfaces._core import ProxyBasedInterfaceValidator @@ -252,9 +255,12 @@ def __init__(self) -> None: def configure(self, config: pytest.Config) -> None: super().configure(config) - if self.lambda_weblog.image.labels.get("system-tests-library") == "python_lambda": - # Inject a synthetic advisory without coupling requests upgrades to a real CVE. - self.lambda_weblog.volumes["./tests/appsec/sca_python_lambda.json"] = { + if not self.replay and self.lambda_weblog.image.labels.get("system-tests-library") == "python_lambda": + # Each tracer receives its native payload from the shared catalog. + catalog = json.loads(Path("tests/appsec/sca_advisories.json").read_text(encoding="utf-8")) + payload_path = Path(self.host_log_folder) / "sca_advisories.json" + payload_path.write_text(json.dumps(catalog["python"]), encoding="utf-8") + self.lambda_weblog.volumes[str(payload_path)] = { "bind": "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json", "mode": "ro", } diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 7577fe3f797..670f5918b2b 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -683,7 +683,7 @@ patterns: scenario_groups: null libraries: [java, java_lambda, python, python_lambda] - tests/appsec/sca_python_lambda.json: + tests/appsec/sca_advisories.json: scenario_groups: null scenarios: [APPSEC_LAMBDA_SCA] libraries: python_lambda From 1f28f7905738ff4ff3de2d00b37701c5c80a0cff Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 29 Oct 2026 15:24:50 +0100 Subject: [PATCH 04/17] test: inject Lambda SCA advisories through scenario arguments --- tests/appsec/sca_advisories.json | 56 +++++++++++-------------- utils/_context/_scenarios/aws_lambda.py | 23 ++++------ 2 files changed, 31 insertions(+), 48 deletions(-) diff --git a/tests/appsec/sca_advisories.json b/tests/appsec/sca_advisories.json index 3c9d0fdc82e..186d812b022 100644 --- a/tests/appsec/sca_advisories.json +++ b/tests/appsec/sca_advisories.json @@ -1,34 +1,26 @@ { - "python": { - "targets": [ - { - "id": "system-tests-sca", - "dependency_name": "requests", - "package_versions": [ - ">=0" - ], - "targets": [ - "requests.sessions:Session.send" - ] - } - ] - }, - "java": { - "version": 1, - "entries": [ - { - "vuln_id": "system-tests-sca", - "artifact": "com.github.junrar:junrar", - "version_ranges": [ - ">=0" - ], - "symbols": [ - { - "class": "com/github/junrar/LocalFolderExtractor", - "method": "createDirectory" - } - ] - } - ] - } + "targets": [ + { + "id": "system-tests-sca", + "lang": "python", + "dependency_name": "requests", + "package_versions": [ + ">=0" + ], + "targets": [ + "requests.sessions:Session.send" + ] + }, + { + "id": "system-tests-sca", + "lang": "maven", + "dependency_name": "com.github.junrar:junrar", + "package_versions": [ + ">=0" + ], + "targets": [ + "com.github.junrar:LocalFolderExtractor.createDirectory" + ] + } + ] } diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 26c37fb3e73..e57e61ea160 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -1,6 +1,3 @@ -import json -from pathlib import Path - import pytest from utils import interfaces from utils.interfaces._core import ProxyBasedInterfaceValidator @@ -249,22 +246,16 @@ class AppsecLambdaSca(_LambdaScenario): def __init__(self) -> None: super().__init__( "APPSEC_LAMBDA_SCA", - weblog_env={"DD_APPSEC_ENABLED": "false", "DD_APPSEC_SCA_ENABLED": "true"}, + weblog_env={ + "DD_APPSEC_ENABLED": "false", + "DD_APPSEC_SCA_ENABLED": "true", + "_DD_APPSEC_SCA_DATA_FILE": "/sca_advisories.json", + }, + weblog_volumes={"./tests/appsec/sca_advisories.json": {"bind": "/sca_advisories.json", "mode": "ro"}}, + doc="SCA dependency metadata and runtime reachability in Lambda with AppSec disabled", scenario_groups=[scenario_groups.appsec, scenario_groups.appsec_lambda], ) - def configure(self, config: pytest.Config) -> None: - super().configure(config) - if not self.replay and self.lambda_weblog.image.labels.get("system-tests-library") == "python_lambda": - # Each tracer receives its native payload from the shared catalog. - catalog = json.loads(Path("tests/appsec/sca_advisories.json").read_text(encoding="utf-8")) - payload_path = Path(self.host_log_folder) / "sca_advisories.json" - payload_path.write_text(json.dumps(catalog["python"]), encoding="utf-8") - self.lambda_weblog.volumes[str(payload_path)] = { - "bind": "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json", - "mode": "ro", - } - class AppsecLambdaRasp(_LambdaScenario): """Enable APPSEC RASP""" From cce43f6b6e8c2f62087cd4802c11b2878f3584e9 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 29 Oct 2026 15:30:39 +0100 Subject: [PATCH 05/17] test: inject SCA fixtures through Lambda test startup --- utils/_context/_scenarios/aws_lambda.py | 1 - utils/build/docker/python_lambda/function/app.sh | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index e57e61ea160..c57137098d7 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -249,7 +249,6 @@ def __init__(self) -> None: weblog_env={ "DD_APPSEC_ENABLED": "false", "DD_APPSEC_SCA_ENABLED": "true", - "_DD_APPSEC_SCA_DATA_FILE": "/sca_advisories.json", }, weblog_volumes={"./tests/appsec/sca_advisories.json": {"bind": "/sca_advisories.json", "mode": "ro"}}, doc="SCA dependency metadata and runtime reachability in Lambda with AppSec disabled", diff --git a/utils/build/docker/python_lambda/function/app.sh b/utils/build/docker/python_lambda/function/app.sh index eb958bd98f3..96c28071310 100644 --- a/utils/build/docker/python_lambda/function/app.sh +++ b/utils/build/docker/python_lambda/function/app.sh @@ -4,6 +4,22 @@ set -eu export DD_LAMBDA_HANDLER=handler.lambda_handler +# Only the SCA scenario mounts this catalog. Install its Python entries before +# starting the Lambda wrapper, which initializes reachability instrumentation. +if [ -f /sca_advisories.json ]; then + python3 - <<'PY' +import json +from pathlib import Path + +catalog = json.loads(Path("/sca_advisories.json").read_text()) +targets = [entry for entry in catalog["targets"] if entry["lang"] == "python"] +data_paths = list(Path("/opt/python").glob("lib/python*/site-packages/ddtrace/appsec/sca/_cve_data.json")) +if len(data_paths) != 1: + raise RuntimeError(f"Expected one bundled SCA catalog, found {data_paths}") +data_paths[0].write_text(json.dumps({"targets": targets})) +PY +fi + socat TCP-LISTEN:8127,reuseaddr,fork,bind=0.0.0.0 TCP:127.0.0.1:8126 & exec /lambda-entrypoint.sh datadog_lambda.handler.handler From 9805055a000cb70366faf4d945e5ef404efd43c3 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Tue, 3 Nov 2026 10:10:27 +0100 Subject: [PATCH 06/17] test: split Lambda SCA advisories by language --- .../java/advisories.json} | 11 ----------- tests/appsec/sca/python/advisories.json | 15 +++++++++++++++ utils/_context/_scenarios/aws_lambda.py | 11 ++++++++++- utils/build/docker/python_lambda/function/app.sh | 8 +++----- utils/scripts/libraries_and_scenarios_rules.yml | 7 ++++++- 5 files changed, 34 insertions(+), 18 deletions(-) rename tests/appsec/{sca_advisories.json => sca/java/advisories.json} (55%) create mode 100644 tests/appsec/sca/python/advisories.json diff --git a/tests/appsec/sca_advisories.json b/tests/appsec/sca/java/advisories.json similarity index 55% rename from tests/appsec/sca_advisories.json rename to tests/appsec/sca/java/advisories.json index 186d812b022..3757b497945 100644 --- a/tests/appsec/sca_advisories.json +++ b/tests/appsec/sca/java/advisories.json @@ -1,16 +1,5 @@ { "targets": [ - { - "id": "system-tests-sca", - "lang": "python", - "dependency_name": "requests", - "package_versions": [ - ">=0" - ], - "targets": [ - "requests.sessions:Session.send" - ] - }, { "id": "system-tests-sca", "lang": "maven", diff --git a/tests/appsec/sca/python/advisories.json b/tests/appsec/sca/python/advisories.json new file mode 100644 index 00000000000..7893eeb1cab --- /dev/null +++ b/tests/appsec/sca/python/advisories.json @@ -0,0 +1,15 @@ +{ + "targets": [ + { + "id": "system-tests-sca", + "lang": "python", + "dependency_name": "requests", + "package_versions": [ + ">=0" + ], + "targets": [ + "requests.sessions:Session.send" + ] + } + ] +} diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index c57137098d7..6666fd74dfb 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -250,11 +250,20 @@ def __init__(self) -> None: "DD_APPSEC_ENABLED": "false", "DD_APPSEC_SCA_ENABLED": "true", }, - weblog_volumes={"./tests/appsec/sca_advisories.json": {"bind": "/sca_advisories.json", "mode": "ro"}}, doc="SCA dependency metadata and runtime reachability in Lambda with AppSec disabled", scenario_groups=[scenario_groups.appsec, scenario_groups.appsec_lambda], ) + def configure(self, config: pytest.Config) -> None: + super().configure(config) + + language = self.lambda_weblog.library_name.removesuffix("_lambda") + if language in ("python", "java"): + self.lambda_weblog.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = { + "bind": "/sca_advisories.json", + "mode": "ro", + } + class AppsecLambdaRasp(_LambdaScenario): """Enable APPSEC RASP""" diff --git a/utils/build/docker/python_lambda/function/app.sh b/utils/build/docker/python_lambda/function/app.sh index 96c28071310..1efe2a62901 100644 --- a/utils/build/docker/python_lambda/function/app.sh +++ b/utils/build/docker/python_lambda/function/app.sh @@ -4,19 +4,17 @@ set -eu export DD_LAMBDA_HANDLER=handler.lambda_handler -# Only the SCA scenario mounts this catalog. Install its Python entries before +# Only the SCA scenario mounts this language's catalog. Install it before # starting the Lambda wrapper, which initializes reachability instrumentation. if [ -f /sca_advisories.json ]; then python3 - <<'PY' -import json from pathlib import Path +from shutil import copyfile -catalog = json.loads(Path("/sca_advisories.json").read_text()) -targets = [entry for entry in catalog["targets"] if entry["lang"] == "python"] data_paths = list(Path("/opt/python").glob("lib/python*/site-packages/ddtrace/appsec/sca/_cve_data.json")) if len(data_paths) != 1: raise RuntimeError(f"Expected one bundled SCA catalog, found {data_paths}") -data_paths[0].write_text(json.dumps({"targets": targets})) +copyfile("/sca_advisories.json", data_paths[0]) PY fi diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 670f5918b2b..010dfc45c61 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -683,11 +683,16 @@ patterns: scenario_groups: null libraries: [java, java_lambda, python, python_lambda] - tests/appsec/sca_advisories.json: + tests/appsec/sca/python/advisories.json: scenario_groups: null scenarios: [APPSEC_LAMBDA_SCA] libraries: python_lambda + tests/appsec/sca/java/advisories.json: + scenario_groups: null + scenarios: [APPSEC_LAMBDA_SCA] + libraries: java_lambda + ################################# Default rules ################################ # The rules in this section are only applied if no other rule is applicable. # They are considered safe to override in previous rules. They should match a From 1bc0a7f5b99d96135d33f7f448cea779fa0d1552 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Tue, 3 Nov 2026 10:15:18 +0100 Subject: [PATCH 07/17] test: mount native Python SCA catalog directly --- tests/appsec/sca/python/advisories.json | 7 ++++++- utils/_context/_scenarios/aws_lambda.py | 8 ++++++-- utils/build/docker/python_lambda/function/app.sh | 14 -------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/tests/appsec/sca/python/advisories.json b/tests/appsec/sca/python/advisories.json index 7893eeb1cab..4835edf62d2 100644 --- a/tests/appsec/sca/python/advisories.json +++ b/tests/appsec/sca/python/advisories.json @@ -9,7 +9,12 @@ ], "targets": [ "requests.sessions:Session.send" - ] + ], + "vulnerability": { + "id": "system-tests-sca", + "severity": "LOW", + "description": "Synthetic requests target for system-tests SCA reachability coverage." + } } ] } diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 6666fd74dfb..50b24234232 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -258,9 +258,13 @@ def configure(self, config: pytest.Config) -> None: super().configure(config) language = self.lambda_weblog.library_name.removesuffix("_lambda") - if language in ("python", "java"): + catalog_paths = { + "python": "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json", + "java": "/sca_advisories.json", + } + if language in catalog_paths: self.lambda_weblog.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = { - "bind": "/sca_advisories.json", + "bind": catalog_paths[language], "mode": "ro", } diff --git a/utils/build/docker/python_lambda/function/app.sh b/utils/build/docker/python_lambda/function/app.sh index 1efe2a62901..eb958bd98f3 100644 --- a/utils/build/docker/python_lambda/function/app.sh +++ b/utils/build/docker/python_lambda/function/app.sh @@ -4,20 +4,6 @@ set -eu export DD_LAMBDA_HANDLER=handler.lambda_handler -# Only the SCA scenario mounts this language's catalog. Install it before -# starting the Lambda wrapper, which initializes reachability instrumentation. -if [ -f /sca_advisories.json ]; then - python3 - <<'PY' -from pathlib import Path -from shutil import copyfile - -data_paths = list(Path("/opt/python").glob("lib/python*/site-packages/ddtrace/appsec/sca/_cve_data.json")) -if len(data_paths) != 1: - raise RuntimeError(f"Expected one bundled SCA catalog, found {data_paths}") -copyfile("/sca_advisories.json", data_paths[0]) -PY -fi - socat TCP-LISTEN:8127,reuseaddr,fork,bind=0.0.0.0 TCP:127.0.0.1:8126 & exec /lambda-entrypoint.sh datadog_lambda.handler.handler From f34eaca79504833b5ff31954ef7f459846f24a93 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Tue, 3 Nov 2026 10:27:36 +0100 Subject: [PATCH 08/17] test: share synthetic SCA catalogs across regular and Lambda weblogs --- tests/appsec/sca/java/advisories.json | 17 ++++++----- tests/appsec/test_sca_reachability.py | 9 +++--- utils/_context/_scenarios/_core/sca.py | 29 +++++++++++++++++++ utils/_context/_scenarios/appsec.py | 5 ++++ utils/_context/_scenarios/aws_lambda.py | 13 ++------- .../springboot/ScaReachability.java | 2 +- .../com/datadoghq/lambda/ScaReachability.java | 2 +- utils/build/docker/python/flask/app.py | 4 +-- utils/build/docker/python/flask/app.sh | 5 ---- utils/build/docker/python/flask/uwsgi_app.sh | 5 ---- .../scripts/libraries_and_scenarios_rules.yml | 16 ++++++---- 11 files changed, 64 insertions(+), 43 deletions(-) create mode 100644 utils/_context/_scenarios/_core/sca.py diff --git a/tests/appsec/sca/java/advisories.json b/tests/appsec/sca/java/advisories.json index 3757b497945..9ef569b28f6 100644 --- a/tests/appsec/sca/java/advisories.json +++ b/tests/appsec/sca/java/advisories.json @@ -1,14 +1,17 @@ { - "targets": [ + "version": 1, + "entries": [ { - "id": "system-tests-sca", - "lang": "maven", - "dependency_name": "com.github.junrar:junrar", - "package_versions": [ + "vuln_id": "system-tests-sca", + "artifact": "com.github.junrar:junrar", + "version_ranges": [ ">=0" ], - "targets": [ - "com.github.junrar:LocalFolderExtractor.createDirectory" + "symbols": [ + { + "class": "com/github/junrar/LocalFolderExtractor", + "method": "createDirectory" + } ] } ] diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index e494e3eddfc..a5e5ae1b5da 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -18,17 +18,16 @@ # Only populate entries once the language's tracer supports SCA reachability # and the expected values are confirmed. Missing languages gracefully # degrade: structural assertions still run, but value comparisons are skipped. -# `cve_id` is a list to support retrocompatibility across tracer versions that -# may emit different identifiers (e.g. CVE id vs GHSA id) for the same advisory. +# Regular and Lambda scenarios use the same synthetic advisory for each language. _LANG_CONFIG: dict[str, dict[str, Any]] = { "python": { - "cve_id": ["CVE-2024-35195", "GHSA-652x-xj99-gmcc"], + "cve_id": ["system-tests-sca"], "vulnerable_dep": "requests", "path": "app.py", "symbol": "sca_requests_vulnerable_call", }, "java": { - "cve_id": ["GHSA-hf5p-q87m-crj7"], + "cve_id": ["system-tests-sca"], "vulnerable_dep": "junrar", "path": "com.datadoghq.system_tests.springboot.ScaReachability", "symbol": "junrarHit", @@ -40,7 +39,7 @@ "symbol": "sca_requests_vulnerable_call", }, "java_lambda": { - "cve_id": ["GHSA-hf5p-q87m-crj7"], + "cve_id": ["system-tests-sca"], "vulnerable_dep": "junrar", "path": "com.datadoghq.lambda.ScaReachability", "symbol": "junrarHit", diff --git a/utils/_context/_scenarios/_core/sca.py b/utils/_context/_scenarios/_core/sca.py new file mode 100644 index 00000000000..98227b46c16 --- /dev/null +++ b/utils/_context/_scenarios/_core/sca.py @@ -0,0 +1,29 @@ +from utils._context.containers import TestedContainer + + +def configure_sca_advisories(container: TestedContainer) -> None: + library = container.image.labels["system-tests-library"] + language = library.removesuffix("_lambda") + + if language == "python": + if library == "python_lambda": + package_root = "/opt/python/lib/python3.13/site-packages" + elif any(volume["bind"] == "/volumes/dd-trace-py" for volume in container.volumes.values()): + package_root = "/volumes/dd-trace-py" + else: + assert container.image.env is not None + python_version = ".".join(container.image.env["PYTHON_VERSION"].split(".")[:2]) + package_root = f"/usr/local/lib/python{python_version}/site-packages" + catalog_path = f"{package_root}/ddtrace/appsec/sca/_cve_data.json" + elif language == "java": + catalog_path = "/sca/sca_cves.json" + # The agent checks bootstrap resources before its bundled classpath resources. + java_options = ( + container.environment.get("JAVA_TOOL_OPTIONS", (container.image.env or {}).get("JAVA_TOOL_OPTIONS", "")) + or "" + ) + container.environment["JAVA_TOOL_OPTIONS"] = f"{java_options} -Xbootclasspath/a:/sca".strip() + else: + return + + container.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = {"bind": catalog_path, "mode": "ro"} diff --git a/utils/_context/_scenarios/appsec.py b/utils/_context/_scenarios/appsec.py index 9d59079b435..9bea2f33631 100644 --- a/utils/_context/_scenarios/appsec.py +++ b/utils/_context/_scenarios/appsec.py @@ -1,6 +1,7 @@ import pytest from ._core import DdTraceEndToEndScenario, EndToEndScenario, scenario_groups +from ._core.sca import configure_sca_advisories from utils._context.constants import WeblogCategory from utils._context.containers import PostgresContainer @@ -159,6 +160,10 @@ def __init__(self) -> None: scenario_groups=[scenario_groups.appsec], ) + def configure(self, config: pytest.Config) -> None: + super().configure(config) + configure_sca_advisories(self.weblog_infra.library_container) + class IastDeduplication(DdTraceEndToEndScenario): """Iast scenario with deduplication enabled""" diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 50b24234232..df7efeba31f 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -8,6 +8,7 @@ scenario_groups as all_scenario_groups, ScenarioGroup, ) +from ._core.sca import configure_sca_advisories from utils._context.constants import WeblogCategory from utils._context.containers import ( InternalServerContainer, @@ -256,17 +257,7 @@ def __init__(self) -> None: def configure(self, config: pytest.Config) -> None: super().configure(config) - - language = self.lambda_weblog.library_name.removesuffix("_lambda") - catalog_paths = { - "python": "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json", - "java": "/sca_advisories.json", - } - if language in catalog_paths: - self.lambda_weblog.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = { - "bind": catalog_paths[language], - "mode": "ro", - } + configure_sca_advisories(self.lambda_weblog) class AppsecLambdaRasp(_LambdaScenario): diff --git a/utils/build/docker/java/spring-boot/src/main/java/com/datadoghq/system_tests/springboot/ScaReachability.java b/utils/build/docker/java/spring-boot/src/main/java/com/datadoghq/system_tests/springboot/ScaReachability.java index 95c3bdc1f4a..ebbf485dad1 100644 --- a/utils/build/docker/java/spring-boot/src/main/java/com/datadoghq/system_tests/springboot/ScaReachability.java +++ b/utils/build/docker/java/spring-boot/src/main/java/com/datadoghq/system_tests/springboot/ScaReachability.java @@ -15,7 +15,7 @@ public class ScaReachability { @PostConstruct private void preloadVulnerableClass() { // Force LocalFolderExtractor class load during Spring startup so the SCA transformer can - // register GHSA-hf5p-q87m-crj7 with reached=[] before any HTTP request triggers junrarHit(). + // register system-tests-sca with reached=[] before any HTTP request triggers junrarHit(). // Without this, the class loads lazily on the first request, so registerCve() and recordHit() // fire in the same request with no heartbeat window between them. try { diff --git a/utils/build/docker/java_lambda/src/main/java/com/datadoghq/lambda/ScaReachability.java b/utils/build/docker/java_lambda/src/main/java/com/datadoghq/lambda/ScaReachability.java index dbc63c55f6b..6740a6c03f5 100644 --- a/utils/build/docker/java_lambda/src/main/java/com/datadoghq/lambda/ScaReachability.java +++ b/utils/build/docker/java_lambda/src/main/java/com/datadoghq/lambda/ScaReachability.java @@ -9,7 +9,7 @@ public class ScaReachability { public static void preloadVulnerableClass() { // Force LocalFolderExtractor class load during Lambda initialization so the SCA transformer can - // register GHSA-hf5p-q87m-crj7 with reached=[] before any HTTP request triggers junrarHit(). + // register system-tests-sca with reached=[] before any HTTP request triggers junrarHit(). // Without this, the class loads lazily on the first request, so registerCve() and recordHit() // fire in the same request with no heartbeat window between them. try { diff --git a/utils/build/docker/python/flask/app.py b/utils/build/docker/python/flask/app.py index 869250381f4..b0c8d8cf54f 100644 --- a/utils/build/docker/python/flask/app.py +++ b/utils/build/docker/python/flask/app.py @@ -2386,7 +2386,7 @@ async def llm(): @app.route("/sca/vulnerable-call") def sca_requests_vulnerable_call(): - """Trigger a call to requests.sessions.Session.send (CVE-2024-35195 target).""" + """Trigger the synthetic advisory's requests.sessions.Session.send target.""" session = requests.Session() try: session.get("http://localhost:1") @@ -2397,7 +2397,7 @@ def sca_requests_vulnerable_call(): @app.route("/sca/vulnerable-call-alt") def sca_requests_vulnerable_call_alt(): - """Alternate call site for same CVE-2024-35195 target (first-hit-wins test).""" + """Alternate call site for the same synthetic advisory (first-hit-wins test).""" session = requests.Session() try: session.post("http://localhost:1", data="x") diff --git a/utils/build/docker/python/flask/app.sh b/utils/build/docker/python/flask/app.sh index a636fdb0a57..9d23abdb9bc 100755 --- a/utils/build/docker/python/flask/app.sh +++ b/utils/build/docker/python/flask/app.sh @@ -1,10 +1,5 @@ #!/bin/bash -if [[ ${DD_APPSEC_SCA_ENABLED:-} = "1" || ${DD_APPSEC_SCA_ENABLED:-} = "true" ]]; then - # We need a requirement with a CVE to test SCA features - python -m pip install requests==2.31.0 -fi - echo "--- PIP FREEZE ---" python -m pip freeze echo "------------------" diff --git a/utils/build/docker/python/flask/uwsgi_app.sh b/utils/build/docker/python/flask/uwsgi_app.sh index e10e7b505a9..1a148a3794c 100755 --- a/utils/build/docker/python/flask/uwsgi_app.sh +++ b/utils/build/docker/python/flask/uwsgi_app.sh @@ -1,10 +1,5 @@ #!/bin/bash -if [[ ${DD_APPSEC_SCA_ENABLED:-} = "1" || ${DD_APPSEC_SCA_ENABLED:-} = "true" ]]; then - # We need a requirement with a CVE to test SCA features - python -m pip install requests==2.31.0 -fi - echo "--- PIP FREEZE ---" python -m pip freeze echo "------------------" diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 010dfc45c61..21bb05060f1 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -234,6 +234,10 @@ patterns: utils/_context/_scenarios/_core/fake_datadog_keys.py: # fake key values: tests get them from the scenario, none depends on a value scenario_groups: null libraries: null + utils/_context/_scenarios/_core/sca.py: + scenario_groups: null + scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] + libraries: [java, java_lambda, python, python_lambda] utils/_context/_scenarios/_core/*: # base classes shared by many scenarios: runs everything utils/_context/_scenarios/*/*: # any other subfolder: not a definition file, runs everything utils/_context/_scenarios/open_telemetry.py: # its scenarios only run with OTel libraries @@ -683,15 +687,15 @@ patterns: scenario_groups: null libraries: [java, java_lambda, python, python_lambda] - tests/appsec/sca/python/advisories.json: + tests/appsec/sca/java/advisories.json: scenario_groups: null - scenarios: [APPSEC_LAMBDA_SCA] - libraries: python_lambda + scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] + libraries: [java, java_lambda] - tests/appsec/sca/java/advisories.json: + tests/appsec/sca/python/advisories.json: scenario_groups: null - scenarios: [APPSEC_LAMBDA_SCA] - libraries: java_lambda + scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] + libraries: [python, python_lambda] ################################# Default rules ################################ # The rules in this section are only applied if no other rule is applicable. From 9a11b3f06694641b5514a7664b007040fd02ad49 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Tue, 3 Nov 2026 10:40:21 +0100 Subject: [PATCH 09/17] refactor: match SCA advisory setup on library --- utils/_context/_scenarios/_core/sca.py | 38 ++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/utils/_context/_scenarios/_core/sca.py b/utils/_context/_scenarios/_core/sca.py index 98227b46c16..a5ecf8aaccf 100644 --- a/utils/_context/_scenarios/_core/sca.py +++ b/utils/_context/_scenarios/_core/sca.py @@ -3,27 +3,25 @@ def configure_sca_advisories(container: TestedContainer) -> None: library = container.image.labels["system-tests-library"] - language = library.removesuffix("_lambda") - - if language == "python": - if library == "python_lambda": - package_root = "/opt/python/lib/python3.13/site-packages" - elif any(volume["bind"] == "/volumes/dd-trace-py" for volume in container.volumes.values()): - package_root = "/volumes/dd-trace-py" - else: + match library: + case "python_lambda": + catalog_path = "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json" + case "python" if any(volume["bind"] == "/volumes/dd-trace-py" for volume in container.volumes.values()): + catalog_path = "/volumes/dd-trace-py/ddtrace/appsec/sca/_cve_data.json" + case "python": assert container.image.env is not None python_version = ".".join(container.image.env["PYTHON_VERSION"].split(".")[:2]) - package_root = f"/usr/local/lib/python{python_version}/site-packages" - catalog_path = f"{package_root}/ddtrace/appsec/sca/_cve_data.json" - elif language == "java": - catalog_path = "/sca/sca_cves.json" - # The agent checks bootstrap resources before its bundled classpath resources. - java_options = ( - container.environment.get("JAVA_TOOL_OPTIONS", (container.image.env or {}).get("JAVA_TOOL_OPTIONS", "")) - or "" - ) - container.environment["JAVA_TOOL_OPTIONS"] = f"{java_options} -Xbootclasspath/a:/sca".strip() - else: - return + catalog_path = f"/usr/local/lib/python{python_version}/site-packages/ddtrace/appsec/sca/_cve_data.json" + case "java" | "java_lambda": + catalog_path = "/sca/sca_cves.json" + # The agent checks bootstrap resources before its bundled classpath resources. + java_options = ( + container.environment.get("JAVA_TOOL_OPTIONS", (container.image.env or {}).get("JAVA_TOOL_OPTIONS", "")) + or "" + ) + container.environment["JAVA_TOOL_OPTIONS"] = f"{java_options} -Xbootclasspath/a:/sca".strip() + case _: + return + language = library.removesuffix("_lambda") container.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = {"bind": catalog_path, "mode": "ro"} From 553470d85248d074c535539f125149b3ee9c3846 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Fri, 6 Nov 2026 10:19:15 +0100 Subject: [PATCH 10/17] Use the SCA CVE file override for Java and Python weblogs --- manifests/java.yml | 10 ++++---- manifests/java_lambda.yml | 10 ++++---- manifests/python.yml | 10 ++++---- manifests/python_lambda.yml | 2 +- tests/test_the_test/test_sca_advisories.py | 30 ++++++++++++++++++++++ utils/_context/_scenarios/_core/sca.py | 23 +++-------------- 6 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 tests/test_the_test/test_sca_advisories.py diff --git a/manifests/java.yml b/manifests/java.yml index 751f996eda8..bd246a5704e 100644 --- a/manifests/java.yml +++ b/manifests/java.yml @@ -2642,27 +2642,27 @@ manifest: tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: v1.64.0-SNAPSHOT + spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: v1.64.0-SNAPSHOT + spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: v1.64.0-SNAPSHOT + spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: v1.64.0-SNAPSHOT + spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: v1.64.0-SNAPSHOT + spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarConfigurationMetric: missing_feature tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarMetric: missing_feature diff --git a/manifests/java_lambda.yml b/manifests/java_lambda.yml index 4779ab062db..c160b530a36 100644 --- a/manifests/java_lambda.yml +++ b/manifests/java_lambda.yml @@ -158,11 +158,11 @@ manifest: tests/appsec/test_reports.py::Test_TagsFromRule: v1.67.0 tests/appsec/test_reports.py::Test_TagsFromRule::test_category: v1.68.0 tests/appsec/test_reports.py::Test_TagsFromRule::test_type: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: v1.68.0 + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules: v1.67.0 tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules::test_rule_with_attributes_keep_event: v1.68.0 tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules::test_rule_with_attributes_keep_no_event: v1.68.0 diff --git a/manifests/python.yml b/manifests/python.yml index d6eb5db903a..0e8a8850875 100644 --- a/manifests/python.yml +++ b/manifests/python.yml @@ -1669,23 +1669,23 @@ manifest: tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.8.0.dev + *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.8.0.dev + *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.8.0.dev + *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.8.0.dev + *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.8.0.dev + *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarConfigurationMetric: v3.12.0.dev tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarMetric: - declaration: irrelevant (drop support in v3.12.0.dev) diff --git a/manifests/python_lambda.yml b/manifests/python_lambda.yml index d8d8e6397c4..aa1d518c66e 100644 --- a/manifests/python_lambda.yml +++ b/manifests/python_lambda.yml @@ -284,7 +284,7 @@ manifest: tests/appsec/test_reports.py::Test_Info: v7.112.0 tests/appsec/test_reports.py::Test_RequestHeaders: v7.112.0 tests/appsec/test_reports.py::Test_StatusCode: v7.112.0 - tests/appsec/test_sca_reachability.py: missing_feature (requires Lambda SCA reachability support in dd-trace-py and datadog-lambda-python) + tests/appsec/test_sca_reachability.py: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE and Lambda SCA reachability support) tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules: v8.113.0 tests/appsec/test_traces.py::Test_AppSecEventSpanTags: v7.112.0 tests/appsec/test_traces.py::Test_AppSecEventSpanTags::test_header_collection: bug (APPSEC-58202) diff --git a/tests/test_the_test/test_sca_advisories.py b/tests/test_the_test/test_sca_advisories.py new file mode 100644 index 00000000000..b0987d89665 --- /dev/null +++ b/tests/test_the_test/test_sca_advisories.py @@ -0,0 +1,30 @@ +from pathlib import Path +from unittest.mock import MagicMock + +from utils import pytest, scenarios +from utils._context._scenarios._core.sca import configure_sca_advisories +from utils._context.containers import TestedContainer as _TestedContainer + + +@scenarios.test_the_test +@pytest.mark.parametrize("library", ["java", "python", "java_lambda", "python_lambda"]) +def test_sca_catalog_override_preserves_container_configuration(library: str) -> None: + container = MagicMock(spec=_TestedContainer) + container.image = MagicMock(labels={"system-tests-library": library}) + container.environment = {"JAVA_TOOL_OPTIONS": "-javaagent:/opt/dd-java-agent.jar", "DD_APPSEC_SCA_ENABLED": "true"} + tracer_mount = {"bind": "/volumes/dd-trace-py", "mode": "ro"} + container.volumes = {"./binaries/dd-trace-py": tracer_mount} + + configure_sca_advisories(container) + + source = f"./tests/appsec/sca/{library.removesuffix('_lambda')}/advisories.json" + assert Path(source).is_file() + assert container.volumes == { + "./binaries/dd-trace-py": tracer_mount, + source: {"bind": "/sca/advisories.json", "mode": "ro"}, + } + assert container.environment == { + "JAVA_TOOL_OPTIONS": "-javaagent:/opt/dd-java-agent.jar", + "DD_APPSEC_SCA_ENABLED": "true", + "_DD_APPSEC_SCA_CVE_FILE": "/sca/advisories.json", + } diff --git a/utils/_context/_scenarios/_core/sca.py b/utils/_context/_scenarios/_core/sca.py index a5ecf8aaccf..7253aa40b18 100644 --- a/utils/_context/_scenarios/_core/sca.py +++ b/utils/_context/_scenarios/_core/sca.py @@ -3,25 +3,10 @@ def configure_sca_advisories(container: TestedContainer) -> None: library = container.image.labels["system-tests-library"] - match library: - case "python_lambda": - catalog_path = "/opt/python/lib/python3.13/site-packages/ddtrace/appsec/sca/_cve_data.json" - case "python" if any(volume["bind"] == "/volumes/dd-trace-py" for volume in container.volumes.values()): - catalog_path = "/volumes/dd-trace-py/ddtrace/appsec/sca/_cve_data.json" - case "python": - assert container.image.env is not None - python_version = ".".join(container.image.env["PYTHON_VERSION"].split(".")[:2]) - catalog_path = f"/usr/local/lib/python{python_version}/site-packages/ddtrace/appsec/sca/_cve_data.json" - case "java" | "java_lambda": - catalog_path = "/sca/sca_cves.json" - # The agent checks bootstrap resources before its bundled classpath resources. - java_options = ( - container.environment.get("JAVA_TOOL_OPTIONS", (container.image.env or {}).get("JAVA_TOOL_OPTIONS", "")) - or "" - ) - container.environment["JAVA_TOOL_OPTIONS"] = f"{java_options} -Xbootclasspath/a:/sca".strip() - case _: - return + if library not in ("java", "python", "java_lambda", "python_lambda"): + return + catalog_path = "/sca/advisories.json" language = library.removesuffix("_lambda") container.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = {"bind": catalog_path, "mode": "ro"} + container.environment["_DD_APPSEC_SCA_CVE_FILE"] = catalog_path From 0da3c7df5c3bfb8bda336ce73072d020bd8522d0 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Fri, 6 Nov 2026 14:57:12 +0100 Subject: [PATCH 11/17] Enable Python SCA reachability tests for main development builds --- manifests/python.yml | 10 +++++----- tests/appsec/test_sca_reachability.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/manifests/python.yml b/manifests/python.yml index 0e8a8850875..93c45bf6456 100644 --- a/manifests/python.yml +++ b/manifests/python.yml @@ -1669,23 +1669,23 @@ manifest: tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + *flask : v4.17.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + *flask : v4.17.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + *flask : v4.17.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + *flask : v4.17.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + *flask : v4.17.0-rc1 tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarConfigurationMetric: v3.12.0.dev tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarMetric: - declaration: irrelevant (drop support in v3.12.0.dev) diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index a5e5ae1b5da..4241dad0e8f 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -8,12 +8,17 @@ """ import json +import os from typing import Any -from utils import weblog, interfaces, scenarios, features, rfc, context +from utils import weblog, interfaces, scenarios, features, rfc, context, missing_feature SCA_REACHABILITY_RFC = "https://docs.google.com/document/d/1xDw9iG6h41VCEgJGTqoJdruRaNS4pYgNifO6nhiizWA/edit" +# Main builds currently share a package version with published RCs that lack the +# file override. Keep released builds disabled until the override is released. +_PYTHON_RELEASE_BUILD = context.library.name == "python" and os.environ.get("SYSTEM_TESTS_DEV_MODE") != "true" + # Per-language expected values for SCA reachability tests. # Only populate entries once the language's tracer supports SCA reachability # and the expected values are confirmed. Missing languages gracefully @@ -120,6 +125,7 @@ def _get_deps_with_reachability_metadata() -> set[str]: return deps +@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -138,6 +144,7 @@ def test_dependencies_have_metadata_key(self) -> None: ) +@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -158,6 +165,7 @@ def test_cve_registered_at_load_time(self) -> None: ) +@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -198,6 +206,7 @@ def test_cve_metadata_after_vulnerable_call(self) -> None: assert caller["symbol"] == expected_symbol, f"Expected symbol '{expected_symbol}', got '{caller['symbol']}'" +@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -249,6 +258,7 @@ def test_same_cve_first_hit_wins(self) -> None: ) +@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability From da2d605dbdb34b4ffd16ee04f2852622abf58f61 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Mon, 9 Nov 2026 15:04:25 +0100 Subject: [PATCH 12/17] Enable Java SCA reachability tests for development builds --- manifests/java.yml | 10 +++++----- manifests/java_lambda.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifests/java.yml b/manifests/java.yml index bd246a5704e..ad41ce94106 100644 --- a/manifests/java.yml +++ b/manifests/java.yml @@ -2642,27 +2642,27 @@ manifest: tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + spring-boot: v1.69.0-SNAPSHOT spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + spring-boot: v1.69.0-SNAPSHOT spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + spring-boot: v1.69.0-SNAPSHOT spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + spring-boot: v1.69.0-SNAPSHOT spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: - weblog_declaration: "*": irrelevant (endpoint only implemented in spring-boot weblog) - spring-boot: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + spring-boot: v1.69.0-SNAPSHOT spring-boot-3-native: irrelevant (GraalVM. Tracing support only) tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarConfigurationMetric: missing_feature tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarMetric: missing_feature diff --git a/manifests/java_lambda.yml b/manifests/java_lambda.yml index c160b530a36..89d641cab1e 100644 --- a/manifests/java_lambda.yml +++ b/manifests/java_lambda.yml @@ -158,11 +158,11 @@ manifest: tests/appsec/test_reports.py::Test_TagsFromRule: v1.67.0 tests/appsec/test_reports.py::Test_TagsFromRule::test_category: v1.68.0 tests/appsec/test_reports.py::Test_TagsFromRule::test_type: v1.68.0 - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) - tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: missing_feature (requires _DD_APPSEC_SCA_CVE_FILE support) + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: v1.69.0-SNAPSHOT + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: v1.69.0-SNAPSHOT + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: v1.69.0-SNAPSHOT + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: v1.69.0-SNAPSHOT + tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: v1.69.0-SNAPSHOT tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules: v1.67.0 tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules::test_rule_with_attributes_keep_event: v1.68.0 tests/appsec/test_trace_tagging.py::Test_TraceTaggingRules::test_rule_with_attributes_keep_no_event: v1.68.0 From 515afd32d59b5f93690578958666fe7cdf77829e Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Mon, 9 Nov 2026 15:13:17 +0100 Subject: [PATCH 13/17] Remove redundant SCA advisory container test --- tests/test_the_test/test_sca_advisories.py | 30 ---------------------- 1 file changed, 30 deletions(-) delete mode 100644 tests/test_the_test/test_sca_advisories.py diff --git a/tests/test_the_test/test_sca_advisories.py b/tests/test_the_test/test_sca_advisories.py deleted file mode 100644 index b0987d89665..00000000000 --- a/tests/test_the_test/test_sca_advisories.py +++ /dev/null @@ -1,30 +0,0 @@ -from pathlib import Path -from unittest.mock import MagicMock - -from utils import pytest, scenarios -from utils._context._scenarios._core.sca import configure_sca_advisories -from utils._context.containers import TestedContainer as _TestedContainer - - -@scenarios.test_the_test -@pytest.mark.parametrize("library", ["java", "python", "java_lambda", "python_lambda"]) -def test_sca_catalog_override_preserves_container_configuration(library: str) -> None: - container = MagicMock(spec=_TestedContainer) - container.image = MagicMock(labels={"system-tests-library": library}) - container.environment = {"JAVA_TOOL_OPTIONS": "-javaagent:/opt/dd-java-agent.jar", "DD_APPSEC_SCA_ENABLED": "true"} - tracer_mount = {"bind": "/volumes/dd-trace-py", "mode": "ro"} - container.volumes = {"./binaries/dd-trace-py": tracer_mount} - - configure_sca_advisories(container) - - source = f"./tests/appsec/sca/{library.removesuffix('_lambda')}/advisories.json" - assert Path(source).is_file() - assert container.volumes == { - "./binaries/dd-trace-py": tracer_mount, - source: {"bind": "/sca/advisories.json", "mode": "ro"}, - } - assert container.environment == { - "JAVA_TOOL_OPTIONS": "-javaagent:/opt/dd-java-agent.jar", - "DD_APPSEC_SCA_ENABLED": "true", - "_DD_APPSEC_SCA_CVE_FILE": "/sca/advisories.json", - } From 4be2d57610e95996760117ff8658a4a2c0152a0d Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Mon, 9 Nov 2026 16:58:06 +0100 Subject: [PATCH 14/17] Use manifests to activate Python SCA reachability tests --- tests/appsec/test_sca_reachability.py | 12 +----------- utils/_context/_scenarios/aws_lambda.py | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/appsec/test_sca_reachability.py b/tests/appsec/test_sca_reachability.py index 4241dad0e8f..a5e5ae1b5da 100644 --- a/tests/appsec/test_sca_reachability.py +++ b/tests/appsec/test_sca_reachability.py @@ -8,17 +8,12 @@ """ import json -import os from typing import Any -from utils import weblog, interfaces, scenarios, features, rfc, context, missing_feature +from utils import weblog, interfaces, scenarios, features, rfc, context SCA_REACHABILITY_RFC = "https://docs.google.com/document/d/1xDw9iG6h41VCEgJGTqoJdruRaNS4pYgNifO6nhiizWA/edit" -# Main builds currently share a package version with published RCs that lack the -# file override. Keep released builds disabled until the override is released. -_PYTHON_RELEASE_BUILD = context.library.name == "python" and os.environ.get("SYSTEM_TESTS_DEV_MODE") != "true" - # Per-language expected values for SCA reachability tests. # Only populate entries once the language's tracer supports SCA reachability # and the expected values are confirmed. Missing languages gracefully @@ -125,7 +120,6 @@ def _get_deps_with_reachability_metadata() -> set[str]: return deps -@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -144,7 +138,6 @@ def test_dependencies_have_metadata_key(self) -> None: ) -@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -165,7 +158,6 @@ def test_cve_registered_at_load_time(self) -> None: ) -@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -206,7 +198,6 @@ def test_cve_metadata_after_vulnerable_call(self) -> None: assert caller["symbol"] == expected_symbol, f"Expected symbol '{expected_symbol}', got '{caller['symbol']}'" -@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability @@ -258,7 +249,6 @@ def test_same_cve_first_hit_wins(self) -> None: ) -@missing_feature(_PYTHON_RELEASE_BUILD, reason="CVE file override is currently only available in Python main builds") @rfc(SCA_REACHABILITY_RFC) @features.runtime_sca_reachability @scenarios.runtime_sca_reachability diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index df7efeba31f..2cb774f9290 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -251,7 +251,6 @@ def __init__(self) -> None: "DD_APPSEC_ENABLED": "false", "DD_APPSEC_SCA_ENABLED": "true", }, - doc="SCA dependency metadata and runtime reachability in Lambda with AppSec disabled", scenario_groups=[scenario_groups.appsec, scenario_groups.appsec_lambda], ) From 9182df22290e1d8b581fa07766059d7d58fb08a1 Mon Sep 17 00:00:00 2001 From: "florentin.labelle" Date: Thu, 19 Nov 2026 09:37:08 +0000 Subject: [PATCH 15/17] Inline the synthetic SCA advisory catalogs Keep the tracer-native catalogs in appsec.py and generate the read-only JSON files for the existing regular and Lambda scenarios. Let the Lambda SCA scenario select its libraries without a separate CI rule. --- tests/appsec/sca/java/advisories.json | 18 ------- tests/appsec/sca/python/advisories.json | 20 ------- utils/_context/_scenarios/_core/sca.py | 12 ----- utils/_context/_scenarios/appsec.py | 54 +++++++++++++++++-- utils/_context/_scenarios/aws_lambda.py | 13 ++--- .../scripts/libraries_and_scenarios_rules.yml | 16 +----- 6 files changed, 59 insertions(+), 74 deletions(-) delete mode 100644 tests/appsec/sca/java/advisories.json delete mode 100644 tests/appsec/sca/python/advisories.json delete mode 100644 utils/_context/_scenarios/_core/sca.py diff --git a/tests/appsec/sca/java/advisories.json b/tests/appsec/sca/java/advisories.json deleted file mode 100644 index 9ef569b28f6..00000000000 --- a/tests/appsec/sca/java/advisories.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 1, - "entries": [ - { - "vuln_id": "system-tests-sca", - "artifact": "com.github.junrar:junrar", - "version_ranges": [ - ">=0" - ], - "symbols": [ - { - "class": "com/github/junrar/LocalFolderExtractor", - "method": "createDirectory" - } - ] - } - ] -} diff --git a/tests/appsec/sca/python/advisories.json b/tests/appsec/sca/python/advisories.json deleted file mode 100644 index 4835edf62d2..00000000000 --- a/tests/appsec/sca/python/advisories.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "targets": [ - { - "id": "system-tests-sca", - "lang": "python", - "dependency_name": "requests", - "package_versions": [ - ">=0" - ], - "targets": [ - "requests.sessions:Session.send" - ], - "vulnerability": { - "id": "system-tests-sca", - "severity": "LOW", - "description": "Synthetic requests target for system-tests SCA reachability coverage." - } - } - ] -} diff --git a/utils/_context/_scenarios/_core/sca.py b/utils/_context/_scenarios/_core/sca.py deleted file mode 100644 index 7253aa40b18..00000000000 --- a/utils/_context/_scenarios/_core/sca.py +++ /dev/null @@ -1,12 +0,0 @@ -from utils._context.containers import TestedContainer - - -def configure_sca_advisories(container: TestedContainer) -> None: - library = container.image.labels["system-tests-library"] - if library not in ("java", "python", "java_lambda", "python_lambda"): - return - - catalog_path = "/sca/advisories.json" - language = library.removesuffix("_lambda") - container.volumes[f"./tests/appsec/sca/{language}/advisories.json"] = {"bind": catalog_path, "mode": "ro"} - container.environment["_DD_APPSEC_SCA_CVE_FILE"] = catalog_path diff --git a/utils/_context/_scenarios/appsec.py b/utils/_context/_scenarios/appsec.py index 9bea2f33631..31e1e2f1a03 100644 --- a/utils/_context/_scenarios/appsec.py +++ b/utils/_context/_scenarios/appsec.py @@ -1,9 +1,11 @@ +import json +from pathlib import Path + import pytest from ._core import DdTraceEndToEndScenario, EndToEndScenario, scenario_groups -from ._core.sca import configure_sca_advisories from utils._context.constants import WeblogCategory -from utils._context.containers import PostgresContainer +from utils._context.containers import PostgresContainer, TestedContainer # ASM scenarios @@ -148,6 +150,51 @@ def __init__(self) -> None: ) +# Synthetic tracer-native advisory catalogs shared by the regular and Lambda SCA scenarios. +_SCA_ADVISORIES = { + "java": { + "version": 1, + "entries": [ + { + "vuln_id": "system-tests-sca", + "artifact": "com.github.junrar:junrar", + "version_ranges": [">=0"], + "symbols": [{"class": "com/github/junrar/LocalFolderExtractor", "method": "createDirectory"}], + } + ], + }, + "python": { + "targets": [ + { + "id": "system-tests-sca", + "lang": "python", + "dependency_name": "requests", + "package_versions": [">=0"], + "targets": ["requests.sessions:Session.send"], + "vulnerability": { + "id": "system-tests-sca", + "severity": "LOW", + "description": "Synthetic requests target for system-tests SCA reachability coverage.", + }, + } + ] + }, +} + + +def configure_sca_advisories(container: TestedContainer) -> None: + language = container.image.labels["system-tests-library"].removesuffix("_lambda") + if language not in _SCA_ADVISORIES: + return + + catalog = Path(container.log_folder_path) / "sca-advisories.json" + catalog.write_text(json.dumps(_SCA_ADVISORIES[language]), encoding="utf-8") + + container_path = "/sca/advisories.json" + container.volumes[str(catalog)] = {"bind": container_path, "mode": "ro"} + container.environment["_DD_APPSEC_SCA_CVE_FILE"] = container_path + + class RuntimeScaReachability(DdTraceEndToEndScenario): """Scenario to test SCA telemetry events""" @@ -162,7 +209,8 @@ def __init__(self) -> None: def configure(self, config: pytest.Config) -> None: super().configure(config) - configure_sca_advisories(self.weblog_infra.library_container) + if not self.replay: + configure_sca_advisories(self.weblog_infra.library_container) class IastDeduplication(DdTraceEndToEndScenario): diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 2cb774f9290..20c8adf7154 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -8,7 +8,7 @@ scenario_groups as all_scenario_groups, ScenarioGroup, ) -from ._core.sca import configure_sca_advisories +from .appsec import configure_sca_advisories from utils._context.constants import WeblogCategory from utils._context.containers import ( InternalServerContainer, @@ -247,16 +247,17 @@ class AppsecLambdaSca(_LambdaScenario): def __init__(self) -> None: super().__init__( "APPSEC_LAMBDA_SCA", - weblog_env={ - "DD_APPSEC_ENABLED": "false", - "DD_APPSEC_SCA_ENABLED": "true", - }, + weblog_env={"DD_APPSEC_ENABLED": "false", "DD_APPSEC_SCA_ENABLED": "true"}, scenario_groups=[scenario_groups.appsec, scenario_groups.appsec_lambda], ) def configure(self, config: pytest.Config) -> None: super().configure(config) - configure_sca_advisories(self.lambda_weblog) + if not self.replay: + configure_sca_advisories(self.lambda_weblog) + + def get_libraries(self) -> set[str]: + return {"java_lambda", "python_lambda"} class AppsecLambdaRasp(_LambdaScenario): diff --git a/utils/scripts/libraries_and_scenarios_rules.yml b/utils/scripts/libraries_and_scenarios_rules.yml index 21bb05060f1..76e21e362e2 100644 --- a/utils/scripts/libraries_and_scenarios_rules.yml +++ b/utils/scripts/libraries_and_scenarios_rules.yml @@ -234,10 +234,6 @@ patterns: utils/_context/_scenarios/_core/fake_datadog_keys.py: # fake key values: tests get them from the scenario, none depends on a value scenario_groups: null libraries: null - utils/_context/_scenarios/_core/sca.py: - scenario_groups: null - scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] - libraries: [java, java_lambda, python, python_lambda] utils/_context/_scenarios/_core/*: # base classes shared by many scenarios: runs everything utils/_context/_scenarios/*/*: # any other subfolder: not a definition file, runs everything utils/_context/_scenarios/open_telemetry.py: # its scenarios only run with OTel libraries @@ -685,17 +681,7 @@ patterns: tests/appsec/test_sca_reachability.py: scenario_groups: null - libraries: [java, java_lambda, python, python_lambda] - - tests/appsec/sca/java/advisories.json: - scenario_groups: null - scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] - libraries: [java, java_lambda] - - tests/appsec/sca/python/advisories.json: - scenario_groups: null - scenarios: [APPSEC_LAMBDA_SCA, RUNTIME_SCA_REACHABILITY] - libraries: [python, python_lambda] + libraries: [java, java_lambda, python] ################################# Default rules ################################ # The rules in this section are only applied if no other rule is applicable. From f31e0b568b67caed0ebf47d70faa92b5c7624311 Mon Sep 17 00:00:00 2001 From: "florentin.labelle" Date: Thu, 19 Nov 2026 12:27:27 +0000 Subject: [PATCH 16/17] Keep SCA advisory fixtures local to each scenario Avoid the prohibited cross-scenario import. Keeping each catalog in its own scenario definition also lets CI select the right scenario for fixture edits without changing selection rules. --- utils/_context/_scenarios/appsec.py | 33 ++++++++------- utils/_context/_scenarios/aws_lambda.py | 54 +++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/utils/_context/_scenarios/appsec.py b/utils/_context/_scenarios/appsec.py index 31e1e2f1a03..d3a14f225d3 100644 --- a/utils/_context/_scenarios/appsec.py +++ b/utils/_context/_scenarios/appsec.py @@ -5,7 +5,7 @@ from ._core import DdTraceEndToEndScenario, EndToEndScenario, scenario_groups from utils._context.constants import WeblogCategory -from utils._context.containers import PostgresContainer, TestedContainer +from utils._context.containers import PostgresContainer # ASM scenarios @@ -150,7 +150,7 @@ def __init__(self) -> None: ) -# Synthetic tracer-native advisory catalogs shared by the regular and Lambda SCA scenarios. +# Inline fixtures so edits select this scenario in CI. _SCA_ADVISORIES = { "java": { "version": 1, @@ -182,19 +182,6 @@ def __init__(self) -> None: } -def configure_sca_advisories(container: TestedContainer) -> None: - language = container.image.labels["system-tests-library"].removesuffix("_lambda") - if language not in _SCA_ADVISORIES: - return - - catalog = Path(container.log_folder_path) / "sca-advisories.json" - catalog.write_text(json.dumps(_SCA_ADVISORIES[language]), encoding="utf-8") - - container_path = "/sca/advisories.json" - container.volumes[str(catalog)] = {"bind": container_path, "mode": "ro"} - container.environment["_DD_APPSEC_SCA_CVE_FILE"] = container_path - - class RuntimeScaReachability(DdTraceEndToEndScenario): """Scenario to test SCA telemetry events""" @@ -209,8 +196,20 @@ def __init__(self) -> None: def configure(self, config: pytest.Config) -> None: super().configure(config) - if not self.replay: - configure_sca_advisories(self.weblog_infra.library_container) + if self.replay: + return + + container = self.weblog_infra.library_container + advisory = _SCA_ADVISORIES.get(container.image.labels["system-tests-library"]) + if advisory is None: + return + + catalog = Path(container.log_folder_path) / "sca-advisories.json" + catalog.write_text(json.dumps(advisory), encoding="utf-8") + + container_path = "/sca/advisories.json" + container.volumes[str(catalog)] = {"bind": container_path, "mode": "ro"} + container.environment["_DD_APPSEC_SCA_CVE_FILE"] = container_path class IastDeduplication(DdTraceEndToEndScenario): diff --git a/utils/_context/_scenarios/aws_lambda.py b/utils/_context/_scenarios/aws_lambda.py index 20c8adf7154..742e51ef5bf 100644 --- a/utils/_context/_scenarios/aws_lambda.py +++ b/utils/_context/_scenarios/aws_lambda.py @@ -1,3 +1,6 @@ +import json +from pathlib import Path + import pytest from utils import interfaces from utils.interfaces._core import ProxyBasedInterfaceValidator @@ -8,7 +11,6 @@ scenario_groups as all_scenario_groups, ScenarioGroup, ) -from .appsec import configure_sca_advisories from utils._context.constants import WeblogCategory from utils._context.containers import ( InternalServerContainer, @@ -241,6 +243,38 @@ def __init__(self) -> None: ) +# Inline fixtures so edits select this scenario in CI without importing appsec.py. +_SCA_ADVISORIES = { + "java_lambda": { + "version": 1, + "entries": [ + { + "vuln_id": "system-tests-sca", + "artifact": "com.github.junrar:junrar", + "version_ranges": [">=0"], + "symbols": [{"class": "com/github/junrar/LocalFolderExtractor", "method": "createDirectory"}], + } + ], + }, + "python_lambda": { + "targets": [ + { + "id": "system-tests-sca", + "lang": "python", + "dependency_name": "requests", + "package_versions": [">=0"], + "targets": ["requests.sessions:Session.send"], + "vulnerability": { + "id": "system-tests-sca", + "severity": "LOW", + "description": "Synthetic requests target for system-tests SCA reachability coverage.", + }, + } + ] + }, +} + + class AppsecLambdaSca(_LambdaScenario): """SCA dependency metadata and runtime reachability in Lambda with AppSec disabled""" @@ -253,11 +287,23 @@ def __init__(self) -> None: def configure(self, config: pytest.Config) -> None: super().configure(config) - if not self.replay: - configure_sca_advisories(self.lambda_weblog) + if self.replay: + return + + container = self.lambda_weblog + advisory = _SCA_ADVISORIES.get(container.image.labels["system-tests-library"]) + if advisory is None: + return + + catalog = Path(container.log_folder_path) / "sca-advisories.json" + catalog.write_text(json.dumps(advisory), encoding="utf-8") + + container_path = "/sca/advisories.json" + container.volumes[str(catalog)] = {"bind": container_path, "mode": "ro"} + container.environment["_DD_APPSEC_SCA_CVE_FILE"] = container_path def get_libraries(self) -> set[str]: - return {"java_lambda", "python_lambda"} + return set(_SCA_ADVISORIES) class AppsecLambdaRasp(_LambdaScenario): From 9eda9959d8f62c1204843e241f6420e20df7e959 Mon Sep 17 00:00:00 2001 From: "florentin.labelle" Date: Thu, 19 Nov 2026 14:04:06 +0000 Subject: [PATCH 17/17] Gate Python SCA reachability on catalog override support The three production Flask variants use ddtrace 4.17.1, which predates the catalog override in dd-trace-py #21534. All three development variants pass with 4.18.0-rc1; use that as the minimum version. --- manifests/python.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/manifests/python.yml b/manifests/python.yml index 3b355dca3d9..82763af2e1c 100644 --- a/manifests/python.yml +++ b/manifests/python.yml @@ -1664,26 +1664,27 @@ manifest: tests/appsec/test_sca_reachability.py: - weblog_declaration: aiohttp: missing_feature (new weblog, tests are enabled with easy wins) + # These tests require the SCA catalog override added in dd-trace-py #21534. tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_After_Vulnerable_Call: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.17.0-rc1 + *flask : v4.18.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_CVE_Registered_At_Load_Time: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.17.0-rc1 + *flask : v4.18.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Deduplication: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.17.0-rc1 + *flask : v4.18.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_Dependencies_Have_Metadata: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.17.0-rc1 + *flask : v4.18.0-rc1 tests/appsec/test_sca_reachability.py::Test_SCA_Reachability_First_Hit_Wins: - weblog_declaration: "*": irrelevant (endpoint only implemented in flask weblog) - *flask : v4.17.0-rc1 + *flask : v4.18.0-rc1 tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarConfigurationMetric: v3.12.0.dev tests/appsec/test_service_activation_metric.py::TestServiceActivationEnvVarMetric: - declaration: irrelevant (drop support in v3.12.0.dev)