mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
FileAnalysis: insert explicit event queue flush points.
And added an event called "event_queue_flush_point" to mark where that occured in the event stream. The FAF now uses an explicit event queue flush instead of buffering input in order to wait for a file handle to be returned from script-layer.
This commit is contained in:
parent
d9321e2203
commit
2747e839fb
15 changed files with 128 additions and 382 deletions
|
@ -5,46 +5,43 @@
|
|||
module FTP;
|
||||
|
||||
export {
|
||||
## Determines whether the default :bro:see:`get_file_handle` handler
|
||||
## is used to return file handles to the file analysis framework.
|
||||
## Redefine to true in order to provide a custom handler which overrides
|
||||
## the default for FTP.
|
||||
const disable_default_file_handle_provider: bool = F &redef;
|
||||
|
||||
## Default file handle provider for FTP.
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( [c$id$resp_h, c$id$resp_p] !in ftp_data_expected ) return "";
|
||||
|
||||
local info: FTP::Info = ftp_data_expected[c$id$resp_h, c$id$resp_p];
|
||||
|
||||
local rval = fmt("%s %s %s", ANALYZER_FTP_DATA, c$start_time,
|
||||
id_string(c$id));
|
||||
|
||||
if ( info$passive )
|
||||
# FTP client initiates data channel.
|
||||
if ( is_orig )
|
||||
# Don't care about FTP client data.
|
||||
return "";
|
||||
else
|
||||
# Do care about FTP server data.
|
||||
return rval;
|
||||
else
|
||||
# FTP server initiates dta channel.
|
||||
if ( is_orig )
|
||||
# Do care about FTP server data.
|
||||
return rval;
|
||||
else
|
||||
# Don't care about FTP client data.
|
||||
return "";
|
||||
}
|
||||
global get_file_handle: function(c: connection, is_orig: bool): string;
|
||||
}
|
||||
|
||||
function get_handle_string(c: connection): string
|
||||
{
|
||||
return fmt("%s %s %s", ANALYZER_FTP_DATA, c$start_time, id_string(c$id));
|
||||
}
|
||||
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( [c$id$resp_h, c$id$resp_p] !in ftp_data_expected ) return "";
|
||||
|
||||
local info: FTP::Info = ftp_data_expected[c$id$resp_h, c$id$resp_p];
|
||||
|
||||
if ( info$passive )
|
||||
# FTP client initiates data channel.
|
||||
if ( is_orig )
|
||||
# Don't care about FTP client data.
|
||||
return "";
|
||||
else
|
||||
# Do care about FTP server data.
|
||||
return get_handle_string(c);
|
||||
else
|
||||
# FTP server initiates dta channel.
|
||||
if ( is_orig )
|
||||
# Do care about FTP server data.
|
||||
return get_handle_string(c);
|
||||
else
|
||||
# Don't care about FTP client data.
|
||||
return "";
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
event get_file_handle(tag: AnalyzerTag, c: connection, is_orig: bool)
|
||||
{
|
||||
if ( tag != ANALYZER_FTP_DATA ) return;
|
||||
if ( FTP::disable_default_file_handle_provider ) return;
|
||||
return_file_handle(FTP::get_file_handle(c, is_orig));
|
||||
set_file_handle(FTP::get_file_handle(c, is_orig));
|
||||
}
|
||||
|
|
|
@ -6,31 +6,26 @@
|
|||
module HTTP;
|
||||
|
||||
export {
|
||||
## Determines whether the default :bro:see:`get_file_handle` handler
|
||||
## is used to return file handles to the file analysis framework.
|
||||
## Redefine to true in order to provide a custom handler which overrides
|
||||
## the default HTTP.
|
||||
const disable_default_file_handle_provider: bool = F &redef;
|
||||
|
||||
## Default file handle provider for HTTP.
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( ! c?$http ) return "";
|
||||
|
||||
if ( c$http$range_request )
|
||||
return fmt("%s %s %s %s", ANALYZER_HTTP, is_orig, c$id$orig_h,
|
||||
build_url(c$http));
|
||||
|
||||
return fmt("%s %s %s %s %s", ANALYZER_HTTP, c$start_time, is_orig,
|
||||
c$http$trans_depth, id_string(c$id));
|
||||
}
|
||||
global get_file_handle: function(c: connection, is_orig: bool): string;
|
||||
}
|
||||
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( ! c?$http ) return "";
|
||||
|
||||
if ( c$http$range_request )
|
||||
return fmt("%s %s %s %s", ANALYZER_HTTP, is_orig, c$id$orig_h,
|
||||
build_url(c$http));
|
||||
|
||||
return fmt("%s %s %s %s %s", ANALYZER_HTTP, c$start_time, is_orig,
|
||||
c$http$trans_depth, id_string(c$id));
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
event get_file_handle(tag: AnalyzerTag, c: connection, is_orig: bool)
|
||||
{
|
||||
if ( tag != ANALYZER_HTTP ) return;
|
||||
if ( HTTP::disable_default_file_handle_provider ) return;
|
||||
return_file_handle(HTTP::get_file_handle(c, is_orig));
|
||||
set_file_handle(HTTP::get_file_handle(c, is_orig));
|
||||
}
|
||||
|
|
|
@ -5,26 +5,20 @@
|
|||
module IRC;
|
||||
|
||||
export {
|
||||
## Determines whether the default :bro:see:`get_file_handle` handler
|
||||
## is used to return file handles to the file analysis framework.
|
||||
## Redefine to true in order to provide a custom handler which overrides
|
||||
## the default for IRC.
|
||||
const disable_default_file_handle_provider: bool = F &redef;
|
||||
|
||||
## Default file handle provider for IRC.
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( is_orig ) return "";
|
||||
return fmt("%s %s %s", ANALYZER_IRC_DATA, c$start_time,
|
||||
id_string(c$id));
|
||||
}
|
||||
global get_file_handle: function(c: connection, is_orig: bool): string;
|
||||
}
|
||||
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( is_orig ) return "";
|
||||
return fmt("%s %s %s", ANALYZER_IRC_DATA, c$start_time, id_string(c$id));
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
event get_file_handle(tag: AnalyzerTag, c: connection, is_orig: bool)
|
||||
{
|
||||
if ( tag != ANALYZER_IRC_DATA ) return;
|
||||
if ( IRC::disable_default_file_handle_provider ) return;
|
||||
return_file_handle(IRC::get_file_handle(c, is_orig));
|
||||
set_file_handle(IRC::get_file_handle(c, is_orig));
|
||||
}
|
||||
|
|
|
@ -6,27 +6,21 @@
|
|||
module SMTP;
|
||||
|
||||
export {
|
||||
## Determines whether the default :bro:see:`get_file_handle` handler
|
||||
## is used to return file handles to the file analysis framework.
|
||||
## Redefine to true in order to provide a custom handler which overrides
|
||||
## the default for SMTP.
|
||||
const disable_default_file_handle_provider: bool = F &redef;
|
||||
|
||||
## Default file handle provider for SMTP.
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( ! c?$smtp ) return "";
|
||||
|
||||
return fmt("%s %s %s %s", ANALYZER_SMTP, c$start_time,
|
||||
c$smtp$trans_depth, c$smtp_state$mime_level);
|
||||
}
|
||||
global get_file_handle: function(c: connection, is_orig: bool): string;
|
||||
}
|
||||
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
{
|
||||
if ( ! c?$smtp ) return "";
|
||||
return fmt("%s %s %s %s", ANALYZER_SMTP, c$start_time,
|
||||
c$smtp$trans_depth, c$smtp_state$mime_level);
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
event get_file_handle(tag: AnalyzerTag, c: connection, is_orig: bool)
|
||||
{
|
||||
if ( tag != ANALYZER_SMTP ) return;
|
||||
if ( SMTP::disable_default_file_handle_provider ) return;
|
||||
return_file_handle(SMTP::get_file_handle(c, is_orig));
|
||||
set_file_handle(SMTP::get_file_handle(c, is_orig));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue