Sentinel: don't log auth-pass value for better security (#9652)

This commit is contained in:
Wen Hui 2021-10-26 06:13:12 -04:00 committed by GitHub
parent 37559ca79f
commit 43b22f17dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4156,6 +4156,7 @@ void sentinelSetCommand(client *c) {
int j, changes = 0;
int badarg = 0; /* Bad argument position for error reporting. */
char *option;
int redacted;
if ((ri = sentinelGetMasterByNameOrReplyError(c,c->argv[2]))
== NULL) return;
@ -4166,6 +4167,7 @@ void sentinelSetCommand(client *c) {
option = c->argv[j]->ptr;
long long ll;
int old_j = j; /* Used to know what to log as an event. */
redacted = 0;
if (!strcasecmp(option,"down-after-milliseconds") && moreargs > 0) {
/* down-after-milliseconds <milliseconds> */
@ -4240,6 +4242,7 @@ void sentinelSetCommand(client *c) {
sdsfree(ri->auth_pass);
ri->auth_pass = strlen(value) ? sdsnew(value) : NULL;
changes++;
redacted = 1;
} else if (!strcasecmp(option,"auth-user") && moreargs > 0) {
/* auth-user <username> */
char *value = c->argv[++j]->ptr;
@ -4287,7 +4290,7 @@ void sentinelSetCommand(client *c) {
switch(numargs) {
case 2:
sentinelEvent(LL_WARNING,"+set",ri,"%@ %s %s",(char*)c->argv[old_j]->ptr,
(char*)c->argv[old_j+1]->ptr);
redacted ? "******" : (char*)c->argv[old_j+1]->ptr);
break;
case 3:
sentinelEvent(LL_WARNING,"+set",ri,"%@ %s %s %s",(char*)c->argv[old_j]->ptr,