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

2
doc

@ -1 +1 @@
Subproject commit 5acafa0d340a6f4096dccbe69b8fb62d7c9ce87f
Subproject commit 9823bc0bcdbd8fb148bfdd2295afcc97de313a92

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;

View file

@ -181,6 +181,27 @@ void Expr::ExprError(const char msg[])
SetError();
}
void Expr::RuntimeError(const std::string& msg) const
{
reporter->ExprRuntimeError(this, "%s", msg.data());
}
void Expr::RuntimeErrorWithCallStack(const std::string& msg) const
{
auto rcs = render_call_stack();
if ( rcs.empty() )
reporter->ExprRuntimeError(this, "%s", msg.data());
else
{
ODesc d;
d.SetShort();
Describe(&d);
reporter->RuntimeError(GetLocationInfo(), "%s, expression: %s, call stack: %s",
msg.data(), d.Description(), rcs.data());
}
}
bool Expr::Serialize(SerialInfo* info) const
{
return SerialObj::Serialize(info);
@ -272,7 +293,7 @@ Val* NameExpr::Eval(Frame* f) const
return v->Ref();
else
{
Error("value used but not set");
RuntimeError("value used but not set");
return 0;
}
}
@ -580,7 +601,7 @@ Val* BinaryExpr::Eval(Frame* f) const
if ( v_op1->Size() != v_op2->Size() )
{
Error("vector operands are of different sizes");
RuntimeError("vector operands are of different sizes");
return 0;
}
@ -707,7 +728,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
d2 = v2->InternalDouble();
}
else
Internal("bad type in BinaryExpr::Fold");
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
switch ( tag ) {
#define DO_INT_FOLD(op) \
@ -716,13 +737,13 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned ) \
u3 = u1 op u2; \
else \
Internal("bad type in BinaryExpr::Fold");
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
#define DO_UINT_FOLD(op) \
if ( is_unsigned ) \
u3 = u1 op u2; \
else \
Internal("bad type in BinaryExpr::Fold");
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
#define DO_FOLD(op) \
if ( is_integral ) \
@ -750,7 +771,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
if ( is_integral )
{
if ( i2 == 0 )
reporter->ExprRuntimeError(this, "division by zero");
RuntimeError("division by zero");
i3 = i1 / i2;
}
@ -758,14 +779,14 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned )
{
if ( u2 == 0 )
reporter->ExprRuntimeError(this, "division by zero");
RuntimeError("division by zero");
u3 = u1 / u2;
}
else
{
if ( d2 == 0 )
reporter->ExprRuntimeError(this, "division by zero");
RuntimeError("division by zero");
d3 = d1 / d2;
}
@ -778,7 +799,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
if ( is_integral )
{
if ( i2 == 0 )
reporter->ExprRuntimeError(this, "modulo by zero");
RuntimeError("modulo by zero");
i3 = i1 % i2;
}
@ -786,13 +807,13 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned )
{
if ( u2 == 0 )
reporter->ExprRuntimeError(this, "modulo by zero");
RuntimeError("modulo by zero");
u3 = u1 % u2;
}
else
Internal("bad type in BinaryExpr::Fold");
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
}
break;
@ -1122,7 +1143,7 @@ Val* IncrExpr::DoSingleEval(Frame* f, Val* v) const
if ( k < 0 &&
v->Type()->InternalType() == TYPE_INTERNAL_UNSIGNED )
Error("count underflow");
RuntimeError("count underflow");
}
BroType* ret_type = Type();
@ -1522,7 +1543,7 @@ Val* AddToExpr::Eval(Frame* f) const
{
VectorVal* vv = v1->AsVectorVal();
if ( ! vv->Assign(vv->Size(), v2) )
reporter->Error("type-checking failed in vector append");
RuntimeError("type-checking failed in vector append");
return v1;
}
@ -1959,7 +1980,7 @@ Val* BoolExpr::Eval(Frame* f) const
if ( vec_v1->Size() != vec_v2->Size() )
{
Error("vector operands have different sizes");
RuntimeError("vector operands have different sizes");
return 0;
}
@ -2344,7 +2365,7 @@ Val* CondExpr::Eval(Frame* f) const
if ( cond->Size() != a->Size() || a->Size() != b->Size() )
{
Error("vectors in conditional expression have different sizes");
RuntimeError("vectors in conditional expression have different sizes");
return 0;
}
@ -2669,7 +2690,7 @@ Val* AssignExpr::Eval(Frame* f) const
{
if ( is_init )
{
Error("illegal assignment in initialization");
RuntimeError("illegal assignment in initialization");
return 0;
}
@ -2709,7 +2730,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
{
if ( t->Tag() != TYPE_RECORD )
{
Error("not a record initializer", t);
RuntimeError("not a record initializer");
return;
}
@ -2718,7 +2739,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
if ( field < 0 )
{
Error("no such field");
RuntimeError("no such field");
return;
}
@ -2732,7 +2753,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
}
if ( op1->Tag() != EXPR_LIST )
Error("bad table insertion");
RuntimeError("bad table insertion");
TableVal* tv = aggr->AsTableVal();
@ -2742,7 +2763,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
return;
if ( ! tv->Assign(index, v) )
Error("type clash in table assignment");
RuntimeError("type clash in table assignment");
Unref(index);
}
@ -3008,7 +3029,7 @@ Val* IndexExpr::Eval(Frame* f) const
{
if ( v_v1->Size() != v_v2->Size() )
{
Error("size mismatch, boolean index and vector");
RuntimeError("size mismatch, boolean index and vector");
Unref(v_result);
return 0;
}
@ -3096,14 +3117,14 @@ Val* IndexExpr::Fold(Val* v1, Val* v2) const
}
default:
Error("type cannot be indexed");
RuntimeError("type cannot be indexed");
break;
}
if ( v )
return v->Ref();
Error("no such index");
RuntimeError("no such index");
return 0;
}
@ -3136,12 +3157,12 @@ void IndexExpr::Assign(Frame* f, Val* v, Opcode op)
auto vt = v->Type();
auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
Internal(fmt(
RuntimeErrorWithCallStack(fmt(
"vector index assignment failed for invalid type '%s', value: %s",
tn.data(), d.Description()));
}
else
Internal("assignment failed with null value");
RuntimeErrorWithCallStack("assignment failed with null value");
}
break;
@ -3155,21 +3176,21 @@ void IndexExpr::Assign(Frame* f, Val* v, Opcode op)
auto vt = v->Type();
auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
Internal(fmt(
RuntimeErrorWithCallStack(fmt(
"table index assignment failed for invalid type '%s', value: %s",
tn.data(), d.Description()));
}
else
Internal("assignment failed with null value");
RuntimeErrorWithCallStack("assignment failed with null value");
}
break;
case TYPE_STRING:
Internal("assignment via string index accessor not allowed");
RuntimeErrorWithCallStack("assignment via string index accessor not allowed");
break;
default:
Internal("bad index expression type in assignment");
RuntimeErrorWithCallStack("bad index expression type in assignment");
break;
}
@ -3269,9 +3290,6 @@ void FieldExpr::Assign(Frame* f, Val* v, Opcode opcode)
if ( IsError() )
return;
if ( field < 0 )
ExprError("no such field in record");
Val* op_v = op->Eval(f);
if ( op_v )
{
@ -3298,7 +3316,7 @@ Val* FieldExpr::Fold(Val* v) const
return def_attr->AttrExpr()->Eval(0);
else
{
reporter->ExprRuntimeError(this, "field value missing");
RuntimeError("field value missing");
assert(false);
return 0; // Will never get here, but compiler can't tell.
}
@ -3483,7 +3501,7 @@ Val* RecordConstructorExpr::Fold(Val* v) const
RecordType* rt = type->AsRecordType();
if ( lv->Length() != rt->NumFields() )
Internal("inconsistency evaluating record constructor");
RuntimeErrorWithCallStack("inconsistency evaluating record constructor");
RecordVal* rv = new RecordVal(rt);
@ -3838,7 +3856,7 @@ Val* VectorConstructorExpr::Eval(Frame* f) const
Val* v = e->Eval(f);
if ( ! vec->Assign(i, v) )
{
Error(fmt("type mismatch at index %d", i), e);
RuntimeError(fmt("type mismatch at index %d", i));
return 0;
}
}
@ -3997,7 +4015,7 @@ Val* ArithCoerceExpr::FoldSingleVal(Val* v, InternalTypeTag t) const
return val_mgr->GetCount(v->CoerceToUnsigned());
default:
Internal("bad type in CoerceExpr::Fold");
RuntimeErrorWithCallStack("bad type in CoerceExpr::Fold");
return 0;
}
}
@ -4305,7 +4323,7 @@ Val* TableCoerceExpr::Fold(Val* v) const
TableVal* tv = v->AsTableVal();
if ( tv->Size() > 0 )
Internal("coercion of non-empty table/set");
RuntimeErrorWithCallStack("coercion of non-empty table/set");
return new TableVal(Type()->AsTableType(), tv->Attrs());
}
@ -4349,7 +4367,7 @@ Val* VectorCoerceExpr::Fold(Val* v) const
VectorVal* vv = v->AsVectorVal();
if ( vv->Size() > 0 )
Internal("coercion of non-empty vector");
RuntimeErrorWithCallStack("coercion of non-empty vector");
return new VectorVal(Type()->Ref()->AsVectorType());
}
@ -4410,7 +4428,7 @@ Val* FlattenExpr::Fold(Val* v) const
l->Append(fa->AttrExpr()->Eval(0));
else
reporter->ExprRuntimeError(this, "missing field value");
RuntimeError("missing field value");
}
return l;
@ -5070,7 +5088,7 @@ Val* ListExpr::Eval(Frame* f) const
Val* ev = exprs[i]->Eval(f);
if ( ! ev )
{
Error("uninitialized list value");
RuntimeError("uninitialized list value");
Unref(v);
return 0;
}
@ -5367,7 +5385,7 @@ void ListExpr::Assign(Frame* f, Val* v, Opcode op)
ListVal* lv = v->AsListVal();
if ( exprs.length() != lv->Vals()->length() )
ExprError("mismatch in list lengths");
RuntimeError("mismatch in list lengths");
loop_over_list(exprs, i)
exprs[i]->Assign(f, (*lv->Vals())[i]->Ref(), op);
@ -5542,7 +5560,7 @@ Val* CastExpr::Eval(Frame* f) const
d.Add(" (nil $data field)");
Unref(v);
reporter->ExprRuntimeError(this, "%s", d.Description());
RuntimeError(d.Description());
return 0; // not reached.
}

View file

@ -210,6 +210,10 @@ protected:
// TYPE_ERROR.
void ExprError(const char msg[]);
void RuntimeError(const std::string& msg) const;
void RuntimeErrorWithCallStack(const std::string& msg) const;
DECLARE_ABSTRACT_SERIAL(Expr);
BroExprTag tag;

View file

@ -467,7 +467,11 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
catch ( InterpreterException& e )
{
// Already reported, but we continue exec'ing remaining bodies.
// Already reported, but now determine whether to unwind further.
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
throw;
// Continue exec'ing remaining bodies of hooks/events.
continue;
}

View file

@ -451,7 +451,7 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
if ( postfix && *postfix )
// Note, if you change this fmt string, adjust the additional
// buffer size above.
safe_snprintf(buffer + strlen(buffer), size - strlen(buffer), " [%s]", postfix);
safe_snprintf(buffer + strlen(buffer), size - strlen(buffer), " (%s)", postfix);
bool raise_event = true;

View file

@ -42,12 +42,20 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
{
const IndexExpr* e = static_cast<const IndexExpr*>(expr);
BroObj::SuppressErrors no_errors;
Val* v = e->Eval(trigger->frame);
if ( v )
try
{
trigger->Register(v);
Unref(v);
Val* v = e->Eval(trigger->frame);
if ( v )
{
trigger->Register(v);
Unref(v);
}
}
catch ( InterpreterException& )
{ /* Already reported */ }
break;
}
@ -132,7 +140,17 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
arg_frame->SetDelayed();
}
Val* timeout_val = arg_timeout ? arg_timeout->Eval(arg_frame) : 0;
Val* timeout_val = nullptr;
if ( arg_timeout )
{
try
{
timeout_val = arg_timeout->Eval(arg_frame);
}
catch ( InterpreterException& )
{ /* Already reported */ }
}
if ( timeout_val )
{
@ -202,7 +220,16 @@ bool Trigger::Eval()
// constants.
Frame* f = frame->Clone();
f->SetTrigger(this);
Val* v = cond->Eval(f);
Val* v = nullptr;
try
{
v = cond->Eval(f);
}
catch ( InterpreterException& )
{ /* Already reported */ }
f->ClearTrigger();
if ( f->HasDelayed() )

View file

@ -2391,9 +2391,18 @@ double TableVal::GetExpireTime()
if ( ! expire_time )
return -1;
Val* timeout = expire_time->Eval(0);
double interval = (timeout ? timeout->AsInterval() : -1);
Unref(timeout);
double interval;
try
{
Val* timeout = expire_time->Eval(0);
interval = (timeout ? timeout->AsInterval() : -1);
Unref(timeout);
}
catch ( InterpreterException& e )
{
interval = -1;
}
if ( interval >= 0 )
return interval;

View file

@ -13,7 +13,14 @@
static Val* init_val(Expr* init, const BroType* t, Val* aggr)
{
return init->InitVal(t, aggr);
try
{
return init->InitVal(t, aggr);
}
catch ( InterpreterException& e )
{
return nullptr;
}
}
static void make_var(ID* id, BroType* t, init_class c, Expr* init,

View file

@ -1223,7 +1223,7 @@ function any_set%(v: any%) : bool
##
## v: The boolean vector instance.
##
## Returns: True iff all elements in *v* are true.
## Returns: True iff all elements in *v* are true or there are no elements.
##
## .. bro:see:: any_set
##

View file

@ -1161,7 +1161,16 @@ int main(int argc, char** argv)
stmt_flow_type flow;
Frame f(current_scope()->Length(), 0, 0);
g_frame_stack.push_back(&f);
stmts->Exec(&f, flow);
try
{
stmts->Exec(&f, flow);
}
catch ( InterpreterException& )
{
reporter->FatalError("failed to execute script statements at top-level scope");
}
g_frame_stack.pop_back();
}
@ -1185,6 +1194,15 @@ int main(int argc, char** argv)
// Drain the event queue here to support the protocols framework configuring DPM
mgr.Drain();
if ( reporter->Errors() > 0 )
{
auto allow_init_errors = global_scope()->Lookup("allow_init_errors");
if ( ! allow_init_errors->ID_Val()->AsBool() &&
! getenv("ZEEK_ALLOW_INIT_ERRORS") )
reporter->FatalError("errors occurred while initializing");
}
broker_mgr->BroInitDone();
analyzer_mgr->DumpDebug();

View file

@ -1,3 +1,3 @@
F
F
T
T

View file

@ -1,5 +1,5 @@
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 6: division by zero [a / b]
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 11: division by zero [a / b]
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 16: division by zero [a / b]
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 21: modulo by zero [a % b]
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 26: modulo by zero [a % b]
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 6: division by zero (a / b)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 11: division by zero (a / b)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 16: division by zero (a / b)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 21: modulo by zero (a % b)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 26: modulo by zero (a % b)

View file

@ -6,13 +6,13 @@
#open 2011-03-18-19-06-08
#fields ts level message location
#types time enum string string
1300475168.783842 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.915940 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.916118 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.918295 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.952193 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.952228 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.954761 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.962628 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475169.780331 Reporter::ERROR field value missing [c$ftp] /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.783842 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.915940 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.916118 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.918295 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.952193 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.952228 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.954761 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475168.962628 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
1300475169.780331 Reporter::ERROR field value missing (c$ftp) /da/home/robin/bro/master/testing/btest/.tmp/core.expr-exception/expr-exception.bro, line 10
#close 2011-03-18-19-06-13

View file

@ -0,0 +1,5 @@
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/core.init-error/init-error.bro, line 16: no such index (v[10])
fatal error: errors occurred while initializing
1st event
2nd event
3rd event

View file

@ -1,3 +1,3 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-error-in-handler/reporter-error-in-handler.bro, line 28: no such index (a[1])
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-error-in-handler/reporter-error-in-handler.bro, line 22: no such index (a[2])
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-error-in-handler/reporter-error-in-handler.bro, line 28: no such index (a[1])
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-error-in-handler/reporter-error-in-handler.bro, line 22: no such index (a[2])
1st error printed on script level

View file

@ -1,2 +1,2 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-runtime-error/reporter-runtime-error.bro, line 12: no such index (a[1])
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.reporter-runtime-error/reporter-runtime-error.bro, line 9: no such index (a[2])
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/core.reporter-runtime-error/reporter-runtime-error.bro, line 12: no such index (a[1])
fatal error: failed to execute script statements at top-level scope

View file

@ -1,7 +1,7 @@
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 47: field value missing [myrecord$notset]
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 91: field value missing [myrecord$notset]
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 72: field value missing [myrecord$notset]
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 103: field value missing [myrecord$notset]
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 47: field value missing (myrecord$notset)
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 91: field value missing (myrecord$notset)
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 72: field value missing (myrecord$notset)
expression error in /Users/jon/Projects/bro/bro/testing/btest/.tmp/core.when-interpreter-exceptions/when-interpreter-exceptions.bro, line 103: field value missing (myrecord$notset)
received termination signal
[f(F)]
f() done, no exception, T

View file

@ -0,0 +1,4 @@
expression error in ./1.bro, line 9: field value missing (mr$f)
bar start
foo start
other bro_init

View file

@ -0,0 +1,2 @@
expression error in ./2.bro, line 7: no such index (t[nope])
in foo

View file

@ -0,0 +1,2 @@
expression error in ./3.bro, line 5: type-checking failed in vector append (v += ok)
in foo

View file

@ -1,2 +1,2 @@
error in /home/robin/bro/master/testing/btest/.tmp/language.expire-expr-error/expire-expr-error.bro, line 8: no such index (x[kaputt])
expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-expr-error/expire-expr-error.bro, line 8: no such index (x[kaputt])
received termination signal

View file

@ -1,20 +1,20 @@
1299470395.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299470405.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299473995.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299474005.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299477595.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299477605.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299481195.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299481205.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299484795.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299484805.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299488395.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299488405.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299491995.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299492005.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299495595.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299495605.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299499195.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299499205.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299502795.000000 error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299470395.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299470405.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299473995.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299474005.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299477595.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299477605.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299481195.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299481205.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299484795.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299484805.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299488395.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299488405.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299491995.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299492005.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299495595.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299495605.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299499195.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299499205.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
1299502795.000000 expression error in /home/robin/bro/master/testing/btest/.tmp/language.expire-func-undef/expire-func-undef.bro, line 12: value used but not set (segfault::scan_summary)
orig: 10.0.0.2: peers: {\x0a\x0910.0.0.3\x0a}

View file

@ -1,4 +1,4 @@
internal error in /home/jon/pro/zeek/zeek/scripts/base/utils/queue.bro, line 152: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>] (Queue::ret[Queue::j]), call stack:
runtime error in /home/jon/pro/zeek/zeek/scripts/base/utils/queue.bro, line 152: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>], expression: Queue::ret[Queue::j], call stack:
#0 Queue::get_vector([initialized=T, vals={[2] = test,[6] = jkl;,[4] = asdf,[1] = goodbye,[5] = 3,[0] = hello,[3] = [a=T, b=hi, c=<uninitialized>]}, settings=[max_len=<uninitialized>], top=7, bottom=0, size=0], [hello, goodbye, test]) at /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.index-assignment-invalid/index-assignment-invalid.bro:19
#1 bar(55) at /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.index-assignment-invalid/index-assignment-invalid.bro:27
#2 foo(hi, 13) at /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.index-assignment-invalid/index-assignment-invalid.bro:39

View file

@ -1,7 +1,5 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 8: no such index (foo[1])
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 9: no such index (foo[2])
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 12: no such index (foo2[1])
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 13: no such index (foo2[2])
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 10: no such index (foo[1])
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 16: no such index (foo2[1])
foo[0], 42
foo2[0], 13
done

View file

@ -1,3 +1,2 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.record-bad-ctor/record-bad-ctor.bro, line 6: no type given (asdfasdf)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.record-bad-ctor/record-bad-ctor.bro, line 7: uninitialized list value ($ports=asdfasdf)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.record-bad-ctor/record-bad-ctor.bro, line 7: bad record initializer ((coerce [$ports=asdfasdf] to record { ports:error; }))
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.record-bad-ctor/record-bad-ctor.bro, line 6: no type given (asdfasdf)
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.record-bad-ctor/record-bad-ctor.bro, line 7: uninitialized list value ($ports=asdfasdf)

View file

@ -4,7 +4,7 @@ error in port and /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.tab
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 10: inconsistent types in table constructor (table(one = 1))
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 17: type clash in assignment (gda = gda2)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 21 and /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 4: index type doesn't match table (three and list of port)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 21: type clash in table assignment (three = 3)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 21: type clash in table assignment (three = 3)
error in port and /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 26: type clash (port and thousand)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 26: inconsistent types in table constructor (table(thousand = 1000))
error in port and /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.table-type-checking/table-type-checking.bro, line 32: type clash (port and thousand-one)

View file

@ -1,4 +1,4 @@
expression error in /Users/jon/projects/bro/bro/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'count' to type 'string' [a as string]
expression error in /Users/jon/projects/bro/bro/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'record { a:addr; b:port; }' to type 'string' [a as string]
expression error in /Users/jon/projects/bro/bro/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'record { data:opaque of Broker::Data; }' to type 'string' (nil $data field) [a as string]
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'count' to type 'string' (a as string)
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'record { a:addr; b:port; }' to type 'string' (a as string)
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.type-cast-error-dynamic/type-cast-error-dynamic.bro, line 11: invalid cast of value with type 'record { data:opaque of Broker::Data; }' to type 'string' (nil $data field) (a as string)
data is string, F

View file

@ -1,2 +1 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.uninitialized-local/uninitialized-local.bro, line 16: value used but not set (my_string)
Continuing
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.uninitialized-local/uninitialized-local.bro, line 16: value used but not set (my_string)

View file

@ -1,2 +1,2 @@
error in /home/jon/projects/bro/bro/testing/btest/.tmp/language.uninitialized-local2/uninitialized-local2.bro, line 19: value used but not set (var_b)
expression error in /home/jon/projects/bro/bro/testing/btest/.tmp/language.uninitialized-local2/uninitialized-local2.bro, line 19: value used but not set (var_b)
var_a is, baz

View file

@ -1,5 +1,5 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 9: value used but not set (crashMe)
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 14: value used but not set (x)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 9: value used but not set (crashMe)
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 14: value used but not set (x)
1
2
3

View file

@ -1,10 +1,10 @@
| Hook Some Info <...>/reporter-hook.bro, line 16
| Hook error An Error <...>/reporter-hook.bro, line 18
| Hook error An Error that does not show up in the log <...>/reporter-hook.bro, line 19
| Hook expression error field value missing [b$a] <...>/reporter-hook.bro, line 23
| Hook expression error field value missing (b$a) <...>/reporter-hook.bro, line 23
| Hook warning A warning <...>/reporter-hook.bro, line 17
<...>/reporter-hook.bro, line 16: Some Info
error in <...>/reporter-hook.bro, line 18: An Error
error in <...>/reporter-hook.bro, line 19: An Error that does not show up in the log
expression error in <...>/reporter-hook.bro, line 23: field value missing [b$a]
expression error in <...>/reporter-hook.bro, line 23: field value missing (b$a)
warning in <...>/reporter-hook.bro, line 17: A warning

View file

@ -9,5 +9,5 @@
0.000000 Reporter::INFO Some Info /Users/johanna/corelight/bro/testing/btest/.tmp/plugins.reporter-hook/reporter-hook.bro, line 16
0.000000 Reporter::WARNING A warning /Users/johanna/corelight/bro/testing/btest/.tmp/plugins.reporter-hook/reporter-hook.bro, line 17
0.000000 Reporter::ERROR An Error /Users/johanna/corelight/bro/testing/btest/.tmp/plugins.reporter-hook/reporter-hook.bro, line 18
0.000000 Reporter::ERROR field value missing [b$a] /Users/johanna/corelight/bro/testing/btest/.tmp/plugins.reporter-hook/reporter-hook.bro, line 23
0.000000 Reporter::ERROR field value missing (b$a) /Users/johanna/corelight/bro/testing/btest/.tmp/plugins.reporter-hook/reporter-hook.bro, line 23
#close 2017-07-26-17-58-52

View file

@ -1 +1 @@
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/scripts.base.frameworks.reporter.stderr/stderr.bro, line 9: no such index (test[3])
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/scripts.base.frameworks.reporter.stderr/stderr.bro, line 9: no such index (test[3])

View file

@ -7,7 +7,7 @@ event bro_init()
local a = vector( T, F, T );
print all_set(a);
local b = vector();
local b: vector of bool = vector();
print all_set(b);
local c = vector( T );

View file

@ -7,7 +7,7 @@ event bro_init()
local a = vector( F, T, F );
print any_set(a);
local b = vector();
local b: vector of bool = vector();
print any_set(b);
local c = vector( F );

View file

@ -17,7 +17,6 @@ event bro_init()
print b[1];
print b[2];
print b[3];
print b[4];
print "---------------------";
print c[1];
print c[2];

View file

@ -28,3 +28,4 @@ BRO_DEFAULT_LISTEN_ADDRESS=127.0.0.1
BRO_DEFAULT_LISTEN_RETRY=1
BRO_DEFAULT_CONNECT_RETRY=1
BRO_DISABLE_BROXYGEN=1
ZEEK_ALLOW_INIT_ERRORS=1

View file

@ -0,0 +1,22 @@
# The default is for an initialization error to be a hard failure.
# Behavior may be changed via the `allow_init_errors` option.
# @TEST-EXEC-FAIL: unset ZEEK_ALLOW_INIT_ERRORS && bro -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
event bro_init() &priority=10
{
print "1st event";
}
event bro_init() &priority=10
{
print "2nd event";
local v = vector(1, 2, 3);
print v[10];
}
event bro_init() &priority=-10
{
print "3rd event";
}

View file

@ -60,7 +60,7 @@ global event_count = 0;
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
{
print "Broker peer added", endpoint$network;
print "Broker peer added", endpoint$network$address;
Broker::publish("bro/event/hi", event_handler, "ping", event_count);
++event_count;
}

View file

@ -81,7 +81,7 @@ event do_write()
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
{
print "Broker peer added", endpoint$network;
print "Broker peer added", endpoint$network$address;
event do_write();
}

View file

@ -1,5 +1,5 @@
#
# @TEST-EXEC: bro %INPUT >output 2>&1
# @TEST-EXEC-FAIL: bro %INPUT >output 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
global a: table[count] of count;

View file

@ -0,0 +1,95 @@
# These tests show off common scripting mistakes, which should be
# handled internally by way of throwing an exception to unwind out
# of the current event handler body.
# @TEST-EXEC: bro -b 1.bro >1.out 2>&1
# @TEST-EXEC: btest-diff 1.out
# @TEST-EXEC: bro -b 2.bro >2.out 2>&1
# @TEST-EXEC: btest-diff 2.out
# @TEST-EXEC: bro -b 3.bro >3.out 2>&1
# @TEST-EXEC: btest-diff 3.out
@TEST-START-FILE 1.bro
type myrec: record {
f: string &optional;
};
function foo(mr: myrec)
{
print "foo start";
# Unitialized field access: unwind out of current event handler body
print mr$f;
# Unreachable
print "foo done";
}
function bar()
{
print "bar start";
foo(myrec());
# Unreachable
print "bar done";
}
event bro_init()
{
bar();
# Unreachable
print "bro_init done";
}
event bro_init() &priority=-10
{
# Reachable
print "other bro_init";
}
@TEST-END-FILE
@TEST-START-FILE 2.bro
function foo()
{
print "in foo";
local t: table[string] of string = table();
# Non-existing index access: (sub)expressions should not be evaluated
if ( t["nope"] == "nope" )
# Unreachable
print "yes";
else
# Unreachable
print "no";
# Unreachable
print "foo done";
}
event bro_init()
{
foo();
# Unreachable
print "bro_init done";
}
@TEST-END-FILE
@TEST-START-FILE 3.bro
function foo(v: vector of any)
{
print "in foo";
# Vector append incompatible element type
v += "ok";
# Unreachable
print "foo done";
}
event bro_init()
{
local v: vector of count;
v += 1;
foo(v);
# Unreachable
print "bro_init done", v;
}
@TEST-END-FILE

View file

@ -1,5 +1,5 @@
# @TEST-EXEC-FAIL: bro -b %INPUT >output 2>&1
# @TEST-EXEC: grep "internal error" output >output2
# @TEST-EXEC: bro -b %INPUT >output 2>&1
# @TEST-EXEC: grep "error" output >output2
# @TEST-EXEC: for i in 1 2 3 4 5; do cat output2 | cut -d'|' -f$i >>out; done
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out

View file

@ -4,12 +4,19 @@
global foo: vector of count = { 42 };
global foo2: table[count] of count = { [0] = 13 };
print "foo[0]", foo[0];
print "foo[1]", foo[1];
print "foo[2]", foo[2];
event bro_init()
{
print "foo[0]", foo[0];
print "foo[1]", foo[1];
}
print "foo2[0]", foo2[0];
print "foo2[1]", foo2[1];
print "foo2[2]", foo2[2];
event bro_init()
{
print "foo2[0]", foo2[0];
print "foo2[1]", foo2[1];
}
print "done";
event bro_done()
{
print "done";
}

View file

@ -11,15 +11,22 @@ function cast_to_string(a: any)
print a as string;
}
event bro_init()
{
cast_to_string(42);
}
event bro_init()
{
local x: X;
x = [$a = 1.2.3.4, $b=1947/tcp];
cast_to_string(42);
cast_to_string(x);
cast_to_string(Broker::Data());
}
event bro_init()
{
print "data is string", Broker::Data() is string;
cast_to_string(Broker::Data());
}

View file

@ -14,7 +14,6 @@ event testit()
local my_string: string;
local my_vector: vector of string;
my_vector[0] = my_string;
print "Continuing";
}
event bro_init()

View file

@ -30,7 +30,7 @@ export BRO_SEED_FILE=$source_dir/testing/btest/random.seed
function run_bro
{
bro -X $conf_file broxygen >/dev/null 2>$bro_error_file
ZEEK_ALLOW_INIT_ERRORS=1 bro -X $conf_file broxygen >/dev/null 2>$bro_error_file
if [ $? -ne 0 ]; then
echo "Failed running bro with broxygen config file $conf_file"