summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2020-07-23 08:05:50 -0700
committerILYA Khlopotov <iilyak@apache.org>2020-07-30 05:10:08 -0700
commit52d532727a3cc7b94516e9ba4b0e1c7ba447fd3c (patch)
treeb0c686316c718ca7f58523922c12250fc5475c8d
parent97e7a95c3c25c1ece7db25ee87e6476ba0a11282 (diff)
downloadcouchdb-52d532727a3cc7b94516e9ba4b0e1c7ba447fd3c.tar.gz
Do not log sensitive data during _cluster_setup
-rw-r--r--src/setup/src/setup_httpd.erl17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/setup/src/setup_httpd.erl b/src/setup/src/setup_httpd.erl
index 949675b6a..48b1b2a5a 100644
--- a/src/setup/src/setup_httpd.erl
+++ b/src/setup/src/setup_httpd.erl
@@ -19,7 +19,7 @@ handle_setup_req(#httpd{method='POST'}=Req) ->
ok = chttpd:verify_is_server_admin(Req),
couch_httpd:validate_ctype(Req, "application/json"),
Setup = get_body(Req),
- couch_log:notice("Setup: ~p~n", [Setup]),
+ couch_log:notice("Setup: ~p~n", [remove_sensitive(Setup)]),
Action = binary_to_list(couch_util:get_value(<<"action">>, Setup, <<"missing">>)),
case handle_action(Action, Setup) of
ok ->
@@ -91,7 +91,7 @@ handle_action("enable_cluster", Setup) ->
handle_action("finish_cluster", Setup) ->
- couch_log:notice("finish_cluster: ~p~n", [Setup]),
+ couch_log:notice("finish_cluster: ~p~n", [remove_sensitive(Setup)]),
Options = get_options([
{ensure_dbs_exist, <<"ensure_dbs_exist">>}
@@ -105,7 +105,7 @@ handle_action("finish_cluster", Setup) ->
end;
handle_action("enable_single_node", Setup) ->
- couch_log:notice("enable_single_node: ~p~n", [Setup]),
+ couch_log:notice("enable_single_node: ~p~n", [remove_sensitive(Setup)]),
Options = get_options([
{ensure_dbs_exist, <<"ensure_dbs_exist">>},
@@ -125,7 +125,7 @@ handle_action("enable_single_node", Setup) ->
handle_action("add_node", Setup) ->
- couch_log:notice("add_node: ~p~n", [Setup]),
+ couch_log:notice("add_node: ~p~n", [remove_sensitive(Setup)]),
Options = get_options([
{username, <<"username">>},
@@ -147,10 +147,10 @@ handle_action("add_node", Setup) ->
end;
handle_action("remove_node", Setup) ->
- couch_log:notice("remove_node: ~p~n", [Setup]);
+ couch_log:notice("remove_node: ~p~n", [remove_sensitive(Setup)]);
handle_action("receive_cookie", Setup) ->
- couch_log:notice("receive_cookie: ~p~n", [Setup]),
+ couch_log:notice("receive_cookie: ~p~n", [remove_sensitive(Setup)]),
Options = get_options([
{cookie, <<"cookie">>}
], Setup),
@@ -173,3 +173,8 @@ get_body(Req) ->
couch_log:notice("Body Fail: ~p~n", [Else]),
couch_httpd:send_error(Req, 400, <<"bad_request">>, <<"Missing JSON body'">>)
end.
+
+remove_sensitive(KVList0) ->
+ KVList1 = lists:keyreplace(<<"username">>, 1, KVList0, {<<"username">>, <<"****">>}),
+ KVList2 = lists:keyreplace(<<"password">>, 1, KVList1, {<<"password">>, <<"****">>}),
+ KVList2. \ No newline at end of file