mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Migrate table-based for-loops to key-value iteration
This commit is contained in:
parent
41c7b229d3
commit
01d303b480
36 changed files with 150 additions and 153 deletions
|
@ -215,9 +215,8 @@ event connection_state_remove(c: connection)
|
|||
return;
|
||||
|
||||
# TODO: Go through any remaining dce_rpc requests that haven't been processed with replies.
|
||||
for ( i in c$dce_rpc_backing )
|
||||
for ( i, x in c$dce_rpc_backing )
|
||||
{
|
||||
local x = c$dce_rpc_backing[i];
|
||||
set_state(c, x);
|
||||
|
||||
# In the event that the binding wasn't seen, but the pipe
|
||||
|
|
|
@ -184,9 +184,9 @@ function log_unmatched_msgs_queue(q: Queue::Queue)
|
|||
|
||||
function log_unmatched_msgs(msgs: PendingMessages)
|
||||
{
|
||||
for ( trans_id in msgs )
|
||||
for ( trans_id, q in msgs )
|
||||
{
|
||||
log_unmatched_msgs_queue(msgs[trans_id]);
|
||||
log_unmatched_msgs_queue(q);
|
||||
}
|
||||
|
||||
clear_table(msgs);
|
||||
|
@ -285,8 +285,8 @@ hook set_session(c: connection, msg: dns_msg, is_query: bool) &priority=5
|
|||
else
|
||||
{
|
||||
# Just pick an arbitrary, unpaired query.
|
||||
for ( trans_id in c$dns_state$pending_queries )
|
||||
if ( Queue::len(c$dns_state$pending_queries[trans_id]) > 0 )
|
||||
for ( trans_id, q in c$dns_state$pending_queries )
|
||||
if ( Queue::len(q) > 0 )
|
||||
{
|
||||
c$dns_state$pending_query = pop_msg(c$dns_state$pending_queries, trans_id);
|
||||
break;
|
||||
|
|
|
@ -37,10 +37,10 @@ function describe_file(f: fa_file): string
|
|||
if ( f$source != "FTP" )
|
||||
return "";
|
||||
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
if ( f$conns[cid]?$ftp )
|
||||
return FTP::describe(f$conns[cid]$ftp);
|
||||
if ( c?$ftp )
|
||||
return FTP::describe(c$ftp);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -295,9 +295,9 @@ event connection_state_remove(c: connection) &priority=-5
|
|||
{
|
||||
if ( ! c?$ftp ) return;
|
||||
|
||||
for ( ca in c$ftp$pending_commands )
|
||||
for ( ca, cmdarg in c$ftp$pending_commands )
|
||||
{
|
||||
c$ftp$cmdarg = c$ftp$pending_commands[ca];
|
||||
c$ftp$cmdarg = cmdarg;
|
||||
ftp_message(c$ftp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,9 +91,8 @@ function get_pending_cmd(pc: PendingCmds, reply_code: count, reply_msg: string):
|
|||
local best_seq = 0;
|
||||
local best_score: int = -1;
|
||||
|
||||
for ( cmd_seq in pc )
|
||||
for ( cmd_seq, cmd in pc )
|
||||
{
|
||||
local cmd = pc[cmd_seq];
|
||||
local score: int = 0;
|
||||
|
||||
# if the command is compatible with the reply code
|
||||
|
|
|
@ -40,10 +40,10 @@ function describe_file(f: fa_file): string
|
|||
if ( f$source != "HTTP" )
|
||||
return "";
|
||||
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
if ( f$conns[cid]?$http )
|
||||
return build_url_http(f$conns[cid]$http);
|
||||
if ( c?$http )
|
||||
return build_url_http(c$http);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -326,11 +326,11 @@ event connection_state_remove(c: connection) &priority=-5
|
|||
# Flush all pending but incomplete request/response pairs.
|
||||
if ( c?$http_state )
|
||||
{
|
||||
for ( r in c$http_state$pending )
|
||||
for ( r, info in c$http_state$pending )
|
||||
{
|
||||
# We don't use pending elements at index 0.
|
||||
if ( r == 0 ) next;
|
||||
Log::write(HTTP::LOG, c$http_state$pending[r]);
|
||||
Log::write(HTTP::LOG, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,10 +65,8 @@ function log_dcc(f: fa_file)
|
|||
{
|
||||
if ( ! f?$conns ) return;
|
||||
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
local c: connection = f$conns[cid];
|
||||
|
||||
if ( [cid$resp_h, cid$resp_p] !in dcc_expected_transfers ) next;
|
||||
|
||||
local irc = dcc_expected_transfers[cid$resp_h, cid$resp_p];
|
||||
|
|
|
@ -48,11 +48,10 @@ function describe_file(f: fa_file): string
|
|||
# are already populated).
|
||||
#
|
||||
# Just return a bit of our connection information and hope that that is good enough.
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
if ( f$conns[cid]?$krb )
|
||||
if ( c?$krb )
|
||||
{
|
||||
local c = f$conns[cid];
|
||||
return cat(c$id$resp_h, ":", c$id$resp_p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,13 +149,13 @@ function flush_pending(c: connection)
|
|||
# Flush all pending but incomplete request/response pairs.
|
||||
if ( c?$sip_state )
|
||||
{
|
||||
for ( r in c$sip_state$pending )
|
||||
for ( r, info in c$sip_state$pending )
|
||||
{
|
||||
# We don't use pending elements at index 0.
|
||||
if ( r == 0 )
|
||||
next;
|
||||
|
||||
Log::write(SIP::LOG, c$sip_state$pending[r]);
|
||||
Log::write(SIP::LOG, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,9 +293,9 @@ event connection_state_remove(c: connection) &priority=-5
|
|||
{
|
||||
if ( c?$sip_state )
|
||||
{
|
||||
for ( r in c$sip_state$pending )
|
||||
for ( r, info in c$sip_state$pending )
|
||||
{
|
||||
Log::write(SIP::LOG, c$sip_state$pending[r]);
|
||||
Log::write(SIP::LOG, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,10 @@ function describe_file(f: fa_file): string
|
|||
if ( f$source != "SMB" )
|
||||
return "";
|
||||
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
local info = f$conns[cid];
|
||||
if ( info?$smb_state && info$smb_state?$current_file && info$smb_state$current_file?$name )
|
||||
return info$smb_state$current_file$name;
|
||||
if ( c?$smb_state && c$smb_state?$current_file && c$smb_state$current_file?$name )
|
||||
return c$smb_state$current_file$name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -238,9 +238,8 @@ event file_state_remove(f: fa_file) &priority=-5
|
|||
if ( f$source != "SMB" )
|
||||
return;
|
||||
|
||||
for ( id in f$conns )
|
||||
for ( id, c in f$conns )
|
||||
{
|
||||
local c = f$conns[id];
|
||||
if ( c?$smb_state && c$smb_state?$current_file)
|
||||
{
|
||||
write_file_log(c$smb_state);
|
||||
|
|
|
@ -31,9 +31,8 @@ function describe_file(f: fa_file): string
|
|||
if ( f$source != "SMTP" )
|
||||
return "";
|
||||
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
local c = f$conns[cid];
|
||||
return SMTP::describe(c$smtp);
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -66,11 +66,10 @@ function describe_file(f: fa_file): string
|
|||
# are already populated).
|
||||
#
|
||||
# Just return a bit of our connection information and hope that that is good enough.
|
||||
for ( cid in f$conns )
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
if ( f$conns[cid]?$ssl )
|
||||
if ( c?$ssl )
|
||||
{
|
||||
local c = f$conns[cid];
|
||||
return cat(c$id$resp_h, ":", c$id$resp_p);
|
||||
}
|
||||
}
|
||||
|
@ -103,12 +102,12 @@ event file_sniff(f: fa_file, meta: fa_metadata) &priority=5
|
|||
|| f$info$mime_type == "application/pkix-cert" ) )
|
||||
return;
|
||||
|
||||
for ( cid in f$conns )
|
||||
{
|
||||
if ( ! f$conns[cid]?$ssl )
|
||||
return;
|
||||
local c: connection;
|
||||
|
||||
local c = f$conns[cid];
|
||||
for ( cid, c in f$conns )
|
||||
{
|
||||
if ( ! c?$ssl )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! c$ssl?$cert_chain )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue