mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-236: Add zeek_script_loaded event, deprecate bro_script_loaded
This commit is contained in:
parent
a994be9eeb
commit
3ea34d6ea3
11 changed files with 58 additions and 12 deletions
7
CHANGES
7
CHANGES
|
@ -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
|
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)
|
* Add zeek_init/zeek_done events and deprecate bro_init/bro_done (Seth Hall, Corelight)
|
||||||
|
|
11
NEWS
11
NEWS
|
@ -176,11 +176,12 @@ Deprecated Functionality
|
||||||
instead. The later will automatically return a value that is enclosed
|
instead. The later will automatically return a value that is enclosed
|
||||||
in double-quotes.
|
in double-quotes.
|
||||||
|
|
||||||
- The ``bro_init`` and ``bro_done`` events are now deprecated, use
|
- The ``bro_init``, ``bro_done``, and ``bro_script_loaded`` events are now
|
||||||
``zeek_init`` and ``zeek_done`` instead. Any existing handlers for
|
deprecated, use ``zeek_init``, ``zeek_done``, and
|
||||||
``bro_init`` and ``bro_done`` will automatically alias to the new
|
``zeek_script_loaded`` instead. Any existing event handlers for
|
||||||
``zeek_init`` and ``zeek_done`` events such that existing code will
|
the deprecated versions will automatically alias to the new events
|
||||||
not break, but will emit a deprecation warning.
|
such that existing code will not break, but will emit a deprecation
|
||||||
|
warning.
|
||||||
|
|
||||||
Bro 2.6
|
Bro 2.6
|
||||||
=======
|
=======
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.6-236
|
2.6-237
|
||||||
|
|
2
doc
2
doc
|
@ -1 +1 @@
|
||||||
Subproject commit 5e02a297eefe8740e8b84f7610fbf126af5c3475
|
Subproject commit ef39a55ef00382d49459783aa0144ef672b4de97
|
|
@ -32,7 +32,7 @@ event zeek_init() &priority=5
|
||||||
Log::create_stream(LoadedScripts::LOG, [$columns=Info, $path="loaded_scripts"]);
|
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))]);
|
Log::write(LoadedScripts::LOG, [$name=cat(get_indent(level), compress_path(path))]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -872,9 +872,14 @@ event reporter_error%(t: time, msg: string, location: string%) &error_handler;
|
||||||
##
|
##
|
||||||
## path: The full path to the script loaded.
|
## 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``.
|
## 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
|
## 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
|
## triggered only for files opened via :bro:id:`open`, and in particular not for
|
||||||
|
|
|
@ -1193,7 +1193,7 @@ int main(int argc, char** argv)
|
||||||
val_list* vl = new val_list;
|
val_list* vl = new val_list;
|
||||||
vl->append(new StringVal(i->name.c_str()));
|
vl->append(new StringVal(i->name.c_str()));
|
||||||
vl->append(val_mgr->GetCount(i->include_level));
|
vl->append(val_mgr->GetCount(i->include_level));
|
||||||
mgr.QueueEvent(bro_script_loaded, vl);
|
mgr.QueueEvent(zeek_script_loaded, vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
reporter->ReportViaEvents(true);
|
reporter->ReportViaEvents(true);
|
||||||
|
|
|
@ -1171,11 +1171,14 @@ func_hdr:
|
||||||
}
|
}
|
||||||
| TOK_EVENT event_id func_params opt_attr
|
| 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()) )
|
if ( streq("bro_init", $2->Name()) )
|
||||||
$2 = global_scope()->Lookup("zeek_init");
|
$2 = global_scope()->Lookup("zeek_init");
|
||||||
else if ( streq("bro_done", $2->Name()) )
|
else if ( streq("bro_done", $2->Name()) )
|
||||||
$2 = global_scope()->Lookup("zeek_done");
|
$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(),
|
begin_func($2, current_module.c_str(),
|
||||||
FUNC_FLAVOR_EVENT, 0, $3, $4);
|
FUNC_FLAVOR_EVENT, 0, $3, $4);
|
||||||
|
|
4
testing/btest/Baseline/language.zeek_script_loaded/out
Normal file
4
testing/btest/Baseline/language.zeek_script_loaded/out
Normal 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
|
26
testing/btest/language/zeek_script_loaded.zeek
Normal file
26
testing/btest/language/zeek_script_loaded.zeek
Normal 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";
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue