Add C API to retrieve matched rules from a transaction#3551
Open
meirdev wants to merge 3 commits intoowasp-modsecurity:v3/masterfrom
Open
Add C API to retrieve matched rules from a transaction#3551meirdev wants to merge 3 commits intoowasp-modsecurity:v3/masterfrom
meirdev wants to merge 3 commits intoowasp-modsecurity:v3/masterfrom
Conversation
airween
reviewed
Apr 22, 2026
| * @retval 0 Index is out of range. | ||
| * | ||
| */ | ||
| extern "C" int64_t msc_get_matched_rule_id(Transaction *transaction, |
Member
There was a problem hiding this comment.
This function returns only with one rule id, right?
In case of CRS, if it uses anomaly scoring model, this will return always with rule 949110, or similar ID (depends on intervention's phase).
Does it make sense?
Author
There was a problem hiding this comment.
Not exactly - the function returns a single rule ID, but I'm using msc_get_matched_rules_count to iterate through all matched rules.
Example of log from my tests:
["2026-04-22T06:44:46+00:00","172.20.0.1","36770","","178","localhost","0.000","POST","/etc/nginx/html/","","HTTP/1.1","http","1df077358d8536cd96324e994abf6256","","403","308","text/html","curl/8.5.0","","","1", "920273,941100,941110,941160,941390,941320,942131,942370,942431,942511,942432,949110"]
Member
|
Tests on Windows were failed, could you check them? |
|
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.



references
Required for: owasp-modsecurity/ModSecurity-nginx#374