GH-211: improve consistency of how scripting errors are handled

Scripting errors/mistakes now consistently generate a runtime error
which have the behavior of unwinding the call stack all the way out of
the current event handler.

Before, such errors were not treated consistently and either aborted
the process entirely or emitted a message while continuing to execute
subsequent statements without well-defined behavior (possibly causing
a cascade of errors).

The previous behavior also would only unwind out of the current
function (if within a function body), not out the current event
handler, which is especially problematic for functions that return
a value: the caller is essentially left a mess with no way to deal
with it.

This also changes the behavior of the startup/initialization process
to abort if there's errors during bro_init() rather than continue one
to the main run loop.  The `allow_init_errors` option may change this
new, default behavior.
This commit is contained in:
Jon Siwek 2019-01-30 11:20:09 -06:00
parent 49a30d61cf
commit 67484a90fa
49 changed files with 374 additions and 144 deletions

View file

@ -4959,3 +4959,9 @@ const bits_per_uid: count = 96 &redef;
## and set up the old comm. system. Deprecation warnings are still emitted
## when setting this flag, but they will not result in a fatal error.
const old_comm_usage_is_ok: bool = F &redef;
## Whether errors, such as scripting mistakes, during initialization
## (:bro:see:`bro_init`) are allowed or whether they will cause the
## process to terminate before it enters the main, run-time loop.
## The ZEEK_ALLOW_INIT_ERRORS environment variable also controls this option.
const allow_init_errors: bool = F &redef;

View file

@ -120,13 +120,11 @@ function find_all_emails(ip: addr): set[string]
for ( i in one_to_32 )
{
tmp_subnet = mask_addr(ip, one_to_32[i]);
for ( email in local_admins[tmp_subnet] )
{
if ( tmp_subnet in local_admins )
for ( email in local_admins[tmp_subnet] )
{
if ( email != "" )
add output_values[email];
}
}
}
return output_values;