Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9cc23b1
Add Python Lambda SCA reachability fixtures
florentinl Oct 29, 2026
8e94c64
Use a synthetic advisory for Python Lambda SCA tests
florentinl Oct 29, 2026
d9f5947
Share SCA advisory fixtures across languages
florentinl Oct 29, 2026
1f28f79
test: inject Lambda SCA advisories through scenario arguments
florentinl Oct 29, 2026
cce43f6
test: inject SCA fixtures through Lambda test startup
florentinl Oct 29, 2026
9805055
test: split Lambda SCA advisories by language
florentinl Nov 3, 2026
1bc0a7f
test: mount native Python SCA catalog directly
florentinl Nov 3, 2026
f34eaca
test: share synthetic SCA catalogs across regular and Lambda weblogs
florentinl Nov 3, 2026
9a11b3f
refactor: match SCA advisory setup on library
florentinl Nov 3, 2026
553470d
Use the SCA CVE file override for Java and Python weblogs
florentinl Nov 6, 2026
0da3c7d
Enable Python SCA reachability tests for main development builds
florentinl Nov 6, 2026
da2d605
Enable Java SCA reachability tests for development builds
florentinl Nov 9, 2026
515afd3
Remove redundant SCA advisory container test
florentinl Nov 9, 2026
4be2d57
Use manifests to activate Python SCA reachability tests
florentinl Nov 9, 2026
9182df2
Inline the synthetic SCA advisory catalogs
florentinl Nov 19, 2026
f31e0b5
Keep SCA advisory fixtures local to each scenario
florentinl Nov 19, 2026
f221d51
Merge branch 'main' into flabel/python-lambda-sca
florentinl Nov 19, 2026
9eda995
Gate Python SCA reachability on catalog override support
florentinl Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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: v1.64.0-SNAPSHOT
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: v1.64.0-SNAPSHOT
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: v1.64.0-SNAPSHOT
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: v1.64.0-SNAPSHOT
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
Expand Down
10 changes: 5 additions & 5 deletions manifests/java_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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
Expand Down
11 changes: 6 additions & 5 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.0.dev
*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.8.0.dev
*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.8.0.dev
*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.8.0.dev
*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.8.0.dev
*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)
Expand Down
2 changes: 1 addition & 1 deletion manifests/python_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 _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)
Expand Down
15 changes: 10 additions & 5 deletions tests/appsec/test_sca_reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@
# 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",
},
"python_lambda": {
"cve_id": ["system-tests-sca"],
"vulnerable_dep": "requests",
"path": "handler.py",
"symbol": "sca_requests_vulnerable_call",
Comment thread
florentinl marked this conversation as resolved.
Resolved
},
"java_lambda": {
"cve_id": ["GHSA-hf5p-q87m-crj7"],
"cve_id": ["system-tests-sca"],
"vulnerable_dep": "junrar",
"path": "com.datadoghq.lambda.ScaReachability",
"symbol": "junrarHit",
Expand Down
52 changes: 52 additions & 0 deletions utils/_context/_scenarios/appsec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
from pathlib import Path

import pytest

from ._core import DdTraceEndToEndScenario, EndToEndScenario, scenario_groups
Expand Down Expand Up @@ -147,6 +150,38 @@ def __init__(self) -> None:
)


# Inline fixtures so edits select this scenario in CI.
_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.",
},
}
]
},
}


class RuntimeScaReachability(DdTraceEndToEndScenario):
"""Scenario to test SCA telemetry events"""

Expand All @@ -159,6 +194,23 @@ def __init__(self) -> None:
scenario_groups=[scenario_groups.appsec],
)

def configure(self, config: pytest.Config) -> None:
super().configure(config)
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):
"""Iast scenario with deduplication enabled"""
Expand Down
55 changes: 55 additions & 0 deletions utils/_context/_scenarios/aws_lambda.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
from pathlib import Path

import pytest
from utils import interfaces
from utils.interfaces._core import ProxyBasedInterfaceValidator
Expand Down Expand Up @@ -240,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"""

Expand All @@ -250,6 +285,26 @@ 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.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 set(_SCA_ADVISORIES)


class AppsecLambdaRasp(_LambdaScenario):
"""Enable APPSEC RASP"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions utils/build/docker/python/flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
5 changes: 0 additions & 5 deletions utils/build/docker/python/flask/app.sh
Original file line number Diff line number Diff line change
@@ -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 "------------------"
Expand Down
5 changes: 0 additions & 5 deletions utils/build/docker/python/flask/uwsgi_app.sh
Original file line number Diff line number Diff line change
@@ -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 "------------------"
Expand Down
22 changes: 22 additions & 0 deletions utils/build/docker/python_lambda/function/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@
_TRACK_CUSTOM_APPSEC_EVENT_NAME = "system_tests_appsec_event"


@app.get("/sca/vulnerable-call")
def sca_requests_vulnerable_call() -> str:
"""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)
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",
Expand Down
Loading