Skip to content

Commit b23b513

Browse files
committed
fix minor tweaks
1 parent 579fe3e commit b23b513

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

tests/appsec/test_traces.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,20 @@ def setup_custom_span_tags(self):
6868
weblog.get("/waf", params={"key": "\n :"}) # rules.http_protocol_violation.crs_921_160
6969
weblog.get("/waf", headers={"random-key": "acunetix-user-agreement"}) # rules.security_scanner.crs_913_110
7070

71-
@bug(library="python_lambda", reason="APPSEC-58201")
7271
def test_custom_span_tags(self):
7372
"""AppSec should store in all APM spans some tags when enabled."""
7473

7574
spans = [span for _, span in interfaces.library.get_root_spans()]
7675
assert spans, "No root spans to validate"
77-
spans = [s for s in spans if s.get("type") == "web"]
78-
assert spans, "No spans of type web to validate"
76+
spans = [s for s in spans if s.get("type") in ("web", "serverless")]
77+
assert spans, "No spans of type web or serverless to validate"
7978
for span in spans:
79+
if span.get("type") == "serverless" and "_dd.appsec.unsupported_event_type" in span["metrics"]:
80+
# For serverless, the `healthcheck` event is not supported
81+
assert (
82+
span["metrics"]["_dd.appsec.unsupported_event_type"] == 1
83+
), "_dd.appsec.unsupported_event_type should be 1 or 1.0"
84+
continue
8085
assert "_dd.appsec.enabled" in span["metrics"], "Cannot find _dd.appsec.enabled in span metrics"
8186
assert span["metrics"]["_dd.appsec.enabled"] == 1, "_dd.appsec.enabled should be 1 or 1.0"
8287
assert "_dd.runtime_family" in span["meta"], "Cannot find _dd.runtime_family in span meta"
@@ -87,14 +92,15 @@ def test_custom_span_tags(self):
8792
def setup_header_collection(self):
8893
self.r = weblog.get("/headers", headers={"User-Agent": "Arachni/v1", "Content-Type": "text/plain"})
8994

95+
@bug(library="python_lambda", reason="APPSEC-58202")
9096
@bug(context.library < f"python@{PYTHON_RELEASE_GA_1_1}", reason="APMRP-360")
9197
@bug(context.library < "java@1.2.0", weblog_variant="spring-boot-openliberty", reason="APPSEC-6734")
9298
@bug(
9399
context.library < "nodejs@5.57.0",
94100
weblog_variant="fastify",
95101
reason="APPSEC-57432", # Response headers collection not supported yet
96102
)
97-
@irrelevant(context.library not in ["golang", "nodejs", "java", "dotnet"], reason="test")
103+
@irrelevant(context.library not in ["golang", "nodejs", "java", "dotnet", "python_lambda"], reason="test")
98104
@irrelevant(context.scenario is scenarios.external_processing, reason="Irrelevant tag set for golang")
99105
def test_header_collection(self):
100106
"""AppSec should collect some headers for http.request and http.response and store them in span tags.

utils/_context/_scenarios/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22

3-
from utils._context._scenarios.aws_lambda import LambdaScenario
43
from utils._context.header_tag_vars import VALID_CONFIGS, INVALID_CONFIGS, CONFIG_WILDCARD
54
from utils.proxy.ports import ProxyPorts
65
from utils.tools import update_environ_with_local_env
76

7+
from .aws_lambda import LambdaScenario
88
from .core import Scenario, scenario_groups
99
from .default import DefaultScenario
1010
from .endtoend import DockerScenario, EndToEndScenario

utils/_context/containers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,21 +1065,18 @@ def __init__(
10651065
volumes = volumes or {}
10661066

10671067
environment["DD_PROXY_HTTPS"] = f"http://proxy:{ProxyPorts.agent}"
1068-
environment["DD_PROXY_HTTP"] = f"http://proxy:{ProxyPorts.agent}"
1069-
environment["DD_APM_NON_LOCAL_TRAFFIC"] = (
1070-
"true" # Required for the extension to receive traces from outside the container
1071-
)
1068+
environment["DD_LOG_LEVEL"] = "debug"
10721069
volumes.update(
10731070
{
10741071
"./utils/build/docker/agent/ca-certificates.crt": {
10751072
"bind": "/etc/ssl/certs/ca-certificates.crt",
10761073
"mode": "ro",
10771074
},
10781075
"./utils/build/docker/agent/datadog.yaml": {
1079-
"bind": "/etc/datadog-agent/datadog.yaml",
1076+
"bind": "/var/task/datadog.yaml",
10801077
"mode": "ro",
10811078
},
1082-
},
1079+
}
10831080
)
10841081

10851082
super().__init__(

utils/build/docker/python_lambda/apigw-rest.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ COPY utils/build/docker/python_lambda/function/. ${LAMBDA_TASK_ROOT}
1414
RUN pip install -r ${LAMBDA_TASK_ROOT}/requirements.txt
1515

1616
ENV DD_LAMBDA_HANDLER=handler.lambda_handler
17+
ENV DD_TRACE_MANAGED_SERVICES=false
1718

1819
ENTRYPOINT ["/bin/sh"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
aws-lambda-powertools
1+
aws-lambda-powertools==3.17.0

0 commit comments

Comments
 (0)