-
Notifications
You must be signed in to change notification settings - Fork 9k
HDFS-16945 . RBF: add RouterSecurityAuditLogger for router security manager #5468
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
base: trunk
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
private static final ThreadLocal<StringBuilder> STRING_BUILDER = | ||
new ThreadLocal<StringBuilder>() { | ||
@Override | ||
protected StringBuilder initialValue() { | ||
return new StringBuilder(); | ||
} | ||
}; |
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.
The Java8 construct is a bit more readable.
ThreadLocal.withInitial(() -> new StringBuilder());
sb.append("ip=").append(addr).append("\t"); | ||
sb.append("cmd=").append(cmd).append("\t"); | ||
|
||
sb.append("\t").append("toeknId="); |
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.
Typo tokenId
} | ||
|
||
@VisibleForTesting | ||
public String creatAuditLog(boolean succeeded, String userName, |
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.
Typo createAuditLog
@@ -152,7 +160,8 @@ public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) | |||
tokenId = dtId.toStringStable(); | |||
success = true; | |||
} finally { | |||
logAuditEvent(success, operationName, tokenId); | |||
logAuditEvent(success, user, Server.getRemoteIp(), operationName, |
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.
The remote address should be part of the CallerContext as well after HDFS-13248.
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.
Some comments. Good to have stuff
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*; | ||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_CALLER_CONTEXT_SIGNATURE_MAX_SIZE_DEFAULT; | ||
|
||
public class RouterSecurityAuditLogger { |
There was a problem hiding this comment.
Choose a reason for hiding this commen 8000 t
The reason will be displayed to describe this comment to others. Learn more.
I think this extend any child class of AuditLogger?
|
||
import java.net.InetAddress; | ||
|
||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*; |
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.
Don't use *, expand the imports
private static final ThreadLocal<StringBuilder> STRING_BUILDER = | ||
new ThreadLocal<StringBuilder>() { | ||
@Override | ||
protected StringBuilder initialValue() { | ||
return new StringBuilder(); | ||
} | ||
}; |
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.
May be
private static final ThreadLocal<StringBuilder> STRING_BUILDER =
ThreadLocal.withInitial(StringBuilder::new);
private int callerContextMaxLen; | ||
private int callerSignatureMaxLen; |
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.
can be final
?
if ( | ||
callerContext != null && | ||
callerContext.isContextValid()) { | ||
sb.append("\t").append("callerContext="); |
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.
Formatting issue
if (callerContext != null && callerContext.isContextValid()) {
@@ -186,7 +196,8 @@ public long renewDelegationToken(Token<DelegationTokenIdentifier> token) | |||
tokenId = id.toStringStable(); | |||
throw ace; | |||
} finally { | |||
logAuditEvent(success, operationName, tokenId); | |||
logAuditEvent(success, user, Server.getRemoteIp(), operationName, |
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.
isn't user always an empty string here? Should have been user = getRemoteUser().getUserName();
?
logAuditEvent(success, user, Server.getRemoteIp(), operationName, | ||
CallerContext.getCurrent(), tokenId); |
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.
user is empty here?
There is a line above
String canceller = getRemoteUser().getUserName();
This guy is your user
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.*; |
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.
No grouping of imports
|
||
import static org.junit.Assert.*; | ||
|
||
public class TestRouterSecurityAuditLogger { |
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.
Add a javadoc for the test class that It has tests related to RouterSecurityAuditLogs
public class TestRouterSecurityAuditLogger { | ||
|
||
@Test | ||
public void testRouterSecurityAuditLog() throws IOException { |
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.
This is very basic and invoking directly the audit logger not invoking from the actual API. any scope to add tests which invokes audit logging via API invocation and you can grep the logs?
Description of PR
HDFS-16945
we should add audit log for router security manager for token APIs. For examples,
How was this patch tested?
add testRouterSecurityAuditLog
For code changes:
add RouterSecurityAuditLogger