Skip to content

[EXPERIMENTAL] AppSec snapshot generation with unreleased tracer#147

Draft
Strech wants to merge 18 commits into
mainfrom
experimental/appsec-snapshot-generation
Draft

[EXPERIMENTAL] AppSec snapshot generation with unreleased tracer#147
Strech wants to merge 18 commits into
mainfrom
experimental/appsec-snapshot-generation

Conversation

@Strech
Copy link
Copy Markdown
Member

@Strech Strech commented May 7, 2026

⚠️ Experimental — do not merge

Combines PR #144 (AppSec setup) with PR #146 (build layer from dd-trace-rb branch) to test snapshot generation with unreleased tracer code.

What's here

How to use

  1. Go to Actions → "update-snapshots" → Run workflow
  2. Select this branch
  3. Set git_ref to the dd-trace-rb branch with AppSec aws_lambda instrumentation
  4. Download snapshot artifacts when complete

🤖 Generated with Claude Code

Strech and others added 18 commits April 30, 2026 20:07
Initialize AppSec context around each Lambda invocation, push request and
response events through the AppSec gateway, and record security events on
the aws.lambda span. The extension handles tag propagation to inferred spans.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adding an Exclude key overrides rubocop's default excludes, which
includes vendor/**. Re-add it explicitly so CI lint passes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Precompiled FFI binaries have glibc mismatch with Lambda AL2 runtime,
causing crashes when AppSec loads the libddwaf chain. Force source
compilation and remove precompiled variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add appsec-request handler with DD_APPSEC_ENABLED=true and an input
event containing Arachni user-agent to trigger WAF detection. Snapshots
will be recorded on first AWS deploy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wrap gateway pushes in catch(Datadog::AppSec::Ext::INTERRUPT) in both
on_start and on_finish. When WAF decides to block, build a Lambda-shaped
response override (statusCode/headers/body) via AppSec::Response.

The listener exposes response_override for wrap to short-circuit the
handler on request-phase blocks or replace the response on response-phase
blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Normalize raw AWS event payloads into a standard key set before
passing to DataContainer and Request. This removes v1/v2 detection
from Request and aligns with dd-trace-rb's simplified WAFAddresses
that consume standard keys.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
V2 events were missing the `query` key, causing `server.request.query`
WAF address to be empty for API Gateway V2 payloads.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename add_appsec_tags to tag_and_keep, move from create_context to
  on_start for visibility
- Pass cold_start flag from listener through to AppSec.on_start instead
  of tracking @oneshot_tags_sent module state
- Align guard clause with Rack: return unless trace && span
- Improve test quality: inline event values, use receive_messages,
  remove instance_variable_set for @request, relax unrelated assertions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The layer was built on ruby:X.Y (Debian Bookworm) which has libffi.so.8,
but Lambda AL2 runtime only has libffi.so.6. Source-compiled FFI linked
against .so.8 and crashed at runtime.

Switch to public.ecr.aws/lambda/ruby:X.Y as builder so native extensions
compile against the same system libraries available at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ruby 3.2 uses AL2 with yum, Ruby 3.3+ uses AL2023 with dnf.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants