virajjasani commented on a change in pull request #3683:
URL: https://github.com/apache/hadoop/pull/3683#discussion_r753453312
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java
##########
@@ -74,9 +82,24 @@ public String getContext() {
null : Arrays.copyOf(signature, signature.length);
}
+ /**
+ * Whether the context is valid.
+ * The context should not contain '\t', '\n', '='.
+ * Because the context could be written to audit log.
+ */
@InterfaceAudience.Private
public boolean isContextValid() {
- return context != null && !context.isEmpty();
+ if (context == null || context.isEmpty()) {
+ return false;
+ }
+
+ for (String str: ILLEGAL_CHARACTERS) {
+ if (context.contains(str)) {
+ return false;
+ }
+ }
+
+ return true;
Review comment:
nit: could be replaced with `return
ILLEGAL_CHARACTERS.stream().noneMatch(context::contains)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]