Fix GatewayBridge to re-register additional IG callbacks on Remote Config reload - #12271
Fix GatewayBridge to re-register additional IG callbacks on Remote Config reload#12271jandro996 wants to merge 5 commits into
Conversation
GatewayBridge.init() computed the set of conditionally registered instrumentation gateway callbacks (requestPathParams, requestBodyProcessed, requestFilesFilenames, requestFilesContent) once at startup and never re-evaluated it. A ruleset delivered later via Remote Config that newly required one of those addresses left the callback permanently unregistered. Extract the registration into registerAdditionalIGCallbacksIfNeeded(), guarded by idempotent volatile Subscription markers, and call it from AppSecSystem.reloadSubscriptions() on every reload in addition to init().
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
🎯 Code Coverage (details) 🔗 Commit SHA: 067c0a2 | Docs | View more details | Give us feedback! |
🟢 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. |
There was a problem hiding this comment.
More details
The reload path computes the required callback types again and registers each callback only one time. The static review finds no defect.
🤖 Datadog Autotest · Commit 10974a6 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
What Does This Do
requestPathParams,requestBodyProcessed,requestFilesFilenames,requestFilesContent) fromGatewayBridge.init()into a new method,registerAdditionalIGCallbacksIfNeeded(Collection<EventType<?>>).volatile Subscriptionfields toGatewayBridgethat mark each callback as already registered, making the new method idempotent across repeated calls.registerAdditionalIGCallbacksIfNeededfromAppSecSystem.reloadSubscriptions()on every Remote Config reload, in addition toGatewayBridge.init()at startup, recomputing the required event types from the current subscribed data addresses.try/catch (RuntimeException), separate from the existing cache-clearing logic inreset(), so a failure there cannot prevent the rest of the reload from completing.Subscriptionfields inGatewayBridge.stop().Motivation
GatewayBridge.init()computed the set of additional IG event types required by the initially subscribed WAF addresses once, at agent startup, and registered the matching callbacks. This computation was never repeated. If a ruleset delivered later via Remote Config newly required one of those addresses (e.g.server.request.path_params), the corresponding callback was never registered, so the addresses stayed subscribed but with no data ever reaching them.Additional Notes
Subscription.cancel()is called when an address stops being required after a reload — callbacks are only added, never removed. This is a conscious choice to avoid unregister/re-register churn across reloads; the addresses it can affect are:server.request.path_params,server.request.body,server.request.files.filenamesandserver.request.files.content.SubscriptionService.registerCallbacknever returningnullfor an unregistered event and throwingIllegalStateExceptionfor an already-registered one, both true in every current implementation (InstrumentationGateway,SubscriptionServiceNoop).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-69447
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.