Merge remote-tracking branch 'origin/topic/jsiwek/gh-211'

* origin/topic/jsiwek/gh-211:
  GH-208: change invalid subnet expressions to a runtime error
  GH-211: improve consistency of how scripting errors are handled

Removed the 'allow_init_errors' option.
This commit is contained in:
Jon Siwek 2019-02-07 10:32:01 -06:00
commit 0790c1c559
53 changed files with 441 additions and 156 deletions

14
CHANGES
View file

@ -1,4 +1,18 @@
2.6-116 | 2019-02-07 10:32:01 -0600
* GH-208: change invalid subnet expressions to a runtime error (Jon Siwek, Corelight)
* GH-211: improve consistency of how scripting errors are handled (Jon Siwek, Corelight)
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.
This also changes the behavior of the startup/initialization process
to abort if there's errors during bro_init() rather than continue on
to the main run loop.
2.6-113 | 2019-02-06 13:17:39 -0600 2.6-113 | 2019-02-06 13:17:39 -0600
* Add validity checking/warnings for Broker messages (Jon Siwek, Corelight) * Add validity checking/warnings for Broker messages (Jon Siwek, Corelight)

View file

@ -1 +1 @@
2.6-113 2.6-116

2
doc

@ -1 +1 @@
Subproject commit 5acafa0d340a6f4096dccbe69b8fb62d7c9ce87f Subproject commit 0083f9004852a1843569b699900d0728ec0137b6

View file

@ -120,15 +120,13 @@ function find_all_emails(ip: addr): set[string]
for ( i in one_to_32 ) for ( i in one_to_32 )
{ {
tmp_subnet = mask_addr(ip, one_to_32[i]); 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] ) for ( email in local_admins[tmp_subnet] )
{ {
if ( email != "" ) if ( email != "" )
add output_values[email]; add output_values[email];
} }
} }
}
return output_values; return output_values;
} }

View file

@ -181,6 +181,27 @@ void Expr::ExprError(const char msg[])
SetError(); 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 bool Expr::Serialize(SerialInfo* info) const
{ {
return SerialObj::Serialize(info); return SerialObj::Serialize(info);
@ -272,7 +293,7 @@ Val* NameExpr::Eval(Frame* f) const
return v->Ref(); return v->Ref();
else else
{ {
Error("value used but not set"); RuntimeError("value used but not set");
return 0; return 0;
} }
} }
@ -580,7 +601,7 @@ Val* BinaryExpr::Eval(Frame* f) const
if ( v_op1->Size() != v_op2->Size() ) if ( v_op1->Size() != v_op2->Size() )
{ {
Error("vector operands are of different sizes"); RuntimeError("vector operands are of different sizes");
return 0; return 0;
} }
@ -707,7 +728,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
d2 = v2->InternalDouble(); d2 = v2->InternalDouble();
} }
else else
Internal("bad type in BinaryExpr::Fold"); RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
switch ( tag ) { switch ( tag ) {
#define DO_INT_FOLD(op) \ #define DO_INT_FOLD(op) \
@ -716,13 +737,13 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned ) \ else if ( is_unsigned ) \
u3 = u1 op u2; \ u3 = u1 op u2; \
else \ else \
Internal("bad type in BinaryExpr::Fold"); RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
#define DO_UINT_FOLD(op) \ #define DO_UINT_FOLD(op) \
if ( is_unsigned ) \ if ( is_unsigned ) \
u3 = u1 op u2; \ u3 = u1 op u2; \
else \ else \
Internal("bad type in BinaryExpr::Fold"); RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
#define DO_FOLD(op) \ #define DO_FOLD(op) \
if ( is_integral ) \ if ( is_integral ) \
@ -750,7 +771,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
if ( is_integral ) if ( is_integral )
{ {
if ( i2 == 0 ) if ( i2 == 0 )
reporter->ExprRuntimeError(this, "division by zero"); RuntimeError("division by zero");
i3 = i1 / i2; i3 = i1 / i2;
} }
@ -758,14 +779,14 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned ) else if ( is_unsigned )
{ {
if ( u2 == 0 ) if ( u2 == 0 )
reporter->ExprRuntimeError(this, "division by zero"); RuntimeError("division by zero");
u3 = u1 / u2; u3 = u1 / u2;
} }
else else
{ {
if ( d2 == 0 ) if ( d2 == 0 )
reporter->ExprRuntimeError(this, "division by zero"); RuntimeError("division by zero");
d3 = d1 / d2; d3 = d1 / d2;
} }
@ -778,7 +799,7 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
if ( is_integral ) if ( is_integral )
{ {
if ( i2 == 0 ) if ( i2 == 0 )
reporter->ExprRuntimeError(this, "modulo by zero"); RuntimeError("modulo by zero");
i3 = i1 % i2; i3 = i1 % i2;
} }
@ -786,13 +807,13 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
else if ( is_unsigned ) else if ( is_unsigned )
{ {
if ( u2 == 0 ) if ( u2 == 0 )
reporter->ExprRuntimeError(this, "modulo by zero"); RuntimeError("modulo by zero");
u3 = u1 % u2; u3 = u1 % u2;
} }
else else
Internal("bad type in BinaryExpr::Fold"); RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
} }
break; break;
@ -1122,7 +1143,7 @@ Val* IncrExpr::DoSingleEval(Frame* f, Val* v) const
if ( k < 0 && if ( k < 0 &&
v->Type()->InternalType() == TYPE_INTERNAL_UNSIGNED ) v->Type()->InternalType() == TYPE_INTERNAL_UNSIGNED )
Error("count underflow"); RuntimeError("count underflow");
} }
BroType* ret_type = Type(); BroType* ret_type = Type();
@ -1522,7 +1543,7 @@ Val* AddToExpr::Eval(Frame* f) const
{ {
VectorVal* vv = v1->AsVectorVal(); VectorVal* vv = v1->AsVectorVal();
if ( ! vv->Assign(vv->Size(), v2) ) if ( ! vv->Assign(vv->Size(), v2) )
reporter->Error("type-checking failed in vector append"); RuntimeError("type-checking failed in vector append");
return v1; return v1;
} }
@ -1774,7 +1795,20 @@ Val* DivideExpr::AddrFold(Val* v1, Val* v2) const
else else
mask = static_cast<uint32>(v2->InternalInt()); mask = static_cast<uint32>(v2->InternalInt());
return new SubNetVal(v1->AsAddr(), mask); auto& a = v1->AsAddr();
if ( a.GetFamily() == IPv4 )
{
if ( mask > 32 )
RuntimeError(fmt("bad IPv4 subnet prefix length: %" PRIu32, mask));
}
else
{
if ( mask > 128 )
RuntimeError(fmt("bad IPv6 subnet prefix length: %" PRIu32, mask));
}
return new SubNetVal(a, mask);
} }
IMPLEMENT_SERIAL(DivideExpr, SER_DIVIDE_EXPR); IMPLEMENT_SERIAL(DivideExpr, SER_DIVIDE_EXPR);
@ -1959,7 +1993,7 @@ Val* BoolExpr::Eval(Frame* f) const
if ( vec_v1->Size() != vec_v2->Size() ) if ( vec_v1->Size() != vec_v2->Size() )
{ {
Error("vector operands have different sizes"); RuntimeError("vector operands have different sizes");
return 0; return 0;
} }
@ -2344,7 +2378,7 @@ Val* CondExpr::Eval(Frame* f) const
if ( cond->Size() != a->Size() || a->Size() != b->Size() ) 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; return 0;
} }
@ -2669,7 +2703,7 @@ Val* AssignExpr::Eval(Frame* f) const
{ {
if ( is_init ) if ( is_init )
{ {
Error("illegal assignment in initialization"); RuntimeError("illegal assignment in initialization");
return 0; return 0;
} }
@ -2709,7 +2743,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
{ {
if ( t->Tag() != TYPE_RECORD ) if ( t->Tag() != TYPE_RECORD )
{ {
Error("not a record initializer", t); RuntimeError("not a record initializer");
return; return;
} }
@ -2718,7 +2752,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
if ( field < 0 ) if ( field < 0 )
{ {
Error("no such field"); RuntimeError("no such field");
return; return;
} }
@ -2732,7 +2766,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
} }
if ( op1->Tag() != EXPR_LIST ) if ( op1->Tag() != EXPR_LIST )
Error("bad table insertion"); RuntimeError("bad table insertion");
TableVal* tv = aggr->AsTableVal(); TableVal* tv = aggr->AsTableVal();
@ -2742,7 +2776,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
return; return;
if ( ! tv->Assign(index, v) ) if ( ! tv->Assign(index, v) )
Error("type clash in table assignment"); RuntimeError("type clash in table assignment");
Unref(index); Unref(index);
} }
@ -3008,7 +3042,7 @@ Val* IndexExpr::Eval(Frame* f) const
{ {
if ( v_v1->Size() != v_v2->Size() ) if ( v_v1->Size() != v_v2->Size() )
{ {
Error("size mismatch, boolean index and vector"); RuntimeError("size mismatch, boolean index and vector");
Unref(v_result); Unref(v_result);
return 0; return 0;
} }
@ -3096,14 +3130,14 @@ Val* IndexExpr::Fold(Val* v1, Val* v2) const
} }
default: default:
Error("type cannot be indexed"); RuntimeError("type cannot be indexed");
break; break;
} }
if ( v ) if ( v )
return v->Ref(); return v->Ref();
Error("no such index"); RuntimeError("no such index");
return 0; return 0;
} }
@ -3136,12 +3170,12 @@ void IndexExpr::Assign(Frame* f, Val* v, Opcode op)
auto vt = v->Type(); auto vt = v->Type();
auto vtt = vt->Tag(); auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt); 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", "vector index assignment failed for invalid type '%s', value: %s",
tn.data(), d.Description())); tn.data(), d.Description()));
} }
else else
Internal("assignment failed with null value"); RuntimeErrorWithCallStack("assignment failed with null value");
} }
break; break;
@ -3155,21 +3189,21 @@ void IndexExpr::Assign(Frame* f, Val* v, Opcode op)
auto vt = v->Type(); auto vt = v->Type();
auto vtt = vt->Tag(); auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt); 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", "table index assignment failed for invalid type '%s', value: %s",
tn.data(), d.Description())); tn.data(), d.Description()));
} }
else else
Internal("assignment failed with null value"); RuntimeErrorWithCallStack("assignment failed with null value");
} }
break; break;
case TYPE_STRING: case TYPE_STRING:
Internal("assignment via string index accessor not allowed"); RuntimeErrorWithCallStack("assignment via string index accessor not allowed");
break; break;
default: default:
Internal("bad index expression type in assignment"); RuntimeErrorWithCallStack("bad index expression type in assignment");
break; break;
} }
@ -3269,9 +3303,6 @@ void FieldExpr::Assign(Frame* f, Val* v, Opcode opcode)
if ( IsError() ) if ( IsError() )
return; return;
if ( field < 0 )
ExprError("no such field in record");
Val* op_v = op->Eval(f); Val* op_v = op->Eval(f);
if ( op_v ) if ( op_v )
{ {
@ -3298,7 +3329,7 @@ Val* FieldExpr::Fold(Val* v) const
return def_attr->AttrExpr()->Eval(0); return def_attr->AttrExpr()->Eval(0);
else else
{ {
reporter->ExprRuntimeError(this, "field value missing"); RuntimeError("field value missing");
assert(false); assert(false);
return 0; // Will never get here, but compiler can't tell. return 0; // Will never get here, but compiler can't tell.
} }
@ -3483,7 +3514,7 @@ Val* RecordConstructorExpr::Fold(Val* v) const
RecordType* rt = type->AsRecordType(); RecordType* rt = type->AsRecordType();
if ( lv->Length() != rt->NumFields() ) if ( lv->Length() != rt->NumFields() )
Internal("inconsistency evaluating record constructor"); RuntimeErrorWithCallStack("inconsistency evaluating record constructor");
RecordVal* rv = new RecordVal(rt); RecordVal* rv = new RecordVal(rt);
@ -3838,7 +3869,7 @@ Val* VectorConstructorExpr::Eval(Frame* f) const
Val* v = e->Eval(f); Val* v = e->Eval(f);
if ( ! vec->Assign(i, v) ) if ( ! vec->Assign(i, v) )
{ {
Error(fmt("type mismatch at index %d", i), e); RuntimeError(fmt("type mismatch at index %d", i));
return 0; return 0;
} }
} }
@ -3997,7 +4028,7 @@ Val* ArithCoerceExpr::FoldSingleVal(Val* v, InternalTypeTag t) const
return val_mgr->GetCount(v->CoerceToUnsigned()); return val_mgr->GetCount(v->CoerceToUnsigned());
default: default:
Internal("bad type in CoerceExpr::Fold"); RuntimeErrorWithCallStack("bad type in CoerceExpr::Fold");
return 0; return 0;
} }
} }
@ -4305,7 +4336,7 @@ Val* TableCoerceExpr::Fold(Val* v) const
TableVal* tv = v->AsTableVal(); TableVal* tv = v->AsTableVal();
if ( tv->Size() > 0 ) 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()); return new TableVal(Type()->AsTableType(), tv->Attrs());
} }
@ -4349,7 +4380,7 @@ Val* VectorCoerceExpr::Fold(Val* v) const
VectorVal* vv = v->AsVectorVal(); VectorVal* vv = v->AsVectorVal();
if ( vv->Size() > 0 ) if ( vv->Size() > 0 )
Internal("coercion of non-empty vector"); RuntimeErrorWithCallStack("coercion of non-empty vector");
return new VectorVal(Type()->Ref()->AsVectorType()); return new VectorVal(Type()->Ref()->AsVectorType());
} }
@ -4410,7 +4441,7 @@ Val* FlattenExpr::Fold(Val* v) const
l->Append(fa->AttrExpr()->Eval(0)); l->Append(fa->AttrExpr()->Eval(0));
else else
reporter->ExprRuntimeError(this, "missing field value"); RuntimeError("missing field value");
} }
return l; return l;
@ -5070,7 +5101,7 @@ Val* ListExpr::Eval(Frame* f) const
Val* ev = exprs[i]->Eval(f); Val* ev = exprs[i]->Eval(f);
if ( ! ev ) if ( ! ev )
{ {
Error("uninitialized list value"); RuntimeError("uninitialized list value");
Unref(v); Unref(v);
return 0; return 0;
} }
@ -5367,7 +5398,7 @@ void ListExpr::Assign(Frame* f, Val* v, Opcode op)
ListVal* lv = v->AsListVal(); ListVal* lv = v->AsListVal();
if ( exprs.length() != lv->Vals()->length() ) if ( exprs.length() != lv->Vals()->length() )
ExprError("mismatch in list lengths"); RuntimeError("mismatch in list lengths");
loop_over_list(exprs, i) loop_over_list(exprs, i)
exprs[i]->Assign(f, (*lv->Vals())[i]->Ref(), op); exprs[i]->Assign(f, (*lv->Vals())[i]->Ref(), op);
@ -5542,7 +5573,7 @@ Val* CastExpr::Eval(Frame* f) const
d.Add(" (nil $data field)"); d.Add(" (nil $data field)");
Unref(v); Unref(v);
reporter->ExprRuntimeError(this, "%s", d.Description()); RuntimeError(d.Description());
return 0; // not reached. return 0; // not reached.
} }

View file

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

View file

@ -467,7 +467,11 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
catch ( InterpreterException& e ) 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; continue;
} }

View file

@ -216,7 +216,10 @@ IPPrefix::IPPrefix(const in4_addr& in4, uint8_t length)
: prefix(in4), length(96 + length) : prefix(in4), length(96 + length)
{ {
if ( length > 32 ) if ( length > 32 )
reporter->InternalError("Bad in4_addr IPPrefix length : %d", length); {
reporter->Error("Bad in4_addr IPPrefix length : %d", length);
this->length = 0;
}
prefix.Mask(this->length); prefix.Mask(this->length);
} }
@ -225,7 +228,10 @@ IPPrefix::IPPrefix(const in6_addr& in6, uint8_t length)
: prefix(in6), length(length) : prefix(in6), length(length)
{ {
if ( length > 128 ) if ( length > 128 )
reporter->InternalError("Bad in6_addr IPPrefix length : %d", length); {
reporter->Error("Bad in6_addr IPPrefix length : %d", length);
this->length = 0;
}
prefix.Mask(this->length); prefix.Mask(this->length);
} }
@ -236,18 +242,22 @@ IPPrefix::IPPrefix(const IPAddr& addr, uint8_t length, bool len_is_v6_relative)
if ( prefix.GetFamily() == IPv4 && ! len_is_v6_relative ) if ( prefix.GetFamily() == IPv4 && ! len_is_v6_relative )
{ {
if ( length > 32 ) if ( length > 32 )
reporter->InternalError("Bad IPAddr(v4) IPPrefix length : %d", {
length); reporter->Error("Bad IPAddr(v4) IPPrefix length : %d", length);
this->length = 0;
}
else
this->length = length + 96; this->length = length + 96;
} }
else else
{ {
if ( length > 128 ) if ( length > 128 )
reporter->InternalError("Bad IPAddr(v6) IPPrefix length : %d", {
length); reporter->Error("Bad IPAddr(v6) IPPrefix length : %d", length);
this->length = 0;
}
else
this->length = length; this->length = length;
} }

View file

@ -451,7 +451,7 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
if ( postfix && *postfix ) if ( postfix && *postfix )
// Note, if you change this fmt string, adjust the additional // Note, if you change this fmt string, adjust the additional
// buffer size above. // 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; bool raise_event = true;

View file

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

View file

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

View file

@ -12,9 +12,16 @@
#include "Traverse.h" #include "Traverse.h"
static Val* init_val(Expr* init, const BroType* t, Val* aggr) static Val* init_val(Expr* init, const BroType* t, Val* aggr)
{
try
{ {
return init->InitVal(t, aggr); return init->InitVal(t, aggr);
} }
catch ( InterpreterException& e )
{
return nullptr;
}
}
static void make_var(ID* id, BroType* t, init_class c, Expr* init, static void make_var(ID* id, BroType* t, init_class c, Expr* init,
attr_list* attr, decl_type dt, int do_init) attr_list* attr, decl_type dt, int do_init)

View file

@ -1223,7 +1223,7 @@ function any_set%(v: any%) : bool
## ##
## v: The boolean vector instance. ## 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 ## .. bro:see:: any_set
## ##

View file

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

View file

@ -1,3 +1,3 @@
F F
F T
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 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 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 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 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 26: modulo by zero (a % b)

View file

@ -6,13 +6,13 @@
#open 2011-03-18-19-06-08 #open 2011-03-18-19-06-08
#fields ts level message location #fields ts level message location
#types time enum string string #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.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.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.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.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.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.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.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 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 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 #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 15: 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]) 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])
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 22: no such index (a[2])
1st error printed on script level 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]) 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])
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]) 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 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 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 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 103: field value missing (myrecord$notset)
received termination signal received termination signal
[f(F)] [f(F)]
f() done, no exception, T 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 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) 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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} 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 #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 #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 #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]) expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 10: 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]) expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.invalid_index/invalid_index.bro, line 16: no such index (foo2[1])
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])
foo[0], 42 foo[0], 42
foo2[0], 13 foo2[0], 13
done 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 /home/jon/pro/zeek/zeek/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) 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)
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; }))

View file

@ -0,0 +1,5 @@
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.subnet-errors/subnet-errors.bro, line 9: bad IPv4 subnet prefix length: 33 (1.2.3.4 / i)
expression error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.subnet-errors/subnet-errors.bro, line 18: bad IPv6 subnet prefix length: 129 (:: / i)
1.2.3.4/32
::/128
init last

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 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 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 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 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 /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) 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 /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 /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 /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 /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 'record { data:opaque of Broker::Data; }' to type 'string' (nil $data field) (a as string)
data is string, F 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) 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)
Continuing

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 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) 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)
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 14: value used but not set (x)
1 1
2 2
3 3

View file

@ -1,10 +1,10 @@
| Hook Some Info <...>/reporter-hook.bro, line 16 | Hook Some Info <...>/reporter-hook.bro, line 16
| Hook error An Error <...>/reporter-hook.bro, line 18 | 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 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 | Hook warning A warning <...>/reporter-hook.bro, line 17
<...>/reporter-hook.bro, line 16: Some Info <...>/reporter-hook.bro, line 16: Some Info
error in <...>/reporter-hook.bro, line 18: An Error 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 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 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::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::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 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 #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 ); local a = vector( T, F, T );
print all_set(a); print all_set(a);
local b = vector(); local b: vector of bool = vector();
print all_set(b); print all_set(b);
local c = vector( T ); local c = vector( T );

View file

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

View file

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

View file

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

View file

@ -0,0 +1,21 @@
# The default is for an initialization error to be a hard failure.
# @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) 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); Broker::publish("bro/event/hi", event_handler, "ping", event_count);
++event_count; ++event_count;
} }

View file

@ -81,7 +81,7 @@ event do_write()
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string) 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(); 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 # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
global a: table[count] of count; 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: bro -b %INPUT >output 2>&1
# @TEST-EXEC: grep "internal error" output >output2 # @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: 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 # @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 foo: vector of count = { 42 };
global foo2: table[count] of count = { [0] = 13 }; global foo2: table[count] of count = { [0] = 13 };
event bro_init()
{
print "foo[0]", foo[0]; print "foo[0]", foo[0];
print "foo[1]", foo[1]; print "foo[1]", foo[1];
print "foo[2]", foo[2]; }
event bro_init()
{
print "foo2[0]", foo2[0]; print "foo2[0]", foo2[0];
print "foo2[1]", foo2[1]; print "foo2[1]", foo2[1];
print "foo2[2]", foo2[2]; }
event bro_done()
{
print "done"; print "done";
}

View file

@ -0,0 +1,26 @@
# @TEST-EXEC: bro -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
event bro_init()
{
local i = 32;
print 1.2.3.4/i;
++i;
print 1.2.3.4/i;
print "init 1";
}
event bro_init()
{
local i = 128;
print [::]/i;
++i;
print [::]/i;
print "init 1";
}
event bro_init() &priority=-10
{
print "init last";
}

View file

@ -11,15 +11,22 @@ function cast_to_string(a: any)
print a as string; print a as string;
} }
event bro_init()
{
cast_to_string(42);
}
event bro_init() event bro_init()
{ {
local x: X; local x: X;
x = [$a = 1.2.3.4, $b=1947/tcp]; x = [$a = 1.2.3.4, $b=1947/tcp];
cast_to_string(42);
cast_to_string(x); cast_to_string(x);
cast_to_string(Broker::Data()); }
event bro_init()
{
print "data is string", Broker::Data() is string; 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_string: string;
local my_vector: vector of string; local my_vector: vector of string;
my_vector[0] = my_string; my_vector[0] = my_string;
print "Continuing";
} }
event bro_init() event bro_init()

View file

@ -30,7 +30,7 @@ export BRO_SEED_FILE=$source_dir/testing/btest/random.seed
function run_bro 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 if [ $? -ne 0 ]; then
echo "Failed running bro with broxygen config file $conf_file" echo "Failed running bro with broxygen config file $conf_file"