cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.2 to 5436878
Date Tue, 25 Feb 2014 21:49:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.2 bb01aad37 -> 5436878e8


CLOUDSTACK-6163 obfuscation of passwords in log


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

Branch: refs/heads/4.2
Commit: 5436878e888318dffb1cd01b9e8701c7f0890cf4
Parents: bb01aad
Author: Daan Hoogland <daan@onecht.net>
Authored: Tue Feb 25 22:49:41 2014 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Tue Feb 25 22:49:41 2014 +0100

----------------------------------------------------------------------
 core/src/com/cloud/agent/transport/Request.java | 28 +++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5436878e/core/src/com/cloud/agent/transport/Request.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/transport/Request.java b/core/src/com/cloud/agent/transport/Request.java
index b0fa4cc..a25f6ab 100755
--- a/core/src/com/cloud/agent/transport/Request.java
+++ b/core/src/com/cloud/agent/transport/Request.java
@@ -23,6 +23,7 @@ import java.io.StringReader;
 import java.lang.reflect.Type;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
@@ -38,6 +39,7 @@ import com.cloud.exception.UnsupportedVersionException;
 import com.cloud.serializer.GsonHelper;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
+import com.cloud.utils.StringUtils;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.google.gson.Gson;
 import com.google.gson.JsonArray;
@@ -424,11 +426,35 @@ public class Request {
         buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via);
         buf.append(", Ver: ").append(_ver.toString());
         buf.append(", Flags: ").append(Integer.toBinaryString(getFlags())).append(", ");
-        buf.append(content);
+        String cleanContent = content.toString();
+        if(cleanContent.contains("password")) {
+            buf.append(cleanPassword(cleanContent));
+        } else {
+            buf.append(content);
+        }
         buf.append(" }");
         return buf.toString();
     }
 
+    public static String cleanPassword(String logString) {
+        String cleanLogString = null;
+        if (logString != null) {
+            cleanLogString = logString;
+            String[] temp = logString.split(",");
+            int i = 0;
+            if (temp != null) {
+                while (i < temp.length) {
+                    temp[i] = StringUtils.cleanString(temp[i]);
+                    i++;
+                }
+                List<String> stringList = new ArrayList<String>();
+                Collections.addAll(stringList, temp);
+                cleanLogString = StringUtils.join(stringList, ",");
+            }
+        }
+        return cleanLogString;
+    }
+
     /**
      * Factory method for Request and Response. It expects the bytes to be
      * correctly formed so it's possible that it throws underflow exceptions


Mime
View raw message