Fix rasp.rule.match metric always reporting block:N/A#11723
Merged
Conversation
rasp.rule.match was always reporting block:N/A because raspRuleMatch() was called before the action loop; flow.isBlocking() is only valid after setAction() runs inside the loop. - Move raspRuleMatch() call to after the action loop (setRaspMatched stays in place) - Add boolean blocked param; double counter array for per-outcome tracking - Update prepareMetrics() to drain both blocked/non-blocked slots per RuleType - Add block: tag to both variant and non-variant RaspRuleMatch branches - Guard flow.setAction(rba) against null return from createBlockRequestAction/createRedirectRequestAction
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9de4c7a700
ℹ️ 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".
claponcet
approved these changes
Jun 24, 2026
Contributor
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 25, 2026
gh-worker-dd-mergequeue-cf854d
Bot
merged commit Jun 25, 2026
b622864
into
master
586 of 589 checks passed
TophrC-dd
pushed a commit
that referenced
this pull request
Jun 29, 2026
fix: report correct block outcome tag in rasp.rule.match metric rasp.rule.match was always reporting block:N/A because raspRuleMatch() was called before the action loop; flow.isBlocking() is only valid after setAction() runs inside the loop. - Move raspRuleMatch() call to after the action loop (setRaspMatched stays in place) - Add boolean blocked param; double counter array for per-outcome tracking - Update prepareMetrics() to drain both blocked/non-blocked slots per RuleType - Add block: tag to both variant and non-variant RaspRuleMatch branches - Guard flow.setAction(rba) against null return from createBlockRequestAction/createRedirectRequestAction Merge branch 'master' into rasp-rule-match-fix Co-authored-by: devflow.devflow-routing-intake <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
WafMetricCollector.raspRuleMatch()call inWAFModuleto after the WAF action loop so thatflow.isBlocking()reflects the actual blocking decision (it always returnedfalsebefore the loop because no action had been set yet)boolean blockedparameter toraspRuleMatch(RuleType, boolean)raspRuleMatchCounterarray size toRuleType.getNumValues() * 2, using index formularuleType.ordinal() * 2 + (blocked ? 1 : 0)to track blocked and non-blocked counts independently per rule typeprepareMetrics()to drain both the blocked slot (ordinal*2+1) and non-blocked slot (ordinal*2) perRuleType, emitting separaterasp.rule.matchmetrics for each outcomeblock:tag to both variant and non-variant branches ofRaspRuleMatchflow.setAction(rba)againstnullreturn fromcreateBlockRequestAction/createRedirectRequestAction(prevents NPE onflow.isBlocking()when action data is malformed)Motivation
rasp.rule.matchwas always emitted withblock:N/A(APPSEC-62729). Root cause: the metric was recorded before the WAF action loop inWAFModule.runWAF(). At that pointflow.isBlocking()always returnsfalsebecause blocking actions are only set viaflow.setAction()inside the loop. Moving the call to after the loop fixes the tag.Additional Notes
The counter-doubling pattern follows the existing
aiGuardRequestcanonical reference already present inWafMetricCollector.java(same index formula, same drain pattern).RuleType.getNumValues()is unchanged — the array size is the caller's responsibility.setRaspMatched(true)(a state flag consumed during action processing) intentionally stays in its original position before the loop; only the metric recording call moves.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-62729
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.