Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c40d23b8
Unverified
Commit
c40d23b8
authored
Dec 13, 2021
by
Madelyn Olson
Committed by
GitHub
Dec 13, 2021
Browse files
Redact ACL SETUSER arguments if the user has spaces (#9935)
parent
b93ccee4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
c40d23b8
...
...
@@ -1966,6 +1966,12 @@ void addACLLogEntry(client *c, int reason, int context, int argpos, sds username
void
aclCommand
(
client
*
c
)
{
char
*
sub
=
c
->
argv
[
1
]
->
ptr
;
if
(
!
strcasecmp
(
sub
,
"setuser"
)
&&
c
->
argc
>=
3
)
{
/* Initially redact all of the arguments to not leak any information
* about the user. */
for
(
int
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
redactClientCommandArgument
(
c
,
j
);
}
sds
username
=
c
->
argv
[
2
]
->
ptr
;
/* Check username validity. */
if
(
ACLStringHasSpaces
(
username
,
sdslen
(
username
)))
{
...
...
@@ -1982,12 +1988,6 @@ void aclCommand(client *c) {
user
*
u
=
ACLGetUserByName
(
username
,
sdslen
(
username
));
if
(
u
)
ACLCopyUser
(
tempu
,
u
);
/* Initially redact all of the arguments to not leak any information
* about the user. */
for
(
int
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
redactClientCommandArgument
(
c
,
j
);
}
for
(
int
j
=
3
;
j
<
c
->
argc
;
j
++
)
{
if
(
ACLSetUser
(
tempu
,
c
->
argv
[
j
]
->
ptr
,
sdslen
(
c
->
argv
[
j
]
->
ptr
))
!=
C_OK
)
{
const
char
*
errmsg
=
ACLSetUserStringError
();
...
...
tests/unit/slowlog.tcl
View file @
c40d23b8
...
...
@@ -49,6 +49,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
test
{
SLOWLOG - Certain commands are omitted that contain sensitive information
}
{
r config set slowlog-log-slower-than 0
r slowlog reset
catch
{
r acl setuser
"slowlog test user"
+get +set
}
_
r config set masterauth
""
r acl setuser slowlog-test-user +get +set
r config set slowlog-log-slower-than 0
...
...
@@ -57,8 +58,9 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
# Make sure normal configs work, but the two sensitive
# commands are omitted or redacted
assert_equal 4
[
llength $slowlog_resp
]
assert_equal
{
slowlog reset
}
[
lindex
[
lindex
[
r slowlog get
]
3
]
3
]
assert_equal 5
[
llength $slowlog_resp
]
assert_equal
{
slowlog reset
}
[
lindex
[
lindex
[
r slowlog get
]
4
]
3
]
assert_equal
{
acl setuser
(
redacted
)
(
redacted
)
(
redacted
)}
[
lindex
[
lindex
[
r slowlog get
]
3
]
3
]
assert_equal
{
config set masterauth
(
redacted
)}
[
lindex
[
lindex
[
r slowlog get
]
2
]
3
]
assert_equal
{
acl setuser
(
redacted
)
(
redacted
)
(
redacted
)}
[
lindex
[
lindex
[
r slowlog get
]
1
]
3
]
assert_equal
{
config set slowlog-log-slower-than 0
}
[
lindex
[
lindex
[
r slowlog get
]
0
]
3
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment