Repository navigation
Conversation
Set the RFC-1125 normalized route next to http.route on the netty and
ratpack.handler spans when AppSec is active and API Security is enabled.
- RatpackRouteParser (internal-api) turns PathBinding.getDescription(),
which already holds the whole prefix(...) chain, into a RouteTemplate:
:name, :name? (optional), :name:regex and :name?:regex (regex removed),
::regex (unnamed), literals percent-decoded since Ratpack matches the
raw path. prefix(x){all{}} reached with an unconsumed rest renders a
trailing unnamed catch-all; the join slash of get("") under a prefix is
not a declared trailing slash.
- RatpackPresenceResolver takes presence from getAllTokens() and the
catch-all presence from getPastBinding().
- RootPathBinding (404, root all{}) gets no tag; root get("") renders "/".
- JUnit tests for the parser, the RFC-1125 vectors expressible in Ratpack
syntax, the cache and an embedded Ratpack app (both spans, error, 405,
fall-through 404, API Security disabled); existing Spock suites assert
the new tag.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79abb7ba24
ℹ️ 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".
There was a problem hiding this comment.
More details
Ratpack route grammar compatibility remains the main validation limit: framework sources were unavailable for independent verification, and tests were not run. No concrete defect was identified.
🤖 Bits Code Review · Commit 22bf06d
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
What Does This Do
Sets
_dd.appsec.normalized_route(RFC-1125) next tohttp.routeon Ratpack server spans (netty.requestandratpack.handler) when AppSec is active and API Security is enabled. Same approach as the Spring MVC (#13633) and WebFlux (#13635) integrations, on top of the shared core indatadog.trace.api.appsec.route(unchanged).Route grammar
RatpackRouteParser(internal-api) turnsPathBinding.getDescription()into aRouteTemplate. The description already holds the wholeprefix(...)chain and Ratpack has no context path, so no mount prefix is added.DefaultPathBinderBuilderby hand (nojava.util.regex): tokens only start a segment;:name->{name}(static text may follow it,:name.json->{name}.json);:name?-> optional segment;:name:regex/:name?:regex-> regex removed;::regex-> unnamed{param<N>}; any other:is static text.caf%C3%A9renderscaf%C3%A9).prefix(x) { all {} }reached with an unconsumed rest (getPastBinding()) renders a trailing unnamed catch-all (/x/a/b->/x/{param1},/x//->/x/,/x->/x)./that Ratpack adds when joiningget(handler)(==get("", handler)) under a prefix is not a declared trailing slash:prefix("users") { get {} }renders/users.DDCaches, one per (empty inner path, remainder) combination.Presence and tagging
RatpackPresenceResolver: optional tokens fromPathBinding.getAllTokens()(includes prefix tokens), catch-all fromgetPastBinding().RatpackServerDecorator.onContexttags the span right afterwithRoute, gated byNormalizedRouteHelper.isEnabled(), never throws.RootPathBinding(unmatched request, rootall {}) gets no tag; a rootget("")renders/.Tests
RatpackRouteParserTest,RatpackRouteParserRfcVectorsTest(RFC-1125 rows expressible in Ratpack syntax, non-applicable rows listed),RatpackRouteParserCacheTest,RatpackPresenceResolverTest.NormalizedRouteTeston an embedded Ratpack app: optional segment and chain, prefix catch-all, prefix tokens, regex,::regex, encoded literal, static text after a token, root, 404, prefix fall-through 404, 405, handler error under a nested prefix, both spans.NormalizedRouteApiSecurityDisabledForkedTest.RatpackHttpServerTest(expectedNormalizedRoute+ theratpack.handlerspan) andRatpackOtherTestassert the new tag.Motivation
RFC-1125 (amends RFC-1103): stable normalized routes for App and API Protection. Follow-up of APPSEC-62077 for Ratpack.
Additional Notes
test_normalized_route.pyfor theratpackweblog (commit 560cfd680). Validated locally against this branch: 16 passed, 11 skipped (irrelevant). CI there stays red until a snapshot contains this change.ratpack.handler, both carryhttp.route). Routes without optional parts cost one cache lookup per span.RatpackRouteParser):/x/underprefix(x) { all {} }renders/x: Ratpack reports an empty past binding, so prefix and exact bindings look the same (RFC fallback).:fmt?.json, Ratpack makes its/optional too) or sharing a name with another token (getAllTokens()lets the child value replace the parent one).PathBinder.builder()descriptions that the string grammar cannot express (a literal starting with:, a regex containing/) and user regexes with capturing groups (Ratpack shifts its own token group indexes) follow the description and the values Ratpack binds.prefix("users") { prefix("") { get {} } }give the same description asprefix("users/") { get {} }and render a trailing slash.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: APPSEC-72045
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels 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.