feat(audit): Add audit_request_id correlation field to all FGAC audit… - #6343
feat(audit): Add audit_request_id correlation field to all FGAC audit…#6343Taiwo435 wants to merge 1 commit into
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 94d6b7e. ⛔ Hard block: Issues at High severity or above will block this PR from merging.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍(Review updated until commit 94d6b7e)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 94d6b7e
Previous suggestionsSuggestions up to commit d1ac125
|
… events Add a unique request correlation ID to every audit event so multiple events from the same REST request can be traced together. Uses the client-provided X-Request-Id header when available, otherwise generates a UUID per request as fallback. Implementation: - SecurityRestFilter: reads X-Request-Id header or generates UUID, stashes in ThreadContext as transient - AuditLogImpl.save(): reads from ThreadContext and stamps on every message before routing to sinks - AuditMessage: new REQUEST_ID field constant and addRequestId() setter Works across all FGAC event types: AUTHENTICATED, GRANTED_PRIVILEGES, MISSING_PRIVILEGES, INDEX_EVENT, COMPLIANCE_DOC_READ/WRITE, etc. Signed-off-by: Muzzamil Jolaade <muzzajol@amazon.com>
d1ac125 to
94d6b7e
Compare
|
Persistent review updated to latest commit 94d6b7e |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6343 +/- ##
==========================================
+ Coverage 75.39% 75.40% +0.01%
==========================================
Files 456 456
Lines 29924 29939 +15
Branches 4530 4534 +4
==========================================
+ Hits 22560 22576 +16
Misses 5265 5265
+ Partials 2099 2098 -1
🚀 New features to boost your workflow:
|
Description
Add an
audit_request_idfield to all audit events so that multiple events generated by a single request (AUTHENTICATED → GRANTED_PRIVILEGES → COMPLIANCE_DOC_WRITE) can be correlated.How it works
SecurityRestFilterreads theX-Request-Idheader if present, otherwise generates a UUIDThreadContextas a transient for local eventsAuditLogImpl.save()reads the transient first, falls back toX-Request-Idheader (propagated by core across nodes)Cross-node propagation
When a client sends
X-Request-Id, OpenSearch core propagates it across nodes viaTask.REQUEST_HEADERS. This means compliance events (COMPLIANCE_DOC_WRITE,COMPLIANCE_DOC_READ) on remote shard-hosting nodes also get the correlation ID.Known limitation: Server-generated UUIDs (when no X-Request-Id header is sent) appear on user-initiated events (AUTHENTICATED, GRANTED_PRIVILEGES for the user action) but NOT on internally-spawned events COMPLIANCE_DOC_WRITE, auto-mapping INDEX_EVENT). This is because internal sub-actions run in a fresh ThreadContext where transients are cleared. When the client provides X-Request-Id, ALL events get the correlation ID because headers survive context changes.
References
X-Request-Idsupport: Add Add X-Request-Id header to uniquely identify a search request OpenSearch#19798Testing
AuditRequestIdCorrelationTest):X-Request-Idheader used verbatimX-Request-Idsent)AuditMessageTest):addRequestId()behaviorWhoAmITests): excludeaudit_request_idfrom structural equality comparisonCheck List