Skip to content

Skip AppSec for non-HTTP Lambda triggers and report _dd.appsec.unsupported_event_type - #12247

Open
claponcet wants to merge 2 commits into
masterfrom
clara.poncet/lambda-appsec-unsupported-event-type
Open

Skip AppSec for non-HTTP Lambda triggers and report _dd.appsec.unsupported_event_type#12247
claponcet wants to merge 2 commits into
masterfrom
clara.poncet/lambda-appsec-unsupported-event-type

Conversation

@claponcet

@claponcet claponcet commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Emits _dd.appsec.unsupported_event_type for Lambda requests that are not HTTP/HTTP-like requests.

  • LambdaAppSecHandler.processRequestStart now 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.processRequestEnd sets the numeric span metric _dd.appsec.unsupported_event_type = 1 on 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 returns LambdaRequestData.EMPTY.

Motivation

Before this change, an unrecognised Lambda event was still fed to the WAF on whatever method / path / headers could be scraped from an arbitrary payload — best-effort scanning of data that is not an HTTP request. dd-trace-py (_processor.py, via datadog_lambda/asm.py) and datadog-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 (scenario appsec_lambda_default) treats the metric as the sanctioned opt-out: a serverless span carrying it is exempted from the _dd.appsec.enabled / _dd.runtime_family assertions.

Additional Notes

  • The metric is written at request end rather than request start because processRequestStart runs before the invocation span exists, and a value carried through TagContext would land in meta as a string rather than in metrics.
  • A genuinely-HTTP event whose shape detectTriggerType fails to recognise now loses best-effort coverage instead of degrading to it — matching Python and JS, and making the span state honest.
  • One pre-existing test expectation changed: responseCallbacksSkipNonApiGatewayResponseForNonHttpEvent asserted appSecEnded for a non-HTTP event; with the skip there is no request context to end.

Contributor Checklist

🤖 Generated with Claude Code

…orted_event_type

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@claponcet claponcet added tag: ai generated Largely based on code generated by an AI or LLM comp: asm waf Application Security Management (WAF) tag: serverless Serverless support type: feature Enhancements and improvements labels Aug 20, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 75.00%
Overall Coverage: 58.87% (+0.28%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2ffcab5 | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.88 s 13.91 s [-0.8%; +0.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 12.94 s [-0.8%; +0.8%] (no difference)
startup:petclinic:appsec:Agent 17.02 s 16.82 s [+0.0%; +2.3%] (maybe worse)
startup:petclinic:iast:Agent 16.98 s 16.95 s [-0.7%; +1.0%] (no difference)
startup:petclinic:profiling:Agent 16.75 s 16.77 s [-1.2%; +1.0%] (no difference)
startup:petclinic:sca:Agent 16.66 s 16.60 s [-0.4%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.11 s 16.16 s [-1.0%; +0.4%] (no difference)

Commit: 2ffcab51 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@claponcet

Copy link
Copy Markdown
Contributor Author

@codex review

@claponcet claponcet added the tag: no release notes Changes to exclude from release notes label Aug 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread dd-trace-core/src/main/java/datadog/trace/lambda/LambdaAppSecHandler.java Outdated
Comment thread dd-trace-core/src/main/java/datadog/trace/lambda/LambdaAppSecHandler.java Outdated
…equest start

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@claponcet
claponcet force-pushed the clara.poncet/lambda-appsec-unsupported-event-type branch from bc45b37 to 2ffcab5 Compare August 20, 2026 15:43
@claponcet
claponcet marked this pull request as ready for review August 20, 2026 15:44
@claponcet
claponcet requested a review from a team as a code owner August 20, 2026 15:44
@claponcet
claponcet requested a review from jandro996 August 20, 2026 15:45

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: FAIL

A non-HTTP Lambda handler that throws does not run AppSec request-end processing. Its error span therefore lacks the unsupported-event metric.

Open Bits AI session

🤖 Datadog Autotest · Commit 2ffcab5 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: asm waf Application Security Management (WAF) tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes tag: serverless Serverless support type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant