mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
spicy-redis: Separate client/server
This makes the parser more official and splits the client/server out from each other. Apparently they're different enough to be separate.
This commit is contained in:
parent
f0f2969a66
commit
757cbbf902
28 changed files with 809 additions and 702 deletions
|
@ -1,3 +1,3 @@
|
|||
# @TEST-DOC: Check that the RESP analyzer is available.
|
||||
# @TEST-DOC: Check that the Redis analyzer is available.
|
||||
#
|
||||
# @TEST-EXEC: zeek -NN | grep -Eqi 'ANALYZER_SPICY_RESP'
|
||||
# @TEST-EXEC: zeek -NN | grep -Eqi 'ANALYZER_SPICY_REDIS'
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# code directly to the server, but it's useful to see if that trace might come
|
||||
# up with something different. See:
|
||||
# https://redis.io/docs/latest/develop/use/patterns/bulk-loading/
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff resp.log
|
||||
|
||||
redef RESP::ports += {
|
||||
redef Redis::ports += {
|
||||
10625/tcp,
|
||||
};
|
||||
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
# Print the whole command because these have extra data that's worth capturing.
|
||||
print fmt("SET: %s %s expires in %d milliseconds", command$key, command$value, command$px);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff resp.log
|
||||
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
# Print the whole command because these have extra data that's worth capturing.
|
||||
print fmt("SET: %s %s expires in %d milliseconds", command$key, command$value, command$px);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @TEST-EXEC: zeek -Cr $TRACES/redis/pipeline-quotes.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff resp.log
|
||||
# @TEST-EXEC: btest-diff weird.log
|
||||
# TODO: Make it so weird.log exists again with `zeek::weird` for inline commands
|
||||
# btest-diff weird.log
|
||||
|
||||
# Tests unserialized data where quotes should make one token
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
# Sometimes commands aren't serialized, like when pipelining. This still works! So we
|
||||
# should handle this. This particular example has a few commands, amongst them a SET and
|
||||
# a GET.
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
||||
event RESP::get_command(c: connection, is_orig: bool, command: RESP::GetCommand)
|
||||
event Redis::get_command(c: connection, is_orig: bool, command: Redis::GetCommand)
|
||||
{
|
||||
print fmt("GET: %s", command);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# @TEST-EXEC: zeek -Cr $TRACES/redis/set.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("Key: %s Value: %s", command$key, command$value);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# @TEST-DOC: Test parsing behavior of RESP.
|
||||
#
|
||||
# @TEST-EXEC: spicyc ${DIST}/analyzer/resp.spicy -j -d -o resp.hlto
|
||||
# @TEST-EXEC: spicyc ${DIST}/analyzer/resp.spicy ${DIST}/analyzer/redis.spicy -j -d -o resp.hlto
|
||||
#
|
||||
# TODO: A lot of tests are possible from the docs and having them would be nice.
|
||||
# But, a lot of characters ($, -, etc.) cause problems with TEST_EXEC. ugh.
|
||||
|
|
7
testing/btest/scripts/base/protocols/redis/stream.zeek
Normal file
7
testing/btest/scripts/base/protocols/redis/stream.zeek
Normal file
|
@ -0,0 +1,7 @@
|
|||
# @TEST-DOC: Test Zeek parsing pubsub commands
|
||||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/stream.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff resp.log
|
||||
|
||||
# Streams like with XRANGE return arrays of bulk strings. We shouldn't count the
|
||||
# response as commands.
|
|
@ -1,15 +1,15 @@
|
|||
# @TEST-DOC: Test Zeek parsing a trace file through the RESP analyzer.
|
||||
# @TEST-DOC: Test Zeek parsing a trace file through the Redis analyzer.
|
||||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/loop-redis.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff resp.log
|
||||
|
||||
event RESP::set_command(c: connection, is_orig: bool, command: RESP::SetCommand)
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
||||
event RESP::get_command(c: connection, is_orig: bool, command: RESP::GetCommand)
|
||||
event Redis::get_command(c: connection, is_orig: bool, command: Redis::GetCommand)
|
||||
{
|
||||
print fmt("GET: %s", command);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue