-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Logs print different messages for each the disruptive actions #827
fix: Logs print different messages for each the disruptive actions #827
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #827 +/- ##
==========================================
+ Coverage 81.51% 81.56% +0.04%
==========================================
Files 160 160
Lines 9033 9051 +18
==========================================
+ Hits 7363 7382 +19
+ Misses 1418 1417 -1
Partials 252 252
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
What is missing here? |
Co-authored-by: José Carlos Chávez <jcchavezs@gmail.com>
I moved it to |
@@ -229,6 +231,22 @@ func (mr MatchedRule) ErrorLog() string { | |||
} | |||
} | |||
|
|||
log.WriteString("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line should fix corazawaf/coraza-caddy#87 and supersede corazawaf/coraza-caddy#93. Now writing the new line is delegated to the ErrorLog() caller.
internal/corazarules/rule_match.go
Outdated
return log.String() | ||
} | ||
|
||
func writeDisruptiveActionSpecificLog(log *strings.Builder, mr MatchedRule) { | ||
switch mr.DisruptiveActionName_ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for another PR but we should migrate this to an enum instead of string for faster matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please take care of that before merge, @M4tteoP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Rag, I tried to address it. A better way might be propagating the Action enum from the parser mapping into Action functions, but it requires quite a broad refactor. Did you have in mind something like what I just implemented?
Are you happy with the change @anuraaga ? |
Initial report: corazawaf/coraza-proxy-wasm#209
This PR proposes to add different messages for each disruptive action, following the same logic used by ModSecurity v2 ( See here).
Currently, we have two Error log prefixes based on the
Disruptive_
field of the matched rules that we are logging:Considering that the
Disruptive_
field itself is kind of misleading (actions likedeny
,allow
, andpass
are all considered disruptive actions), some logs ends up being misleading.For example, a log from the
980170
rule, which has apass
action, starts withAccess denied
: