Repository navigation
chore(layer): minify the App and API Protection rules file - #904
Merged
Merged
Conversation
ddtrace/appsec/rules.json ships pretty-printed (454 kB). ddtrace hands the file's bytes to libddwaf, which parses the JSON, so minifying it changes nothing at runtime and saves ~175 kB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
More details
The focused command check supports JSON minification without changing parsed content, and the static reviewer reported no actionable defects. Full layer-build and AppSec integration validation were not rerun.
🤖 Bits Code Review · Commit a6aa08c
purple4reina
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Rewrites
ddtrace/appsec/rules.jsonin the layer as minified JSON.Motivation
The rules file ships pretty-printed: 454 kB, 278 kB minified.
AppSecSpanProcessorreads the file as bytes and passes them to libddwaf, which parses the JSON, so whitespace makes no difference at runtime. A smaller file is also less to read on cold start. This is part of keeping the layer under the size check without raising the budget (see #901, #902, #903).DD_APPSEC_RULESstill points at a user's own file, which this doesn't touch.Results (Python 3.15, amd64, dd-trace-py main pipeline 157654945)
Testing Guidelines
UPSTREAM_PIPELINE_ID=157654945 PYTHON_VERSION=3.15 ARCH=amd64 ./scripts/build_layers.shand rancheck_layer_size.sh(numbers above).public.ecr.aws/sam/build-python3.15:1against this layer and against main. It sends an API Gateway event with a scanner User-Agent and a path-traversal query throughdatadog_lambda.handler, withDD_APPSEC_ENABLED=true. Both layers report WAF 2.2.1, rules 1.20.0,_dd.appsec.event_rules.loaded=224,error_count=0, andappsec.event=trueon theaws.lambdaspan.Types of Changes
Check all that apply
🤖 Generated with Claude Code