diff --git a/doc b/doc index 5acafa0d34..9823bc0bcd 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 5acafa0d340a6f4096dccbe69b8fb62d7c9ce87f +Subproject commit 9823bc0bcdbd8fb148bfdd2295afcc97de313a92 diff --git a/scripts/base/init-bare.bro b/scripts/base/init-bare.bro index 600a507d4f..e0e9ec2551 100644 --- a/scripts/base/init-bare.bro +++ b/scripts/base/init-bare.bro @@ -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; diff --git a/scripts/base/utils/site.bro b/scripts/base/utils/site.bro index 696f091410..aa40e1b92b 100644 --- a/scripts/base/utils/site.bro +++ b/scripts/base/utils/site.bro @@ -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; diff --git a/src/Expr.cc b/src/Expr.cc index ba3e8b1143..cb932ff7ee 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -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. } diff --git a/src/Expr.h b/src/Expr.h index d7dc01807e..820de2b876 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -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; diff --git a/src/Func.cc b/src/Func.cc index abc9331473..cbbbef6fa5 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -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; } diff --git a/src/Reporter.cc b/src/Reporter.cc index a21d0a0538..ba1196de21 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -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; diff --git a/src/Trigger.cc b/src/Trigger.cc index 3867c607fd..213707b6b8 100644 --- a/src/Trigger.cc +++ b/src/Trigger.cc @@ -42,12 +42,20 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr) { const IndexExpr* e = static_cast(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() ) diff --git a/src/Val.cc b/src/Val.cc index d57cffa45b..a96d2b098e 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -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; diff --git a/src/Var.cc b/src/Var.cc index d4659023a0..8534fdd910 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -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, diff --git a/src/bro.bif b/src/bro.bif index 13b2b9aa2e..9d6c34584f 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -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 ## diff --git a/src/main.cc b/src/main.cc index 6c714d806f..2fdcd2189e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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(); diff --git a/testing/btest/Baseline/bifs.all_set/out b/testing/btest/Baseline/bifs.all_set/out index ed4964b655..f776b10b48 100644 --- a/testing/btest/Baseline/bifs.all_set/out +++ b/testing/btest/Baseline/bifs.all_set/out @@ -1,3 +1,3 @@ F -F +T T diff --git a/testing/btest/Baseline/core.div-by-zero/out b/testing/btest/Baseline/core.div-by-zero/out index f5524b0cbf..dca1894e32 100644 --- a/testing/btest/Baseline/core.div-by-zero/out +++ b/testing/btest/Baseline/core.div-by-zero/out @@ -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) diff --git a/testing/btest/Baseline/core.expr-exception/reporter.log b/testing/btest/Baseline/core.expr-exception/reporter.log index d6e07b42b3..f546142dca 100644 --- a/testing/btest/Baseline/core.expr-exception/reporter.log +++ b/testing/btest/Baseline/core.expr-exception/reporter.log @@ -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 diff --git a/testing/btest/Baseline/core.init-error/out b/testing/btest/Baseline/core.init-error/out new file mode 100644 index 0000000000..9e11a25179 --- /dev/null +++ b/testing/btest/Baseline/core.init-error/out @@ -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 diff --git a/testing/btest/Baseline/core.reporter-error-in-handler/output b/testing/btest/Baseline/core.reporter-error-in-handler/output index 2f92afe6b0..ab5309b659 100644 --- a/testing/btest/Baseline/core.reporter-error-in-handler/output +++ b/testing/btest/Baseline/core.reporter-error-in-handler/output @@ -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 diff --git a/testing/btest/Baseline/core.reporter-runtime-error/output b/testing/btest/Baseline/core.reporter-runtime-error/output index c2ace6ceb6..695e2e2f81 100644 --- a/testing/btest/Baseline/core.reporter-runtime-error/output +++ b/testing/btest/Baseline/core.reporter-runtime-error/output @@ -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 diff --git a/testing/btest/Baseline/core.when-interpreter-exceptions/bro.output b/testing/btest/Baseline/core.when-interpreter-exceptions/bro.output index 200e850a12..27a90d137c 100644 --- a/testing/btest/Baseline/core.when-interpreter-exceptions/bro.output +++ b/testing/btest/Baseline/core.when-interpreter-exceptions/bro.output @@ -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 diff --git a/testing/btest/Baseline/language.common-mistakes/1.out b/testing/btest/Baseline/language.common-mistakes/1.out new file mode 100644 index 0000000000..8070f84644 --- /dev/null +++ b/testing/btest/Baseline/language.common-mistakes/1.out @@ -0,0 +1,4 @@ +expression error in ./1.bro, line 9: field value missing (mr$f) +bar start +foo start +other bro_init diff --git a/testing/btest/Baseline/language.common-mistakes/2.out b/testing/btest/Baseline/language.common-mistakes/2.out new file mode 100644 index 0000000000..dd62af107c --- /dev/null +++ b/testing/btest/Baseline/language.common-mistakes/2.out @@ -0,0 +1,2 @@ +expression error in ./2.bro, line 7: no such index (t[nope]) +in foo diff --git a/testing/btest/Baseline/language.common-mistakes/3.out b/testing/btest/Baseline/language.common-mistakes/3.out new file mode 100644 index 0000000000..d914d399a7 --- /dev/null +++ b/testing/btest/Baseline/language.common-mistakes/3.out @@ -0,0 +1,2 @@ +expression error in ./3.bro, line 5: type-checking failed in vector append (v += ok) +in foo diff --git a/testing/btest/Baseline/language.expire-expr-error/output b/testing/btest/Baseline/language.expire-expr-error/output index cf43dd4c80..dfa0bf64c3 100644 --- a/testing/btest/Baseline/language.expire-expr-error/output +++ b/testing/btest/Baseline/language.expire-expr-error/output @@ -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 diff --git a/testing/btest/Baseline/language.expire-func-undef/output b/testing/btest/Baseline/language.expire-func-undef/output index 05b71a9908..cf869bbe6b 100644 --- a/testing/btest/Baseline/language.expire-func-undef/output +++ b/testing/btest/Baseline/language.expire-func-undef/output @@ -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} diff --git a/testing/btest/Baseline/language.index-assignment-invalid/out b/testing/btest/Baseline/language.index-assignment-invalid/out index 9b8b47be9d..3972a9f10e 100644 --- a/testing/btest/Baseline/language.index-assignment-invalid/out +++ b/testing/btest/Baseline/language.index-assignment-invalid/out @@ -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=] (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=], 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=]}, settings=[max_len=], 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 diff --git a/testing/btest/Baseline/language.invalid_index/out b/testing/btest/Baseline/language.invalid_index/out index 9110a8979d..4ba0373e91 100644 --- a/testing/btest/Baseline/language.invalid_index/out +++ b/testing/btest/Baseline/language.invalid_index/out @@ -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 diff --git a/testing/btest/Baseline/language.record-bad-ctor/out b/testing/btest/Baseline/language.record-bad-ctor/out index 97f853b5a8..d30d0ab9d3 100644 --- a/testing/btest/Baseline/language.record-bad-ctor/out +++ b/testing/btest/Baseline/language.record-bad-ctor/out @@ -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) diff --git a/testing/btest/Baseline/language.table-type-checking/out b/testing/btest/Baseline/language.table-type-checking/out index 00a4bb2491..488cb83ab2 100644 --- a/testing/btest/Baseline/language.table-type-checking/out +++ b/testing/btest/Baseline/language.table-type-checking/out @@ -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) diff --git a/testing/btest/Baseline/language.type-cast-error-dynamic/output b/testing/btest/Baseline/language.type-cast-error-dynamic/output index 8ebf0cc90e..7c4ec0332f 100644 --- a/testing/btest/Baseline/language.type-cast-error-dynamic/output +++ b/testing/btest/Baseline/language.type-cast-error-dynamic/output @@ -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 diff --git a/testing/btest/Baseline/language.uninitialized-local/out b/testing/btest/Baseline/language.uninitialized-local/out index f803415fe6..24d45d3456 100644 --- a/testing/btest/Baseline/language.uninitialized-local/out +++ b/testing/btest/Baseline/language.uninitialized-local/out @@ -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) diff --git a/testing/btest/Baseline/language.uninitialized-local2/out b/testing/btest/Baseline/language.uninitialized-local2/out index 75d09294e6..bba567878e 100644 --- a/testing/btest/Baseline/language.uninitialized-local2/out +++ b/testing/btest/Baseline/language.uninitialized-local2/out @@ -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 diff --git a/testing/btest/Baseline/language.when-unitialized-rhs/out b/testing/btest/Baseline/language.when-unitialized-rhs/out index 620b384da2..6698887be0 100644 --- a/testing/btest/Baseline/language.when-unitialized-rhs/out +++ b/testing/btest/Baseline/language.when-unitialized-rhs/out @@ -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 diff --git a/testing/btest/Baseline/plugins.reporter-hook/output b/testing/btest/Baseline/plugins.reporter-hook/output index e5ed573e67..8f706ec644 100644 --- a/testing/btest/Baseline/plugins.reporter-hook/output +++ b/testing/btest/Baseline/plugins.reporter-hook/output @@ -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 diff --git a/testing/btest/Baseline/plugins.reporter-hook/reporter.log b/testing/btest/Baseline/plugins.reporter-hook/reporter.log index ab70b0c17a..bce2fb909f 100644 --- a/testing/btest/Baseline/plugins.reporter-hook/reporter.log +++ b/testing/btest/Baseline/plugins.reporter-hook/reporter.log @@ -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 diff --git a/testing/btest/Baseline/scripts.base.frameworks.reporter.stderr/.stderr b/testing/btest/Baseline/scripts.base.frameworks.reporter.stderr/.stderr index dc5065f5c8..ed161b2409 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.reporter.stderr/.stderr +++ b/testing/btest/Baseline/scripts.base.frameworks.reporter.stderr/.stderr @@ -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]) diff --git a/testing/btest/bifs/all_set.bro b/testing/btest/bifs/all_set.bro index 67ae36622b..56f7b6e7f2 100644 --- a/testing/btest/bifs/all_set.bro +++ b/testing/btest/bifs/all_set.bro @@ -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 ); diff --git a/testing/btest/bifs/any_set.bro b/testing/btest/bifs/any_set.bro index 9f3f364556..b3e9e3c711 100644 --- a/testing/btest/bifs/any_set.bro +++ b/testing/btest/bifs/any_set.bro @@ -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 ); diff --git a/testing/btest/bifs/split.bro b/testing/btest/bifs/split.bro index 4fd994ce41..b117844645 100644 --- a/testing/btest/bifs/split.bro +++ b/testing/btest/bifs/split.bro @@ -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]; diff --git a/testing/btest/btest.cfg b/testing/btest/btest.cfg index 6624d70431..5a570d9021 100644 --- a/testing/btest/btest.cfg +++ b/testing/btest/btest.cfg @@ -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 diff --git a/testing/btest/core/init-error.bro b/testing/btest/core/init-error.bro new file mode 100644 index 0000000000..c8c1018324 --- /dev/null +++ b/testing/btest/core/init-error.bro @@ -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"; + } diff --git a/testing/btest/core/leaks/broker/remote_event.test b/testing/btest/core/leaks/broker/remote_event.test index e11d083db3..5000bd98d7 100644 --- a/testing/btest/core/leaks/broker/remote_event.test +++ b/testing/btest/core/leaks/broker/remote_event.test @@ -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; } diff --git a/testing/btest/core/leaks/broker/remote_log.test b/testing/btest/core/leaks/broker/remote_log.test index 4d55705e4a..12abc1a313 100644 --- a/testing/btest/core/leaks/broker/remote_log.test +++ b/testing/btest/core/leaks/broker/remote_log.test @@ -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(); } diff --git a/testing/btest/core/reporter-runtime-error.bro b/testing/btest/core/reporter-runtime-error.bro index 330e2a7e5c..f8dd8c504c 100644 --- a/testing/btest/core/reporter-runtime-error.bro +++ b/testing/btest/core/reporter-runtime-error.bro @@ -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; diff --git a/testing/btest/language/common-mistakes.bro b/testing/btest/language/common-mistakes.bro new file mode 100644 index 0000000000..361aae0ff4 --- /dev/null +++ b/testing/btest/language/common-mistakes.bro @@ -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 diff --git a/testing/btest/language/index-assignment-invalid.bro b/testing/btest/language/index-assignment-invalid.bro index 19bf54ea20..68458eb149 100644 --- a/testing/btest/language/index-assignment-invalid.bro +++ b/testing/btest/language/index-assignment-invalid.bro @@ -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 diff --git a/testing/btest/language/invalid_index.bro b/testing/btest/language/invalid_index.bro index 96b7fa78c5..23fdb50d06 100644 --- a/testing/btest/language/invalid_index.bro +++ b/testing/btest/language/invalid_index.bro @@ -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"; + } diff --git a/testing/btest/language/type-cast-error-dynamic.bro b/testing/btest/language/type-cast-error-dynamic.bro index 91fa212ce4..c18548b0c4 100644 --- a/testing/btest/language/type-cast-error-dynamic.bro +++ b/testing/btest/language/type-cast-error-dynamic.bro @@ -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()); } diff --git a/testing/btest/language/uninitialized-local.bro b/testing/btest/language/uninitialized-local.bro index e1cc178c0a..ae486ebf1f 100644 --- a/testing/btest/language/uninitialized-local.bro +++ b/testing/btest/language/uninitialized-local.bro @@ -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() diff --git a/testing/scripts/gen-broxygen-docs.sh b/testing/scripts/gen-broxygen-docs.sh index 5ba33235fa..11f1cb066e 100755 --- a/testing/scripts/gen-broxygen-docs.sh +++ b/testing/scripts/gen-broxygen-docs.sh @@ -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"