Skip AppSec for non-HTTP Lambda triggers and report _dd.appsec.unsupported_event_type - #12247
Skip AppSec for non-HTTP Lambda triggers and report _dd.appsec.unsupported_event_type#12247claponcet wants to merge 2 commits into
Conversation
…orted_event_type Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🎯 Code Coverage (details) 🔗 Commit SHA: 2ffcab5 | Docs | View more details | Give us feedback! |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab36aee085
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…equest start Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bc45b37 to
2ffcab5
Compare
There was a problem hiding this comment.
A non-HTTP Lambda handler that throws does not run AppSec request-end processing. Its error span therefore lacks the unsupported-event metric.
🤖 Datadog Autotest · Commit 2ffcab5 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
What Does This Do
Emits
_dd.appsec.unsupported_event_typefor Lambda requests that are not HTTP/HTTP-like requests.LambdaAppSecHandler.processRequestStartnow returns early (with a debug log) for any trigger the parser does not recognise as HTTP, so no WAF request callback fires and no AppSec request context is created.LambdaAppSecHandler.processRequestEndsets the numeric span metric_dd.appsec.unsupported_event_type = 1on those invocations, so the span explicitly reports that AppSec did not process it. The metric is only emitted when AppSec is active.LambdaEventParser.isHttp()becomes an explicit whitelist of the five HTTP trigger types, so any trigger type added later defaults to non-HTTP until it is deliberately listed.LambdaEventParser.extractGenericData(~60 lines) is removed: with the skip in place, its result was never consumed.parseEvent's default branch now returnsLambdaRequestData.EMPTY.Motivation
Before this change, an unrecognised Lambda event was still fed to the WAF on whatever
method/path/headerscould be scraped from an arbitrary payload — best-effort scanning of data that is not an HTTP request.dd-trace-py(_processor.py, viadatadog_lambda/asm.py) anddatadog-lambda-js(src/appsec/index.ts) both skip AppSec entirely in that case and mark the span with_dd.appsec.unsupported_event_type. The metric is tracer-side only; the Lambda extension does not emit it.system-tests
Test_AppSecEventSpanTags::test_custom_span_tags(scenarioappsec_lambda_default) treats the metric as the sanctioned opt-out: aserverlessspan carrying it is exempted from the_dd.appsec.enabled/_dd.runtime_familyassertions.Additional Notes
processRequestStartruns before the invocation span exists, and a value carried throughTagContextwould land inmetaas a string rather than inmetrics.detectTriggerTypefails to recognise now loses best-effort coverage instead of degrading to it — matching Python and JS, and making the span state honest.responseCallbacksSkipNonApiGatewayResponseForNonHttpEventassertedappSecEndedfor a non-HTTP event; with the skip there is no request context to end.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue🤖 Generated with Claude Code