Skip to content

fix(contrib/go-chi): set the AppSec route and path params after chi routing - #5847

Draft
RomainMuller wants to merge 23 commits into
mainfrom
romain.marcadier/chi-appsec-route
Draft

RomainMuller wants to merge 23 commits into
mainfrom
romain.marcadier/chi-appsec-route

Conversation

@RomainMuller

@RomainMuller RomainMuller commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the AppSec route and path parameters of contrib/go-chi/chi.v5 and contrib/go-chi/chi when Middleware() is added with Use before routing:

  • Reports the route that chi selected (the http.route value) to AppSec; it was empty.
  • Before the handler, asks chi which route matches (Routes.Match) and gives its path parameters to the WAF.
  • After the handler, calls httpsec.RouteMatched with the final route and parameters, guarded by an input shared by all tracers of the request.
  • Adds a commit tracker: a block never adds its body after a response that is already sent.

Motivation

APPSEC-69059. api_security.missing_route counted almost every 2xx chi request, and all endpoints shared 1 API Security sampling key per method and status.

Behavior changes

  • Path-parameter rules can block before the handler when the early check finds the route.
  • After the handler, a block or a redirect replaces the response only if it is not sent yet; it never stops the handler.
  • On a sent response (written, flushed, hijacked), a block is reported as block_failure:true; a redirect is not a block.
  • With AppSec on, Status() returns 200 after Flush() without WriteHeader (chi reports 0); the span status does not change.
  • The writer has a FlushError() method only if chi's writer has no Flush() but a writer under it can flush.

Known limits

  • The early check can use other parameters than the handler gets (path rewrites, wrapped mounts); a wrong detection can hide a later same-type rule.
  • A rule can match a predicted value and a final value across 2 WAF runs (main 200, this PR 403).
  • A tracer hidden by both the writer chain and the request context can lose a block that works today (main 403, this PR 200).
  • AppSec cannot clear parameters; other AppSec integrations that give path parameters are not covered.
  • A middleware that writes or flushes must come after the tracer; a hidden writer plus a flush can still add a block body.

Details and the writer contract: Middleware godoc.

Notes for the API Security team

  • Expect more schemas from chi services after they upgrade: 1 sampling key per endpoint, and _dd.appsec.s.req.params.
  • With DD_APM_TRACING_ENABLED=false, at most 1 kept trace per (method, route, status) every 30 s per process.
  • Expect api_security.missing_route for chi to fall to almost 0.
  • Expect more waf.requests with request_blocked:true (early blocks) and block_failure:true.

How to review

  1. chi.v5/chi.go: reportedRoute and the Middleware godoc.
  2. */appsec.go: early lookup, shared input, late RouteMatched.
  3. */writer_appsec.go, make_writer_appsec.go: the commit tracker (generated types).
  4. *_appsec_test.go: route per setup, real server and WAF, preservation of existing blocks.

Tests and benchmarks

  • The new tests fail at 65148c8b2, except the guards for behavior that must not change and the documented limits.
  • 18 mutations of the new code each fail tests in both packages.
  • Run go test ./... in both modules; go generate leaves no diff.

Allocations per request, main vs this PR (benchstat, 10 runs):

Benchmark Allocs
route with 2 parameters +26%
route without parameters +2.5%
4 nested routers, each with the tracer +24%

Times are noisy on the machine used; allocations are the reliable numbers.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag. (Not added in this PR.)
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

…r chi routing

With r.Use(Middleware()) before routing, AppSec read the route and the path
parameters before chi routed the request. Look the route up before the handler,
run the WAF again with the final route and parameters after it, and track when
the response is sent.
@github-actions github-actions Bot added the apm:ecosystem contrib/* related feature requests or bugs label Nov 9, 2026
…hi routing

The same change as for chi.v5: look the route up before the handler, run the
WAF with the final route and parameters after it, and track when the response
is sent.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Config Audit

PACKAGE: contrib/cloud.google.com/go/pubsubtrace
  STATUS      CONFIG                                            CALL_SITES
  UNMIGRATED  DD_GOOGLE_CLOUD_PUBSUB_PROPAGATION_AS_SPAN_LINKS  1

PACKAGE: contrib/confluentinc/confluent-kafka-go/kafkatrace
  STATUS      CONFIG                            CALL_SITES
  UNMIGRATED  DD_TRACE_KAFKA_ANALYTICS_ENABLED  1

PACKAGE: crashtracker
  STATUS      CONFIG                    CALL_SITES
  STILL_READ  DD_API_KEY                1
  STILL_READ  DD_SITE                   1
  STILL_READ  DD_TAGS                   1
  UNMIGRATED  DD_CRASHTRACKING_ENABLED  1

PACKAGE: ddtrace/opentelemetry/log
  STATUS      CONFIG                    CALL_SITES
  STILL_READ  DD_ENV                    1
  STILL_READ  DD_SERVICE                1
  STILL_READ  DD_TAGS                   1
  STILL_READ  DD_TRACE_REPORT_HOSTNAME  1
  STILL_READ  DD_VERSION                1
  UNMIGRATED  DD_HOSTNAME               1
  UNMIGRATED  OTEL_RESOURCE_ATTRIBUTES  1
  UNMIGRATED  OTEL_SERVICE_NAME         1

PACKAGE: ddtrace/opentelemetry/metric
  STATUS      CONFIG                    CALL_SITES
  STILL_READ  DD_ENV                    1
  STILL_READ  DD_METRICS_OTEL_ENABLED   1
  STILL_READ  DD_SERVICE                1
  STILL_READ  DD_TAGS                   1
  STILL_READ  DD_TRACE_REPORT_HOSTNAME  1
  STILL_READ  DD_VERSION                1
  STILL_READ  OTEL_METRICS_EXPORTER     1
  UNMIGRATED  DD_HOSTNAME               1
  UNMIGRATED  OTEL_RESOURCE_ATTRIBUTES  1
  UNMIGRATED  OTEL_SERVICE_NAME         1

PACKAGE: ddtrace/tracer
  STATUS      CONFIG                                    CALL_SITES
  STILL_READ  DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT     1
  STILL_READ  DD_TRACE_PROPAGATION_EXTRACT_FIRST        1
  STILL_READ  DD_TRACE_PROPAGATION_STYLE_EXTRACT        1
  STILL_READ  DD_TRACE_PROPAGATION_STYLE_INJECT         1
  UNMIGRATED  DD_APM_TRACING_ENABLED                    1
  UNMIGRATED  DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED  1
  UNMIGRATED  DD_TRACE_DEBUG_SEELOG_WORKAROUND          1
  UNMIGRATED  OTEL_TRACES_SAMPLER_ARG                   1

PACKAGE: instrumentation
  STATUS      CONFIG                                       CALL_SITES
  STILL_READ  DD_DATA_STREAMS_ENABLED                      1
  UNMIGRATED  DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED  1

PACKAGE: instrumentation/graphql
  STATUS      CONFIG                             CALL_SITES
  UNMIGRATED  DD_TRACE_GRAPHQL_ERROR_EXTENSIONS  1

PACKAGE: instrumentation/httptrace
  STATUS      CONFIG                                                 CALL_SITES
  UNMIGRATED  DD_GOOGLE_CLOUD_PUBSUB_PROPAGATION_AS_SPAN_LINKS       1
  UNMIGRATED  DD_HTTP_SERVER_TAG_QUERY_STRING_SIZE                   1
  UNMIGRATED  DD_TRACE_BAGGAGE_TAG_KEYS                              1
  UNMIGRATED  DD_TRACE_CLIENT_IP_ENABLED                             1
  UNMIGRATED  DD_TRACE_HTTP_SERVER_ERROR_STATUSES                    1
  UNMIGRATED  DD_TRACE_HTTP_URL_QUERY_STRING_ALLOWLIST               1
  UNMIGRATED  DD_TRACE_HTTP_URL_QUERY_STRING_ALLOWLIST_CLIENT        1
  UNMIGRATED  DD_TRACE_HTTP_URL_QUERY_STRING_ALLOWLIST_SERVER        1
  UNMIGRATED  DD_TRACE_HTTP_URL_QUERY_STRING_DISABLED                1
  UNMIGRATED  DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED               1
  UNMIGRATED  DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP               2
  UNMIGRATED  DD_TRACE_RESOURCE_RENAMING_ALWAYS_SIMPLIFIED_ENDPOINT  1
  UNMIGRATED  DD_TRACE_RESOURCE_RENAMING_ENABLED                     1

PACKAGE: instrumentation/internal/namingschema
  STATUS      CONFIG                                             CALL_SITES
  STILL_READ  DD_SERVICE                                         1
  UNMIGRATED  DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED  1

PACKAGE: internal
  STATUS      CONFIG                         CALL_SITES
  STILL_READ  DD_AGENT_HOST                  1
  STILL_READ  DD_TAGS                        1
  STILL_READ  DD_TRACE_AGENT_PORT            1
  STILL_READ  DD_TRACE_AGENT_URL             1
  UNMIGRATED  DD_EXTERNAL_ENV                1
  UNMIGRATED  DD_GIT_COMMIT_SHA              1
  UNMIGRATED  DD_GIT_REPOSITORY_URL          1
  UNMIGRATED  DD_TRACE_GIT_METADATA_ENABLED  1

PACKAGE: internal/appsec
  STATUS      CONFIG           CALL_SITES
  UNMIGRATED  DD_APPSEC_RULES  1

PACKAGE: internal/appsec/config
  STATUS      CONFIG                                                CALL_SITES
  UNMIGRATED  DD_API_SECURITY_DOWNSTREAM_BODY_ANALYSIS_SAMPLE_RATE  1
  UNMIGRATED  DD_API_SECURITY_ENABLED                               1
  UNMIGRATED  DD_API_SECURITY_MAX_DOWNSTREAM_REQUEST_BODY_ANALYSIS  1
  UNMIGRATED  DD_API_SECURITY_PROXY_SAMPLE_RATE                     1
  UNMIGRATED  DD_API_SECURITY_REQUEST_SAMPLE_RATE                   1
  UNMIGRATED  DD_API_SECURITY_SAMPLE_DELAY                          1
  UNMIGRATED  DD_APM_TRACING_ENABLED                                1
  UNMIGRATED  DD_APPSEC_AGENTIC_ONBOARDING                          1
  UNMIGRATED  DD_APPSEC_DISABLE_FEATURES                            1
  UNMIGRATED  DD_APPSEC_ENABLED                                     2
  UNMIGRATED  DD_APPSEC_MAX_STACK_TRACE_DEPTH                       1
  UNMIGRATED  DD_APPSEC_RASP_ENABLED                                1
  UNMIGRATED  DD_APPSEC_RULES                                       1
  UNMIGRATED  DD_APPSEC_SCA_ENABLED                                 1
  UNMIGRATED  DD_APPSEC_STACK_TRACE_ENABLED                         1
  UNMIGRATED  DD_APPSEC_TRACE_RATE_LIMIT                            1
  UNMIGRATED  DD_APPSEC_WAF_TIMEOUT                                 1

PACKAGE: internal/bazel
  STATUS      CONFIG                                  CALL_SITES
  UNMIGRATED  DD_TEST_OPTIMIZATION_MANIFEST_FILE      1
  UNMIGRATED  DD_TEST_OPTIMIZATION_PAYLOADS_IN_FILES  1

PACKAGE: internal/civisibility/envconfig
  STATUS      CONFIG                   CALL_SITES
  STILL_READ  DD_CIVISIBILITY_ENABLED  1

PACKAGE: internal/civisibility/integrations
  STATUS      CONFIG                                               CALL_SITES
  STILL_READ  DD_SERVICE                                           1
  STILL_READ  DD_TRACE_DEBUG                                       1
  UNMIGRATED  DD_CIVISIBILITY_CODE_COVERAGE_REPORT_UPLOAD_ENABLED  1
  UNMIGRATED  DD_CIVISIBILITY_DYNAMIC_ATR_BUCKETS                  1
  UNMIGRATED  DD_CIVISIBILITY_DYNAMIC_ATR_ENABLED                  1
  UNMIGRATED  DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED        1
  UNMIGRATED  DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_MAX_RETRIES    1
  UNMIGRATED  DD_CIVISIBILITY_FLAKY_RETRY_COUNT                    1
  UNMIGRATED  DD_CIVISIBILITY_FLAKY_RETRY_ENABLED                  1
  UNMIGRATED  DD_CIVISIBILITY_GIT_UPLOAD_ENABLED                   1
  UNMIGRATED  DD_CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED     1
  UNMIGRATED  DD_CIVISIBILITY_SUBTEST_FEATURES_ENABLED             1
  UNMIGRATED  DD_CIVISIBILITY_TOTAL_FLAKY_RETRY_COUNT              1
  UNMIGRATED  DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES            1
  UNMIGRATED  DD_TEST_MANAGEMENT_ENABLED                           1

PACKAGE: internal/civisibility/integrations/gotesting
  STATUS      CONFIG                                                           CALL_SITES
  UNMIGRATED  DD_CIVISIBILITY_INTERNAL_PARALLEL_EARLY_FLAKE_DETECTION_ENABLED  2
  UNMIGRATED  DD_CIVISIBILITY_RETRY_EXECUTION_MODE                             1
  UNMIGRATED  DD_CIVISIBILITY_RETRY_PROCESS_MAX_CONCURRENCY                    1
  UNMIGRATED  DD_CIVISIBILITY_RETRY_PROCESS_TIMEOUT                            1
  UNMIGRATED  DD_TEST_MANAGEMENT_ENABLED                                       2

PACKAGE: internal/civisibility/integrations/logs
  STATUS      CONFIG                        CALL_SITES
  UNMIGRATED  DD_CIVISIBILITY_LOGS_ENABLED  1

PACKAGE: internal/civisibility/utils
  STATUS      CONFIG                              CALL_SITES
  STILL_READ  DD_SERVICE                          1
  UNMIGRATED  DD_ACTION_EXECUTION_ID              1
  UNMIGRATED  DD_PIPELINE_EXECUTION_ID            1
  UNMIGRATED  DD_TEST_OPTIMIZATION_ENV_DATA_FILE  1
  UNMIGRATED  DD_TEST_SESSION_NAME                1

PACKAGE: internal/civisibility/utils/net
  STATUS      CONFIG                             CALL_SITES
  STILL_READ  DD_API_KEY                         1
  STILL_READ  DD_CIVISIBILITY_AGENTLESS_ENABLED  1
  STILL_READ  DD_CIVISIBILITY_AGENTLESS_URL      1
  STILL_READ  DD_ENV                             1
  STILL_READ  DD_SERVICE                         1
  STILL_READ  DD_SITE                            1
  STILL_READ  DD_TAGS                            1
  STILL_READ  DD_VERSION                         1
  UNMIGRATED  DD_CODE_COVERAGE_FLAGS             1

PACKAGE: internal/civisibility/utils/telemetry
  STATUS      CONFIG                                         CALL_SITES
  UNMIGRATED  DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER  1

PACKAGE: internal/clientip
  STATUS      CONFIG                     CALL_SITES
  UNMIGRATED  DD_TRACE_CLIENT_IP_HEADER  1

PACKAGE: internal/globalconfig
  STATUS      CONFIG                           CALL_SITES
  UNMIGRATED  DD_INSTRUMENTATION_INSTALL_ID    1
  UNMIGRATED  DD_INSTRUMENTATION_INSTALL_TIME  1
  UNMIGRATED  DD_INSTRUMENTATION_INSTALL_TYPE  1

PACKAGE: internal/hostname
  STATUS      CONFIG       CALL_SITES
  UNMIGRATED  DD_HOSTNAME  1

PACKAGE: internal/namingschema
  STATUS      CONFIG                                             CALL_SITES
  UNMIGRATED  DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED  1

PACKAGE: internal/processtags
  STATUS      CONFIG                                          CALL_SITES
  UNMIGRATED  DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED  1

PACKAGE: internal/remoteconfig
  STATUS      CONFIG                                  CALL_SITES
  STILL_READ  DD_ENV                                  1
  UNMIGRATED  DD_RC_TUF_ROOT                          1
  UNMIGRATED  DD_REMOTE_CONFIGURATION_ENABLED         1
  UNMIGRATED  DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS  1

PACKAGE: internal/telemetry
  STATUS      CONFIG                                             CALL_SITES
  STILL_READ  DD_API_KEY                                         1
  STILL_READ  DD_SITE                                            1
  UNMIGRATED  DD_API_SECURITY_ENDPOINT_COLLECTION_MESSAGE_LIMIT  1
  UNMIGRATED  DD_INSTRUMENTATION_TELEMETRY_ENABLED               1
  UNMIGRATED  DD_TELEMETRY_DEBUG                                 1
  UNMIGRATED  DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED         1
  UNMIGRATED  DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL           1
  UNMIGRATED  DD_TELEMETRY_HEARTBEAT_INTERVAL                    1
  UNMIGRATED  DD_TELEMETRY_LOG_COLLECTION_ENABLED                1
  UNMIGRATED  DD_TELEMETRY_METRICS_ENABLED                       1

PACKAGE: openfeature
  STATUS      CONFIG                                                     CALL_SITES
  STILL_READ  DD_ENV                                                     2
  STILL_READ  DD_SERVICE                                                 2
  STILL_READ  DD_VERSION                                                 2
  UNMIGRATED  DD_EXPERIMENTAL_FLAGGING_PROVIDER_SPAN_ENRICHMENT_ENABLED  1
  UNMIGRATED  DD_FLAGGING_EVALUATION_COUNTS_ENABLED                      1

PACKAGE: profiler
  STATUS      CONFIG                                    CALL_SITES
  STILL_READ  DD_API_KEY                                1
  STILL_READ  DD_ENV                                    1
  STILL_READ  DD_SERVICE                                1
  STILL_READ  DD_SITE                                   1
  STILL_READ  DD_TAGS                                   1
  STILL_READ  DD_TRACE_STARTUP_LOGS                     1
  STILL_READ  DD_VERSION                                1
  UNMIGRATED  DD_PROFILING_AGENTLESS                    1
  UNMIGRATED  DD_PROFILING_DEBUG_COMPRESSION_SETTINGS   1
  UNMIGRATED  DD_PROFILING_DELTA                        1
  UNMIGRATED  DD_PROFILING_ENABLED                      3
  UNMIGRATED  DD_PROFILING_ENDPOINT_COUNT_ENABLED       1
  UNMIGRATED  DD_PROFILING_EXECUTION_TRACE_ENABLED      1
  UNMIGRATED  DD_PROFILING_EXECUTION_TRACE_LIMIT_BYTES  1
  UNMIGRATED  DD_PROFILING_EXECUTION_TRACE_PERIOD       1
  UNMIGRATED  DD_PROFILING_FLUSH_ON_EXIT                1
  UNMIGRATED  DD_PROFILING_OUTPUT_DIR                   1
  UNMIGRATED  DD_PROFILING_UPLOAD_TIMEOUT               1
  UNMIGRATED  DD_PROFILING_URL                          1

@datadog-official

datadog-official Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Tests  Pipelines

⚠️ Warnings

Your PR has warnings. Please review the issues below.

❄️ 2 New flaky tests detected

TestAppSecWireCompress from github.com/DataDog/dd-trace-go/contrib/go-chi/chi/v2
Failed

=== RUN   TestAppSecWireCompress
--- FAIL: TestAppSecWireCompress (0.01s)
TestAppSecWireCompress/hidden-parent-early-H from github.com/DataDog/dd-trace-go/contrib/go-chi/chi/v2
Failed

=== RUN   TestAppSecWireCompress/hidden-parent-early-H
    wire_appsec_test.go:777: 
        	Error Trace:	/Users/runner/work/dd-trace-go/dd-trace-go/contrib/go-chi/chi/wire_appsec_test.go:777
        	Error:      	"   does not contain "{\"errors\":"
        	Test:       	TestAppSecWireCompress/hidden-parent-early-H
        	Messages:   	documented limit (this exists without this change)
    --- FAIL: TestAppSecWireCompress/hidden-parent-early-H (0.01s)

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🎯 Code Coverage (details)
• Patch Coverage: 98.39%
• Overall Coverage: 74.98% (+1.11%)

Useful? React with 👍 / 👎

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

@dd-octo-sts dd-octo-sts Bot mentioned this pull request Nov 9, 2026
…tatus of a flushed response

Address the review of the first version:
- the early lookup adds to the path parameters that chi already knows when the
  tracer runs, and never replaces them (except the "*" of a mount), so a block
  that works without the lookup still works when a middleware rewrites the route
  path before a tracer in a mount with a parameter;
- Status() keeps the status of the first successful flush, also when the
  handler calls WriteHeader after a flush that bypassed chi's writer;
- go generate fails when the generator fails;
- godoc: failed flush, ordinary mounts and parameters that AppSec cannot remove;
- tests: same-type rules for chi v1, panic without late run, raw and empty path,
  concurrent requests, bounded cycle, HTTP/2 check, stale parameters.
…utes chi matched

The merge of the known parameters (previous commit) had edge cases with
duplicate names and catch-all routes. Use a simpler rule: a prediction that does
not extend the route patterns that chi already matched contradicts chi (a
parent mount was routed with a changed route path), so keep what chi matched, as
before the lookup existed. Also add the same-type rule tests to chi v1.
…h the lookup

Same route patterns do not mean the same parameters: a parent that rewrites the
route path can route a mount with another value of its parameter. Drop the
prediction when the parameters of the patterns that chi matched differ. Document
the handling of the mount wildcard.
…y matched

Round 1 of the review found requests that AppSec blocked before the lookup
existed and that were not blocked anymore:
- a name used at several mount levels: the prediction (last value) replaced the
  value that chi matched; chi.v5 also changed its early read from the first to
  the last value;
- r.With(Middleware()).Mount: the lookup reset the "*" of the mount before the
  rule could check it.
The early parameters are now the ones that chi matched (first value for chi.v5, as
before). The prediction only adds names; if it has another value for a known
name, it is dropped. The known "*" stays. The final report keeps the last value.

Add the preservation tests, the missing assertions of the review (missing_route
after a panic, route and server log of the hidden-parent rows, the methods of
the 24 tracker types) and a benchmark with 4 nested tracers and a long path.
… chi matched

Round 2 of the review found 2 cases where a rule that does not block on main
blocked, or a rule that blocks on main did not:
- the late run replaced a parameter that chi matched before the handler (a name
  used at several mount levels), so a rule with a condition on the response
  header first lost its match, and the WAF mixed the 2 values across the runs;
- the early check kept the known '*' of a mount and added the names of the
  lookup, a set that chi never has.
The late run now adds the final parameters to the known ones, and reports only
the route when they contradict them. The known '*' is a contradiction too.

Add the compatibility tests, the Push call check and the godoc.
…ers of a request

An outer tracer reported its final parameters after the inner tracer returned and
replaced the value that the inner tracer kept (the same value as on main), so a
response rule lost its match. All the tracers of a request now share the path
parameters that AppSec gave to the WAF as baseline input: a late run or an early
prediction that contradicts a value in it reports only the route; a tracer still
adds new names. A tracker that cannot reach the shared input of the outer tracers
(the writer chain reaches an outer tracker but the request context does not)
gives no new parameters.

Add the nested tests and the shared input tests.
…acer cannot share it

A tracer that finds an outer tracer through the writer chain but not through the
request context cannot share the baseline input of the outer tracers, but it
still gives its known parameters to their WAF context. The outer late runs did
not know it and could replace the value that it kept. Such a tracer now marks the
shared input of the outer tracers that it finds (through the writer chain and the
request context) as uncertain; they report only their route. The tracer itself
keeps giving its known parameters.

Document that baseline input is replaced at tracer entry and that predictions
are not recorded, and that a rule can still match a predicted and a final value
across 2 runs. Add the restored-context test and TestPredictionPhaseCombination.
The guard protects the baseline input that is already known when a late update
happens. Document that it cannot undo an earlier WAF match (a later tracer that
replaces the baseline input or sets the flag), that a tracer hidden through both
the writer chain and the request context cannot be flagged, and that other AppSec
integrations are not covered. Add the tests that document the first two limits.
… tests

The gzip bytes of a small body depend on the Go version (go1.27 can store the
body, go1.26 compresses it), so a test that looks for plain text in the body
failed on CI. A client does not decompress a body that was flushed before the
Content-Encoding header. Decompress the body when it is a gzip stream, and
check the documented behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant