mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 03:58:20 +00:00
FileAnalysis: file handles now set from events.
Versus from synchronous function calls, which doesn't work well because the function call can see a script-layer state that doesn't reflect the state as it will be in terms of the event/network stream.
This commit is contained in:
parent
00a1de3593
commit
84a0c2fdac
21 changed files with 362 additions and 392 deletions
|
@ -5,18 +5,32 @@
|
|||
|
||||
module HTTP;
|
||||
|
||||
function get_file_handle(c: connection, is_orig: bool): string
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
event get_file_handle(tag: AnalyzerTag, c: connection, is_orig: bool)
|
||||
{
|
||||
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));
|
||||
if ( tag != ANALYZER_HTTP ) return;
|
||||
if ( HTTP::disable_default_file_handle_provider ) return;
|
||||
return_file_handle(HTTP::get_file_handle(c, is_orig));
|
||||
}
|
||||
|
||||
redef FileAnalysis::handle_callbacks += {
|
||||
[ANALYZER_HTTP] = get_file_handle,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue