mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
spicy-redis: Add some commands and touch up parsing
This commit is contained in:
parent
22bda56af3
commit
f0e9f46c7c
21 changed files with 200 additions and 114 deletions
|
@ -0,0 +1,8 @@
|
|||
# @TEST-DOC: Test 2 commands that look like RESP, then server responses don't
|
||||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/almost-resp.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
#
|
||||
# Really, the first 2 ARE Redis. The later ones should not be logged because we
|
||||
# realized it's not Redis. The output from the server is:
|
||||
# +OK\r\n+OK\r\nnot RESP\r\nStill not RESP\r\nNope\r\n
|
16
testing/btest/scripts/base/protocols/redis/auth.zeek
Normal file
16
testing/btest/scripts/base/protocols/redis/auth.zeek
Normal file
|
@ -0,0 +1,16 @@
|
|||
# @TEST-DOC: Test Zeek with AUTH commands
|
||||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/auth.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
event Redis::auth_command(c: connection, is_orig: bool,
|
||||
command: Redis::AuthCommand)
|
||||
{
|
||||
print "AUTH";
|
||||
if ( command?$username )
|
||||
print fmt("username: %s", command$username);
|
||||
else
|
||||
print "username: default";
|
||||
|
||||
print fmt("password: %s", command$password);
|
||||
}
|
|
@ -7,7 +7,8 @@
|
|||
# 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 Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
event Redis::set_command(c: connection, is_orig: bool,
|
||||
command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
|
|
@ -2,4 +2,3 @@
|
|||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/reply-off-on-2conn.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
|
|
|
@ -2,4 +2,3 @@
|
|||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/reply-off-on.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
|
|
|
@ -2,4 +2,3 @@
|
|||
#
|
||||
# @TEST-EXEC: zeek -Cr $TRACES/redis/client-skip-while-off.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
redef Redis::ports += {
|
||||
10625/tcp,
|
||||
};
|
||||
redef Redis::ports += { 10625/tcp, };
|
||||
|
||||
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);
|
||||
}
|
||||
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,8 +4,10 @@
|
|||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
# 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 Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
event Redis::set_command(c: connection, is_orig: bool,
|
||||
command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
||||
event Redis::get_command(c: connection, is_orig: bool, command: Redis::GetCommand)
|
||||
{
|
||||
print fmt("GET: %s", command);
|
||||
}
|
||||
event Redis::get_command(c: connection, is_orig: bool,
|
||||
command: Redis::GetCommand)
|
||||
{
|
||||
print fmt("GET: %s", command);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
# @TEST-EXEC: zeek -Cr $TRACES/redis/set.trace base/protocols/redis %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("Key: %s Value: %s", command$key, command$value);
|
||||
}
|
||||
event Redis::set_command(c: connection, is_orig: bool,
|
||||
command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("Key: %s Value: %s", command$key, command$value);
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# @TEST-DOC: Test parsing behavior of RESP.
|
||||
#
|
||||
# @TEST-EXEC: spicyc ${DIST}/analyzer/resp.spicy ${DIST}/analyzer/redis.spicy -j -d -o redis.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.
|
||||
# @TEST-EXEC: printf "+OK\x0d\x0a" | spicy-dump -p RESP::Data redis.hlto >>output 2>&1
|
||||
# @TEST-EXEC: printf ":1000\x0d\x0a" | spicy-dump -p RESP::Data redis.hlto >>output 2>&1
|
||||
# @TEST-EXEC: printf ":-1000\x0d\x0a" | spicy-dump -p RESP::Data redis.hlto >>output 2>&1
|
||||
# @TEST-EXEC: printf ":+1000\x0d\x0a" | spicy-dump -p RESP::Data redis.hlto >>output 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output
|
|
@ -4,12 +4,14 @@
|
|||
# @TEST-EXEC: btest-diff output
|
||||
# @TEST-EXEC: btest-diff redis.log
|
||||
|
||||
event Redis::set_command(c: connection, is_orig: bool, command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
event Redis::set_command(c: connection, is_orig: bool,
|
||||
command: Redis::SetCommand)
|
||||
{
|
||||
print fmt("SET: %s %s", command$key, command$value);
|
||||
}
|
||||
|
||||
event Redis::get_command(c: connection, is_orig: bool, command: Redis::GetCommand)
|
||||
{
|
||||
print fmt("GET: %s", command);
|
||||
}
|
||||
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