-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
audit: H
should populate also with error logs.
#1310
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1310 +/- ##
==========================================
+ Coverage 81.94% 81.99% +0.04%
==========================================
Files 170 170
Lines 9777 9803 +26
==========================================
+ Hits 8012 8038 +26
Misses 1518 1518
Partials 247 247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1098a44
to
df5b689
Compare
2169a67
to
560063e
Compare
@@ -47,4 +47,6 @@ type MatchedRule interface { | |||
AuditLog() string | |||
|
|||
ErrorLog() string | |||
|
|||
// TODO(4.x): Add Log() |
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.
Do you mind elaborating why?
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.
I remember that with #848 we agreed that Log()
was indeed helpful to be exported, but then to avoid breaking the Coraza v3.* API adding a Log() method to the MatchedRule interface we provided the workaround via the type assertion. So I guess that the proper outcome is to have it properly exported.
See also
coraza/internal/corazawaf/transaction.go
Lines 1499 to 1503 in e29a849
// Log action is required to log a matched rule on both error log and audit log | |
// An assertion has to be done to check if the MatchedRule implements the Log() function before calling Log() | |
// It is performed to avoid breaking the Coraza v3.* API adding a Log() method to the MatchedRule interface | |
mrWithlog, ok := mr.(*corazarules.MatchedRule) | |
if ok && mrWithlog.Log() { |
for _, alEntry := range al.Messages() { | ||
alWithErrMsg, ok := alEntry.(auditLogWithErrMesg) | ||
if ok && alWithErrMsg.ErrorMessage() != "" { | ||
res.WriteByte('\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.
res.WriteByte('\n') | |
fmt.Fprintln(res, "") |
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.
I can't use it as is with a string builder (complains of missing io.Writer). We are using in several places res.WriteByte('\n')
, is it a performance or readability suggestion?
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.
it is because the method is in the pointer not in the value. The main use here is to make this working on windows but I see this has been used before so we can keep it.
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.
I see, thanks!
560063e
to
42601f5
Compare
Fixed go.sum conflicts |
42601f5
to
07c6a2d
Compare
Part of #1305.
Address point 1 of #1305 (comment)