GH-236: Add zeek_script_loaded event, deprecate bro_script_loaded

This commit is contained in:
Jon Siwek 2019-04-19 12:00:37 -07:00
parent a994be9eeb
commit 3ea34d6ea3
11 changed files with 58 additions and 12 deletions

View file

@ -872,9 +872,14 @@ event reporter_error%(t: time, msg: string, location: string%) &error_handler;
##
## path: The full path to the script loaded.
##
## level: The "nesting level": zero for a top-level Bro script and incremented
## level: The "nesting level": zero for a top-level Zeek script and incremented
## recursively for each ``@load``.
event bro_script_loaded%(path: string, level: count%);
event zeek_script_loaded%(path: string, level: count%);
## Deprecated synonym for ``zeek_script_loaded``.
##
## .. bro:see: zeek_script_loaded
event bro_script_loaded%(path: string, level: count%) &deprecated;
## Generated each time Bro's script interpreter opens a file. This event is
## triggered only for files opened via :bro:id:`open`, and in particular not for

View file

@ -1193,7 +1193,7 @@ int main(int argc, char** argv)
val_list* vl = new val_list;
vl->append(new StringVal(i->name.c_str()));
vl->append(val_mgr->GetCount(i->include_level));
mgr.QueueEvent(bro_script_loaded, vl);
mgr.QueueEvent(zeek_script_loaded, vl);
}
reporter->ReportViaEvents(true);

View file

@ -1171,11 +1171,14 @@ func_hdr:
}
| TOK_EVENT event_id func_params opt_attr
{
// Gracefully handle the deprecation of bro_init and bro_done
// Gracefully handle the deprecation of bro_init, bro_done,
// and bro_script_loaded
if ( streq("bro_init", $2->Name()) )
$2 = global_scope()->Lookup("zeek_init");
else if ( streq("bro_done", $2->Name()) )
$2 = global_scope()->Lookup("zeek_done");
else if ( streq("bro_script_loaded", $2->Name()) )
$2 = global_scope()->Lookup("zeek_script_loaded");
begin_func($2, current_module.c_str(),
FUNC_FLAVOR_EVENT, 0, $3, $4);