Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

X out passwords from stats proxy

The "stats proxy" command will now show XXX'ed out passwords,
like...

  STAT 11211:test:info:config { "name": "test", "saslPassword": "XXXXXXXX"

Change-Id: I0edc0f0b9c017abdbdba47b75e88f4ba4802243d
Reviewed-on: http://review.couchbase.org/11037
Tested-by: Steve Yen <steve.yen@gmail.com>
Reviewed-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
commit 3119473ae18a6b3a25062ed33a73858743d68d73 1 parent 6a04074
Steve Yen steveyen authored bcui6611 committed
Showing with 26 additions and 0 deletions.
  1. +26 −0 agent_stats.c
26 agent_stats.c
View
@@ -21,6 +21,8 @@
// Local declarations.
//
+void xpassword(char *p);
+
static void add_stat_prefix(const void *dump_opaque,
const char *prefix,
const char *key,
@@ -781,6 +783,28 @@ void proxy_stats_dump_proxy_main(ADD_STAT add_stats, conn *c,
}
}
+void xpassword(char *p) {
+ // X out passwords in input string.
+ // Example: ..."nodeLocator": "vbucket", "saslPassword": "test", "nodes":...
+ // Becomes: ..."nodeLocator": "vbucket", "saslPassword": "XXXX", "nodes":...
+ while (true) {
+ p = strstr(p, "assword\"");
+ if (p == NULL) {
+ return;
+ }
+
+ p = p + 8;
+ p = strchr(p, '"');
+ if (p != NULL) {
+ p = p + 1;
+ while (p != NULL && *p != '\0' && *p != '"') {
+ *p = 'X';
+ p = p + 1;
+ }
+ }
+ }
+}
+
void proxy_stats_dump_proxies(ADD_STAT add_stats, conn *c,
struct proxy_stats_cmd_info *pscip) {
assert(c != NULL);
@@ -828,6 +852,8 @@ void proxy_stats_dump_proxies(ADD_STAT add_stats, conn *c,
}
*slow = '\0';
+ xpassword(buf);
+
APPEND_PREFIX_STAT("config", "%s", buf);
free(buf);
Please sign in to comment.
Something went wrong with that request. Please try again.