Repository navigation
Conversation
Capture the mount prefix and bound path values in Jersey (UriRoutingContext.setMatchedResourceMethod) and RESTEasy (ResourceMethodInvoker.invoke), and set _dd.appsec.normalized_route next to http.route in the jax-rs 2 and jakarta-rs 3 decorators. Dropwizard and new Jetty servlet tests for Jersey and RESTEasy cover the tag end to end.
- Clear _dd.appsec.normalized_route before recomputing it on every withRoute, so the last writer of http.route owns the tag (no stale value on re-dispatch or Quarkus on Vert.x) - Mark sub-resource locators only where the locator sets the route - Drop dead root-scope tagging (no server span, no capture) - Unit tests for JaxRsRequestMatchCapture (null base URI, no span, SUBRESOURCE kept) - jakarta-rs negative tests (AppSec inactive, malformed route) and stale-tag tests
|
@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 Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ 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. |
This comment has been minimized.
This comment has been minimized.
🟢 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_routeon JAX-RS server spans for Jersey 2/3 and RESTEasy 3, next tohttp.route, only when AppSec is active and API Security is enabled. Stacked on #13717 (PR 2 of 2).Request capture
The JAX-RS annotations advice that sets
http.routehas no access to the request, so the framework modules capture what it needs and hand it over through a global context store keyed by the local root span:jersey-appsec-2.0, Jersey 2.x to 4.x, new muzzle directivejersey_server_2+3):UriRoutingContextMatchInstrumentationon exit ofUriRoutingContext.setMatchedResourceMethod. It reads the bound values from theencodedTemplateValuesfield and the mount prefix fromgetBaseUri(). It never callsgetPathParameters, which jersey-appsec already hooks for the WAF.resteasy-appsec-3.0):ResourceMethodInvokerInstrumentationon enter ofResourceMethodInvoker.invoke(HttpRequest, HttpResponse, Object), withgetBaseUri()andgetPathParameters(false)(encoded values, like Jersey).JaxRsRequestMatchCapture(one copy per module) stores a copy of the decoded prefix and the values, never the framework objects. With no base URI, nothing is stored.Tagging
JaxRsAnnotationsDecorator(javax) andJakartaRsAnnotationsDecorator(jakarta): right after eachwithRoute, the tag is cleared and recomputed fromJaxRsRouteParser.cached(route)and the stored match, so the last writer ofhttp.routeowns the tag. No stored match (unknown mount prefix) means no tag.http.routeis truncated for them, so the locator stores aSUBRESOURCEmarker that the capture keeps, and the request gets no tag.http.routeand its priority logic are unchanged.Tests
JaxRsAnnotationsDecoratorTest,JakartaRsNormalizedRouteTest,JaxRsRequestMatchCaptureTest(both modules)./ctxand servlet mapping/api:JerseyNormalizedRouteTestandResteasyNormalizedRouteTest(regex, catch-all, several parameters, encoded literals, locators, AppSec inactive), plus forked tests with API Security disabled and with route-based naming off.DropwizardTestdeclares the tag.Motivation
RFC-1125 (amends RFC-1103): normalized routes for API Security Testing.
Additional Notes
tests/appsec/api_security_testing/test_normalized_route.py, manifest entries added locally):jersey-grizzly2(Jersey 3) 27 passed;resteasy-netty326 passed, 1 skipped (test_empty_catch_all, RESTEasy returns 404 for//).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-72043
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.