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

@ -1,4 +1,11 @@
2.6-237 | 2019-04-19 12:00:37 -0700
* GH-236: Add zeek_script_loaded event, deprecate bro_script_loaded (Jon Siwek, Corelight)
Existing handlers for bro_script_loaded automatically alias to the new
zeek_script_loaded event, but emit a deprecation warning.
2.6-236 | 2019-04-19 11:16:35 -0700
* Add zeek_init/zeek_done events and deprecate bro_init/bro_done (Seth Hall, Corelight)

11
NEWS
View file

@ -176,11 +176,12 @@ Deprecated Functionality
instead. The later will automatically return a value that is enclosed
in double-quotes.
- The ``bro_init`` and ``bro_done`` events are now deprecated, use
``zeek_init`` and ``zeek_done`` instead. Any existing handlers for
``bro_init`` and ``bro_done`` will automatically alias to the new
``zeek_init`` and ``zeek_done`` events such that existing code will
not break, but will emit a deprecation warning.
- The ``bro_init``, ``bro_done``, and ``bro_script_loaded`` events are now
deprecated, use ``zeek_init``, ``zeek_done``, and
``zeek_script_loaded`` instead. Any existing event handlers for
the deprecated versions will automatically alias to the new events
such that existing code will not break, but will emit a deprecation
warning.
Bro 2.6
=======

View file

@ -1 +1 @@
2.6-236
2.6-237

2
doc

@ -1 +1 @@
Subproject commit 5e02a297eefe8740e8b84f7610fbf126af5c3475
Subproject commit ef39a55ef00382d49459783aa0144ef672b4de97

View file

@ -32,7 +32,7 @@ event zeek_init() &priority=5
Log::create_stream(LoadedScripts::LOG, [$columns=Info, $path="loaded_scripts"]);
}
event bro_script_loaded(path: string, level: count)
event zeek_script_loaded(path: string, level: count)
{
Log::write(LoadedScripts::LOG, [$name=cat(get_indent(level), compress_path(path))]);
}

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);

View file

@ -0,0 +1,4 @@
zeek_script_loaded priority 10
bro_script_loaded priority 5
zeek_script_loaded priority 0
bro_script_loaded priority -10

View file

@ -0,0 +1,26 @@
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
event zeek_script_loaded(path: string, level: count) &priority=10
{
if ( /zeek_script_loaded.zeek/ in path )
print "zeek_script_loaded priority 10";
}
event bro_script_loaded(path: string, level: count) &priority=5
{
if ( /zeek_script_loaded.zeek/ in path )
print "bro_script_loaded priority 5";
}
event zeek_script_loaded(path: string, level: count) &priority=0
{
if ( /zeek_script_loaded.zeek/ in path )
print "zeek_script_loaded priority 0";
}
event bro_script_loaded(path: string, level: count) &priority=-10
{
if ( /zeek_script_loaded.zeek/ in path )
print "bro_script_loaded priority -10";
}