File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from typing import Any
55from typing import Dict
66from typing import Optional
7+ from typing import Union
78
89import xmltodict
910
1011from ddtrace ._trace .span import Span
1112from ddtrace .appsec ._asm_request_context import _call_waf
1213from ddtrace .appsec ._asm_request_context import _call_waf_first
1314from ddtrace .appsec ._asm_request_context import get_blocked
15+ from ddtrace .appsec ._asm_request_context import set_body_response
1416from ddtrace .appsec ._constants import SPAN_DATA_NAMES
1517from ddtrace .appsec ._http_utils import extract_cookies_from_headers
1618from ddtrace .appsec ._http_utils import normalize_headers
@@ -131,6 +133,7 @@ def _on_lambda_start_response(
131133 span : Span ,
132134 status_code : str ,
133135 response_headers : Dict [str , str ],
136+ response_body : Optional [Union [str , Dict [str , Any ]]],
134137):
135138 if not (asm_config ._asm_enabled and span .span_type in asm_config ._asm_http_span_types ):
136139 return
@@ -156,6 +159,10 @@ def _on_lambda_start_response(
156159
157160 _call_waf (("aws_lambda" ,))
158161
162+ if asm_config ._api_security_feature_active :
163+ if response_body :
164+ set_body_response (response_body )
165+
159166
160167# ASGI
161168
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ def on_span_start(self, span: Span) -> None:
189189 if skip_event :
190190 core .discard_item ("appsec_skip_next_lambda_event" )
191191 log .debug (
192- "appsec: ignoring unsupported lamdba event" ,
192+ "appsec: ignoring unsupported lambda event" ,
193193 )
194194 span .set_metric (APPSEC .UNSUPPORTED_EVENT_TYPE , 1.0 )
195195 return
Original file line number Diff line number Diff line change @@ -246,9 +246,8 @@ def __init__(self):
246246 self ._asm_processed_span_types .add (SpanTypes .SERVERLESS )
247247 self ._asm_http_span_types .add (SpanTypes .SERVERLESS )
248248
249- # As a first step, only Threat Management in monitoring mode should be enabled in AWS Lambda
249+ # Disable all features that are not supported in Lambda
250250 tracer_config ._remote_config_enabled = False
251- self ._api_security_enabled = False
252251 self ._ep_enabled = False
253252 self ._iast_supported = False
254253
You can’t perform that action at this time.
0 commit comments