-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #14872: fix incorrectly handle with two-words redis command #14873
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
1 similar comment
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mazhechao for reporting AND fixing this 😄
Can you add a entry to CHANGELOG.next.asciidoc
too?
@@ -423,7 +424,7 @@ func (p *parser) parseArray(depth int, buf *streambuf.Buffer) (common.NetString, | |||
} | |||
|
|||
// handle top-level request command | |||
if depth == 0 && isRedisCommand(content[0]) { | |||
if depth == 0 && (isRedisCommand(content[0]) || isRedisCommand(bytes.Join(content[0:2], []byte(" ")))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a check in the (unlikely?) case that count < 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you explain more details about what to check? I just don't understand what do you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean accessing content[0:2]
can fail if len(content)
is 1, so you can write
if depth == 0 && (isRedisCommand(content[0]) || (count > 1 && isRedisCommand(bytes.Join(content[0:2], []byte(" "))))) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I get it.
@adriansr Would you please review again? |
@@ -423,7 +424,7 @@ func (p *parser) parseArray(depth int, buf *streambuf.Buffer) (common.NetString, | |||
} | |||
|
|||
// handle top-level request command | |||
if depth == 0 && isRedisCommand(content[0]) { | |||
if depth == 0 && (isRedisCommand(content[0]) || (count > 1 && isRedisCommand(bytes.Join(content[0:2], []byte(" "))))) { | |||
p.message.isRequest = true | |||
p.message.method = content[0] | |||
if len(content) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like p.message.method
and p.message.path
need to be computed differently as well to handle the two-word case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have a look and test again.
@@ -70,6 +70,24 @@ func TestRedisParser_ArrayRequest(t *testing.T) { | |||
assert.Equal(t, len(arrayRequest), msg.size) | |||
} | |||
|
|||
var arrayRequest2 = []byte("*3\r\n" + | |||
"$6\r\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the extra whitespace here is probably what's breaking the linter... can you run mage fmt update
and re-commit to make sure everything is formatted right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get errors, would you please help me?
\# command-line-arguments
./magefile.go:153:13: undefined: "github.com/elastic/beats/dev-tools/mage".DefaultIncludeListOptions
./magefile.go:156:39: not enough arguments in call to "github.com/elastic/beats/dev-tools/mage".GenerateIncludeListGo
Error: error compiling magefiles
@adriansr @faec Would you please review my commits again?
|
Pinging @elastic/siem (Team:SIEM) |
jenkins, test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
elastic#14873) Updated redis protocol decoder to support two-word commands. Fixes elastic#14872 (cherry picked from commit 30a5687)
Is this released in v7.7.0, I can't find in the release notes. @adriansr |
@mazhechao I don't know why it's not in the release notes, but it made it to 7.7.0 |
I think it's better to mention this fix in the release notes. @adriansr |
Fixes #14872