Skip to content

Tag Vert.x server spans with _dd.appsec.normalized_route - #13724

Open
jandro996 wants to merge 10 commits into
masterfrom
APPSEC-72044
Open

jandro996 wants to merge 10 commits into
masterfrom
APPSEC-72044

Conversation

@jandro996

@jandro996 jandro996 commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What Does This Do

Sets the _dd.appsec.normalized_route span tag (RFC-1125) on Vert.x web server spans: Vert.x 3.x (vertx-web-3.4) and Vert.x 4.x and 5.x (vertx-web-4.0, which also handles 5.x at runtime). It is set next to http.route, only when AppSec is active and API Security is enabled, on top of the core from #13501 and #13518.

Declared route capture

  • RouteImpl.getPath() drops the trailing * (so /files/* and the exact /files/ look the same), and Vert.x has no public way to tell them apart before 4.0.2. The route is therefore taken from the path the application declared.
  • RouteSetPathAdvice: exit advice on the private RouteImpl.setPath(String). It stores the declared path in a ContextStore<Route, String> only when setPath did not throw. RouteSetRegexAdvice removes it when the route becomes a regex route (pathRegex).
  • RouteHandlerWrapperAdvice passes the store to RouteHandlerWrapper. In setRoute, inside the existing shouldUpdateRoute branch and right after withRoute, the wrapper calls VertxNormalizedRoute.tag(...) with the declared path, mountPoint(), normalisedPath() (3.x) or normalizedPath() (4.x/5.x), and pathParams(). The tagging is wrapped in try/catch with a debug log, and http.route is unchanged.

Vert.x route grammar (internal-api)

  • VertxRouteParser: tokenizer for Vert.x paths, next to SpringRouteParser:
    • :name params, several per segment (:id.:format, user-:id, :a-:b-:c).
    • Name grammars per version: LEGACY (3.x), DEFAULT (4.0.3+) and EXTENDED (-Dio.vertx.web.route.param.extended-pattern=true).
    • A trailing * becomes an unnamed catch-all.
    • Literals are percent-decoded, because Vert.x matches the encoded path (caf%C3%A9 renders caf%C3%A9).
    • Paths with params that contain live regex characters (? [ ] { } | ^ \, or a * that is not the last character) cannot be expressed, so they get no tag.
    • One lazily created 256-entry DDCache per grammar.
  • VertxNormalizedRoute: single entry point for both modules.
    • It clears the previous tag before recomputing, so a later route that cannot be expressed (for example a regex route after a /* middleware) never keeps an earlier route's value.
    • It builds the mount prefix from mountPoint().
    • It derives the catch-all presence from Vert.x's own matching: startsWith for routes without params, the [^/]+ segments of the compiled regex otherwise, with the mount joined as RouteState.pathMatches does. This gives RFC-1125 rows 39/49: /files for /files, /files/ for /files/, /files/{param1} for /files/a/b. The Vert.x * path param is never used: it does not exist in 3.x and its values are inverted in 4.0.3+.
    • No tag under a mount with params (3.8.2+), where mountPoint() holds the matched request values. No tag either when the static base ends inside a request segment.

Tests

  • internal-api (JUnit 5, @TableTest): VertxRouteParserTest, VertxRouteParserRfcVectorsTest (the RFC-1125 rows Vert.x syntax can express), VertxRouteParserCacheTest, VertxNormalizedRouteTest and VertxNormalizedRouteForkedTest.
  • Vert.x modules: Java tests run against real Vert.x servers on 3.4.0, 3.9.x, 4.0.0, 4.5.x, 5.0.0.CR3 and latest 5.x. They cover several params per segment, catch-all present / / / empty / //, sub-routers, a mount with params, regex routes, the stale-tag cases, an encoded literal, AppSec inactive, and API Security disabled (forked).
    • The vertx-web-4.0 tests are shared between test and latestDepTest through src/testNormalizedRoute.
  • The existing VertxHttpServerForkedTest bases (3.4, 4.0 test and latestDepTest, 5.0; vertx-rx-3.5 inherits from 3.4) override HttpServerTest.expectedNormalizedRoute, so every server suite asserts the tag.

Motivation

RFC-1125 (amends RFC-1103): normalized routes for API Security Testing. Follow-up of the Spring MVC (#13633) and WebFlux (#13635) integrations.

Additional Notes

  • http.route is unchanged. No change to the shared core classes in datadog.trace.api.appsec.route.
  • System-tests: tests/appsec/api_security_testing/test_normalized_route.py was validated locally with this branch on the vertx3 and vertx4 weblogs from [java] Add normalized route endpoints and enable RFC-1125 tests for Spring weblogs system-tests#8689: 25 passed, 2 skipped. test_param_names is irrelevant because Vert.x names cannot contain -. test_static_route cannot pass because the weblog declares /waf as a regex route, which has no normalized route. The manifest change enabling them comes after this PR.
  • Known limitations:
    • Vert.x 4.0.0 to 4.0.2 use the older name grammar. Param names that start with a digit or _ are read with the 4.0.3+ grammar there.
    • Two chained routes with the same http.route but different templates (/files/* middleware then /files/) keep the first route's tag, because the tag follows the http.route updates.
    • The detection of a mount with params is conservative: under a sub-router, a param left by an earlier middleware route (/:lang/*) drops the tag.
    • On 3.x, a regex-only route does not update http.route, so the previous middleware's http.route and normalized route both stay (a consistent pair).
    • pathRegex() followed by path() without : on the same route: Vert.x keeps matching with the regex, while the tag (and http.route) use the static path.
    • On 4.0.3+, if route.path(bad) throws after Vert.x updated its state and the application catches the exception, the stored declared path stays the previous one.
    • Routes with useNormalizedPath(false) still compute the catch-all presence from the normalized path.
    • The extended-pattern system property is read on the first tagged request (Vert.x reads it when RouteImpl is initialized).
    • Reconfiguring a route path while the server already serves traffic is not supported.
    • Under a mount with params, http.route still contains the matched request values (pre-existing). The normalized route is omitted there.
    • A mount point with an encoded / (%2F) gives no tag: the prefix is rendered decoded, so the %2F would become a separator.

Contributor Checklist

Jira ticket: APPSEC-72044

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@jandro996 jandro996 added type: feature Enhancements and improvements inst: vertx Eclipse Vert.x instrumentation comp: asm waf Application Security Management (WAF) labels Nov 27, 2026
@jandro996

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T20:41:56.158637Z 3e92aeb Draft marked ready
🔒 Security Review ✅ Completed 2026-11-27T20:41:56.499213Z 3e92aeb Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: cdfdce2ca6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: cdfdce2ca6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@jandro996
jandro996 marked this pull request as ready for review November 27, 2026 20:37
@jandro996
jandro996 requested review from a team as code owners November 27, 2026 20:37
@jandro996
jandro996 requested review from claponcet, jordan-wong, manuel-alvarez-alvarez and sarahchen6 and removed request for a team November 27, 2026 20:37
@datadog-datadog-prod-us1-2

This comment has been minimized.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: WARN

Isolated rendering admits a request-valued mount prefix when parameter names overlap and changes an encoded slash into a separator. Both remain conditional concerns because their real Vert.x input shapes could not be confirmed.

Open Bits AI session

🤖 Bits Code Review · Commit 3e92aeb

@dd-octo-sts

dd-octo-sts Bot commented Nov 27, 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 14.86 s 14.83 s [-0.6%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 13.74 s 13.79 s [-1.0%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.25 s 17.18 s [-0.6%; +1.4%] (no difference)
startup:petclinic:iast:Agent 17.14 s 17.19 s [-1.1%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.82 s 16.87 s [-1.5%; +0.9%] (no difference)
startup:petclinic:sca:Agent 17.27 s 17.21 s [-0.6%; +1.4%] (no difference)
startup:petclinic:tracing:Agent 16.32 s 16.27 s [-0.7%; +1.4%] (no difference)

Commit: 7964e1e3 · 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.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: PASS

More details

The PR adds AppSec normalized-route tags for Vert.x 3–5 while preserving http.route. Vert.x validation rules out the duplicate-name concern, and encoded-slash mounts now omit the tag before decoding, resolving the remaining concern and leaving no open findings.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 7964e1e

This branch has not been deployed

No deployments
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) inst: vertx Eclipse Vert.x instrumentation type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant