mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Touchup TODOs in the Redis analyzer
Also renames `KnownCommand` to `RedisCommand` to avoid conflicts.
This commit is contained in:
parent
64443e5e5a
commit
e7c798e526
6 changed files with 131 additions and 140 deletions
|
@ -74,17 +74,17 @@ export {
|
||||||
option max_pending_commands = 10000;
|
option max_pending_commands = 10000;
|
||||||
|
|
||||||
# These commands enter subscribed mode
|
# These commands enter subscribed mode
|
||||||
global enter_subscribed_mode = [KnownCommand_PSUBSCRIBE,
|
global enter_subscribed_mode = [RedisCommand_PSUBSCRIBE,
|
||||||
KnownCommand_SSUBSCRIBE, KnownCommand_SUBSCRIBE];
|
RedisCommand_SSUBSCRIBE, RedisCommand_SUBSCRIBE];
|
||||||
|
|
||||||
# These commands exit subscribed mode
|
# These commands exit subscribed mode
|
||||||
global exit_subscribed_mode = [KnownCommand_RESET, KnownCommand_QUIT];
|
global exit_subscribed_mode = [RedisCommand_RESET, RedisCommand_QUIT];
|
||||||
|
|
||||||
# These commands don't expect a response (ever) - their replies are out of band.
|
# These commands don't expect a response (ever) - their replies are out of band.
|
||||||
global no_response_commands = [KnownCommand_PSUBSCRIBE,
|
global no_response_commands = [RedisCommand_PSUBSCRIBE,
|
||||||
KnownCommand_PUNSUBSCRIBE, KnownCommand_SSUBSCRIBE,
|
RedisCommand_PUNSUBSCRIBE, RedisCommand_SSUBSCRIBE,
|
||||||
KnownCommand_SUBSCRIBE, KnownCommand_SUNSUBSCRIBE,
|
RedisCommand_SUBSCRIBE, RedisCommand_SUNSUBSCRIBE,
|
||||||
KnownCommand_UNSUBSCRIBE];
|
RedisCommand_UNSUBSCRIBE];
|
||||||
}
|
}
|
||||||
|
|
||||||
redef record connection += {
|
redef record connection += {
|
||||||
|
@ -147,7 +147,7 @@ function is_last_interval_closed(c: connection): bool
|
||||||
c$redis_state$no_reply_ranges[-1]?$end;
|
c$redis_state$no_reply_ranges[-1]?$end;
|
||||||
}
|
}
|
||||||
|
|
||||||
event Redis::hello_command(c: connection, hello: HelloCommand)
|
event hello_command(c: connection, hello: HelloCommand)
|
||||||
{
|
{
|
||||||
if ( ! c?$redis_state )
|
if ( ! c?$redis_state )
|
||||||
make_new_state(c);
|
make_new_state(c);
|
||||||
|
@ -156,7 +156,7 @@ event Redis::hello_command(c: connection, hello: HelloCommand)
|
||||||
c$redis_state$resp_version = RESP3;
|
c$redis_state$resp_version = RESP3;
|
||||||
}
|
}
|
||||||
|
|
||||||
event Redis::command(c: connection, cmd: Command)
|
event command(c: connection, cmd: Command)
|
||||||
{
|
{
|
||||||
if ( ! c?$redis_state )
|
if ( ! c?$redis_state )
|
||||||
make_new_state(c);
|
make_new_state(c);
|
||||||
|
@ -196,7 +196,7 @@ event Redis::command(c: connection, cmd: Command)
|
||||||
# CLIENT commands can skip a number of replies and may be used with
|
# CLIENT commands can skip a number of replies and may be used with
|
||||||
# pipelining. We need special logic in order to track the command/reply
|
# pipelining. We need special logic in order to track the command/reply
|
||||||
# pairs.
|
# pairs.
|
||||||
if ( cmd?$known && cmd$known == KnownCommand_CLIENT )
|
if ( cmd?$known && cmd$known == RedisCommand_CLIENT )
|
||||||
{
|
{
|
||||||
# All 3 CLIENT commands we care about have 3 elements
|
# All 3 CLIENT commands we care about have 3 elements
|
||||||
if ( |cmd$raw| == 3 )
|
if ( |cmd$raw| == 3 )
|
||||||
|
@ -291,11 +291,12 @@ function log_from(c: connection, previous_reply_num: count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event Redis::reply(c: connection, data: ReplyData)
|
event reply(c: connection, data: ReplyData)
|
||||||
{
|
{
|
||||||
if ( ! c?$redis_state )
|
if ( ! c?$redis_state )
|
||||||
make_new_state(c);
|
make_new_state(c);
|
||||||
|
|
||||||
|
# If the server is talking in RESP3, mark accordingly, even if we didn't see HELLO
|
||||||
if ( data$min_protocol_version == 3 )
|
if ( data$min_protocol_version == 3 )
|
||||||
{
|
{
|
||||||
c$redis_state$resp_version = RESP3;
|
c$redis_state$resp_version = RESP3;
|
||||||
|
@ -307,6 +308,7 @@ event Redis::reply(c: connection, data: ReplyData)
|
||||||
event server_push(c, data);
|
event server_push(c, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
local previous_reply_num = c$redis_state$current_reply;
|
local previous_reply_num = c$redis_state$current_reply;
|
||||||
c$redis_state$current_reply = reply_num(c);
|
c$redis_state$current_reply = reply_num(c);
|
||||||
set_state(c, F);
|
set_state(c, F);
|
||||||
|
@ -320,7 +322,7 @@ event Redis::reply(c: connection, data: ReplyData)
|
||||||
clear_table(c$redis_state$skip_commands);
|
clear_table(c$redis_state$skip_commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
event Redis::error(c: connection, data: ReplyData)
|
event error(c: connection, data: ReplyData)
|
||||||
{
|
{
|
||||||
if ( ! c?$redis_state )
|
if ( ! c?$redis_state )
|
||||||
make_new_state(c);
|
make_new_state(c);
|
||||||
|
|
|
@ -55,7 +55,7 @@ export {
|
||||||
## The value, if this command is known to have a value
|
## The value, if this command is known to have a value
|
||||||
value: string &log &optional;
|
value: string &log &optional;
|
||||||
## The command in an enum if it was known
|
## The command in an enum if it was known
|
||||||
known: KnownCommand &optional;
|
known: RedisCommand &optional;
|
||||||
};
|
};
|
||||||
|
|
||||||
## A generic Redis reply from the client.
|
## A generic Redis reply from the client.
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Redis;
|
||||||
|
|
||||||
import RESP;
|
import RESP;
|
||||||
|
|
||||||
public type KnownCommand = enum {
|
public type RedisCommand = enum {
|
||||||
APPEND,
|
APPEND,
|
||||||
AUTH,
|
AUTH,
|
||||||
BITCOUNT,
|
BITCOUNT,
|
||||||
|
@ -64,7 +64,7 @@ type Command = struct {
|
||||||
name: bytes;
|
name: bytes;
|
||||||
key: optional<bytes>;
|
key: optional<bytes>;
|
||||||
value: optional<bytes>;
|
value: optional<bytes>;
|
||||||
known: optional<KnownCommand>;
|
known: optional<RedisCommand>;
|
||||||
};
|
};
|
||||||
|
|
||||||
# This just assumes all elements in the array is a bulk string and puts them in a vector
|
# This just assumes all elements in the array is a bulk string and puts them in a vector
|
||||||
|
@ -158,44 +158,44 @@ function parse_command(raw: vector<bytes>): Command {
|
||||||
|
|
||||||
if (|raw| >= 2) {
|
if (|raw| >= 2) {
|
||||||
switch (*cmd) {
|
switch (*cmd) {
|
||||||
case KnownCommand::KEYS:
|
case RedisCommand::KEYS:
|
||||||
parsed.key = raw[1];
|
parsed.key = raw[1];
|
||||||
case KnownCommand::APPEND,
|
case RedisCommand::APPEND,
|
||||||
KnownCommand::BITCOUNT,
|
RedisCommand::BITCOUNT,
|
||||||
KnownCommand::BITFIELD,
|
RedisCommand::BITFIELD,
|
||||||
KnownCommand::BITFIELD_RO,
|
RedisCommand::BITFIELD_RO,
|
||||||
KnownCommand::BITPOS,
|
RedisCommand::BITPOS,
|
||||||
KnownCommand::BLPOP,
|
RedisCommand::BLPOP,
|
||||||
KnownCommand::BRPOP,
|
RedisCommand::BRPOP,
|
||||||
KnownCommand::COPY,
|
RedisCommand::COPY,
|
||||||
KnownCommand::DECR,
|
RedisCommand::DECR,
|
||||||
KnownCommand::DECRBY,
|
RedisCommand::DECRBY,
|
||||||
KnownCommand::DEL,
|
RedisCommand::DEL,
|
||||||
KnownCommand::DUMP,
|
RedisCommand::DUMP,
|
||||||
KnownCommand::EXISTS,
|
RedisCommand::EXISTS,
|
||||||
KnownCommand::EXPIRE,
|
RedisCommand::EXPIRE,
|
||||||
KnownCommand::EXPIREAT,
|
RedisCommand::EXPIREAT,
|
||||||
KnownCommand::EXPIRETIME,
|
RedisCommand::EXPIRETIME,
|
||||||
KnownCommand::GET,
|
RedisCommand::GET,
|
||||||
KnownCommand::GETBIT,
|
RedisCommand::GETBIT,
|
||||||
KnownCommand::GETDEL,
|
RedisCommand::GETDEL,
|
||||||
KnownCommand::GETEX,
|
RedisCommand::GETEX,
|
||||||
KnownCommand::GETRANGE,
|
RedisCommand::GETRANGE,
|
||||||
KnownCommand::GETSET,
|
RedisCommand::GETSET,
|
||||||
KnownCommand::HDEL,
|
RedisCommand::HDEL,
|
||||||
KnownCommand::HGET,
|
RedisCommand::HGET,
|
||||||
KnownCommand::HSET,
|
RedisCommand::HSET,
|
||||||
KnownCommand::INCR,
|
RedisCommand::INCR,
|
||||||
KnownCommand::INCRBY,
|
RedisCommand::INCRBY,
|
||||||
KnownCommand::MGET,
|
RedisCommand::MGET,
|
||||||
KnownCommand::MOVE,
|
RedisCommand::MOVE,
|
||||||
KnownCommand::MSET,
|
RedisCommand::MSET,
|
||||||
KnownCommand::PERSIST,
|
RedisCommand::PERSIST,
|
||||||
KnownCommand::RENAME,
|
RedisCommand::RENAME,
|
||||||
KnownCommand::SET,
|
RedisCommand::SET,
|
||||||
KnownCommand::STRLEN,
|
RedisCommand::STRLEN,
|
||||||
KnownCommand::TTL,
|
RedisCommand::TTL,
|
||||||
KnownCommand::TYPE:
|
RedisCommand::TYPE:
|
||||||
parsed.key = raw[1];
|
parsed.key = raw[1];
|
||||||
default: ();
|
default: ();
|
||||||
}
|
}
|
||||||
|
@ -203,22 +203,22 @@ function parse_command(raw: vector<bytes>): Command {
|
||||||
|
|
||||||
if (|raw| >= 3) {
|
if (|raw| >= 3) {
|
||||||
switch (*cmd) {
|
switch (*cmd) {
|
||||||
case KnownCommand::SET,
|
case RedisCommand::SET,
|
||||||
KnownCommand::APPEND,
|
RedisCommand::APPEND,
|
||||||
KnownCommand::DECRBY,
|
RedisCommand::DECRBY,
|
||||||
KnownCommand::EXPIRE,
|
RedisCommand::EXPIRE,
|
||||||
KnownCommand::EXPIREAT,
|
RedisCommand::EXPIREAT,
|
||||||
KnownCommand::GETBIT,
|
RedisCommand::GETBIT,
|
||||||
KnownCommand::GETSET,
|
RedisCommand::GETSET,
|
||||||
KnownCommand::HDEL,
|
RedisCommand::HDEL,
|
||||||
KnownCommand::HGET,
|
RedisCommand::HGET,
|
||||||
KnownCommand::INCRBY,
|
RedisCommand::INCRBY,
|
||||||
KnownCommand::MOVE,
|
RedisCommand::MOVE,
|
||||||
KnownCommand::MSET,
|
RedisCommand::MSET,
|
||||||
KnownCommand::RENAME:
|
RedisCommand::RENAME:
|
||||||
parsed.value = raw[2];
|
parsed.value = raw[2];
|
||||||
# Op first, destination second, then a list of keys. Just log dest
|
# Op first, destination second, then a list of keys. Just log dest
|
||||||
case KnownCommand::BITOP: parsed.key = raw[2];
|
case RedisCommand::BITOP: parsed.key = raw[2];
|
||||||
default: ();
|
default: ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ function parse_command(raw: vector<bytes>): Command {
|
||||||
if (|raw| >= 4) {
|
if (|raw| >= 4) {
|
||||||
switch (*cmd) {
|
switch (*cmd) {
|
||||||
# timeout, numkeys, then key
|
# timeout, numkeys, then key
|
||||||
case KnownCommand::BLMPOP: parsed.key = raw[3];
|
case RedisCommand::BLMPOP: parsed.key = raw[3];
|
||||||
default: ();
|
default: ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,60 +234,60 @@ function parse_command(raw: vector<bytes>): Command {
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function command_from(cmd_bytes: bytes): optional<KnownCommand> {
|
function command_from(cmd_bytes: bytes): optional<RedisCommand> {
|
||||||
local cmd: optional<KnownCommand> = Null;
|
local cmd: optional<RedisCommand> = Null;
|
||||||
switch (cmd_bytes.lower()) {
|
switch (cmd_bytes.lower()) {
|
||||||
case b"append": cmd = KnownCommand::APPEND;
|
case b"append": cmd = RedisCommand::APPEND;
|
||||||
case b"auth": cmd = KnownCommand::AUTH;
|
case b"auth": cmd = RedisCommand::AUTH;
|
||||||
case b"bitcount": cmd = KnownCommand::BITCOUNT;
|
case b"bitcount": cmd = RedisCommand::BITCOUNT;
|
||||||
case b"bitfield": cmd = KnownCommand::BITFIELD;
|
case b"bitfield": cmd = RedisCommand::BITFIELD;
|
||||||
case b"bitfield_ro": cmd = KnownCommand::BITFIELD_RO;
|
case b"bitfield_ro": cmd = RedisCommand::BITFIELD_RO;
|
||||||
case b"bitop": cmd = KnownCommand::BITOP;
|
case b"bitop": cmd = RedisCommand::BITOP;
|
||||||
case b"bitpos": cmd = KnownCommand::BITPOS;
|
case b"bitpos": cmd = RedisCommand::BITPOS;
|
||||||
case b"blmpop": cmd = KnownCommand::BLMPOP;
|
case b"blmpop": cmd = RedisCommand::BLMPOP;
|
||||||
case b"blpop": cmd = KnownCommand::BLPOP;
|
case b"blpop": cmd = RedisCommand::BLPOP;
|
||||||
case b"brpop": cmd = KnownCommand::BRPOP;
|
case b"brpop": cmd = RedisCommand::BRPOP;
|
||||||
case b"client": cmd = KnownCommand::CLIENT;
|
case b"client": cmd = RedisCommand::CLIENT;
|
||||||
case b"copy": cmd = KnownCommand::COPY;
|
case b"copy": cmd = RedisCommand::COPY;
|
||||||
case b"decr": cmd = KnownCommand::DECR;
|
case b"decr": cmd = RedisCommand::DECR;
|
||||||
case b"decrby": cmd = KnownCommand::DECRBY;
|
case b"decrby": cmd = RedisCommand::DECRBY;
|
||||||
case b"del": cmd = KnownCommand::DEL;
|
case b"del": cmd = RedisCommand::DEL;
|
||||||
case b"dump": cmd = KnownCommand::DUMP;
|
case b"dump": cmd = RedisCommand::DUMP;
|
||||||
case b"exists": cmd = KnownCommand::EXISTS;
|
case b"exists": cmd = RedisCommand::EXISTS;
|
||||||
case b"expire": cmd = KnownCommand::EXPIRE;
|
case b"expire": cmd = RedisCommand::EXPIRE;
|
||||||
case b"expireat": cmd = KnownCommand::EXPIREAT;
|
case b"expireat": cmd = RedisCommand::EXPIREAT;
|
||||||
case b"expiretime": cmd = KnownCommand::EXPIRETIME;
|
case b"expiretime": cmd = RedisCommand::EXPIRETIME;
|
||||||
case b"expiretime": cmd = KnownCommand::EXPIRETIME;
|
case b"expiretime": cmd = RedisCommand::EXPIRETIME;
|
||||||
case b"get": cmd = KnownCommand::GET;
|
case b"get": cmd = RedisCommand::GET;
|
||||||
case b"getbit": cmd = KnownCommand::GETBIT;
|
case b"getbit": cmd = RedisCommand::GETBIT;
|
||||||
case b"getdel": cmd = KnownCommand::GETDEL;
|
case b"getdel": cmd = RedisCommand::GETDEL;
|
||||||
case b"getex": cmd = KnownCommand::GETEX;
|
case b"getex": cmd = RedisCommand::GETEX;
|
||||||
case b"getrange": cmd = KnownCommand::GETRANGE;
|
case b"getrange": cmd = RedisCommand::GETRANGE;
|
||||||
case b"getset": cmd = KnownCommand::GETSET;
|
case b"getset": cmd = RedisCommand::GETSET;
|
||||||
case b"hdel": cmd = KnownCommand::HDEL;
|
case b"hdel": cmd = RedisCommand::HDEL;
|
||||||
case b"hello": cmd = KnownCommand::HELLO;
|
case b"hello": cmd = RedisCommand::HELLO;
|
||||||
case b"hget": cmd = KnownCommand::HGET;
|
case b"hget": cmd = RedisCommand::HGET;
|
||||||
case b"hset": cmd = KnownCommand::HSET;
|
case b"hset": cmd = RedisCommand::HSET;
|
||||||
case b"incr": cmd = KnownCommand::INCR;
|
case b"incr": cmd = RedisCommand::INCR;
|
||||||
case b"incrby": cmd = KnownCommand::INCRBY;
|
case b"incrby": cmd = RedisCommand::INCRBY;
|
||||||
case b"keys": cmd = KnownCommand::KEYS;
|
case b"keys": cmd = RedisCommand::KEYS;
|
||||||
case b"mget": cmd = KnownCommand::MGET;
|
case b"mget": cmd = RedisCommand::MGET;
|
||||||
case b"move": cmd = KnownCommand::MOVE;
|
case b"move": cmd = RedisCommand::MOVE;
|
||||||
case b"mset": cmd = KnownCommand::MSET;
|
case b"mset": cmd = RedisCommand::MSET;
|
||||||
case b"persist": cmd = KnownCommand::PERSIST;
|
case b"persist": cmd = RedisCommand::PERSIST;
|
||||||
case b"psubscribe": cmd = KnownCommand::PSUBSCRIBE;
|
case b"psubscribe": cmd = RedisCommand::PSUBSCRIBE;
|
||||||
case b"punsubscribe": cmd = KnownCommand::PUNSUBSCRIBE;
|
case b"punsubscribe": cmd = RedisCommand::PUNSUBSCRIBE;
|
||||||
case b"quit": cmd = KnownCommand::QUIT;
|
case b"quit": cmd = RedisCommand::QUIT;
|
||||||
case b"rename": cmd = KnownCommand::RENAME;
|
case b"rename": cmd = RedisCommand::RENAME;
|
||||||
case b"reset": cmd = KnownCommand::RESET;
|
case b"reset": cmd = RedisCommand::RESET;
|
||||||
case b"set": cmd = KnownCommand::SET;
|
case b"set": cmd = RedisCommand::SET;
|
||||||
case b"strlen": cmd = KnownCommand::STRLEN;
|
case b"strlen": cmd = RedisCommand::STRLEN;
|
||||||
case b"ssubscribe": cmd = KnownCommand::SSUBSCRIBE;
|
case b"ssubscribe": cmd = RedisCommand::SSUBSCRIBE;
|
||||||
case b"subscribe": cmd = KnownCommand::SUBSCRIBE;
|
case b"subscribe": cmd = RedisCommand::SUBSCRIBE;
|
||||||
case b"sunsubscribe": cmd = KnownCommand::SUNSUBSCRIBE;
|
case b"sunsubscribe": cmd = RedisCommand::SUNSUBSCRIBE;
|
||||||
case b"ttl": cmd = KnownCommand::TTL;
|
case b"ttl": cmd = RedisCommand::TTL;
|
||||||
case b"type": cmd = KnownCommand::TYPE;
|
case b"type": cmd = RedisCommand::TYPE;
|
||||||
case b"unsubscribe": cmd = KnownCommand::UNSUBSCRIBE;
|
case b"unsubscribe": cmd = RedisCommand::UNSUBSCRIBE;
|
||||||
default: cmd = Null;
|
default: cmd = Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ public function make_set(command: Command): Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_set(data: RESP::ClientData): bool {
|
public function is_set(data: RESP::ClientData): bool {
|
||||||
return data.command.known && *(data.command.known) == KnownCommand::SET && data.command.key && data.command.value;
|
return data.command.known && *(data.command.known) == RedisCommand::SET && data.command.key && data.command.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Get = struct {
|
type Get = struct {
|
||||||
|
@ -365,7 +365,7 @@ public function make_get(command: Command): Get {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_get(data: RESP::ClientData): bool {
|
public function is_get(data: RESP::ClientData): bool {
|
||||||
return data.command.known && *(data.command.known) == KnownCommand::GET && |data.command.raw| >= 2;
|
return data.command.known && *(data.command.known) == RedisCommand::GET && |data.command.raw| >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Auth = struct {
|
type Auth = struct {
|
||||||
|
@ -383,7 +383,7 @@ public function make_auth(command: Command): Auth {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_auth(data: RESP::ClientData): bool {
|
public function is_auth(data: RESP::ClientData): bool {
|
||||||
return data.command.known && *(data.command.known) == KnownCommand::AUTH && |data.command.raw| >= 2;
|
return data.command.known && *(data.command.known) == RedisCommand::AUTH && |data.command.raw| >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hello = struct {
|
type Hello = struct {
|
||||||
|
@ -398,7 +398,7 @@ public function make_hello(command: Command): Hello {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_hello(data: RESP::ClientData): bool {
|
public function is_hello(data: RESP::ClientData): bool {
|
||||||
return data.command.known && *(data.command.known) == KnownCommand::HELLO;
|
return data.command.known && *(data.command.known) == RedisCommand::HELLO;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplyData = struct {
|
type ReplyData = struct {
|
||||||
|
@ -431,7 +431,7 @@ function bulk_string_content(bulk: RESP::BulkString): bytes {
|
||||||
return b"";
|
return b"";
|
||||||
}
|
}
|
||||||
|
|
||||||
function stringify_map(data: RESP::Map): bytes {
|
function stringify_map(data: RESP::Map&): bytes {
|
||||||
local res = b"{";
|
local res = b"{";
|
||||||
local first = True;
|
local first = True;
|
||||||
local i = 0;
|
local i = 0;
|
||||||
|
@ -451,7 +451,7 @@ function stringify_map(data: RESP::Map): bytes {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns the bytes string value of this, or Null if it cannot.
|
# Returns the bytes string value of this, or Null if it cannot.
|
||||||
function stringify(data: RESP::Data): bytes {
|
function stringify(data: RESP::Data&): bytes {
|
||||||
if (data?.simple_string)
|
if (data?.simple_string)
|
||||||
return data.simple_string.content;
|
return data.simple_string.content;
|
||||||
else if (data?.simple_error)
|
else if (data?.simple_error)
|
||||||
|
|
|
@ -7,7 +7,7 @@ protocol analyzer Redis over TCP:
|
||||||
import RESP;
|
import RESP;
|
||||||
import Redis;
|
import Redis;
|
||||||
|
|
||||||
export Redis::KnownCommand;
|
export Redis::RedisCommand;
|
||||||
|
|
||||||
on RESP::ClientData if ( Redis::is_set(self) ) -> event Redis::set_command($conn, Redis::make_set(self.command));
|
on RESP::ClientData if ( Redis::is_set(self) ) -> event Redis::set_command($conn, Redis::make_set(self.command));
|
||||||
on RESP::ClientData if ( Redis::is_get(self) ) -> event Redis::get_command($conn, Redis::make_get(self.command).key);
|
on RESP::ClientData if ( Redis::is_get(self) ) -> event Redis::get_command($conn, Redis::make_get(self.command).key);
|
||||||
|
|
|
@ -116,7 +116,7 @@ type Data = unit(depth: uint8&) {
|
||||||
DataType::MAP -> map_: Map(depth);
|
DataType::MAP -> map_: Map(depth);
|
||||||
DataType::SET -> set_: Set(depth);
|
DataType::SET -> set_: Set(depth);
|
||||||
# "Push events are encoded similarly to arrays, differing only in their
|
# "Push events are encoded similarly to arrays, differing only in their
|
||||||
# first byte" - TODO: can probably make it more obvious, though
|
# first byte"
|
||||||
DataType::PUSH -> push: Array(depth);
|
DataType::PUSH -> push: Array(depth);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,22 +197,11 @@ type BigNum = unit {
|
||||||
|
|
||||||
type Map = unit(depth: uint8&) {
|
type Map = unit(depth: uint8&) {
|
||||||
num_elements: RedisBytes &convert=$$.to_uint(10);
|
num_elements: RedisBytes &convert=$$.to_uint(10);
|
||||||
# TODO: How can I make this into a map? Alternatively, how can I do this better?
|
|
||||||
raw_data: Data(depth)[self.num_elements * 2];
|
raw_data: Data(depth)[self.num_elements * 2];
|
||||||
|
|
||||||
# TODO: This is broken. See https://github.com/zeek/spicy/issues/2061
|
|
||||||
# var key_val_pairs: vector<tuple<Data, Data>>;
|
|
||||||
# on raw_data {
|
|
||||||
# while (local i = 0; i < self.num_elements) {
|
|
||||||
# self.key_val_pairs.push_back(($$[i], $$[i + 1]));
|
|
||||||
# i += 2;
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type Set = unit(depth: uint8&) {
|
type Set = unit(depth: uint8&) {
|
||||||
num_elements: RedisBytes &convert=$$.to_uint(10) &requires=self.num_elements <= MAX_SIZE;
|
num_elements: RedisBytes &convert=$$.to_uint(10) &requires=self.num_elements <= MAX_SIZE;
|
||||||
# TODO: This should be a set but doesn't go in the backed C++ set
|
|
||||||
elements: Data(depth)[self.num_elements];
|
elements: Data(depth)[self.num_elements];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -589,7 +589,7 @@ connection {
|
||||||
* cmd: record Redis::Command, log=T, optional=F
|
* cmd: record Redis::Command, log=T, optional=F
|
||||||
Redis::Command {
|
Redis::Command {
|
||||||
* key: string, log=T, optional=T
|
* key: string, log=T, optional=T
|
||||||
* known: enum Redis::KnownCommand, log=F, optional=T
|
* known: enum Redis::RedisCommand, log=F, optional=T
|
||||||
* name: string, log=T, optional=F
|
* name: string, log=T, optional=F
|
||||||
* raw: vector of string, log=F, optional=F
|
* raw: vector of string, log=F, optional=F
|
||||||
* value: string, log=T, optional=T
|
* value: string, log=T, optional=T
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue