diff --git a/scripts/base/frameworks/notice/main.bro b/scripts/base/frameworks/notice/main.bro index 8f80961d45..00b202319b 100644 --- a/scripts/base/frameworks/notice/main.bro +++ b/scripts/base/frameworks/notice/main.bro @@ -393,10 +393,7 @@ event bro_init() &priority=10 for ( pi in policy ) { if ( pi$priority < 0 || pi$priority > 10 ) - { - print "All Notice::PolicyItem priorities must be within 0 and 10"; - exit(); - } + Reporter::fatal("All Notice::PolicyItem priorities must be within 0 and 10"); if ( pi$priority !in tmp ) tmp[pi$priority] = set(); diff --git a/scripts/base/frameworks/packet-filter/main.bro b/scripts/base/frameworks/packet-filter/main.bro index 5d5bd61106..ec5c05c6c3 100644 --- a/scripts/base/frameworks/packet-filter/main.bro +++ b/scripts/base/frameworks/packet-filter/main.bro @@ -121,7 +121,7 @@ function install() NOTICE([$note=Compile_Failure, $msg=fmt("Compiling packet filter failed"), $sub=default_filter]); - exit(); + Reporter::fatal(fmt("Bad pcap filter '%s'", default_filter)); } # Do an audit log for the packet filter. diff --git a/src/reporter.bif b/src/reporter.bif index 4a77c2fcda..6b481eeb79 100644 --- a/src/reporter.bif +++ b/src/reporter.bif @@ -28,3 +28,11 @@ function Reporter::error%(msg: string%): bool reporter->PopLocation(); return new Val(1, TYPE_BOOL); %} + +function Reporter::fatal%(msg: string%): bool + %{ + reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->FatalError("%s", msg->CheckString()); + reporter->PopLocation(); + return new Val(1, TYPE_BOOL); + %} diff --git a/testing/btest/scripts/base/frameworks/packet-filter/bad-filter.test b/testing/btest/scripts/base/frameworks/packet-filter/bad-filter.test new file mode 100644 index 0000000000..a3e2a54c57 --- /dev/null +++ b/testing/btest/scripts/base/frameworks/packet-filter/bad-filter.test @@ -0,0 +1,2 @@ +# @TEST-EXEC-FAIL: bro -r $TRACES/web.trace -f "bad filter" +# @TEST-EXEC: test -s .stderr