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:
Evan Typanski 2024-10-23 11:10:44 -04:00
parent f0f2969a66
commit 757cbbf902
28 changed files with 809 additions and 702 deletions

View file

@ -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'

View file

@ -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);
}

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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.

View 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.

View file

@ -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);
}