Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1307 +/- ##
==========================================
- Coverage 86.74% 86.74% -0.01%
==========================================
Files 179 179
Lines 8802 8801 -1
==========================================
- Hits 7635 7634 -1
Misses 908 908
Partials 259 259
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:
|
|
Are you happy with this @M4tteoP ? |
|
Happy to see a green CI :D, allow me some time to review and reason the whole reported issue 🙇🏻♂️ |
There was a problem hiding this comment.
Pull request overview
This PR implements proper handling of audit log parts flags, specifically separating the "log" and "audit" actions for rule matches. It ensures that messages are correctly included in audit logs based on the H flag (AuditLogPartAuditLogTrailer) and the rule's audit status.
Changes:
- Introduced separate
Auditflag tracking for matched rules, distinct from theLogflag - Fixed the audit log logic to check the
Audit()method instead ofLog()when determining which messages to include in audit logs - Moved message logging from the
AuditLogPartRulesMatchedcase toAuditLogPartAuditLogTrailercase where it belongs (H flag) - Added comprehensive tests to verify the behavior of nolog/auditlog combinations and H flag handling
- Updated dependency versions
Reviewed changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/corazarules/rule_match.go | Added Audit_ field and Audit() method to track audit logging separately from error logging |
| internal/corazawaf/transaction.go | Fixed audit log message inclusion logic to use Audit() instead of Log(), moved message processing to correct case, and set Audit_ field on matched rules |
| internal/corazawaf/transaction_test.go | Added Audit flag to test rule to match new behavior |
| testing/auditlog_test.go | Added comprehensive tests for nolog/auditlog combinations and H flag behavior |
| testing/coreruleset/go.sum | Updated dependency versions |
| go.sum | Updated dependency versions |
| examples/http-server/go.sum | Updated dependency versions |
| examples/http-server/go.mod | Updated dependency versions |
| } | ||
| } | ||
| case types.AuditLogPartRulesMatched: | ||
| // implement matched rules |
There was a problem hiding this comment.
This TODO comment suggests that AuditLogPartRulesMatched (K flag) is not implemented. However, this appears to be an intentional placeholder since matched rules are now being handled in AuditLogPartAuditLogTrailer. Consider either implementing this part or documenting why it's left empty (e.g., 'K part is intentionally not implemented as matched rules are logged in H part').
| // implement matched rules | |
| // K part is intentionally not implemented. | |
| // Matched rules are logged in the audit log trailer (H part) above. |
|
@jcchavezs Can we close this one? |
|
@copilot is this change needed? |
…essage Agent-Logs-Url: https://github.com/corazawaf/coraza/sessions/409d9fbf-7395-48ef-a5aa-edabd0176121 Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Yes, the changes are needed. The PR fixes the audit log parts flag handling — specifically, messages were being gated on the In commit |
…-7395-48ef-a5aa-edabd0176121 Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
|
@copilot Can you fix the conflicts? |
Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/corazawaf/coraza/sessions/e42484b1-45d0-46cb-ad66-5a4fbdd9db79 Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Done — merged |
Runs actions as they cannot run in #1304