-
Notifications
You must be signed in to change notification settings - Fork 344
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
[CDAP-21105] Collecting Audit Log Meta Data independently at ACH's readChannel's finally and AuditLogSetterHook. And Create AuditLogRequest in write/close call. #15790
Conversation
c694c25
to
34bdaa7
Compare
/** | ||
* Sets | ||
* Sets audit log metadata to {@link SecurityRequestContext} |
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.
Please fix checkstyles
endTime | ||
) | ||
); | ||
SecurityRequestContext.setAuditMetaDataInMap(AuditLogRequest.PropKey.OP_RESP_CODE, status.code()); |
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 create a builder class for AutditLogRequest and use it here? It would be much better than using a Map
. You can have different methods set different fields in the builder and later you just call build.
842a8a3
to
2628ce9
Compare
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.
LGTM with minor comments
auditLogWriter.publish((AuditLogRequest) auditLogRequestObj); | ||
ctx.channel().attr(AttributeKey.valueOf(AUDIT_LOG_REQ_ATTR_NAME)).set(null); | ||
AuditLogRequest auditLogRequest = getAuditLogRequest(ctx); | ||
if (auditLoggingEnabled && auditLogRequest != null ) { |
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 skip getAuditLogRequest
work if it's not enabled?
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.
Done
@@ -118,31 121,35 @@ public void testWriteWithAuditLogging() throws Exception { | |||
public void testCloseWithAuditLogging() throws Exception { |
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 add a test with other order of the calls, so that we test the use ca that was failing?
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.
Added for both cases.
2628ce9
to
2d8d092
Compare
Quality Gate passedIssues Measures |
…adChannel's finally and AuditLogSetterHook. And Create AuditLogRequest in write/close call.
2d8d092
to
2044739
Compare
The Existing flow / Expectation :
ABCHttpHandler
(gets AuditLogs in SecurityRequestContext[SRC] )->
AuditLogSetterHook
(populates Metadata gets AuditLogs from SRC and creates AuditLogReq and sets in SRC)-->
AuthChannelHandler#readChannel's Finally
(Sets the AuditLogRequest in Attribute of channel)--->
AuthChannelHandler#write
(gets the AuditLogRequest from Attribute of channel and publishes)Problem incase of ArtifactHttpHandler#addArtifact:
The
AuditLogSetterHook
is called afterAuthChannelHandler#readChannel's Finally
ArtifactHttpHandler
(gets AuditLogs in SecurityRequestContext[SRC] )->
AuthChannelHandler#readChannel's Finally
(Sets the AuditLogRequest in Attribute of channelBUT THIS IS NULL
)-->
AuditLogSetterHook
(populates Metadata gets AuditLogs from SRC and creates AuditLogReq and sets in SRC)--->
AuthChannelHandler#write
(gets the AuditLogRequest from Attribute of channel and publishes)The Fix :
Independently Collect info in
AuditLogSetterHook
andAuthChannelHandler#readChannel's Finally
and Later construct theAuditLogRequest
by collecting info stored by above methods.Testing :