You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce allocations when JSON audit-log serialization - #3783
Replace the LOGFY_ADD macros with type-safe local helper lambdas using std::string_view.
Avoid the intermediate YAJL output buffer and the final copy into std::string.
Use const references when iterating over rule messages and tags to avoid unnecessary copies.
why
Reduce allocations and data copying when generating JSON audit logs.
Improve performance on the audit-log serialization path.
Summary by CodeRabbit
Bug Fixes
Transaction JSON output now preserves complete request and response header values, including values with embedded NUL characters that could previously be truncated.
The output retains its trailing newline, keeping the existing end-of-output formatting consistent.
No actionable comments were generated in the recent review.
Walkthrough
Changes
Transaction::toJSON now builds its output with string_view-based helpers and writes YAJL output directly into the result string. Request and response headers are passed as strings, and rule metadata iteration uses const references.
The JSON-emission macros were removed. Transaction::toJSON adds string_view-based helpers and a YAJL callback that appends output directly to the result string.
Transaction field emission src/transaction.cc
Transaction, request, response, producer, and rule-message fields use the new helpers. Header names and values are passed as strings, and iteration over components, messages, and tags uses const references. The trailing newline is appended directly to the result string.
This change reduces allocations when serializing the JSON audit log and keeps the same output structure. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Reduce allocations when JSON audit-log serialization" matches the main change. The summary shows Transaction::toJSON now writes JSON through std::string_view helpers and streams YAJL output…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Reduce allocations when JSON audit-log serialization" matches the main change. The summary shows Transaction::toJSON now writes JSON through std::string_view helpers and streams YAJL output directly into the result string, which avoids intermediate buffers and copies. The PR objectives state the same goal of reducing allocations and copying in JSON audit-log serialization. The title is short, specific, and free of noise. Minor gap: it does not mention the removal of the LOGFY_ADD macros, but that detail is secondary to the title's purpose.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 89f57003-85bd-4136-9adc-d7d457d60b0f
Commits
Reviewing files that changed from the base of the PR and between 475aece and eb07aec.
Files selected for processing: 2
headers/modsecurity/transaction.h
src/transaction.cc
Files with no reviewable changes: 1
headers/modsecurity/transaction.h
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
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
LOGFY_ADDmacros with type-safe local helper lambdas usingstd::string_view.std::string.why
Summary by CodeRabbit