cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/CLOUDSTACK-8566 to 49d1f54
Date Fri, 26 Jun 2015 16:42:51 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/CLOUDSTACK-8566 [created] 49d1f54f9


CLOUDSTACK-8566: Filter sensitive details from listHosts API

Removes any username and password host details from the listHosts API response
before it's wired back to a client.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/CLOUDSTACK-8566
Commit: 49d1f54f98ecf995beae928284f67df56a30f176
Parents: a8959bc
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Fri Jun 26 18:42:00 2015 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Fri Jun 26 18:42:00 2015 +0200

----------------------------------------------------------------------
 .../api/command/admin/host/ListHostsCmd.java    | 37 +++++++++++++-------
 .../cloudstack/api/response/HostResponse.java   |  8 +++--
 2 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49d1f54f/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
index d7aa18b..68790a9 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
@@ -16,13 +16,11 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.host;
 
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.host.Host;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.Pair;
+import com.cloud.utils.Ternary;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -35,12 +33,12 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
 
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.Pair;
-import com.cloud.utils.Ternary;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
 
 @APICommand(name = "listHosts", description = "Lists hosts.", responseObject = HostResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -203,9 +201,22 @@ public class ListHostsCmd extends BaseListCmd {
                 hostResponse.setObjectName("host");
                 hostResponses.add(hostResponse);
             }
-
             response.setResponses(hostResponses, result.second());
         }
+        // Remove sensitive details from host response
+        List<HostResponse> hostResponsesList = response.getResponses();
+        for (HostResponse hostResponse: hostResponsesList) {
+            Map<String, String> hostDetails = hostResponse.getDetails();
+            if (hostDetails == null) continue;
+            if (hostDetails.containsKey("username")) {
+                hostDetails.remove("username");
+            }
+            if (hostDetails.containsKey("password")) {
+                hostDetails.remove("password");
+            }
+            hostResponse.setDetails(hostDetails);
+        }
+        response.setResponses(hostResponsesList);
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49d1f54f/api/src/org/apache/cloudstack/api/response/HostResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/HostResponse.java b/api/src/org/apache/cloudstack/api/response/HostResponse.java
index 9cb0fcb..880e3f9 100644
--- a/api/src/org/apache/cloudstack/api/response/HostResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/HostResponse.java
@@ -215,7 +215,7 @@ public class HostResponse extends BaseResponse {
 
     @SerializedName(ApiConstants.DETAILS)
     @Param(description = "Host details in key/value pairs.", since = "4.5")
-    private Map details;
+    private Map<String, String> details;
 
     @Override
     public String getObjectId() {
@@ -422,8 +422,12 @@ public class HostResponse extends BaseResponse {
         this.haHost = haHost;
     }
 
-    public void setDetails(Map details) {
+    public void setDetails(Map<String, String> details) {
         this.details = details;
     }
 
+    public Map<String, String> getDetails() {
+        return this.details;
+    }
+
 }


Mime
View raw message