hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject hadoop git commit: HDFS-11048. Audit Log should escape control characters. Contributed by Eric Badger
Date Fri, 28 Oct 2016 18:05:48 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 93165c1ad -> a8a99f342


HDFS-11048. Audit Log should escape control characters. Contributed by Eric Badger

(cherry picked from commit 8a9388e5f6d622152798aaaa256064919e4fec37)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a8a99f34
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a8a99f34
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a8a99f34

Branch: refs/heads/branch-2.8
Commit: a8a99f342378d80d2b3878fce58944fbc677ed8a
Parents: 93165c1
Author: Mingliang Liu <liuml07@apache.org>
Authored: Fri Oct 28 10:53:14 2016 -0700
Committer: Mingliang Liu <liuml07@apache.org>
Committed: Fri Oct 28 11:01:09 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java    | 3 +++
 .../apache/hadoop/hdfs/server/namenode/TestAuditLogs.java   | 9 +++++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a8a99f34/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index c1403f7..3318739 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hdfs.server.namenode;
 
+import static org.apache.commons.lang.StringEscapeUtils.escapeJava;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_DEFAULT;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_CALLER_CONTEXT_ENABLED_DEFAULT;
@@ -7437,6 +7438,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
       if (auditLog.isDebugEnabled() ||
           (auditLog.isInfoEnabled() && !debugCmdSet.contains(cmd))) {
         final StringBuilder sb = STRING_BUILDER.get();
+        src = escapeJava(src);
+        dst = escapeJava(dst);
         sb.setLength(0);
         sb.append("allowed=").append(succeeded).append("\t");
         sb.append("ugi=").append(userName).append("\t");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a8a99f34/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java
index 115c0b4..8c53ad6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java
@@ -292,6 +292,15 @@ public class TestAuditLogs {
     verifyAuditLogsCheckPattern(true, 3, webOpenPattern);
   }
 
+  /** make sure that "\r\n" isn't made into a newline in audit log */
+  @Test
+  public void testAuditCharacterEscape() throws Exception {
+    final Path file = new Path("foo" + "\r\n" + "bar");
+    setupAuditLogs();
+    fs.create(file);
+    verifyAuditLogsRepeat(true, 1);
+  }
+
   /** Sets up log4j logger for auditlogs */
   private void setupAuditLogs() throws IOException {
     Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message