diff --git a/src/Anon.cc b/src/Anon.cc index 295b19cb2e..24d7842b23 100644 --- a/src/Anon.cc +++ b/src/Anon.cc @@ -75,7 +75,7 @@ ipaddr32_t AnonymizeIPAddr::Anonymize(ipaddr32_t addr) // Keep the specified prefix unchanged. bool AnonymizeIPAddr::PreservePrefix(ipaddr32_t /* input */, int /* num_bits */) { - reporter->InternalError("prefix preserving is not supported for the anonymizer"); + zeek::reporter->InternalError("prefix preserving is not supported for the anonymizer"); return false; } @@ -172,7 +172,7 @@ bool AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits) if ( ! before_anonymization ) { - reporter->Error("prefix perservation specified after anonymization begun"); + zeek::reporter->Error("prefix perservation specified after anonymization begun"); return false; } @@ -219,7 +219,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::new_node_block() int block_size = 1024; Node* block = new Node[block_size]; if ( ! block ) - reporter->InternalError("out of memory!"); + zeek::reporter->InternalError("out of memory!"); blocks.push_back(block); @@ -271,7 +271,7 @@ ipaddr32_t AnonymizeIPAddr_A50::make_output(ipaddr32_t old_output, int swivel) c AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::make_peer(ipaddr32_t a, Node* n) { if ( a == 0 || a == 0xFFFFFFFFU ) - reporter->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree"); + zeek::reporter->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree"); // Become a peer. // Algorithm: create two nodes, the two peers. Leave orig node as @@ -354,7 +354,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::find_node(ipaddr32_t a) } } - reporter->InternalError("out of memory!"); + zeek::reporter->InternalError("out of memory!"); return nullptr; } @@ -421,14 +421,14 @@ ipaddr32_t zeek::detail::anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_ new_ip = ip; else if ( ! ip_anonymizer[method] ) - reporter->InternalError("IP anonymizer not initialized"); + zeek::reporter->InternalError("IP anonymizer not initialized"); else new_ip = ip_anonymizer[method]->Anonymize(ip); } else - reporter->InternalError("invalid IP anonymization method"); + zeek::reporter->InternalError("invalid IP anonymization method"); #ifdef LOG_ANONYMIZATION_MAPPING log_anonymization_mapping(ip, new_ip); diff --git a/src/Base64.cc b/src/Base64.cc index 443370f542..a13d784574 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -15,10 +15,10 @@ void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, cha char *buf; if ( ! pbuf ) - reporter->InternalError("nil pointer to encoding result buffer"); + zeek::reporter->InternalError("nil pointer to encoding result buffer"); if ( *pbuf && (*pblen % 4 != 0) ) - reporter->InternalError("Base64 encode buffer not a multiple of 4"); + zeek::reporter->InternalError("Base64 encode buffer not a multiple of 4"); if ( *pbuf ) { @@ -121,7 +121,7 @@ int Base64Converter::Decode(int len, const char* data, int* pblen, char** pbuf) base64_table = InitBase64Table(alphabet); if ( ! pbuf ) - reporter->InternalError("nil pointer to decoding result buffer"); + zeek::reporter->InternalError("nil pointer to decoding result buffer"); if ( *pbuf ) { @@ -225,15 +225,15 @@ void Base64Converter::IllegalEncoding(const char* msg) if ( conn ) conn->Weird("base64_illegal_encoding", msg); else - reporter->Error("%s", msg); + zeek::reporter->Error("%s", msg); } zeek::String* decode_base64(const zeek::String* s, const zeek::String* a, Connection* conn) { if ( a && a->Len() != 0 && a->Len() != 64 ) { - reporter->Error("base64 decoding alphabet is not 64 characters: %s", - a->CheckString()); + zeek::reporter->Error("base64 decoding alphabet is not 64 characters: %s", + a->CheckString()); return nullptr; } @@ -266,8 +266,8 @@ zeek::String* encode_base64(const zeek::String* s, const zeek::String* a, Connec { if ( a && a->Len() != 0 && a->Len() != 64 ) { - reporter->Error("base64 alphabet is not 64 characters: %s", - a->CheckString()); + zeek::reporter->Error("base64 alphabet is not 64 characters: %s", + a->CheckString()); return nullptr; } diff --git a/src/Brofiler.cc b/src/Brofiler.cc index 099d0eb2ea..929c4e918e 100644 --- a/src/Brofiler.cc +++ b/src/Brofiler.cc @@ -98,7 +98,7 @@ bool Brofiler::WriteStats() if ( ! ensure_intermediate_dirs(dirname.result.data()) ) { - reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); + zeek::reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); return false; } @@ -113,7 +113,7 @@ bool Brofiler::WriteStats() if ( fd == -1 ) { - reporter->Error("Failed to generate unique file name from ZEEK_PROFILER_FILE: %s", bf); + zeek::reporter->Error("Failed to generate unique file name from ZEEK_PROFILER_FILE: %s", bf); return false; } f = fdopen(fd, "w"); @@ -125,7 +125,7 @@ bool Brofiler::WriteStats() if ( ! f ) { - reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); + zeek::reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); return false; } diff --git a/src/CompHash.cc b/src/CompHash.cc index e3b205cfdd..58d18a9da6 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -305,7 +305,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0, default: { - reporter->InternalError("bad index type in CompositeHash::SingleValHash"); + zeek::reporter->InternalError("bad index type in CompositeHash::SingleValHash"); return nullptr; } } @@ -435,7 +435,7 @@ std::unique_ptr CompositeHash::ComputeSingletonHash(const zeek::Val* v, return std::make_unique(false, key, n); } - reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash"); + zeek::reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash"); return nullptr; case zeek::TYPE_INTERNAL_STRING: @@ -445,7 +445,7 @@ std::unique_ptr CompositeHash::ComputeSingletonHash(const zeek::Val* v, return nullptr; default: - reporter->InternalError("bad internal type in CompositeHash::ComputeSingletonHash"); + zeek::reporter->InternalError("bad internal type in CompositeHash::ComputeSingletonHash"); return nullptr; } } @@ -599,7 +599,7 @@ int CompositeHash::SingleTypeKeySize(zeek::Type* bt, const zeek::Val* v, default: { - reporter->InternalError("bad index type in CompositeHash::CompositeHash"); + zeek::reporter->InternalError("bad index type in CompositeHash::CompositeHash"); return 0; } } @@ -725,7 +725,7 @@ zeek::ListValPtr CompositeHash::RecoverVals(const HashKey& k) const } if ( kp != k_end ) - reporter->InternalError("under-ran key in CompositeHash::DescribeKey %zd", k_end - kp); + zeek::reporter->InternalError("under-ran key in CompositeHash::DescribeKey %zd", k_end - kp); return l; } @@ -737,7 +737,7 @@ const char* CompositeHash::RecoverOneVal( { // k->Size() == 0 for a single empty string. if ( kp0 >= k_end && k.Size() > 0 ) - reporter->InternalError("over-ran key in CompositeHash::RecoverVals"); + zeek::reporter->InternalError("over-ran key in CompositeHash::RecoverVals"); zeek::TypeTag tag = t->Tag(); zeek::InternalTypeTag it = t->InternalType(); @@ -769,7 +769,7 @@ const char* CompositeHash::RecoverOneVal( *pval = zeek::val_mgr->Int(*kp); else { - reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); *pval = nullptr; } } @@ -791,7 +791,7 @@ const char* CompositeHash::RecoverOneVal( break; default: - reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); *pval = nullptr; break; } @@ -825,7 +825,7 @@ const char* CompositeHash::RecoverOneVal( break; default: - reporter->InternalError("bad internal address in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("bad internal address in CompositeHash::RecoverOneVal()"); *pval = nullptr; break; } @@ -852,22 +852,22 @@ const char* CompositeHash::RecoverOneVal( const auto& f = zeek::Func::GetFuncPtrByID(*kp); if ( ! f ) - reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp); + zeek::reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp); *pval = zeek::make_intrusive(f); const auto& pvt = (*pval)->GetType(); if ( ! pvt ) - reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()"); else if ( t->Tag() != zeek::TYPE_FUNC && ! same_type(pvt, t) ) // ### Maybe fix later, but may be fundamentally // un-checkable --US - reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); // ### A crude approximation for now. else if ( t->Tag() == zeek::TYPE_FUNC && pvt->Tag() != zeek::TYPE_FUNC ) - reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); + zeek::reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); } break; @@ -891,8 +891,8 @@ const char* CompositeHash::RecoverOneVal( } if ( ! re->Compile() ) - reporter->InternalError("failed compiling table/set key pattern: %s", - re->PatternText()); + zeek::reporter->InternalError("failed compiling table/set key pattern: %s", + re->PatternText()); *pval = zeek::make_intrusive(re); } @@ -921,7 +921,7 @@ const char* CompositeHash::RecoverOneVal( // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch) if ( ! (v || optional) ) { - reporter->InternalError("didn't recover expected number of fields from HashKey"); + zeek::reporter->InternalError("didn't recover expected number of fields from HashKey"); pval = nullptr; break; } @@ -1023,7 +1023,7 @@ const char* CompositeHash::RecoverOneVal( default: { - reporter->InternalError("bad index type in CompositeHash::DescribeKey"); + zeek::reporter->InternalError("bad index type in CompositeHash::DescribeKey"); } } } diff --git a/src/Conn.cc b/src/Conn.cc index d0a8687069..a9939cce92 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -33,7 +33,7 @@ void ConnectionTimer::Init(Connection* arg_conn, timer_func arg_timer, ConnectionTimer::~ConnectionTimer() { if ( conn->RefCnt() < 1 ) - reporter->InternalError("reference count inconsistency in ~ConnectionTimer"); + zeek::reporter->InternalError("reference count inconsistency in ~ConnectionTimer"); conn->RemoveTimer(this); Unref(conn); @@ -51,7 +51,7 @@ void ConnectionTimer::Dispatch(double t, bool is_expire) (conn->*timer)(t); if ( conn->RefCnt() < 1 ) - reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); + zeek::reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); } uint64_t Connection::total_connections = 0; @@ -125,7 +125,7 @@ Connection::Connection(NetSessions* s, const zeek::detail::ConnIDKey& k, double Connection::~Connection() { if ( ! finished ) - reporter->InternalError("Done() not called before destruction of Connection"); + zeek::reporter->InternalError("Done() not called before destruction of Connection"); CancelTimers(); @@ -535,7 +535,7 @@ void Connection::EnqueueEvent(EventHandlerPtr f, zeek::analyzer::Analyzer* a, void Connection::Weird(const char* name, const char* addl) { weird = 1; - reporter->Weird(this, name, addl ? addl : ""); + zeek::reporter->Weird(this, name, addl ? addl : ""); } void Connection::AddTimer(timer_func timer, double t, bool do_expire, @@ -648,14 +648,14 @@ void Connection::Describe(ODesc* d) const case TRANSPORT_UNKNOWN: d->Add("unknown"); - reporter->InternalWarning( - "unknown transport in Connction::Describe()"); + zeek::reporter->InternalWarning( + "unknown transport in Connction::Describe()"); break; default: - reporter->InternalError( - "unhandled transport type in Connection::Describe"); + zeek::reporter->InternalError( + "unhandled transport type in Connection::Describe"); } d->SP(); diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index 00b0653550..e0a1d4e067 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -440,11 +440,11 @@ void DNS_Mgr::InitSource() if ( nb_dns ) { if ( ! iosource_mgr->RegisterFd(nb_dns_fd(nb_dns), this) ) - reporter->FatalError("Failed to register nb_dns file descriptor with iosource_mgr"); + zeek::reporter->FatalError("Failed to register nb_dns file descriptor with iosource_mgr"); } else { - reporter->Warning("problem initializing NB-DNS: %s", err); + zeek::reporter->Warning("problem initializing NB-DNS: %s", err); } did_init = true; @@ -508,7 +508,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name) if ( (d4 && d4->Failed()) || (d6 && d6->Failed()) ) { - reporter->Warning("no such host: %s", name); + zeek::reporter->Warning("no such host: %s", name); return empty_addr_set(); } else if ( d4 && d6 ) @@ -529,7 +529,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name) return empty_addr_set(); case DNS_FORCE: - reporter->FatalError("can't find DNS entry for %s in cache", name); + zeek::reporter->FatalError("can't find DNS entry for %s in cache", name); return nullptr; case DNS_DEFAULT: @@ -539,7 +539,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name) return LookupHost(name); default: - reporter->InternalError("bad mode in DNS_Mgr::LookupHost"); + zeek::reporter->InternalError("bad mode in DNS_Mgr::LookupHost"); return nullptr; } } @@ -560,7 +560,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr) else { string s(addr); - reporter->Warning("can't resolve IP address: %s", s.c_str()); + zeek::reporter->Warning("can't resolve IP address: %s", s.c_str()); return zeek::make_intrusive(s.c_str()); } } @@ -573,7 +573,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr) return zeek::make_intrusive(""); case DNS_FORCE: - reporter->FatalError("can't find DNS entry for %s in cache", + zeek::reporter->FatalError("can't find DNS entry for %s in cache", addr.AsString().c_str()); return nullptr; @@ -583,7 +583,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr) return LookupAddr(addr); default: - reporter->InternalError("bad mode in DNS_Mgr::LookupAddr"); + zeek::reporter->InternalError("bad mode in DNS_Mgr::LookupAddr"); return nullptr; } } @@ -644,7 +644,7 @@ void DNS_Mgr::Resolve() struct nb_dns_result r; status = nb_dns_activity(nb_dns, &r, err); if ( status < 0 ) - reporter->Warning( + zeek::reporter->Warning( "NB-DNS error in DNS_Mgr::WaitForReplies (%s)", err); else if ( status > 0 ) @@ -861,7 +861,7 @@ void DNS_Mgr::CompareMappings(DNS_Mapping* prev_dm, DNS_Mapping* new_dm) if ( ! prev_a || ! new_a ) { - reporter->InternalWarning("confused in DNS_Mgr::CompareMappings"); + zeek::reporter->InternalWarning("confused in DNS_Mgr::CompareMappings"); return; } @@ -932,7 +932,7 @@ void DNS_Mgr::LoadCache(FILE* f) } if ( ! m->NoMapping() ) - reporter->FatalError("DNS cache corrupted"); + zeek::reporter->FatalError("DNS cache corrupted"); delete m; fclose(f); @@ -1167,7 +1167,7 @@ static bool DoRequest(nb_dns_info* nb_dns, DNS_Mgr_Request* dr) // dr stored in nb_dns cookie and deleted later when results available. return true; - reporter->Warning("can't issue DNS request"); + zeek::reporter->Warning("can't issue DNS request"); delete dr; return false; } @@ -1376,7 +1376,7 @@ void DNS_Mgr::Process() int status = nb_dns_activity(nb_dns, &r, err); if ( status < 0 ) - reporter->Warning("NB-DNS error in DNS_Mgr::Process (%s)", err); + zeek::reporter->Warning("NB-DNS error in DNS_Mgr::Process (%s)", err); else if ( status > 0 ) { @@ -1416,7 +1416,7 @@ int DNS_Mgr::AnswerAvailable(int timeout) int fd = nb_dns_fd(nb_dns); if ( fd < 0 ) { - reporter->Warning("nb_dns_fd() failed in DNS_Mgr::WaitForReplies"); + zeek::reporter->Warning("nb_dns_fd() failed in DNS_Mgr::WaitForReplies"); return -1; } @@ -1434,14 +1434,14 @@ int DNS_Mgr::AnswerAvailable(int timeout) if ( status < 0 ) { if ( errno != EINTR ) - reporter->Warning("problem with DNS select"); + zeek::reporter->Warning("problem with DNS select"); return -1; } if ( status > 1 ) { - reporter->Warning("strange return from DNS select"); + zeek::reporter->Warning("strange return from DNS select"); return -1; } diff --git a/src/DbgBreakpoint.cc b/src/DbgBreakpoint.cc index 111de0d576..e39d06e383 100644 --- a/src/DbgBreakpoint.cc +++ b/src/DbgBreakpoint.cc @@ -219,7 +219,7 @@ bool DbgBreakpoint::Reset() break; } - reporter->InternalError("DbgBreakpoint::Reset function incomplete."); + zeek::reporter->InternalError("DbgBreakpoint::Reset function incomplete."); // Cannot be reached. return false; @@ -312,7 +312,7 @@ BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s) assert(false); default: - reporter->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak"); + zeek::reporter->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak"); } // If we got here, that means that the breakpoint could hit, @@ -329,7 +329,7 @@ BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s) BreakCode DbgBreakpoint::ShouldBreak(double t) { if ( kind != BP_TIME ) - reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint"); + zeek::reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint"); if ( t < at_time ) return BC_NO_HIT; @@ -370,7 +370,7 @@ void DbgBreakpoint::PrintHitMsg() assert(false); default: - reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n"); + zeek::reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n"); } } diff --git a/src/DbgWatch.cc b/src/DbgWatch.cc index 3fc225b23a..c1af0610fa 100644 --- a/src/DbgWatch.cc +++ b/src/DbgWatch.cc @@ -9,10 +9,10 @@ // Support classes zeek::detail::DbgWatch::DbgWatch(zeek::Obj* var_to_watch) { - reporter->InternalError("DbgWatch unimplemented"); + zeek::reporter->InternalError("DbgWatch unimplemented"); } zeek::detail::DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch) { - reporter->InternalError("DbgWatch unimplemented"); + zeek::reporter->InternalError("DbgWatch unimplemented"); } diff --git a/src/Debug.cc b/src/Debug.cc index 4de05cad8f..c5385546e5 100644 --- a/src/Debug.cc +++ b/src/Debug.cc @@ -91,7 +91,7 @@ DebuggerState::~DebuggerState() bool StmtLocMapping::StartsAfter(const StmtLocMapping* m2) { if ( ! m2 ) - reporter->InternalError("Assertion failed: m2 != 0"); + zeek::reporter->InternalError("Assertion failed: m2 != 0"); return loc.first_line > m2->loc.first_line || (loc.first_line == m2->loc.first_line && @@ -395,8 +395,8 @@ vector parse_location_string(const string& s) { auto iter = g_dbgfilemaps.find(loc_filename); if ( iter == g_dbgfilemaps.end() ) - reporter->InternalError("Policy file %s should have been loaded\n", - loc_filename.data()); + zeek::reporter->InternalError("Policy file %s should have been loaded\n", + loc_filename.data()); if ( plr.line > how_many_lines_in(loc_filename.data()) ) { @@ -637,7 +637,7 @@ int dbg_execute_command(const char* cmd) #endif if ( int(cmd_code) >= num_debug_cmds() ) - reporter->InternalError("Assertion failed: int(cmd_code) < num_debug_cmds()"); + zeek::reporter->InternalError("Assertion failed: int(cmd_code) < num_debug_cmds()"); // Dispatch to the op-specific handler (with args). int retcode = dbg_dispatch_cmd(cmd_code, arguments); @@ -646,7 +646,7 @@ int dbg_execute_command(const char* cmd) const DebugCmdInfo* info = get_debug_cmd_info(cmd_code); if ( ! info ) - reporter->InternalError("Assertion failed: info"); + zeek::reporter->InternalError("Assertion failed: info"); if ( ! info ) return -2; // ### yuck, why -2? @@ -803,7 +803,7 @@ int dbg_handle_debug_input() const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt(); if ( ! stmt ) - reporter->InternalError("Assertion failed: stmt != 0"); + zeek::reporter->InternalError("Assertion failed: stmt != 0"); const zeek::detail::Location loc = *stmt->GetLocationInfo(); @@ -909,7 +909,7 @@ bool pre_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f) p = g_debugger_state.breakpoint_map.equal_range(stmt); if ( p.first == p.second ) - reporter->InternalError("Breakpoint count nonzero, but no matching breakpoints"); + zeek::reporter->InternalError("Breakpoint count nonzero, but no matching breakpoints"); for ( BPMapType::iterator i = p.first; i != p.second; ++i ) { @@ -966,11 +966,11 @@ zeek::ValPtr dbg_eval_expr(const char* expr) (g_frame_stack.size() - 1) - g_debugger_state.curr_frame_idx; if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) ) - reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); + zeek::reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); zeek::detail::Frame* frame = g_frame_stack[frame_idx]; if ( ! (frame) ) - reporter->InternalError("Assertion failed: frame"); + zeek::reporter->InternalError("Assertion failed: frame"); const zeek::detail::ScriptFunc* func = frame->GetFunction(); if ( func ) diff --git a/src/DebugCmds.cc b/src/DebugCmds.cc index cf4c761761..57d85a3647 100644 --- a/src/DebugCmds.cc +++ b/src/DebugCmds.cc @@ -206,7 +206,7 @@ static int dbg_backtrace_internal(int start, int end) if ( start < 0 || end < 0 || (unsigned) start >= g_frame_stack.size() || (unsigned) end >= g_frame_stack.size() ) - reporter->InternalError("Invalid stack frame index in DbgBacktraceInternal\n"); + zeek::reporter->InternalError("Invalid stack frame index in DbgBacktraceInternal\n"); if ( start < end ) { @@ -337,7 +337,7 @@ int dbg_cmd_frame(DebugCmd cmd, const vector& args) // for 'list', 'break', etc. const zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); if ( ! stmt ) - reporter->InternalError("Assertion failed: %s", "stmt != 0"); + zeek::reporter->InternalError("Assertion failed: %s", "stmt != 0"); const zeek::detail::Location loc = *stmt->GetLocationInfo(); g_debugger_state.last_loc = loc; @@ -377,7 +377,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector& args) zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); if ( ! stmt ) - reporter->InternalError("Assertion failed: %s", "stmt != 0"); + zeek::reporter->InternalError("Assertion failed: %s", "stmt != 0"); DbgBreakpoint* bp = new DbgBreakpoint(); bp->SetID(g_debugger_state.NextBPID()); @@ -540,7 +540,7 @@ int dbg_cmd_break_set_state(DebugCmd cmd, const vector& args) break; default: - reporter->InternalError("Invalid command in DbgCmdBreakSetState\n"); + zeek::reporter->InternalError("Invalid command in DbgCmdBreakSetState\n"); } } diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index 8f8be1fc97..ab530d0840 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -45,8 +45,8 @@ void DebugLogger::OpenDebugLog(const char* filename) if ( ! file ) { // The reporter may not be initialized here yet. - if ( reporter ) - reporter->FatalError("can't open '%s' for debugging output", filename); + if ( zeek::reporter ) + zeek::reporter->FatalError("can't open '%s' for debugging output", filename); else { fprintf(stderr, "can't open '%s' for debugging output\n", filename); @@ -132,7 +132,7 @@ void DebugLogger::EnableStreams(const char* s) } } - reporter->FatalError("unknown debug stream '%s', try -B help.\n", tok); + zeek::reporter->FatalError("unknown debug stream '%s', try -B help.\n", tok); next: tok = strtok(0, ","); diff --git a/src/Desc.cc b/src/Desc.cc index 8d1f746c5f..32682ef736 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -75,7 +75,7 @@ void ODesc::PushIndent() void ODesc::PopIndent() { if ( --indent_level < 0 ) - reporter->InternalError("ODesc::PopIndent underflow"); + zeek::reporter->InternalError("ODesc::PopIndent underflow"); NL(); } @@ -83,7 +83,7 @@ void ODesc::PopIndent() void ODesc::PopIndentNoNL() { if ( --indent_level < 0 ) - reporter->InternalError("ODesc::PopIndent underflow"); + zeek::reporter->InternalError("ODesc::PopIndent underflow"); } void ODesc::Add(const char* s, int do_indent) @@ -358,7 +358,7 @@ void ODesc::AddBytesRaw(const void* bytes, unsigned int n) if ( ! write_failed ) // Most likely it's a "disk full" so report // subsequent failures only once. - reporter->Error("error writing to %s: %s", f->Name(), strerror(errno)); + zeek::reporter->Error("error writing to %s: %s", f->Name(), strerror(errno)); write_failed = true; return; diff --git a/src/Dict.cc b/src/Dict.cc index 2d1f82f40f..4019563e81 100644 --- a/src/Dict.cc +++ b/src/Dict.cc @@ -650,7 +650,7 @@ void Dictionary::StartChangeSize(int new_size) return; if ( tbl2 ) - reporter->InternalError("Dictionary::StartChangeSize() tbl2 not NULL"); + zeek::reporter->InternalError("Dictionary::StartChangeSize() tbl2 not NULL"); Init2(new_size); @@ -697,7 +697,7 @@ void Dictionary::FinishChangeSize() { // Cheap safety check. if ( num_entries != 0 ) - reporter->InternalError( + zeek::reporter->InternalError( "Dictionary::FinishChangeSize: num_entries is %d\n", num_entries); diff --git a/src/Discard.cc b/src/Discard.cc index e83d1b3f23..42ac9a78c0 100644 --- a/src/Discard.cc +++ b/src/Discard.cc @@ -46,7 +46,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen) discard_packet = check_ip->Invoke(&args)->AsBool(); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { discard_packet = false; } @@ -101,7 +101,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen) discard_packet = check_tcp->Invoke(&args)->AsBool(); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { discard_packet = false; } @@ -125,7 +125,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen) discard_packet = check_udp->Invoke(&args)->AsBool(); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { discard_packet = false; } @@ -145,7 +145,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen) discard_packet = check_icmp->Invoke(&args)->AsBool(); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { discard_packet = false; } diff --git a/src/Event.cc b/src/Event.cc index a173215684..54ffc082fb 100644 --- a/src/Event.cc +++ b/src/Event.cc @@ -52,14 +52,14 @@ void Event::Dispatch(bool no_remote) no_remote = true; if ( handler->ErrorHandler() ) - reporter->BeginErrorHandler(); + zeek::reporter->BeginErrorHandler(); try { handler->Call(&args, no_remote); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { // Already reported. } @@ -69,7 +69,7 @@ void Event::Dispatch(bool no_remote) Unref(obj); if ( handler->ErrorHandler() ) - reporter->EndErrorHandler(); + zeek::reporter->EndErrorHandler(); } EventMgr::EventMgr() @@ -242,5 +242,5 @@ void EventMgr::InitPostScript() { iosource_mgr->Register(this, true, false); if ( ! iosource_mgr->RegisterFd(queue_flare.FD(), this) ) - reporter->FatalError("Failed to register event manager FD with iosource_mgr"); + zeek::reporter->FatalError("Failed to register event manager FD with iosource_mgr"); } diff --git a/src/EventHandler.cc b/src/EventHandler.cc index ba834d4d68..d13bb87f9b 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -78,7 +78,7 @@ void EventHandler::Call(zeek::Args* vl, bool no_remote) { valid_args = false; auto_publish.clear(); - reporter->Error("failed auto-remote event '%s', disabled", Name()); + zeek::reporter->Error("failed auto-remote event '%s', disabled", Name()); break; } } diff --git a/src/EventRegistry.cc b/src/EventRegistry.cc index 21f08ebb62..9050e13705 100644 --- a/src/EventRegistry.cc +++ b/src/EventRegistry.cc @@ -117,6 +117,6 @@ void EventRegistry::SetErrorHandler(std::string_view name) return; } - reporter->InternalWarning("unknown event handler '%s' in SetErrorHandler()", - std::string(name).c_str()); + zeek::reporter->InternalWarning("unknown event handler '%s' in SetErrorHandler()", + std::string(name).c_str()); } diff --git a/src/Expr.cc b/src/Expr.cc index 0b37a9f5dc..39943f6618 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -244,7 +244,7 @@ void Expr::ExprError(const char msg[]) void Expr::RuntimeError(const std::string& msg) const { - reporter->ExprRuntimeError(this, "%s", msg.data()); + zeek::reporter->ExprRuntimeError(this, "%s", msg.data()); } void Expr::RuntimeErrorWithCallStack(const std::string& msg) const @@ -252,14 +252,14 @@ void Expr::RuntimeErrorWithCallStack(const std::string& msg) const auto rcs = render_call_stack(); if ( rcs.empty() ) - reporter->ExprRuntimeError(this, "%s", msg.data()); + zeek::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()); + zeek::reporter->RuntimeError(GetLocationInfo(), "%s, expression: %s, call stack: %s", + msg.data(), d.Description(), rcs.data()); } } @@ -803,7 +803,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const auto rval = v1->Clone(); if ( ! tv2->AddTo(rval.get(), false, false) ) - reporter->InternalError("set union failed to type check"); + zeek::reporter->InternalError("set union failed to type check"); return rval; } @@ -813,7 +813,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const auto rval = v1->Clone(); if ( ! tv2->RemoveFrom(rval.get()) ) - reporter->InternalError("set difference failed to type check"); + zeek::reporter->InternalError("set difference failed to type check"); return rval; } @@ -837,7 +837,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const case EXPR_GE: case EXPR_GT: // These should't happen due to canonicalization. - reporter->InternalError("confusion over canonicalization in set comparison"); + zeek::reporter->InternalError("confusion over canonicalization in set comparison"); break; default: @@ -916,7 +916,7 @@ void BinaryExpr::PromoteOps(TypeTag t) bt2 = op2->GetType()->AsVectorType()->Yield()->Tag(); if ( (is_vec1 || is_vec2) && ! (is_vec1 && is_vec2) ) - reporter->Warning("mixing vector and scalar operands is deprecated"); + zeek::reporter->Warning("mixing vector and scalar operands is deprecated"); if ( bt1 != t ) op1 = zeek::make_intrusive(op1, t); @@ -973,7 +973,7 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, ExprPtr arg_op) ExprError("vector elements must be integral for increment operator"); else { - reporter->Warning("increment/decrement operations for vectors deprecated"); + zeek::reporter->Warning("increment/decrement operations for vectors deprecated"); SetType(t); } } @@ -1541,7 +1541,7 @@ BoolExpr::BoolExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2) if ( is_vector(op1) || is_vector(op2) ) { if ( ! (is_vector(op1) && is_vector(op2)) ) - reporter->Warning("mixing vector and scalar operands is deprecated"); + zeek::reporter->Warning("mixing vector and scalar operands is deprecated"); SetType(zeek::make_intrusive(base_type(zeek::TYPE_BOOL))); } else @@ -2224,12 +2224,12 @@ bool AssignExpr::TypeCheck(const AttributesPtr& attrs) attr_copy = std::make_unique>(a); } - int errors_before = reporter->Errors(); + int errors_before = zeek::reporter->Errors(); op2 = zeek::make_intrusive( IntrusivePtr{zeek::NewRef{}, ctor_list}, std::move(attr_copy), op1->GetType()); - int errors_after = reporter->Errors(); + int errors_after = zeek::reporter->Errors(); if ( errors_after > errors_before ) { @@ -2898,7 +2898,7 @@ FieldExpr::FieldExpr(ExprPtr arg_op, const char* arg_field_name) td = rt->FieldDecl(field); if ( rt->IsFieldDeprecated(field) ) - reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, false).c_str()); + zeek::reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, false).c_str()); } } } @@ -2984,7 +2984,7 @@ HasFieldExpr::HasFieldExpr(ExprPtr arg_op, const char* arg_field_name) if ( field < 0 ) ExprError("no such field in record"); else if ( rt->IsFieldDeprecated(field) ) - reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, true).c_str()); + zeek::reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, true).c_str()); SetType(base_type(zeek::TYPE_BOOL)); } @@ -3451,8 +3451,8 @@ void FieldAssignExpr::EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f int idx = rt->FieldOffset(field_name.c_str()); if ( idx < 0 ) - reporter->InternalError("Missing record field: %s", - field_name.c_str()); + zeek::reporter->InternalError("Missing record field: %s", + field_name.c_str()); rec->Assign(idx, std::move(v)); } @@ -3657,7 +3657,7 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, zeek::RecordTypePtr r) } } else if ( t_r->IsFieldDeprecated(i) ) - reporter->Warning("%s", t_r->GetFieldDeprecationWarning(i, false).c_str()); + zeek::reporter->Warning("%s", t_r->GetFieldDeprecationWarning(i, false).c_str()); } } } diff --git a/src/File.cc b/src/File.cc index 3917267a35..e5c3727373 100644 --- a/src/File.cc +++ b/src/File.cc @@ -38,7 +38,7 @@ static void maximize_num_fds() { struct rlimit rl; if ( getrlimit(RLIMIT_NOFILE, &rl) < 0 ) - reporter->FatalError("maximize_num_fds(): getrlimit failed"); + zeek::reporter->FatalError("maximize_num_fds(): getrlimit failed"); if ( rl.rlim_max == RLIM_INFINITY ) { @@ -50,7 +50,7 @@ static void maximize_num_fds() rl.rlim_cur = rl.rlim_max; if ( setrlimit(RLIMIT_NOFILE, &rl) < 0 ) - reporter->FatalError("maximize_num_fds(): setrlimit failed"); + zeek::reporter->FatalError("maximize_num_fds(): setrlimit failed"); } BroFile::BroFile(FILE* arg_f) @@ -92,7 +92,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access) else if ( ! Open() ) { - reporter->Error("cannot open %s: %s", name, strerror(errno)); + zeek::reporter->Error("cannot open %s: %s", name, strerror(errno)); is_open = false; } } @@ -189,7 +189,7 @@ FILE* BroFile::Seek(long new_position) return nullptr; if ( fseek(f, new_position, SEEK_SET) < 0 ) - reporter->Error("seek failed"); + zeek::reporter->Error("seek failed"); return f; } @@ -200,7 +200,7 @@ void BroFile::SetBuf(bool arg_buffered) return; if ( setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 ) - reporter->Error("setvbuf failed"); + zeek::reporter->Error("setvbuf failed"); buffered = arg_buffered; } @@ -339,7 +339,7 @@ double BroFile::Size() struct stat s; if ( fstat(fileno(f), &s) < 0 ) { - reporter->Error("can't stat fd for %s: %s", name, strerror(errno)); + zeek::reporter->Error("can't stat fd for %s: %s", name, strerror(errno)); return 0; } diff --git a/src/Flare.cc b/src/Flare.cc index 89e24303ab..b0b35f46ae 100644 --- a/src/Flare.cc +++ b/src/Flare.cc @@ -21,8 +21,8 @@ Flare::Flare() char buf[256]; bro_strerror_r(errno, buf, sizeof(buf)); - if ( reporter ) - reporter->FatalErrorWithCore("unexpected pipe %s failure: %s", which, buf); + if ( zeek::reporter ) + zeek::reporter->FatalErrorWithCore("unexpected pipe %s failure: %s", which, buf); else { fprintf(stderr, "unexpected pipe %s failure: %s", which, buf); diff --git a/src/Frag.cc b/src/Frag.cc index d0c0d16b48..01ab4880f6 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -23,7 +23,7 @@ void FragTimer::Dispatch(double t, bool /* is_expire */) if ( f ) f->Expire(t); else - reporter->InternalWarning("fragment timer dispatched w/o reassembler"); + zeek::reporter->InternalWarning("fragment timer dispatched w/o reassembler"); } FragReassembler::FragReassembler(NetSessions* arg_s, @@ -173,8 +173,8 @@ void FragReassembler::Weird(const char* name) const else { - reporter->InternalWarning("Unexpected IP version in FragReassembler"); - reporter->Weird(name); + zeek::reporter->InternalWarning("Unexpected IP version in FragReassembler"); + zeek::reporter->Weird(name); } } @@ -274,7 +274,7 @@ void FragReassembler::BlockInserted(DataBlockMap::const_iterator /* it */) if ( b.upper > n ) { - reporter->InternalWarning("bad fragment reassembly"); + zeek::reporter->InternalWarning("bad fragment reassembly"); DeleteTimer(); Expire(network_time); delete [] pkt_start; @@ -308,8 +308,8 @@ void FragReassembler::BlockInserted(DataBlockMap::const_iterator /* it */) else { - reporter->InternalWarning("bad IP version in fragment reassembly: %d", - version); + zeek::reporter->InternalWarning("bad IP version in fragment reassembly: %d", + version); delete [] pkt_start; } } diff --git a/src/Frame.cc b/src/Frame.cc index ffb1e30968..deeef6b358 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -245,7 +245,7 @@ Frame* Frame::SelectiveClone(const id_list& selection, ScriptFunc* func) const } if ( ! frame[id->Offset()].val ) - reporter->InternalError("Attempted to clone an id ('%s') with no associated value.", id->Name()); + zeek::reporter->InternalError("Attempted to clone an id ('%s') with no associated value.", id->Name()); CloneNonFuncElement(id->Offset(), func, other); } @@ -308,7 +308,7 @@ broker::expected Frame::Serialize(const Frame* target, const id_li if ( them.length() ) { if ( ! target->closure ) - reporter->InternalError("Attempting to serialize values from a frame that does not exist."); + zeek::reporter->InternalError("Attempting to serialize values from a frame that does not exist."); rval.emplace_back(std::string("ClosureFrame")); @@ -502,7 +502,7 @@ void Frame::AddKnownOffsets(const id_list& ids) void Frame::CaptureClosure(Frame* c, id_list arg_outer_ids) { if ( closure || outer_ids.length() ) - reporter->InternalError("Attempted to override a closure."); + zeek::reporter->InternalError("Attempted to override a closure."); outer_ids = std::move(arg_outer_ids); diff --git a/src/Func.cc b/src/Func.cc index c3962cdd23..05a0df481a 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -242,7 +242,7 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result, if ( ! handled ) { if ( hook_result ) - reporter->InternalError("plugin set processed flag to false but actually returned a value"); + zeek::reporter->InternalError("plugin set processed flag to false but actually returned a value"); // The plugin result hasn't been processed yet (read: fall // into ::Call method). @@ -252,15 +252,15 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result, switch ( flavor ) { case zeek::FUNC_FLAVOR_EVENT: if ( hook_result ) - reporter->InternalError("plugin returned non-void result for event %s", - this->Name()); + zeek::reporter->InternalError("plugin returned non-void result for event %s", + this->Name()); break; case zeek::FUNC_FLAVOR_HOOK: if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL ) - reporter->InternalError("plugin returned non-bool for hook %s", - this->Name()); + zeek::reporter->InternalError("plugin returned non-bool for hook %s", + this->Name()); break; @@ -271,14 +271,14 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result, if ( (! yt) || yt->Tag() == zeek::TYPE_VOID ) { if ( hook_result ) - reporter->InternalError("plugin returned non-void result for void method %s", - this->Name()); + zeek::reporter->InternalError("plugin returned non-void result for void method %s", + this->Name()); } else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY ) { - reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s", - hook_result->GetType()->Tag(), yt->Tag(), this->Name()); + zeek::reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s", + hook_result->GetType()->Tag(), yt->Tag(), this->Name()); } break; @@ -453,8 +453,8 @@ zeek::ValPtr ScriptFunc::Invoke(zeek::Args* args, zeek::detail::Frame* parent) c (flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) && ! f->HasDelayed() ) - reporter->Warning("non-void function returning without a value: %s", - Name()); + zeek::reporter->Warning("non-void function returning without a value: %s", + Name()); if ( result && g_trace_state.DoTrace() ) { @@ -523,8 +523,8 @@ bool ScriptFunc::StrengthenClosureReference(zeek::detail::Frame* f) void ScriptFunc::SetClosureFrame(zeek::detail::Frame* f) { if ( closure ) - reporter->InternalError("Tried to override closure for ScriptFunc %s.", - Name()); + zeek::reporter->InternalError("Tried to override closure for ScriptFunc %s.", + Name()); // Have to use weak references initially because otherwise Ref'ing the // original frame creates a circular reference: the function holds a @@ -618,9 +618,9 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name, const auto& id = zeek::detail::lookup_ID(Name(), GLOBAL_MODULE_NAME, false); if ( ! id ) - reporter->InternalError("built-in function %s missing", Name()); + zeek::reporter->InternalError("built-in function %s missing", Name()); if ( id->HasVal() ) - reporter->InternalError("built-in function %s multiply defined", Name()); + zeek::reporter->InternalError("built-in function %s multiply defined", Name()); type = id->GetType(); id->SetVal(zeek::make_intrusive(zeek::IntrusivePtr{zeek::NewRef{}, this})); @@ -800,11 +800,11 @@ static void emit_builtin_error_common(const char* msg, Obj* arg, bool unwind) { ODesc d; arg->Describe(&d); - reporter->ExprRuntimeError(ce, "%s (%s), during call:", msg, - d.Description()); + zeek::reporter->ExprRuntimeError(ce, "%s (%s), during call:", msg, + d.Description()); } else - reporter->ExprRuntimeError(ce, "%s", msg); + zeek::reporter->ExprRuntimeError(ce, "%s", msg); } else ce->Error(msg, arg); @@ -814,16 +814,16 @@ static void emit_builtin_error_common(const char* msg, Obj* arg, bool unwind) if ( arg ) { if ( unwind ) - reporter->RuntimeError(arg->GetLocationInfo(), "%s", msg); + zeek::reporter->RuntimeError(arg->GetLocationInfo(), "%s", msg); else arg->Error(msg); } else { if ( unwind ) - reporter->RuntimeError(nullptr, "%s", msg); + zeek::reporter->RuntimeError(nullptr, "%s", msg); else - reporter->Error("%s", msg); + zeek::reporter->Error("%s", msg); } } }; diff --git a/src/Hash.cc b/src/Hash.cc index 3735b4470d..35eee50f28 100644 --- a/src/Hash.cc +++ b/src/Hash.cc @@ -83,7 +83,7 @@ void init_hash_function() { // Make sure we have already called init_random_seed(). if ( ! KeyedHash::IsInitialized() ) - reporter->InternalError("Zeek's hash functions aren't fully initialized"); + zeek::reporter->InternalError("Zeek's hash functions aren't fully initialized"); } HashKey::HashKey(bro_int_t i) diff --git a/src/ID.cc b/src/ID.cc index 568004e1bd..57d821e5cc 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -42,8 +42,8 @@ const zeek::TypePtr& zeek::id::find_type(std::string_view name) auto id = zeek::detail::global_scope()->Find(name); if ( ! id ) - reporter->InternalError("Failed to find type named: %s", - std::string(name).data()); + zeek::reporter->InternalError("Failed to find type named: %s", + std::string(name).data()); return id->GetType(); } @@ -53,8 +53,8 @@ const zeek::ValPtr& zeek::id::find_val(std::string_view name) auto id = zeek::detail::global_scope()->Find(name); if ( ! id ) - reporter->InternalError("Failed to find variable named: %s", - std::string(name).data()); + zeek::reporter->InternalError("Failed to find variable named: %s", + std::string(name).data()); return id->GetVal(); } @@ -64,12 +64,12 @@ const zeek::ValPtr& zeek::id::find_const(std::string_view name) auto id = zeek::detail::global_scope()->Find(name); if ( ! id ) - reporter->InternalError("Failed to find variable named: %s", - std::string(name).data()); + zeek::reporter->InternalError("Failed to find variable named: %s", + std::string(name).data()); if ( ! id->IsConst() ) - reporter->InternalError("Variable is not 'const', but expected to be: %s", - std::string(name).data()); + zeek::reporter->InternalError("Variable is not 'const', but expected to be: %s", + std::string(name).data()); return id->GetVal(); } @@ -82,8 +82,8 @@ zeek::FuncPtr zeek::id::find_func(std::string_view name) return nullptr; if ( ! IsFunc(v->GetType()->Tag()) ) - reporter->InternalError("Expected variable '%s' to be a function", - std::string(name).data()); + zeek::reporter->InternalError("Expected variable '%s' to be a function", + std::string(name).data()); return v->AsFuncPtr(); } diff --git a/src/IP.cc b/src/IP.cc index 427254c75f..277ec67b3d 100644 --- a/src/IP.cc +++ b/src/IP.cc @@ -284,7 +284,7 @@ zeek::RecordValPtr IPv6_Hdr::ToVal(zeek::VectorValPtr chain) const } default: - reporter->Weird("unknown_mobility_type", fmt("%d", mob->ip6mob_type)); + zeek::reporter->Weird("unknown_mobility_type", fmt("%d", mob->ip6mob_type)); break; } @@ -494,7 +494,7 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, int total_len, if ( total_len < (int)sizeof(struct ip6_hdr) ) { - reporter->InternalWarning("truncated IP header in IPv6_HdrChain::Init"); + zeek::reporter->InternalWarning("truncated IP header in IPv6_HdrChain::Init"); return; } @@ -552,7 +552,7 @@ bool IPv6_Hdr_Chain::IsFragment() const { if ( chain.empty() ) { - reporter->InternalWarning("empty IPv6 header chain"); + zeek::reporter->InternalWarning("empty IPv6 header chain"); return false; } @@ -567,7 +567,7 @@ IPAddr IPv6_Hdr_Chain::SrcAddr() const #endif if ( chain.empty() ) { - reporter->InternalWarning("empty IPv6 header chain"); + zeek::reporter->InternalWarning("empty IPv6 header chain"); return IPAddr(); } @@ -581,7 +581,7 @@ IPAddr IPv6_Hdr_Chain::DstAddr() const if ( chain.empty() ) { - reporter->InternalWarning("empty IPv6 header chain"); + zeek::reporter->InternalWarning("empty IPv6 header chain"); return IPAddr(); } @@ -593,7 +593,7 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le if ( finalDst ) { // RFC 2460 section 4.1 says Routing should occur at most once. - reporter->Weird(SrcAddr(), DstAddr(), "multiple_routing_headers"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "multiple_routing_headers"); return; } @@ -608,11 +608,11 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le if ( r->ip6r_len % 2 == 0 ) finalDst = new IPAddr(*addr); else - reporter->Weird(SrcAddr(), DstAddr(), "odd_routing0_len"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "odd_routing0_len"); } // Always raise a weird since this type is deprecated. - reporter->Weird(SrcAddr(), DstAddr(), "routing0_hdr"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "routing0_hdr"); } break; @@ -624,15 +624,15 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le if ( r->ip6r_len == 2 ) finalDst = new IPAddr(*addr); else - reporter->Weird(SrcAddr(), DstAddr(), "bad_routing2_len"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "bad_routing2_len"); } } break; #endif default: - reporter->Weird(SrcAddr(), DstAddr(), "unknown_routing_type", - fmt("%d", r->ip6r_type)); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "unknown_routing_type", + fmt("%d", r->ip6r_type)); break; } } @@ -652,11 +652,11 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len) { if ( opt->ip6o_len == 16 ) if ( homeAddr ) - reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts"); else homeAddr = new IPAddr(*((const in6_addr*)(data + 2))); else - reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len"); + zeek::reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len"); } break; @@ -722,7 +722,7 @@ zeek::VectorValPtr IPv6_Hdr_Chain::ToVal() const break; #endif default: - reporter->InternalWarning("IPv6_Hdr_Chain bad header %d", type); + zeek::reporter->InternalWarning("IPv6_Hdr_Chain bad header %d", type); continue; } @@ -768,7 +768,7 @@ IPv6_Hdr_Chain* IPv6_Hdr_Chain::Copy(const ip6_hdr* new_hdr) const if ( chain.empty() ) { - reporter->InternalWarning("empty IPv6 header chain"); + zeek::reporter->InternalWarning("empty IPv6 header chain"); delete rval; return nullptr; } diff --git a/src/IPAddr.cc b/src/IPAddr.cc index ddea5d899c..2232f6a468 100644 --- a/src/IPAddr.cc +++ b/src/IPAddr.cc @@ -74,7 +74,7 @@ void IPAddr::Mask(int top_bits_to_keep) { if ( top_bits_to_keep < 0 || top_bits_to_keep > 128 ) { - reporter->Error("Bad IPAddr::Mask value %d", top_bits_to_keep); + zeek::reporter->Error("Bad IPAddr::Mask value %d", top_bits_to_keep); return; } @@ -98,7 +98,7 @@ void IPAddr::ReverseMask(int top_bits_to_chop) { if ( top_bits_to_chop < 0 || top_bits_to_chop > 128 ) { - reporter->Error("Bad IPAddr::ReverseMask value %d", top_bits_to_chop); + zeek::reporter->Error("Bad IPAddr::ReverseMask value %d", top_bits_to_chop); return; } @@ -153,7 +153,7 @@ void IPAddr::Init(const char* s) { if ( ! ConvertString(s, &in6) ) { - reporter->Error("Bad IP address: %s", s); + zeek::reporter->Error("Bad IP address: %s", s); memset(in6.s6_addr, 0, sizeof(in6.s6_addr)); } } @@ -239,7 +239,7 @@ IPPrefix::IPPrefix(const in4_addr& in4, uint8_t length) { if ( length > 32 ) { - reporter->Error("Bad in4_addr IPPrefix length : %d", length); + zeek::reporter->Error("Bad in4_addr IPPrefix length : %d", length); this->length = 0; } @@ -251,7 +251,7 @@ IPPrefix::IPPrefix(const in6_addr& in6, uint8_t length) { if ( length > 128 ) { - reporter->Error("Bad in6_addr IPPrefix length : %d", length); + zeek::reporter->Error("Bad in6_addr IPPrefix length : %d", length); this->length = 0; } @@ -288,7 +288,7 @@ IPPrefix::IPPrefix(const IPAddr& addr, uint8_t length, bool len_is_v6_relative) else { auto vstr = prefix.GetFamily() == IPv4 ? "v4" : "v6"; - reporter->Error("Bad IPAddr(%s) IPPrefix length : %d", vstr, length); + zeek::reporter->Error("Bad IPAddr(%s) IPPrefix length : %d", vstr, length); this->length = 0; } diff --git a/src/Net.cc b/src/Net.cc index eaffe0b749..029a3203ac 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -114,7 +114,7 @@ RETSIGTYPE watchdog(int /* signo */) pkt_dumper = iosource_mgr->OpenPktDumper("watchdog-pkt.pcap", false); if ( ! pkt_dumper || pkt_dumper->IsError() ) { - reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing"); + zeek::reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing"); pkt_dumper = nullptr; } } @@ -127,10 +127,10 @@ RETSIGTYPE watchdog(int /* signo */) net_get_final_stats(); net_finish(0); - reporter->FatalErrorWithCore( - "**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d", - int_ct, frac_ct, int_pst, frac_pst, - current_dispatched); + zeek::reporter->FatalErrorWithCore( + "**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d", + int_ct, frac_ct, int_pst, frac_pst, + current_dispatched); } } @@ -160,8 +160,8 @@ void net_init(const std::optional& interface, assert(ps); if ( ! ps->IsOpen() ) - reporter->FatalError("problem with trace file %s (%s)", - pcap_input_file->c_str(), ps->ErrorMsg()); + zeek::reporter->FatalError("problem with trace file %s (%s)", + pcap_input_file->c_str(), ps->ErrorMsg()); } else if ( interface ) { @@ -172,8 +172,8 @@ void net_init(const std::optional& interface, assert(ps); if ( ! ps->IsOpen() ) - reporter->FatalError("problem with interface %s (%s)", - interface->c_str(), ps->ErrorMsg()); + zeek::reporter->FatalError("problem with interface %s (%s)", + interface->c_str(), ps->ErrorMsg()); } else @@ -190,13 +190,13 @@ void net_init(const std::optional& interface, assert(pkt_dumper); if ( ! pkt_dumper->IsOpen() ) - reporter->FatalError("problem opening dump file %s (%s)", - writefile, pkt_dumper->ErrorMsg()); + zeek::reporter->FatalError("problem opening dump file %s (%s)", + writefile, pkt_dumper->ErrorMsg()); if ( const auto& id = zeek::detail::global_scope()->Find("trace_output_file") ) id->SetVal(zeek::make_intrusive(writefile)); else - reporter->Error("trace_output_file not defined in bro.init"); + zeek::reporter->Error("trace_output_file not defined in bro.init"); } zeek::detail::init_ip_addr_anonymizers(); @@ -373,8 +373,8 @@ void net_get_final_stats() iosource::PktSrc::Stats s; ps->Statistics(&s); double dropped_pct = s.dropped > 0.0 ? ((double)s.dropped / ((double)s.received + (double)s.dropped)) * 100.0 : 0.0; - reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped", - s.received, ps->Path().c_str(), s.dropped, dropped_pct); + zeek::reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped", + s.received, ps->Path().c_str(), s.dropped, dropped_pct); } } @@ -418,7 +418,7 @@ int _processing_suspended = 0; void net_suspend_processing() { if ( _processing_suspended == 0 ) - reporter->Info("processing suspended"); + zeek::reporter->Info("processing suspended"); ++_processing_suspended; } @@ -427,7 +427,7 @@ void net_continue_processing() { if ( _processing_suspended == 1 ) { - reporter->Info("processing continued"); + zeek::reporter->Info("processing continued"); if ( iosource::PktSrc* ps = iosource_mgr->GetPktSrc() ) ps->ContinueAfterSuspend(); } diff --git a/src/Obj.cc b/src/Obj.cc index b733ba0055..dfff7a09a5 100644 --- a/src/Obj.cc +++ b/src/Obj.cc @@ -67,8 +67,8 @@ void Obj::Warn(const char* msg, const Obj* obj2, bool pinpoint_only, const detai { ODesc d; DoMsg(&d, msg, obj2, pinpoint_only, expr_location); - reporter->Warning("%s", d.Description()); - reporter->PopLocation(); + zeek::reporter->Warning("%s", d.Description()); + zeek::reporter->PopLocation(); } void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const detail::Location* expr_location) const @@ -78,8 +78,8 @@ void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const deta ODesc d; DoMsg(&d, msg, obj2, pinpoint_only, expr_location); - reporter->Error("%s", d.Description()); - reporter->PopLocation(); + zeek::reporter->Error("%s", d.Description()); + zeek::reporter->PopLocation(); } void Obj::BadTag(const char* msg, const char* t1, const char* t2) const @@ -95,8 +95,8 @@ void Obj::BadTag(const char* msg, const char* t1, const char* t2) const ODesc d; DoMsg(&d, out); - reporter->FatalErrorWithCore("%s", d.Description()); - reporter->PopLocation(); + zeek::reporter->FatalErrorWithCore("%s", d.Description()); + zeek::reporter->PopLocation(); } void Obj::Internal(const char* msg) const @@ -106,19 +106,19 @@ void Obj::Internal(const char* msg) const auto rcs = zeek::render_call_stack(); if ( rcs.empty() ) - reporter->InternalError("%s", d.Description()); + zeek::reporter->InternalError("%s", d.Description()); else - reporter->InternalError("%s, call stack: %s", d.Description(), rcs.data()); + zeek::reporter->InternalError("%s, call stack: %s", d.Description(), rcs.data()); - reporter->PopLocation(); + zeek::reporter->PopLocation(); } void Obj::InternalWarning(const char* msg) const { ODesc d; DoMsg(&d, msg); - reporter->InternalWarning("%s", d.Description()); - reporter->PopLocation(); + zeek::reporter->InternalWarning("%s", d.Description()); + zeek::reporter->PopLocation(); } void Obj::AddLocation(ODesc* d) const @@ -177,7 +177,7 @@ void Obj::DoMsg(ODesc* d, const char s1[], const Obj* obj2, else if ( expr_location ) loc2 = expr_location; - reporter->PushLocation(GetLocationInfo(), loc2); + zeek::reporter->PushLocation(GetLocationInfo(), loc2); } void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const @@ -203,7 +203,7 @@ void Obj::Print() const void bad_ref(int type) { - reporter->InternalError("bad reference count [%d]", type); + zeek::reporter->InternalError("bad reference count [%d]", type); abort(); } diff --git a/src/OpaqueVal.cc b/src/OpaqueVal.cc index 7587e4f262..c30478f600 100644 --- a/src/OpaqueVal.cc +++ b/src/OpaqueVal.cc @@ -54,8 +54,8 @@ const std::string& OpaqueMgr::TypeID(const OpaqueVal* v) const auto x = _types.find(v->OpaqueName()); if ( x == _types.end() ) - reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered", - v->OpaqueName()); + zeek::reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered", + v->OpaqueName()); return x->first; } @@ -774,13 +774,13 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x, y->Type() && ! same_type(x->Type(), y->Type()) ) { - reporter->Error("cannot merge Bloom filters with different types"); + zeek::reporter->Error("cannot merge Bloom filters with different types"); return nullptr; } if ( typeid(*x->bloom_filter) != typeid(*y->bloom_filter) ) { - reporter->Error("cannot merge different Bloom filter types"); + zeek::reporter->Error("cannot merge different Bloom filter types"); return nullptr; } @@ -789,7 +789,7 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x, if ( ! copy->Merge(y->bloom_filter) ) { delete copy; - reporter->Error("failed to merge Bloom filter"); + zeek::reporter->Error("failed to merge Bloom filter"); return nullptr; } @@ -797,7 +797,7 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x, if ( x->Type() && ! merged->Typify(x->Type()) ) { - reporter->Error("failed to set type on merged Bloom filter"); + zeek::reporter->Error("failed to set type on merged Bloom filter"); return nullptr; } @@ -1008,12 +1008,12 @@ bool ParaglobVal::DoUnserialize(const broker::data& data) } catch (const paraglob::underflow_error& e) { - reporter->Error("Paraglob underflow error -> %s", e.what()); + zeek::reporter->Error("Paraglob underflow error -> %s", e.what()); return false; } catch (const paraglob::overflow_error& e) { - reporter->Error("Paraglob overflow error -> %s", e.what()); + zeek::reporter->Error("Paraglob overflow error -> %s", e.what()); return false; } @@ -1028,12 +1028,12 @@ ValPtr ParaglobVal::DoClone(CloneState* state) } catch (const paraglob::underflow_error& e) { - reporter->Error("Paraglob underflow error while cloning -> %s", e.what()); + zeek::reporter->Error("Paraglob underflow error while cloning -> %s", e.what()); return nullptr; } catch (const paraglob::overflow_error& e) { - reporter->Error("Paraglob overflow error while cloning -> %s", e.what()); + zeek::reporter->Error("Paraglob overflow error while cloning -> %s", e.what()); return nullptr; } } diff --git a/src/PacketDumper.cc b/src/PacketDumper.cc index ffb2a037d9..1c750f61be 100644 --- a/src/PacketDumper.cc +++ b/src/PacketDumper.cc @@ -12,7 +12,7 @@ PacketDumper::PacketDumper(pcap_dumper_t* arg_pkt_dump) pkt_dump = arg_pkt_dump; if ( ! pkt_dump ) - reporter->InternalError("PacketDumper: nil dump file"); + zeek::reporter->InternalError("PacketDumper: nil dump file"); } void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr, @@ -23,7 +23,7 @@ void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr, struct pcap_pkthdr h = *hdr; h.caplen = len; if ( h.caplen > hdr->caplen ) - reporter->InternalError("bad modified caplen"); + zeek::reporter->InternalError("bad modified caplen"); pcap_dump((u_char*) pkt_dump, &h, pkt); } diff --git a/src/Pipe.cc b/src/Pipe.cc index 93ceac50ea..ae5c2a155e 100644 --- a/src/Pipe.cc +++ b/src/Pipe.cc @@ -14,8 +14,8 @@ static void pipe_fail(int eno) char tmp[256]; bro_strerror_r(eno, tmp, sizeof(tmp)); - if ( reporter ) - reporter->FatalError("Pipe failure: %s", tmp); + if ( zeek::reporter ) + zeek::reporter->FatalError("Pipe failure: %s", tmp); else fprintf(stderr, "Pipe failure: %s", tmp); } diff --git a/src/PolicyFile.cc b/src/PolicyFile.cc index 6250a52dad..0bc4e4e9bc 100644 --- a/src/PolicyFile.cc +++ b/src/PolicyFile.cc @@ -32,7 +32,7 @@ static PolicyFileMap policy_files; int how_many_lines_in(const char* policy_filename) { if ( ! policy_filename ) - reporter->InternalError("NULL value passed to how_many_lines_in\n"); + zeek::reporter->InternalError("NULL value passed to how_many_lines_in\n"); FILE* throwaway = fopen(policy_filename, "r"); if ( ! throwaway ) @@ -85,7 +85,7 @@ bool LoadPolicyFileText(const char* policy_filename) { char buf[256]; bro_strerror_r(errno, buf, sizeof(buf)); - reporter->Error("fstat failed on %s: %s", policy_filename, buf); + zeek::reporter->Error("fstat failed on %s: %s", policy_filename, buf); fclose(f); return false; } @@ -97,7 +97,7 @@ bool LoadPolicyFileText(const char* policy_filename) // (probably fine with UTF-8) pf->filedata = new char[size+1]; if ( fread(pf->filedata, size, 1, f) != 1 ) - reporter->InternalError("Failed to fread() file data"); + zeek::reporter->InternalError("Failed to fread() file data"); pf->filedata[size] = 0; fclose(f); diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index 664824a465..7986719d99 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -27,7 +27,7 @@ void* PrefixTable::Insert(const zeek::IPAddr& addr, int width, void* data) if ( ! node ) { - reporter->InternalWarning("Cannot create node in patricia tree"); + zeek::reporter->InternalWarning("Cannot create node in patricia tree"); return nullptr; } @@ -58,7 +58,7 @@ void* PrefixTable::Insert(const zeek::Val* value, void* data) break; default: - reporter->InternalWarning("Wrong index type for PrefixTable"); + zeek::reporter->InternalWarning("Wrong index type for PrefixTable"); return nullptr; } } @@ -118,8 +118,8 @@ void* PrefixTable::Lookup(const zeek::Val* value, bool exact) const break; default: - reporter->InternalWarning("Wrong index type %d for PrefixTable", - value->GetType()->Tag()); + zeek::reporter->InternalWarning("Wrong index type %d for PrefixTable", + value->GetType()->Tag()); return nullptr; } } @@ -157,7 +157,7 @@ void* PrefixTable::Remove(const zeek::Val* value) break; default: - reporter->InternalWarning("Wrong index type for PrefixTable"); + zeek::reporter->InternalWarning("Wrong index type for PrefixTable"); return nullptr; } } diff --git a/src/PriorityQueue.cc b/src/PriorityQueue.cc index 355b3b2a26..e77ed9e7e2 100644 --- a/src/PriorityQueue.cc +++ b/src/PriorityQueue.cc @@ -49,7 +49,7 @@ PQ_Element* PriorityQueue::Remove(PQ_Element* e) PQ_Element* e2 = Remove(); if ( e != e2 ) - reporter->InternalError("inconsistency in PriorityQueue::Remove"); + zeek::reporter->InternalError("inconsistency in PriorityQueue::Remove"); return e2; } diff --git a/src/RE.cc b/src/RE.cc index 2027aa8a7a..e98d707c4e 100644 --- a/src/RE.cc +++ b/src/RE.cc @@ -135,7 +135,7 @@ bool Specific_RE_Matcher::Compile(bool lazy) if ( parse_status ) { - reporter->Error("error compiling pattern /%s/", pattern_text); + zeek::reporter->Error("error compiling pattern /%s/", pattern_text); Unref(nfa); nfa = nullptr; return false; @@ -157,7 +157,7 @@ bool Specific_RE_Matcher::Compile(bool lazy) bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx) { if ( (size_t)set.length() != idx.size() ) - reporter->InternalError("compileset: lengths of sets differ"); + zeek::reporter->InternalError("compileset: lengths of sets differ"); rem = this; @@ -171,7 +171,7 @@ bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx if ( parse_status ) { - reporter->Error("error compiling pattern /%s/", set[i]); + zeek::reporter->Error("error compiling pattern /%s/", set[i]); if ( set_nfa && set_nfa != nfa ) Unref(set_nfa); diff --git a/src/Reporter.cc b/src/Reporter.cc index f3a2bd6248..c0a36e91ed 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -30,7 +30,10 @@ int closelog(); } #endif -Reporter* reporter = nullptr; +zeek::Reporter* zeek::reporter = nullptr; +zeek::Reporter*& reporter = zeek::reporter; + +namespace zeek { Reporter::Reporter(bool arg_abort_on_scripting_errors) { @@ -253,7 +256,7 @@ public: {} void Dispatch(double t, bool is_expire) override - { reporter->ResetNetWeird(weird_name); } + { zeek::reporter->ResetNetWeird(weird_name); } std::string weird_name; }; @@ -267,7 +270,7 @@ public: {} void Dispatch(double t, bool is_expire) override - { reporter->ResetFlowWeird(endpoints.first, endpoints.second); } + { zeek::reporter->ResetFlowWeird(endpoints.first, endpoints.second); } IPPair endpoints; }; @@ -282,7 +285,7 @@ public: {} void Dispatch(double t, bool is_expire) override - { reporter->ResetExpiredConnWeird(conn_id); } + { zeek::reporter->ResetExpiredConnWeird(conn_id); } ConnTuple conn_id; }; @@ -620,3 +623,5 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, if ( alloced ) free(alloced); } + +} // namespace zeek diff --git a/src/Reporter.h b/src/Reporter.h index 508b3e9efc..2b4f984d75 100644 --- a/src/Reporter.h +++ b/src/Reporter.h @@ -18,19 +18,18 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(Analyzer, zeek, analyzer); namespace file_analysis { class File; } class Connection; -class Reporter; class EventHandlerPtr; ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek); +ZEEK_FORWARD_DECLARE_NAMESPACED(Location, zeek::detail); +ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek); +ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); +ZEEK_FORWARD_DECLARE_NAMESPACED(Reporter, zeek); namespace zeek { template class IntrusivePtr; using RecordValPtr = zeek::IntrusivePtr; using StringValPtr = zeek::IntrusivePtr; -} - -ZEEK_FORWARD_DECLARE_NAMESPACED(Location, zeek::detail); -ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek); // One cannot raise this exception directly, go through the // Reporter's methods instead. @@ -47,8 +46,6 @@ protected: InterpreterException() {} }; -ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); - #define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess. class Reporter { @@ -304,3 +301,11 @@ private: }; extern Reporter* reporter; + +} // namespace zeek + +using Reporter [[deprecated("Remove in v4.1. Use zeek::Reporter.")]] = zeek::Reporter; +using ReporterException [[deprecated("Remove in v4.1. Use zeek::ReporterException.")]] = zeek::ReporterException; +using InterpreterException [[deprecated("Remove in v4.1. Use zeek::InterpreterException.")]] = zeek::InterpreterException; + +extern zeek::Reporter*& reporter [[deprecated("Remove v4.1. Use zeek::reporter.")]]; diff --git a/src/RuleAction.cc b/src/RuleAction.cc index c9aa03a5b3..2552f8d6db 100644 --- a/src/RuleAction.cc +++ b/src/RuleAction.cc @@ -54,7 +54,7 @@ RuleActionAnalyzer::RuleActionAnalyzer(const char* arg_analyzer) analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str()); if ( ! analyzer ) - reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); + zeek::reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); if ( pos != string::npos ) { @@ -62,7 +62,7 @@ RuleActionAnalyzer::RuleActionAnalyzer(const char* arg_analyzer) child_analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str()); if ( ! child_analyzer ) - reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); + zeek::reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); } else child_analyzer = zeek::analyzer::Tag(); diff --git a/src/RuleCondition.cc b/src/RuleCondition.cc index 094e6cc12b..a9847e4503 100644 --- a/src/RuleCondition.cc +++ b/src/RuleCondition.cc @@ -122,7 +122,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state, return payload_size >= val; default: - reporter->InternalError("unknown comparison type"); + zeek::reporter->InternalError("unknown comparison type"); } // Should not be reached @@ -162,7 +162,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state, { if ( ! id->HasVal() ) { - reporter->Error("undefined value"); + zeek::reporter->Error("undefined value"); return false; } diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index e970caefa6..3d7ae4f45a 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -265,7 +265,7 @@ bool RuleMatcher::ReadFiles(const std::vector& files) if ( ! rules_in ) { - reporter->Error("Can't open signature file %s", f.data()); + zeek::reporter->Error("Can't open signature file %s", f.data()); return false; } @@ -482,7 +482,7 @@ static inline uint32_t getval(const u_char* data, int size) return ntohl(*(uint32_t*) data); default: - reporter->InternalError("illegal HdrTest size"); + zeek::reporter->InternalError("illegal HdrTest size"); } // Should not be reached. @@ -576,7 +576,7 @@ static inline bool compare(const maskedvalue_list& mvals, uint32_t v, break; default: - reporter->InternalError("unknown RuleHdrTest comparison type"); + zeek::reporter->InternalError("unknown RuleHdrTest comparison type"); break; } return false; @@ -611,7 +611,7 @@ static inline bool compare(const vector& prefixes, const zeek::I break; default: - reporter->InternalError("unknown RuleHdrTest comparison type"); + zeek::reporter->InternalError("unknown RuleHdrTest comparison type"); break; } return false; @@ -666,7 +666,7 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, if ( ! state ) { - reporter->Warning("RuleFileMagicState not initialized yet."); + zeek::reporter->Warning("RuleFileMagicState not initialized yet."); return rval; } @@ -831,7 +831,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(zeek::analyzer::Analyzer* analyzer, break; default: - reporter->InternalError("unknown RuleHdrTest protocol type"); + zeek::reporter->InternalError("unknown RuleHdrTest protocol type"); break; } @@ -856,7 +856,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, { if ( ! state ) { - reporter->Warning("RuleEndpointState not initialized yet."); + zeek::reporter->Warning("RuleEndpointState not initialized yet."); return; } diff --git a/src/Scope.cc b/src/Scope.cc index df61ae89e1..214cadddbe 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -30,7 +30,7 @@ Scope::Scope(zeek::detail::IDPtr id, if ( id_type->Tag() == zeek::TYPE_ERROR ) return; else if ( id_type->Tag() != zeek::TYPE_FUNC ) - reporter->InternalError("bad scope id"); + zeek::reporter->InternalError("bad scope id"); zeek::FuncType* ft = id->GetType()->AsFuncType(); return_type = ft->Yield(); @@ -138,8 +138,8 @@ const zeek::detail::IDPtr& lookup_ID(const char* name, const char* curr_module, if ( id ) { if ( need_export && ! id->IsExport() && ! in_debug ) - reporter->Error("identifier is not exported: %s", - fullname.c_str()); + zeek::reporter->Error("identifier is not exported: %s", + fullname.c_str()); return id; } @@ -159,7 +159,7 @@ zeek::detail::IDPtr install_ID(const char* name, const char* module_name, bool is_global, bool is_export) { if ( scopes.empty() && ! is_global ) - reporter->InternalError("local identifier in global scope"); + zeek::reporter->InternalError("local identifier in global scope"); zeek::detail::IDScope scope; if ( is_export || ! module_name || @@ -201,7 +201,7 @@ void push_scope(zeek::detail::IDPtr id, ScopePtr pop_scope() { if ( scopes.empty() ) - reporter->InternalError("scope underflow"); + zeek::reporter->InternalError("scope underflow"); scopes.pop_back(); Scope* old_top = top_scope; diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index e6611a0ef4..e5a7f26f6b 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -65,7 +65,7 @@ bool SerializationFormat::ReadData(void* b, size_t count) { if ( input_pos + count > input_len ) { - reporter->Error("data underflow during read in binary format"); + zeek::reporter->Error("data underflow during read in binary format"); abort(); return false; } @@ -207,7 +207,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag) for ( int i = 0; i < l; i++ ) if ( ! s[i] ) { - reporter->Error("binary Format: string contains null; replaced by '_'"); + zeek::reporter->Error("binary Format: string contains null; replaced by '_'"); s[i] = '_'; } } diff --git a/src/Sessions.cc b/src/Sessions.cc index 7cd83f2a29..70092302f7 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -839,7 +839,7 @@ int NetSessions::ParseIPPacket(int caplen, const u_char* const pkt, int proto, else { - reporter->InternalWarning("Bad IP protocol version in ParseIPPacket"); + zeek::reporter->InternalWarning("Bad IP protocol version in ParseIPPacket"); return -1; } @@ -1024,21 +1024,21 @@ void NetSessions::Remove(Connection* c) switch ( c->ConnTransport() ) { case TRANSPORT_TCP: if ( tcp_conns.erase(key) == 0 ) - reporter->InternalWarning("connection missing"); + zeek::reporter->InternalWarning("connection missing"); break; case TRANSPORT_UDP: if ( udp_conns.erase(key) == 0 ) - reporter->InternalWarning("connection missing"); + zeek::reporter->InternalWarning("connection missing"); break; case TRANSPORT_ICMP: if ( icmp_conns.erase(key) == 0 ) - reporter->InternalWarning("connection missing"); + zeek::reporter->InternalWarning("connection missing"); break; case TRANSPORT_UNKNOWN: - reporter->InternalWarning("unknown transport when removing connection"); + zeek::reporter->InternalWarning("unknown transport when removing connection"); break; } @@ -1052,7 +1052,7 @@ void NetSessions::Remove(FragReassembler* f) return; if ( fragments.erase(f->Key()) == 0 ) - reporter->InternalWarning("fragment reassembler not in dict"); + zeek::reporter->InternalWarning("fragment reassembler not in dict"); Unref(f); } @@ -1086,7 +1086,7 @@ void NetSessions::Insert(Connection* c) break; default: - reporter->InternalWarning("unknown connection type"); + zeek::reporter->InternalWarning("unknown connection type"); Unref(c); return; } @@ -1185,7 +1185,7 @@ Connection* NetSessions::NewConn(const zeek::detail::ConnIDKey& k, double t, con tproto = TRANSPORT_ICMP; break; default: - reporter->InternalWarning("unknown transport protocol"); + zeek::reporter->InternalWarning("unknown transport protocol"); return nullptr; }; @@ -1310,7 +1310,7 @@ void NetSessions::DumpPacket(const Packet *pkt, int len) if ( len != 0 ) { if ( (uint32_t)len > pkt->cap_len ) - reporter->Warning("bad modified caplen"); + zeek::reporter->Warning("bad modified caplen"); else const_cast(pkt)->cap_len = len; } @@ -1325,19 +1325,19 @@ void NetSessions::Weird(const char* name, const Packet* pkt, dump_this_packet = true; if ( encap && encap->LastType() != BifEnum::Tunnel::NONE ) - reporter->Weird(fmt("%s_in_tunnel", name), addl); + zeek::reporter->Weird(fmt("%s_in_tunnel", name), addl); else - reporter->Weird(name, addl); + zeek::reporter->Weird(name, addl); } void NetSessions::Weird(const char* name, const zeek::IP_Hdr* ip, const EncapsulationStack* encap, const char* addl) { if ( encap && encap->LastType() != BifEnum::Tunnel::NONE ) - reporter->Weird(ip->SrcAddr(), ip->DstAddr(), - fmt("%s_in_tunnel", name), addl); + zeek::reporter->Weird(ip->SrcAddr(), ip->DstAddr(), + fmt("%s_in_tunnel", name), addl); else - reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl); + zeek::reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl); } unsigned int NetSessions::ConnectionMemoryUsage() diff --git a/src/SmithWaterman.cc b/src/SmithWaterman.cc index e67a65b9e7..86e17fc8d6 100644 --- a/src/SmithWaterman.cc +++ b/src/SmithWaterman.cc @@ -174,7 +174,7 @@ bool SubstringCmp::operator()(const Substring* bst1, if ( _index >= bst1->GetNumAlignments() || _index >= bst2->GetNumAlignments() ) { - reporter->Warning("SubstringCmp::operator(): invalid index for input strings.\n"); + zeek::reporter->Warning("SubstringCmp::operator(): invalid index for input strings.\n"); return false; } diff --git a/src/Stmt.cc b/src/Stmt.cc index 073e2c71b9..3329db256c 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -120,7 +120,7 @@ void Stmt::DecrBPCount() if ( breakpoint_count ) --breakpoint_count; else - reporter->InternalError("breakpoint count decremented below 0"); + zeek::reporter->InternalError("breakpoint count decremented below 0"); } void Stmt::AddTag(ODesc* d) const @@ -279,8 +279,8 @@ ValPtr PrintStmt::DoExec(std::vector vals, } break; default: - reporter->InternalError("unknown Log::PrintLogType value: %d", - print_log_type); + zeek::reporter->InternalError("unknown Log::PrintLogType value: %d", + print_log_type); break; } @@ -745,9 +745,10 @@ bool SwitchStmt::AddCaseLabelValueMapping(const Val* v, int idx) if ( ! hk ) { - reporter->PushLocation(e->GetLocationInfo()); - reporter->InternalError("switch expression type mismatch (%s/%s)", - type_name(v->GetType()->Tag()), type_name(e->GetType()->Tag())); + zeek::reporter->PushLocation(e->GetLocationInfo()); + zeek::reporter->InternalError("switch expression type mismatch (%s/%s)", + type_name(v->GetType()->Tag()), + type_name(e->GetType()->Tag())); } int* label_idx = case_label_value_map.Lookup(hk.get()); @@ -785,9 +786,10 @@ std::pair SwitchStmt::FindCaseLabelMatch(const Val* v) const if ( ! hk ) { - reporter->PushLocation(e->GetLocationInfo()); - reporter->Error("switch expression type mismatch (%s/%s)", - type_name(v->GetType()->Tag()), type_name(e->GetType()->Tag())); + zeek::reporter->PushLocation(e->GetLocationInfo()); + zeek::reporter->Error("switch expression type mismatch (%s/%s)", + type_name(v->GetType()->Tag()), + type_name(e->GetType()->Tag())); return std::make_pair(-1, nullptr); } diff --git a/src/Timer.cc b/src/Timer.cc index 97751a9b00..142b63ee9e 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -128,7 +128,7 @@ void PQ_TimerMgr::Add(Timer* timer) // multiple already-added timers are added, they'll still // execute in sorted order. if ( ! q->Add(timer) ) - reporter->InternalError("out of memory"); + zeek::reporter->InternalError("out of memory"); ++current_timers[timer->Type()]; } @@ -174,7 +174,7 @@ int PQ_TimerMgr::DoAdvance(double new_t, int max_expire) void PQ_TimerMgr::Remove(Timer* timer) { if ( ! q->Remove(timer) ) - reporter->InternalError("asked to remove a missing timer"); + zeek::reporter->InternalError("asked to remove a missing timer"); --current_timers[timer->Type()]; delete timer; diff --git a/src/Trigger.cc b/src/Trigger.cc index 600a4aa84a..c8a80b0293 100644 --- a/src/Trigger.cc +++ b/src/Trigger.cc @@ -142,7 +142,7 @@ Trigger::Trigger(zeek::detail::Expr* arg_cond, zeek::detail::Stmt* arg_body, Trigger* parent = frame->GetTrigger(); if ( ! parent ) { - reporter->Error("return trigger in context which does not allow delaying result"); + zeek::reporter->Error("return trigger in context which does not allow delaying result"); Unref(this); return; } diff --git a/src/Type.cc b/src/Type.cc index 940ac32e67..cd85782d32 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -217,7 +217,7 @@ TypePtr Type::ShallowClone() return zeek::make_intrusive(tag, base_type); default: - reporter->InternalError("cloning illegal base Type"); + zeek::reporter->InternalError("cloning illegal base Type"); } return nullptr; } @@ -291,7 +291,7 @@ bool TypeList::AllMatch(const Type* t, bool is_init) const void TypeList::Append(TypePtr t) { if ( pure_type && ! same_type(t, pure_type) ) - reporter->InternalError("pure type-list violation"); + zeek::reporter->InternalError("pure type-list violation"); types_list.push_back(t.get()); types.emplace_back(std::move(t)); @@ -591,7 +591,7 @@ string FuncType::FlavorString() const return "hook"; default: - reporter->InternalError("Invalid function flavor"); + zeek::reporter->InternalError("Invalid function flavor"); return "invalid_func_flavor"; } } @@ -1062,8 +1062,8 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const if ( ! doc ) { - reporter->InternalWarning("Failed to lookup record doc: %s", - GetName().c_str()); + zeek::reporter->InternalWarning("Failed to lookup record doc: %s", + GetName().c_str()); continue; } @@ -1210,7 +1210,7 @@ TypePtr EnumType::ShallowClone() EnumType::~EnumType() = default; -// Note, we use reporter->Error() here (not Error()) to include the current script +// Note, we use zeek::reporter->Error() here (not Error()) to include the current script // location in the error message, rather than the one where the type was // originally defined. void EnumType::AddName(const string& module_name, const char* name, bool is_export, zeek::detail::Expr* deprecation) @@ -1218,7 +1218,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo /* implicit, auto-increment */ if ( counter < 0) { - reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); + zeek::reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); SetError(); return; } @@ -1231,7 +1231,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va /* explicit value specified */ if ( counter > 0 ) { - reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); + zeek::reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); SetError(); return; } @@ -1244,7 +1244,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, { if ( Lookup(val) ) { - reporter->Error("enumerator value in enumerated type definition already exists"); + zeek::reporter->Error("enumerator value in enumerated type definition already exists"); SetError(); return; } @@ -1272,7 +1272,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, || (id->HasVal() && val != id->GetVal()->AsEnum()) || (names.find(fullname) != names.end() && names[fullname] != val) ) { - reporter->Error("identifier or enumerator value in enumerated type definition already exists"); + zeek::reporter->Error("identifier or enumerator value in enumerated type definition already exists"); SetError(); return; } @@ -1378,8 +1378,8 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const if ( ! doc ) { - reporter->InternalWarning("Enum %s documentation lookup failure", - it->second.c_str()); + zeek::reporter->InternalWarning("Enum %s documentation lookup failure", + it->second.c_str()); continue; } @@ -1664,7 +1664,7 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, } case TYPE_UNION: - reporter->Error("union type in same_type()"); + zeek::reporter->Error("union type in same_type()"); } return false; } @@ -1724,7 +1724,7 @@ const Type* flatten_type(const Type* t) const auto& types = tl->GetTypes(); if ( types.size() == 0 ) - reporter->InternalError("empty type list in flatten_type"); + zeek::reporter->InternalError("empty type list in flatten_type"); const auto& ft = types[0]; @@ -1774,7 +1774,7 @@ bool is_assignable(TypeTag t) return false; case TYPE_UNION: - reporter->Error("union type in is_assignable()"); + zeek::reporter->Error("union type in is_assignable()"); } return false; @@ -1803,7 +1803,7 @@ TypeTag max_type(TypeTag t1, TypeTag t2) } else { - reporter->InternalError("non-arithmetic tags in max_type()"); + zeek::reporter->InternalError("non-arithmetic tags in max_type()"); return TYPE_ERROR; } } @@ -2039,11 +2039,11 @@ TypePtr merge_types(const TypePtr& arg_t1, return zeek::make_intrusive(merge_types(t1->Yield(), t2->Yield())); case TYPE_UNION: - reporter->InternalError("union type in merge_types()"); + zeek::reporter->InternalError("union type in merge_types()"); return nullptr; default: - reporter->InternalError("bad type in merge_types()"); + zeek::reporter->InternalError("bad type in merge_types()"); return nullptr; } } @@ -2055,7 +2055,7 @@ TypePtr merge_type_list(zeek::detail::ListExpr* elements) if ( tl.size() < 1 ) { - reporter->Error("no type can be inferred for empty list"); + zeek::reporter->Error("no type can be inferred for empty list"); return nullptr; } @@ -2068,7 +2068,7 @@ TypePtr merge_type_list(zeek::detail::ListExpr* elements) t = merge_types(t, tl[i]); if ( ! t ) - reporter->Error("inconsistent types in list"); + zeek::reporter->Error("inconsistent types in list"); return t; } diff --git a/src/UID.cc b/src/UID.cc index 73d61873be..ac644c3208 100644 --- a/src/UID.cc +++ b/src/UID.cc @@ -32,7 +32,7 @@ void UID::Set(bro_uint_t bits, const uint64_t* v, size_t n) std::string UID::Base62(std::string prefix) const { if ( ! initialized ) - reporter->InternalError("use of uninitialized UID"); + zeek::reporter->InternalError("use of uninitialized UID"); char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation for ( size_t i = 0; i < BRO_UID_LEN; ++i ) diff --git a/src/Var.cc b/src/Var.cc index 16e474ea02..d5ea5439fc 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -27,7 +27,7 @@ static zeek::ValPtr init_val(zeek::detail::Expr* init, { return init->InitVal(t, std::move(aggr)); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { return nullptr; } @@ -541,11 +541,11 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name, if ( f->attrs && f->attrs->Find(zeek::detail::ATTR_DEFAULT) ) { - reporter->PushLocation(args->GetLocationInfo()); - reporter->Warning( + zeek::reporter->PushLocation(args->GetLocationInfo()); + zeek::reporter->Warning( "&default on parameter '%s' has no effect (not a %s declaration)", args->FieldName(i), t->FlavorString().data()); - reporter->PopLocation(); + zeek::reporter->PopLocation(); } } } @@ -597,7 +597,7 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name, break; default: - reporter->InternalError("invalid function flavor"); + zeek::reporter->InternalError("invalid function flavor"); break; } } @@ -836,7 +836,7 @@ zeek::ListVal* internal_list_val(const char* name) } else - reporter->InternalError("internal variable %s is not a list", name); + zeek::reporter->InternalError("internal variable %s is not a list", name); } return nullptr; diff --git a/src/analyzer/protocol/arp/ARP.cc b/src/analyzer/protocol/arp/ARP.cc index 73b7fe96a6..cc8abd55f1 100644 --- a/src/analyzer/protocol/arp/ARP.cc +++ b/src/analyzer/protocol/arp/ARP.cc @@ -202,7 +202,7 @@ void ARP_Analyzer::BadARP(const struct arp_pkthdr* hdr, const char* msg) void ARP_Analyzer::Corrupted(const char* msg) { - reporter->Weird(msg); + zeek::reporter->Weird(msg); } void ARP_Analyzer::RREvent(EventHandlerPtr e, diff --git a/src/analyzer/protocol/asn1/asn1.pac b/src/analyzer/protocol/asn1/asn1.pac index 484ed27db7..8fdee0174d 100644 --- a/src/analyzer/protocol/asn1/asn1.pac +++ b/src/analyzer/protocol/asn1/asn1.pac @@ -120,7 +120,7 @@ zeek::ValPtr asn1_integer_to_val(const ASN1Encoding* i, zeek::TypeTag t) case zeek::TYPE_COUNTER: return zeek::val_mgr->Count(v); default: - reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t)); + zeek::reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t)); return zeek::val_mgr->Count(v); } } diff --git a/src/analyzer/protocol/ayiya/ayiya-analyzer.pac b/src/analyzer/protocol/ayiya/ayiya-analyzer.pac index 4984d3ec58..054864e393 100644 --- a/src/analyzer/protocol/ayiya/ayiya-analyzer.pac +++ b/src/analyzer/protocol/ayiya/ayiya-analyzer.pac @@ -20,7 +20,7 @@ flow AYIYA_Flow if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth ) { - reporter->Weird(c, "tunnel_depth"); + zeek::reporter->Weird(c, "tunnel_depth"); return false; } @@ -33,7 +33,7 @@ flow AYIYA_Flow if ( ${pdu.next_header} != IPPROTO_IPV6 && ${pdu.next_header} != IPPROTO_IPV4 ) { - reporter->Weird(c, "ayiya_tunnel_non_ip"); + zeek::reporter->Weird(c, "ayiya_tunnel_non_ip"); return false; } diff --git a/src/analyzer/protocol/conn-size/ConnSize.cc b/src/analyzer/protocol/conn-size/ConnSize.cc index e49b599666..e236df6a2e 100644 --- a/src/analyzer/protocol/conn-size/ConnSize.cc +++ b/src/analyzer/protocol/conn-size/ConnSize.cc @@ -178,10 +178,10 @@ void ConnSize_Analyzer::UpdateConnVal(zeek::RecordVal *conn_val) int bytesidx = zeek::id::endpoint->FieldOffset("num_bytes_ip"); if ( pktidx < 0 ) - reporter->InternalError("'endpoint' record missing 'num_pkts' field"); + zeek::reporter->InternalError("'endpoint' record missing 'num_pkts' field"); if ( bytesidx < 0 ) - reporter->InternalError("'endpoint' record missing 'num_bytes_ip' field"); + zeek::reporter->InternalError("'endpoint' record missing 'num_bytes_ip' field"); orig_endp->Assign(pktidx, zeek::val_mgr->Count(orig_pkts)); orig_endp->Assign(bytesidx, zeek::val_mgr->Count(orig_bytes)); diff --git a/src/analyzer/protocol/conn-size/functions.bif b/src/analyzer/protocol/conn-size/functions.bif index c5f1e07433..20033e44ef 100644 --- a/src/analyzer/protocol/conn-size/functions.bif +++ b/src/analyzer/protocol/conn-size/functions.bif @@ -11,7 +11,7 @@ static zeek::analyzer::Analyzer* GetConnsizeAnalyzer(zeek::Val* cid) zeek::analyzer::Analyzer* a = c->FindAnalyzer("CONNSIZE"); if ( ! a ) - reporter->Error("connection does not have ConnSize analyzer"); + zeek::reporter->Error("connection does not have ConnSize analyzer"); return a; } diff --git a/src/analyzer/protocol/dce-rpc/dce_rpc-protocol.pac b/src/analyzer/protocol/dce-rpc/dce_rpc-protocol.pac index 5263b20c93..1f2c3958a0 100644 --- a/src/analyzer/protocol/dce-rpc/dce_rpc-protocol.pac +++ b/src/analyzer/protocol/dce-rpc/dce_rpc-protocol.pac @@ -190,7 +190,7 @@ flow DCE_RPC_Flow(is_orig: bool) { if ( it != fb.end() ) { // We already had a first frag earlier. - reporter->Weird(connection()->bro_analyzer()->Conn(), + zeek::reporter->Weird(connection()->bro_analyzer()->Conn(), "multiple_first_fragments_in_dce_rpc_reassembly"); connection()->bro_analyzer()->SetSkip(true); return false; @@ -212,14 +212,14 @@ flow DCE_RPC_Flow(is_orig: bool) { if ( fb.size() > zeek::BifConst::DCE_RPC::max_cmd_reassembly ) { - reporter->Weird(connection()->bro_analyzer()->Conn(), + zeek::reporter->Weird(connection()->bro_analyzer()->Conn(), "too_many_dce_rpc_msgs_in_reassembly"); connection()->bro_analyzer()->SetSkip(true); } if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data ) { - reporter->Weird(connection()->bro_analyzer()->Conn(), + zeek::reporter->Weird(connection()->bro_analyzer()->Conn(), "too_much_dce_rpc_fragment_data"); connection()->bro_analyzer()->SetSkip(true); } @@ -235,7 +235,7 @@ flow DCE_RPC_Flow(is_orig: bool) { if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data ) { - reporter->Weird(connection()->bro_analyzer()->Conn(), + zeek::reporter->Weird(connection()->bro_analyzer()->Conn(), "too_much_dce_rpc_fragment_data"); connection()->bro_analyzer()->SetSkip(true); } diff --git a/src/analyzer/protocol/dnp3/DNP3.cc b/src/analyzer/protocol/dnp3/DNP3.cc index df7dbf72ad..5dce7a290c 100644 --- a/src/analyzer/protocol/dnp3/DNP3.cc +++ b/src/analyzer/protocol/dnp3/DNP3.cc @@ -235,14 +235,14 @@ int DNP3_Base::AddToBuffer(Endpoint* endp, int target_len, const u_char** data, if ( *len < 0 ) { - reporter->AnalyzerError(analyzer, "dnp3 negative input length: %d", *len); + zeek::reporter->AnalyzerError(analyzer, "dnp3 negative input length: %d", *len); return -1; } if ( target_len < endp->buffer_len ) { - reporter->AnalyzerError(analyzer, "dnp3 invalid target length: %d - %d", - target_len, endp->buffer_len); + zeek::reporter->AnalyzerError(analyzer, "dnp3 invalid target length: %d - %d", + target_len, endp->buffer_len); return -1; } @@ -250,8 +250,8 @@ int DNP3_Base::AddToBuffer(Endpoint* endp, int target_len, const u_char** data, if ( endp->buffer_len + to_copy > MAX_BUFFER_SIZE ) { - reporter->AnalyzerError(analyzer, "dnp3 buffer length exceeded: %d + %d", - endp->buffer_len, to_copy); + zeek::reporter->AnalyzerError(analyzer, "dnp3 buffer length exceeded: %d + %d", + endp->buffer_len, to_copy); return -1; } @@ -296,9 +296,9 @@ bool DNP3_Base::ParseAppLayer(Endpoint* endp) if ( data + n >= endp->buffer + endp->buffer_len ) { - reporter->AnalyzerError(analyzer, - "dnp3 app layer parsing overflow %d - %d", - endp->buffer_len, n); + zeek::reporter->AnalyzerError(analyzer, + "dnp3 app layer parsing overflow %d - %d", + endp->buffer_len, n); return false; } diff --git a/src/analyzer/protocol/gtpv1/gtpv1-analyzer.pac b/src/analyzer/protocol/gtpv1/gtpv1-analyzer.pac index 384cdd3a1b..f0a6f32935 100644 --- a/src/analyzer/protocol/gtpv1/gtpv1-analyzer.pac +++ b/src/analyzer/protocol/gtpv1/gtpv1-analyzer.pac @@ -654,7 +654,7 @@ flow GTPv1_Flow(is_orig: bool) if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth ) { - reporter->Weird(c, "tunnel_depth"); + zeek::reporter->Weird(c, "tunnel_depth"); return false; } diff --git a/src/analyzer/protocol/http/HTTP.cc b/src/analyzer/protocol/http/HTTP.cc index 49549984ff..8cc2fcf588 100644 --- a/src/analyzer/protocol/http/HTTP.cc +++ b/src/analyzer/protocol/http/HTTP.cc @@ -798,8 +798,8 @@ void HTTP_Message::SubmitEvent(int event_type, const char* detail) break; default: - reporter->AnalyzerError(MyHTTP_Analyzer(), - "unrecognized HTTP message event"); + zeek::reporter->AnalyzerError(MyHTTP_Analyzer(), + "unrecognized HTTP message event"); return; } @@ -1238,7 +1238,7 @@ int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line) if ( ! ParseRequest(rest, end_of_line) ) { - reporter->AnalyzerError(this, "HTTP ParseRequest failed"); + zeek::reporter->AnalyzerError(this, "HTTP ParseRequest failed"); return -1; } @@ -1251,11 +1251,11 @@ int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line) return 1; bad_http_request_with_version: - reporter->Weird(Conn(), "bad_HTTP_request_with_version"); + zeek::reporter->Weird(Conn(), "bad_HTTP_request_with_version"); return 0; error: - reporter->Weird(Conn(), "bad_HTTP_request"); + zeek::reporter->Weird(Conn(), "bad_HTTP_request"); return 0; } diff --git a/src/analyzer/protocol/icmp/ICMP.cc b/src/analyzer/protocol/icmp/ICMP.cc index 1e1003f0de..b5a898de35 100644 --- a/src/analyzer/protocol/icmp/ICMP.cc +++ b/src/analyzer/protocol/icmp/ICMP.cc @@ -64,8 +64,8 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data, break; default: - reporter->AnalyzerError(this, - "unexpected IP proto in ICMP analyzer: %d", ip->NextProto()); + zeek::reporter->AnalyzerError( + this, "unexpected IP proto in ICMP analyzer: %d", ip->NextProto()); return; } @@ -104,8 +104,8 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data, NextICMP6(current_timestamp, icmpp, len, caplen, data, ip); else { - reporter->AnalyzerError(this, - "expected ICMP as IP packet's protocol, got %d", ip->NextProto()); + zeek::reporter->AnalyzerError( + this, "expected ICMP as IP packet's protocol, got %d", ip->NextProto()); return; } diff --git a/src/analyzer/protocol/imap/imap-analyzer.pac b/src/analyzer/protocol/imap/imap-analyzer.pac index 196af72e98..a8d4af8dc4 100644 --- a/src/analyzer/protocol/imap/imap-analyzer.pac +++ b/src/analyzer/protocol/imap/imap-analyzer.pac @@ -33,7 +33,7 @@ refine connection IMAP_Conn += { if ( is_orig && commands == "starttls" ) { if ( !client_starttls_id.empty() ) - reporter->Weird(bro_analyzer()->Conn(), "IMAP: client sent duplicate StartTLS"); + zeek::reporter->Weird(bro_analyzer()->Conn(), "IMAP: client sent duplicate StartTLS"); client_starttls_id = tags; } @@ -48,7 +48,7 @@ refine connection IMAP_Conn += { zeek::BifEvent::enqueue_imap_starttls(bro_analyzer(), bro_analyzer()->Conn()); } else - reporter->Weird(bro_analyzer()->Conn(), "IMAP: server refused StartTLS"); + zeek::reporter->Weird(bro_analyzer()->Conn(), "IMAP: server refused StartTLS"); } return true; diff --git a/src/analyzer/protocol/krb/KRB.cc b/src/analyzer/protocol/krb/KRB.cc index 0357ca7157..3e4285fd7f 100644 --- a/src/analyzer/protocol/krb/KRB.cc +++ b/src/analyzer/protocol/krb/KRB.cc @@ -29,7 +29,7 @@ KRB_Analyzer::KRB_Analyzer(Connection* conn) static void warn_krb(const char* msg, krb5_context ctx, krb5_error_code code) { auto err = krb5_get_error_message(ctx, code); - reporter->Warning("%s (%s)", msg, err); + zeek::reporter->Warning("%s (%s)", msg, err); krb5_free_error_message(ctx, err); } @@ -41,7 +41,7 @@ void KRB_Analyzer::Initialize_Krb() const char* keytab_filename = zeek::BifConst::KRB::keytab->CheckString(); if ( access(keytab_filename, R_OK) != 0 ) { - reporter->Warning("KRB: Can't access keytab (%s)", keytab_filename); + zeek::reporter->Warning("KRB: Can't access keytab (%s)", keytab_filename); return; } @@ -99,14 +99,14 @@ zeek::StringValPtr KRB_Analyzer::GetAuthenticationInfo(const zeek::String* princ int pos = principal->FindSubstring(&delim); if ( pos == -1 ) { - reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); + zeek::reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); return nullptr; } std::unique_ptr service = unique_ptr(principal->GetSubstring(0, pos)); std::unique_ptr hostname = unique_ptr(principal->GetSubstring(pos + 1, -1)); if ( !service || !hostname ) { - reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); + zeek::reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); return nullptr; } krb5_principal sprinc; diff --git a/src/analyzer/protocol/login/Login.cc b/src/analyzer/protocol/login/Login.cc index 4c64f8ba4c..3df4780e44 100644 --- a/src/analyzer/protocol/login/Login.cc +++ b/src/analyzer/protocol/login/Login.cc @@ -129,8 +129,8 @@ void Login_Analyzer::NewLine(bool orig, char* line) if ( state != LOGIN_STATE_CONFUSED ) { - reporter->AnalyzerError(this, - "bad state in Login_Analyzer::NewLine"); + zeek::reporter->AnalyzerError( + this, "bad state in Login_Analyzer::NewLine"); return; } @@ -572,8 +572,8 @@ char* Login_Analyzer::PeekUserText() { if ( num_user_text <= 0 ) { - reporter->AnalyzerError(this, - "underflow in Login_Analyzer::PeekUserText()"); + zeek::reporter->AnalyzerError( + this, "underflow in Login_Analyzer::PeekUserText()"); return nullptr; } diff --git a/src/analyzer/protocol/login/NVT.cc b/src/analyzer/protocol/login/NVT.cc index 52922e58a7..cf2b6c0c13 100644 --- a/src/analyzer/protocol/login/NVT.cc +++ b/src/analyzer/protocol/login/NVT.cc @@ -44,8 +44,8 @@ void TelnetOption::RecvOption(unsigned int type) if ( ! peer ) { - reporter->AnalyzerError(endp, - "option peer missing in TelnetOption::RecvOption"); + zeek::reporter->AnalyzerError( + endp, "option peer missing in TelnetOption::RecvOption"); return; } @@ -92,8 +92,8 @@ void TelnetOption::RecvOption(unsigned int type) break; default: - reporter->AnalyzerError(endp, - "bad option type in TelnetOption::RecvOption"); + zeek::reporter->AnalyzerError( + endp, "bad option type in TelnetOption::RecvOption"); return; } } @@ -175,8 +175,8 @@ void TelnetEncryptOption::RecvSubOption(u_char* data, int len) if ( ! peer ) { - reporter->AnalyzerError(endp, - "option peer missing in TelnetEncryptOption::RecvSubOption"); + zeek::reporter->AnalyzerError( + endp, "option peer missing in TelnetEncryptOption::RecvSubOption"); return; } @@ -215,8 +215,8 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len) if ( ! peer ) { - reporter->AnalyzerError(endp, - "option peer missing in TelnetAuthenticateOption::RecvSubOption"); + zeek::reporter->AnalyzerError( + endp, "option peer missing in TelnetAuthenticateOption::RecvSubOption"); return; } diff --git a/src/analyzer/protocol/login/RSH.cc b/src/analyzer/protocol/login/RSH.cc index a34889bb5c..ffd4620f42 100644 --- a/src/analyzer/protocol/login/RSH.cc +++ b/src/analyzer/protocol/login/RSH.cc @@ -131,8 +131,8 @@ void Contents_Rsh_Analyzer::DoDeliver(int len, const u_char* data) break; default: - reporter->AnalyzerError(this, - "bad state in Contents_Rsh_Analyzer::DoDeliver"); + zeek::reporter->AnalyzerError( + this, "bad state in Contents_Rsh_Analyzer::DoDeliver"); break; } } @@ -205,7 +205,7 @@ void Rsh_Analyzer::ClientUserName(const char* s) { if ( client_name ) { - reporter->AnalyzerError(this, "multiple rsh client names"); + zeek::reporter->AnalyzerError(this, "multiple rsh client names"); return; } @@ -216,8 +216,8 @@ void Rsh_Analyzer::ServerUserName(const char* s) { if ( username ) { - reporter->AnalyzerError(this, - "multiple rsh initial client names"); + zeek::reporter->AnalyzerError(this, + "multiple rsh initial client names"); return; } diff --git a/src/analyzer/protocol/login/Rlogin.cc b/src/analyzer/protocol/login/Rlogin.cc index dfb868c621..a745640e37 100644 --- a/src/analyzer/protocol/login/Rlogin.cc +++ b/src/analyzer/protocol/login/Rlogin.cc @@ -194,8 +194,8 @@ void Contents_Rlogin_Analyzer::DoDeliver(int len, const u_char* data) break; default: - reporter->AnalyzerError(this, - "bad state in Contents_Rlogin_Analyzer::DoDeliver"); + zeek::reporter->AnalyzerError( + this, "bad state in Contents_Rlogin_Analyzer::DoDeliver"); break; } } @@ -227,7 +227,7 @@ void Rlogin_Analyzer::ClientUserName(const char* s) { if ( client_name ) { - reporter->AnalyzerError(this, "multiple rlogin client names"); + zeek::reporter->AnalyzerError(this, "multiple rlogin client names"); return; } diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index 1eda8ad4b7..03f82bd7ed 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -586,8 +586,8 @@ void MIME_Entity::init() MIME_Entity::~MIME_Entity() { if ( ! end_of_data ) - reporter->AnalyzerError(message ? message->GetAnalyzer() : nullptr, - "missing MIME_Entity::EndOfData() before ~MIME_Entity"); + zeek::reporter->AnalyzerError(message ? message->GetAnalyzer() : nullptr, + "missing MIME_Entity::EndOfData() before ~MIME_Entity"); delete current_header_line; delete content_encoding_str; @@ -973,7 +973,7 @@ int MIME_Entity::CheckBoundaryDelimiter(int len, const char* data) { if ( ! multipart_boundary ) { - reporter->Warning("boundary delimiter was not specified for a multipart message\n"); + zeek::reporter->Warning("boundary delimiter was not specified for a multipart message\n"); DEBUG_MSG("headers of the MIME entity for debug:\n"); DebugPrintHeaders(); return NOT_MULTIPART_BOUNDARY; @@ -1150,7 +1150,7 @@ void MIME_Entity::StartDecodeBase64() { if ( base64_decoder ) { - reporter->InternalWarning("previous MIME Base64 decoder not released"); + zeek::reporter->InternalWarning("previous MIME Base64 decoder not released"); delete base64_decoder; } @@ -1158,7 +1158,7 @@ void MIME_Entity::StartDecodeBase64() if ( ! analyzer ) { - reporter->InternalWarning("no analyzer associated with MIME message"); + zeek::reporter->InternalWarning("no analyzer associated with MIME message"); return; } @@ -1189,7 +1189,7 @@ bool MIME_Entity::GetDataBuffer() int ret = message->RequestBuffer(&data_buf_length, &data_buf_data); if ( ! ret || data_buf_length == 0 || data_buf_data == nullptr ) { - // reporter->InternalError("cannot get data buffer from MIME_Message", ""); + // zeek::reporter->InternalError("cannot get data buffer from MIME_Message", ""); return false; } @@ -1459,8 +1459,8 @@ void MIME_Mail::SubmitData(int len, const char* buf) { if ( buf != (char*) data_buffer->Bytes() + buffer_start ) { - reporter->AnalyzerError(GetAnalyzer(), - "MIME buffer misalignment"); + zeek::reporter->AnalyzerError(GetAnalyzer(), + "MIME buffer misalignment"); return; } @@ -1554,8 +1554,8 @@ void MIME_Mail::SubmitEvent(int event_type, const char* detail) break; default: - reporter->AnalyzerError(GetAnalyzer(), - "unrecognized MIME_Mail event"); + zeek::reporter->AnalyzerError(GetAnalyzer(), + "unrecognized MIME_Mail event"); return; } diff --git a/src/analyzer/protocol/mime/MIME.h b/src/analyzer/protocol/mime/MIME.h index dd0be98c9c..4e889aa987 100644 --- a/src/analyzer/protocol/mime/MIME.h +++ b/src/analyzer/protocol/mime/MIME.h @@ -205,8 +205,8 @@ public: virtual ~MIME_Message() { if ( ! finished ) - reporter->AnalyzerError(analyzer, - "missing MIME_Message::Done() call"); + zeek::reporter->AnalyzerError(analyzer, + "missing MIME_Message::Done() call"); } virtual void Done() { finished = true; } diff --git a/src/analyzer/protocol/pia/PIA.cc b/src/analyzer/protocol/pia/PIA.cc index da7acaa691..a953e53aaf 100644 --- a/src/analyzer/protocol/pia/PIA.cc +++ b/src/analyzer/protocol/pia/PIA.cc @@ -181,7 +181,7 @@ void PIA_UDP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule void PIA_UDP::DeactivateAnalyzer(zeek::analyzer::Tag tag) { - reporter->InternalError("PIA_UDP::Deact not implemented yet"); + zeek::reporter->InternalError("PIA_UDP::Deact not implemented yet"); } //// TCP PIA @@ -420,7 +420,7 @@ void PIA_TCP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule void PIA_TCP::DeactivateAnalyzer(zeek::analyzer::Tag tag) { - reporter->InternalError("PIA_TCP::Deact not implemented yet"); + zeek::reporter->InternalError("PIA_TCP::Deact not implemented yet"); } void PIA_TCP::ReplayStreamBuffer(zeek::analyzer::Analyzer* analyzer) diff --git a/src/analyzer/protocol/pop3/POP3.cc b/src/analyzer/protocol/pop3/POP3.cc index ba0e42434e..7ef57d30dc 100644 --- a/src/analyzer/protocol/pop3/POP3.cc +++ b/src/analyzer/protocol/pop3/POP3.cc @@ -213,8 +213,8 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) break; default: - reporter->AnalyzerError(this, - "unexpected POP3 authorization state"); + zeek::reporter->AnalyzerError( + this, "unexpected POP3 authorization state"); delete decoded; return; } @@ -572,7 +572,7 @@ void POP3_Analyzer::ProcessClientCmd() break; default: - reporter->AnalyzerError(this, "unknown POP3 command"); + zeek::reporter->AnalyzerError(this, "unknown POP3 command"); return; } } @@ -845,7 +845,7 @@ void POP3_Analyzer::BeginData(bool orig) void POP3_Analyzer::EndData() { if ( ! mail ) - reporter->Warning("unmatched end of data"); + zeek::reporter->Warning("unmatched end of data"); else { mail->Done(); diff --git a/src/analyzer/protocol/rdp/RDP.cc b/src/analyzer/protocol/rdp/RDP.cc index 0d1f77a70d..f8ffd75ed4 100644 --- a/src/analyzer/protocol/rdp/RDP.cc +++ b/src/analyzer/protocol/rdp/RDP.cc @@ -60,9 +60,9 @@ void RDP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) if ( ! AddChildAnalyzer(pia) ) { - reporter->AnalyzerError(this, - "failed to add TCP child analyzer " - "to RDP analyzer: already exists"); + zeek::reporter->AnalyzerError(this, + "failed to add TCP child analyzer " + "to RDP analyzer: already exists"); return; } diff --git a/src/analyzer/protocol/rpc/RPC.cc b/src/analyzer/protocol/rpc/RPC.cc index 8c27a1aec0..fc32c4cf22 100644 --- a/src/analyzer/protocol/rpc/RPC.cc +++ b/src/analyzer/protocol/rpc/RPC.cc @@ -308,7 +308,7 @@ int RPC_Interpreter::DeliverRPC(const u_char* buf, int n, int rpclen, else if ( n < 0 ) { - reporter->AnalyzerError(analyzer, "RPC underflow"); + zeek::reporter->AnalyzerError(analyzer, "RPC underflow"); return 0; } @@ -513,8 +513,8 @@ bool Contents_RPC::CheckResync(int& len, const u_char*& data, bool orig) if ( resync_toskip != 0 ) { // Should never happen. - reporter->AnalyzerError(this, - "RPC resync: skipping over data failed"); + zeek::reporter->AnalyzerError( + this, "RPC resync: skipping over data failed"); return false; } @@ -665,8 +665,8 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig) if ( ! dummy_p ) { - reporter->AnalyzerError(this, - "inconsistent RPC record marker extraction"); + zeek::reporter->AnalyzerError( + this, "inconsistent RPC record marker extraction"); return; } diff --git a/src/analyzer/protocol/socks/socks-analyzer.pac b/src/analyzer/protocol/socks/socks-analyzer.pac index 8f2ee90e74..01b801eec3 100644 --- a/src/analyzer/protocol/socks/socks-analyzer.pac +++ b/src/analyzer/protocol/socks/socks-analyzer.pac @@ -175,13 +175,13 @@ refine connection SOCKS_Conn += { function socks5_unsupported_authentication_method(auth_method: uint8): bool %{ - reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication_method", fmt("%d", auth_method)); + zeek::reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication_method", fmt("%d", auth_method)); return true; %} function socks5_unsupported_authentication_version(auth_method: uint8, version: uint8): bool %{ - reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication", fmt("method %d, version %d", auth_method, version)); + zeek::reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication", fmt("method %d, version %d", auth_method, version)); return true; %} diff --git a/src/analyzer/protocol/ssl/proc-certificate.pac b/src/analyzer/protocol/ssl/proc-certificate.pac index d7b2802d0a..2a99c124b6 100644 --- a/src/analyzer/protocol/ssl/proc-certificate.pac +++ b/src/analyzer/protocol/ssl/proc-certificate.pac @@ -18,7 +18,7 @@ if ( cert.length() <= 0 ) { - reporter->Weird(bro_analyzer()->Conn(), "zero_length_certificate"); + zeek::reporter->Weird(bro_analyzer()->Conn(), "zero_length_certificate"); continue; } @@ -35,5 +35,3 @@ } return true; %} - - diff --git a/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac b/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac index b19d9564b4..2106e3bcc2 100644 --- a/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac +++ b/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac @@ -323,7 +323,7 @@ refine connection Handshake_Conn += { } else if ( response.length() == 0 ) { - reporter->Weird(bro_analyzer()->Conn(), "SSL_zero_length_stapled_OCSP_message"); + zeek::reporter->Weird(bro_analyzer()->Conn(), "SSL_zero_length_stapled_OCSP_message"); } return true; diff --git a/src/analyzer/protocol/tcp/ContentLine.cc b/src/analyzer/protocol/tcp/ContentLine.cc index a58ae3e892..6c532ce2f4 100644 --- a/src/analyzer/protocol/tcp/ContentLine.cc +++ b/src/analyzer/protocol/tcp/ContentLine.cc @@ -111,8 +111,8 @@ void ContentLine_Analyzer::SetPlainDelivery(int64_t length) { if ( length < 0 ) { - reporter->AnalyzerError(this, - "negative length for plain delivery"); + zeek::reporter->AnalyzerError( + this, "negative length for plain delivery"); return; } diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 7e3091144a..5448e8ac92 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -1624,8 +1624,8 @@ BroFilePtr TCP_Analyzer::GetContentsFile(unsigned int direction) const break; } - reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile", - direction); + zeek::reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile", + direction); return nullptr; } diff --git a/src/analyzer/protocol/tcp/TCP_Endpoint.cc b/src/analyzer/protocol/tcp/TCP_Endpoint.cc index 2b0874bfdc..2c8e23d862 100644 --- a/src/analyzer/protocol/tcp/TCP_Endpoint.cc +++ b/src/analyzer/protocol/tcp/TCP_Endpoint.cc @@ -234,7 +234,7 @@ bool TCP_Endpoint::DataSent(double t, uint64_t seq, int len, int caplen, { char buf[256]; bro_strerror_r(errno, buf, sizeof(buf)); - reporter->Error("TCP contents write failed: %s", buf); + zeek::reporter->Error("TCP contents write failed: %s", buf); if ( contents_file_write_failure ) tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, diff --git a/src/analyzer/protocol/tcp/TCP_Reassembler.cc b/src/analyzer/protocol/tcp/TCP_Reassembler.cc index 213a9d04c1..60fdf1f56e 100644 --- a/src/analyzer/protocol/tcp/TCP_Reassembler.cc +++ b/src/analyzer/protocol/tcp/TCP_Reassembler.cc @@ -96,7 +96,7 @@ void TCP_Reassembler::SetContentsFile(BroFilePtr f) { if ( ! f->IsOpen() ) { - reporter->Error("no such file \"%s\"", f->Name()); + zeek::reporter->Error("no such file \"%s\"", f->Name()); return; } @@ -203,7 +203,7 @@ void TCP_Reassembler::Undelivered(uint64_t up_to_seq) if ( up_to_seq <= last_reassem_seq ) // This should never happen. (Reassembler::TrimToSeq has the only call // to this method and only if this condition is not true). - reporter->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered"); + zeek::reporter->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered"); if ( zeek::BifConst::detect_filtered_trace && last_reassem_seq == 1 && (endpoint->FIN_cnt > 0 || endpoint->RST_cnt > 0 || @@ -353,7 +353,7 @@ void TCP_Reassembler::RecordBlock(const DataBlock& b, const BroFilePtr& f) if ( f->Write((const char*) b.block, b.Size()) ) return; - reporter->Error("TCP_Reassembler contents write failed"); + zeek::reporter->Error("TCP_Reassembler contents write failed"); if ( contents_file_write_failure ) tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, @@ -368,7 +368,7 @@ void TCP_Reassembler::RecordGap(uint64_t start_seq, uint64_t upper_seq, const Br if ( f->Write(fmt("\n<>\n", upper_seq - start_seq)) ) return; - reporter->Error("TCP_Reassembler contents gap write failed"); + zeek::reporter->Error("TCP_Reassembler contents gap write failed"); if ( contents_file_write_failure ) tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, diff --git a/src/analyzer/protocol/teredo/Teredo.h b/src/analyzer/protocol/teredo/Teredo.h index 373d5b5b40..bd9437df60 100644 --- a/src/analyzer/protocol/teredo/Teredo.h +++ b/src/analyzer/protocol/teredo/Teredo.h @@ -33,7 +33,7 @@ public: void Weird(const char* name, bool force = false) const { if ( ProtocolConfirmed() || force ) - reporter->Weird(Conn(), name); + zeek::reporter->Weird(Conn(), name); } /** diff --git a/src/analyzer/protocol/udp/UDP.cc b/src/analyzer/protocol/udp/UDP.cc index b57b1de87d..f56d1d9584 100644 --- a/src/analyzer/protocol/udp/UDP.cc +++ b/src/analyzer/protocol/udp/UDP.cc @@ -184,7 +184,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, request_len += ulen; #ifdef DEBUG if ( request_len < 0 ) - reporter->Warning("wrapping around for UDP request length"); + zeek::reporter->Warning("wrapping around for UDP request length"); #endif } @@ -202,7 +202,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, reply_len += ulen; #ifdef DEBUG if ( reply_len < 0 ) - reporter->Warning("wrapping around for UDP reply length"); + zeek::reporter->Warning("wrapping around for UDP reply length"); #endif } diff --git a/src/analyzer/protocol/vxlan/VXLAN.cc b/src/analyzer/protocol/vxlan/VXLAN.cc index 3cd7847448..1648fa5fd2 100644 --- a/src/analyzer/protocol/vxlan/VXLAN.cc +++ b/src/analyzer/protocol/vxlan/VXLAN.cc @@ -50,7 +50,7 @@ void VXLAN_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, if ( estack && estack->Depth() >= zeek::BifConst::Tunnel::max_depth ) { - reporter->Weird(Conn(), "tunnel_depth"); + zeek::reporter->Weird(Conn(), "tunnel_depth"); return; } diff --git a/src/analyzer/protocol/xmpp/xmpp-analyzer.pac b/src/analyzer/protocol/xmpp/xmpp-analyzer.pac index 62bcec8fc5..e67ab9e851 100644 --- a/src/analyzer/protocol/xmpp/xmpp-analyzer.pac +++ b/src/analyzer/protocol/xmpp/xmpp-analyzer.pac @@ -36,7 +36,7 @@ refine connection XMPP_Conn += { zeek::BifEvent::enqueue_xmpp_starttls(bro_analyzer(), bro_analyzer()->Conn()); } else if ( !is_orig && token == "proceed" ) - reporter->Weird(bro_analyzer()->Conn(), "XMPP: proceed without starttls"); + zeek::reporter->Weird(bro_analyzer()->Conn(), "XMPP: proceed without starttls"); // printf("Processed: %d %s %s %s \n", is_orig, c_str(name), c_str(rest), token_no_ns.c_str()); @@ -48,4 +48,3 @@ refine connection XMPP_Conn += { refine typeattr XMPP_TOKEN += &let { proc: bool = $context.connection.proc_xmpp_token(is_orig, name, rest); }; - diff --git a/src/binpac_bro-lib.pac b/src/binpac_bro-lib.pac index 5fe9cfaac7..bd06f6122d 100644 --- a/src/binpac_bro-lib.pac +++ b/src/binpac_bro-lib.pac @@ -15,7 +15,7 @@ zeek::StringValPtr utf16_to_utf8_val(Connection* conn, const bytestring& utf16) if ( utf8size > resultstring.max_size() ) { - reporter->Weird(conn, "utf16_conversion_failed", "utf16 too long in utf16_to_utf8_val"); + zeek::reporter->Weird(conn, "utf16_conversion_failed", "utf16 too long in utf16_to_utf8_val"); // If the conversion didn't go well, return the original data. return to_stringval(utf16); } @@ -43,7 +43,7 @@ zeek::StringValPtr utf16_to_utf8_val(Connection* conn, const bytestring& utf16) lenientConversion); if ( res != conversionOK ) { - reporter->Weird(conn, "utf16_conversion_failed", "utf16 conversion failed in utf16_to_utf8_val"); + zeek::reporter->Weird(conn, "utf16_conversion_failed", "utf16 conversion failed in utf16_to_utf8_val"); // If the conversion didn't go well, return the original data. return to_stringval(utf16); } diff --git a/src/broker/Data.cc b/src/broker/Data.cc index ea7d4a6cf8..eebb1073ff 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -426,8 +426,8 @@ struct val_converter { if ( ! re->Compile() ) { - reporter->Error("failed compiling unserialized pattern: %s, %s", - exact_text->c_str(), anywhere_text->c_str()); + zeek::reporter->Error("failed compiling unserialized pattern: %s, %s", + exact_text->c_str(), anywhere_text->c_str()); delete re; return nullptr; } @@ -752,8 +752,8 @@ struct type_checker { if ( ! compiled ) { - reporter->Error("failed compiling pattern: %s, %s", - exact_text->c_str(), anywhere_text->c_str()); + zeek::reporter->Error("failed compiling pattern: %s, %s", + exact_text->c_str(), anywhere_text->c_str()); return false; } @@ -871,7 +871,7 @@ broker::expected bro_broker::val_to_data(const zeek::Val* v) } else { - reporter->InternalWarning("Closure with non-ScriptFunc"); + zeek::reporter->InternalWarning("Closure with non-ScriptFunc"); return broker::ec::invalid_data; } } @@ -995,15 +995,15 @@ broker::expected bro_broker::val_to_data(const zeek::Val* v) auto c = v->AsOpaqueVal()->Serialize(); if ( ! c ) { - reporter->Error("unsupported opaque type for serialization"); + zeek::reporter->Error("unsupported opaque type for serialization"); break; } return {c}; } default: - reporter->Error("unsupported Broker::Data type: %s", - zeek::type_name(v->GetType()->Tag())); + zeek::reporter->Error("unsupported Broker::Data type: %s", + zeek::type_name(v->GetType()->Tag())); break; } @@ -1018,7 +1018,7 @@ zeek::RecordValPtr bro_broker::make_data_val(zeek::Val* v) if ( data ) rval->Assign(0, zeek::make_intrusive(move(*data))); else - reporter->Warning("did not get a value from val_to_data"); + zeek::reporter->Warning("did not get a value from val_to_data"); return rval; } @@ -1122,8 +1122,8 @@ broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail: const auto& d = v->GetField(0); if ( ! d ) - reporter->RuntimeError(f->GetCall()->GetLocationInfo(), - "Broker::Data's opaque field is not set"); + zeek::reporter->RuntimeError(f->GetCall()->GetLocationInfo(), + "Broker::Data's opaque field is not set"); // RuntimeError throws an exception which causes this line to never exceute. // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) diff --git a/src/broker/Data.h b/src/broker/Data.h index b97217878f..ef6571ee97 100644 --- a/src/broker/Data.h +++ b/src/broker/Data.h @@ -205,10 +205,10 @@ T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f) { auto ptr = caf::get_if(&d); if ( ! ptr ) - reporter->RuntimeError(f->GetCall()->GetLocationInfo(), - "data is of type '%s' not of type '%s'", - caf::visit(type_name_getter{tag}, d), - zeek::type_name(tag)); + zeek::reporter->RuntimeError(f->GetCall()->GetLocationInfo(), + "data is of type '%s' not of type '%s'", + caf::visit(type_name_getter{tag}, d), + zeek::type_name(tag)); return *ptr; } diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 5f44bd9b1b..51772110e2 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -33,7 +33,7 @@ static inline zeek::Val* get_option(const char* option) const auto& id = zeek::detail::global_scope()->Find(option); if ( ! (id && id->GetVal()) ) - reporter->FatalError("Unknown Broker option %s", option); + zeek::reporter->FatalError("Unknown Broker option %s", option); return id->GetVal().get(); } @@ -72,12 +72,12 @@ int Manager::script_scope = 0; struct scoped_reporter_location { scoped_reporter_location(zeek::detail::Frame* frame) { - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + zeek::reporter->PushLocation(frame->GetCall()->GetLocationInfo()); } ~scoped_reporter_location() { - reporter->PopLocation(); + zeek::reporter->PopLocation(); } }; @@ -179,7 +179,7 @@ void Manager::InitPostScript() else if ( streq(scheduler_policy, "stealing") ) config.set("scheduler.policy", caf::atom("stealing")); else - reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy); + zeek::reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy); auto max_threads_env = zeekenv("ZEEK_BROKER_MAX_THREADS"); @@ -211,9 +211,9 @@ void Manager::InitPostScript() bstate = std::make_shared(std::move(config), cqs); if ( ! iosource_mgr->RegisterFd(bstate->subscriber.fd(), this) ) - reporter->FatalError("Failed to register broker subscriber with iosource_mgr"); + zeek::reporter->FatalError("Failed to register broker subscriber with iosource_mgr"); if ( ! iosource_mgr->RegisterFd(bstate->status_subscriber.fd(), this) ) - reporter->FatalError("Failed to register broker status subscriber with iosource_mgr"); + zeek::reporter->FatalError("Failed to register broker status subscriber with iosource_mgr"); bstate->subscriber.add_topic(broker::topics::store_events, true); @@ -507,8 +507,8 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer, if ( ! stream_id ) { - reporter->Error("Failed to remotely log: stream %d doesn't have name", - stream->AsEnum()); + zeek::reporter->Error("Failed to remotely log: stream %d doesn't have name", + stream->AsEnum()); return false; } @@ -516,8 +516,8 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer, if ( ! writer_id ) { - reporter->Error("Failed to remotely log: writer %d doesn't have name", - writer->AsEnum()); + zeek::reporter->Error("Failed to remotely log: writer %d doesn't have name", + writer->AsEnum()); return false; } @@ -563,8 +563,8 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri if ( ! stream_id ) { - reporter->Error("Failed to remotely log: stream %d doesn't have name", - stream->AsEnum()); + zeek::reporter->Error("Failed to remotely log: stream %d doesn't have name", + stream->AsEnum()); return false; } @@ -572,8 +572,8 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri if ( ! writer_id ) { - reporter->Error("Failed to remotely log: writer %d doesn't have name", - writer->AsEnum()); + zeek::reporter->Error("Failed to remotely log: writer %d doesn't have name", + writer->AsEnum()); return false; } @@ -587,7 +587,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri if ( ! success ) { - reporter->Error("Failed to remotely log stream %s: num_fields serialization failed", stream_id); + zeek::reporter->Error("Failed to remotely log stream %s: num_fields serialization failed", stream_id); return false; } @@ -595,7 +595,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri { if ( ! vals[i]->Write(&fmt) ) { - reporter->Error("Failed to remotely log stream %s: field %d serialization failed", stream_id, i); + zeek::reporter->Error("Failed to remotely log stream %s: field %d serialization failed", stream_id, i); return false; } } @@ -609,9 +609,9 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri if ( ! v ) { - reporter->Error("Failed to remotely log: log_topic func did not return" - " a value for stream %s at path %s", stream_id, - path.data()); + zeek::reporter->Error("Failed to remotely log: log_topic func did not return" + " a value for stream %s at path %s", stream_id, + path.data()); return false; } @@ -685,7 +685,7 @@ void Manager::Error(const char* format, ...) if ( script_scope ) zeek::emit_builtin_error(msg); else - reporter->Error("%s", msg); + zeek::reporter->Error("%s", msg); } bool Manager::AutoPublishEvent(string topic, zeek::Val* event) @@ -872,8 +872,8 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg) { switch ( broker::zeek::Message::type(msg) ) { case broker::zeek::Message::Type::Invalid: - reporter->Warning("received invalid broker message: %s", - broker::to_string(msg).data()); + zeek::reporter->Warning("received invalid broker message: %s", + broker::to_string(msg).data()); break; case broker::zeek::Message::Type::Event: @@ -898,8 +898,8 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg) if ( ! batch.valid() ) { - reporter->Warning("received invalid broker Batch: %s", - broker::to_string(batch).data()); + zeek::reporter->Warning("received invalid broker Batch: %s", + broker::to_string(batch).data()); return; } @@ -912,8 +912,8 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg) default: // We ignore unknown types so that we could add more in the // future if we had too. - reporter->Warning("received unknown broker message: %s", - broker::to_string(msg).data()); + zeek::reporter->Warning("received unknown broker message: %s", + broker::to_string(msg).data()); break; } } @@ -945,7 +945,7 @@ void Manager::Process() continue; } - reporter->InternalWarning("ignoring status_subscriber message with unexpected type"); + zeek::reporter->InternalWarning("ignoring status_subscriber message with unexpected type"); } auto messages = bstate->subscriber.poll(); @@ -974,7 +974,7 @@ void Manager::Process() } catch ( std::runtime_error& e ) { - reporter->Warning("ignoring invalid Broker message: %s", + e.what()); + zeek::reporter->Warning("ignoring invalid Broker message: %s", + e.what()); continue; } } @@ -1025,7 +1025,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table, if ( table->GetType()->IsSet() && data.get_type() != broker::data::type::none ) { - reporter->Error("ProcessStoreEvent %s got %s when expecting set", type, data.get_type_name()); + zeek::reporter->Error("ProcessStoreEvent %s got %s when expecting set", type, data.get_type_name()); return; } @@ -1034,7 +1034,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table, auto zeek_key = data_to_val(key, its[0].get()); if ( ! zeek_key ) { - reporter->Error("ProcessStoreEvent %s: could not convert key \"%s\" for store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(key).c_str(), store_id.c_str()); + zeek::reporter->Error("ProcessStoreEvent %s: could not convert key \"%s\" for store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(key).c_str(), store_id.c_str()); return; } @@ -1048,7 +1048,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table, auto zeek_value = data_to_val(data, table->GetType()->Yield().get()); if ( ! zeek_value ) { - reporter->Error("ProcessStoreEvent %s: could not convert value \"%s\" for key \"%s\" in store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(data).c_str(), to_string(key).c_str(), store_id.c_str()); + zeek::reporter->Error("ProcessStoreEvent %s: could not convert value \"%s\" for key \"%s\" in store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(data).c_str(), to_string(key).c_str(), store_id.c_str()); return; } @@ -1110,7 +1110,7 @@ void Manager::ProcessStoreEvent(broker::data msg) auto zeek_key = data_to_val(key, its[0].get()); if ( ! zeek_key ) { - reporter->Error("ProcessStoreEvent: could not convert key \"%s\" for store \"%s\" while receiving remote erase. This probably means the tables have different types on different nodes.", to_string(key).c_str(), insert.store_id().c_str()); + zeek::reporter->Error("ProcessStoreEvent: could not convert key \"%s\" for store \"%s\" while receiving remote erase. This probably means the tables have different types on different nodes.", to_string(key).c_str(), insert.store_id().c_str()); return; } @@ -1134,7 +1134,7 @@ void Manager::ProcessStoreEvent(broker::data msg) } else { - reporter->Error("ProcessStoreEvent: Unhandled event type"); + zeek::reporter->Error("ProcessStoreEvent: Unhandled event type"); } } @@ -1142,8 +1142,8 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) { if ( ! ev.valid() ) { - reporter->Warning("received invalid broker Event: %s", - broker::to_string(ev.as_data()).data()); + zeek::reporter->Warning("received invalid broker Event: %s", + broker::to_string(ev.as_data()).data()); return; } @@ -1177,9 +1177,9 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) if ( arg_types.size() != args.size() ) { - reporter->Warning("got event message '%s' with invalid # of args," - " got %zd, expected %zu", name.data(), args.size(), - arg_types.size()); + zeek::reporter->Warning("got event message '%s' with invalid # of args," + " got %zd, expected %zu", name.data(), args.size(), + arg_types.size()); return; } @@ -1198,17 +1198,18 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) { auto expected_name = zeek::type_name(expected_type->Tag()); - reporter->Warning("failed to convert remote event '%s' arg #%lu," - " got %s, expected %s", - name.data(), i, got_type, - expected_name); + zeek::reporter->Warning("failed to convert remote event '%s' arg #%lu," + " got %s, expected %s", + name.data(), i, got_type, + expected_name); // If we got a vector and expected a function this is // possibly because of a mismatch between // anonymous-function bodies. if ( strcmp(expected_name, "func") == 0 && strcmp("vector", got_type) == 0 ) - reporter->Warning("when sending functions the receiver must have access to a" - " version of that function.\nFor anonymous functions, that function must have the same body."); + zeek::reporter->Warning( + "when sending functions the receiver must have access to a" + " version of that function.\nFor anonymous functions, that function must have the same body."); break; } @@ -1223,29 +1224,29 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) DBG_LOG(DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str()); if ( ! lc.valid() ) { - reporter->Warning("received invalid broker LogCreate: %s", - broker::to_string(lc).data()); + zeek::reporter->Warning("received invalid broker LogCreate: %s", + broker::to_string(lc).data()); return false; } auto stream_id = data_to_val(std::move(lc.stream_id()), log_id_type); if ( ! stream_id ) { - reporter->Warning("failed to unpack remote log stream id"); + zeek::reporter->Warning("failed to unpack remote log stream id"); return false; } auto writer_id = data_to_val(std::move(lc.writer_id()), writer_id_type); if ( ! writer_id ) { - reporter->Warning("failed to unpack remote log writer id"); + zeek::reporter->Warning("failed to unpack remote log writer id"); return false; } auto writer_info = std::unique_ptr(new logging::WriterBackend::WriterInfo); if ( ! writer_info->FromBroker(std::move(lc.writer_info())) ) { - reporter->Warning("failed to unpack remote log writer info"); + zeek::reporter->Warning("failed to unpack remote log writer info"); return false; } @@ -1254,7 +1255,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) if ( ! fields_data ) { - reporter->Warning("failed to unpack remote log fields"); + zeek::reporter->Warning("failed to unpack remote log fields"); return false; } @@ -1267,7 +1268,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) fields[i] = field; else { - reporter->Warning("failed to convert remote log field # %lu", i); + zeek::reporter->Warning("failed to convert remote log field # %lu", i); delete [] fields; return false; } @@ -1277,7 +1278,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) { ODesc d; stream_id->Describe(&d); - reporter->Warning("failed to create remote log stream for %s locally", d.Description()); + zeek::reporter->Warning("failed to create remote log stream for %s locally", d.Description()); } return true; @@ -1289,7 +1290,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) if ( ! lw.valid() ) { - reporter->Warning("received invalid broker LogWrite: %s", + zeek::reporter->Warning("received invalid broker LogWrite: %s", broker::to_string(lw).data()); return false; } @@ -1302,8 +1303,8 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) if ( ! stream_id ) { - reporter->Warning("failed to unpack remote log stream id: %s", - stream_id_name.data()); + zeek::reporter->Warning("failed to unpack remote log stream id: %s", + stream_id_name.data()); return false; } @@ -1311,7 +1312,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) auto writer_id = data_to_val(std::move(lw.writer_id()), writer_id_type); if ( ! writer_id ) { - reporter->Warning("failed to unpack remote log writer id for stream: %s", stream_id_name.data()); + zeek::reporter->Warning("failed to unpack remote log writer id for stream: %s", stream_id_name.data()); return false; } @@ -1319,7 +1320,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) if ( ! path ) { - reporter->Warning("failed to unpack remote log values (bad path variant) for stream: %s", stream_id_name.data()); + zeek::reporter->Warning("failed to unpack remote log values (bad path variant) for stream: %s", stream_id_name.data()); return false; } @@ -1327,7 +1328,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) if ( ! serial_data ) { - reporter->Warning("failed to unpack remote log values (bad serial_data variant) for stream: %s", stream_id_name.data()); + zeek::reporter->Warning("failed to unpack remote log values (bad serial_data variant) for stream: %s", stream_id_name.data()); return false; } @@ -1339,7 +1340,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) if ( ! success ) { - reporter->Warning("failed to unserialize remote log num fields for stream: %s", stream_id_name.data()); + zeek::reporter->Warning("failed to unserialize remote log num fields for stream: %s", stream_id_name.data()); return false; } @@ -1355,7 +1356,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) delete vals[j]; delete [] vals; - reporter->Warning("failed to unserialize remote log field %d for stream: %s", i, stream_id_name.data()); + zeek::reporter->Warning("failed to unserialize remote log field %d for stream: %s", i, stream_id_name.data()); return false; } @@ -1373,8 +1374,8 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu) if ( ! iu.valid() ) { - reporter->Warning("received invalid broker IdentifierUpdate: %s", - broker::to_string(iu).data()); + zeek::reporter->Warning("received invalid broker IdentifierUpdate: %s", + broker::to_string(iu).data()); return false; } @@ -1385,8 +1386,8 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu) if ( ! id ) { - reporter->Warning("Received id-update request for unkown id: %s", - id_name.c_str()); + zeek::reporter->Warning("Received id-update request for unkown id: %s", + id_name.c_str()); return false; } @@ -1394,8 +1395,8 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu) if ( ! val ) { - reporter->Error("Failed to receive ID with unsupported type: %s (%s)", - id_name.c_str(), zeek::type_name(id->GetType()->Tag())); + zeek::reporter->Error("Failed to receive ID with unsupported type: %s (%s)", + id_name.c_str(), zeek::type_name(id->GetType()->Tag())); return false; } @@ -1433,7 +1434,7 @@ void Manager::ProcessStatus(broker::status stat) break; default: - reporter->Warning("Unhandled Broker status: %s", to_string(stat).data()); + zeek::reporter->Warning("Unhandled Broker status: %s", to_string(stat).data()); break; } @@ -1489,7 +1490,7 @@ void Manager::ProcessError(broker::error err) ec = static_cast(err.code()); else { - reporter->Warning("Unknown Broker error code %u: mapped to unspecificed enum value ", err.code()); + zeek::reporter->Warning("Unknown Broker error code %u: mapped to unspecificed enum value ", err.code()); ec = BifEnum::Broker::ErrorCode::UNSPECIFIED; } @@ -1515,8 +1516,8 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re if ( request == pending_queries.end() ) { - reporter->Warning("unmatched response to query %" PRIu64 " on store %s", - response.id, s->store.name().c_str()); + zeek::reporter->Warning("unmatched response to query %" PRIu64 " on store %s", + response.id, s->store.name().c_str()); return; } @@ -1545,8 +1546,8 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re else if ( response.answer.error() == broker::ec::no_such_key ) request->second->Result(query_result()); else - reporter->InternalWarning("unknown store response status: %s", - to_string(response.answer.error()).c_str()); + zeek::reporter->InternalWarning("unknown store response status: %s", + to_string(response.answer.error()).c_str()); delete request->second; pending_queries.erase(request); @@ -1634,7 +1635,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV auto zeek_key = data_to_val(key, its[0].get()); if ( ! zeek_key ) { - reporter->Error("Failed to convert key \"%s\" while importing broker store to table for store \"%s\". Aborting import.", to_string(key).c_str(), name.c_str()); + zeek::reporter->Error("Failed to convert key \"%s\" while importing broker store to table for store \"%s\". Aborting import.", to_string(key).c_str(), name.c_str()); // just abort - this probably means the types are incompatible table->EnableChangeNotifications(); return; @@ -1649,7 +1650,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV auto value = handle->store.get(key); if ( ! value ) { - reporter->Error("Failed to load value for key %s while importing Broker store %s to table", to_string(key).c_str(), name.c_str()); + zeek::reporter->Error("Failed to load value for key %s while importing Broker store %s to table", to_string(key).c_str(), name.c_str()); table->EnableChangeNotifications(); continue; } @@ -1657,7 +1658,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV auto zeek_value = data_to_val(*value, table->GetType()->Yield().get()); if ( ! zeek_value ) { - reporter->Error("Could not convert %s to table value while trying to import Broker store %s. Aborting import.", to_string(value).c_str(), name.c_str()); + zeek::reporter->Error("Could not convert %s to table value while trying to import Broker store %s. Aborting import.", to_string(value).c_str(), name.c_str()); table->EnableChangeNotifications(); return; } @@ -1760,7 +1761,7 @@ bool Manager::AddForwardedStore(const std::string& name, zeek::TableValPtr table { if ( forwarded_stores.find(name) != forwarded_stores.end() ) { - reporter->Error("same &broker_store %s specified for two different variables", name.c_str()); + zeek::reporter->Error("same &broker_store %s specified for two different variables", name.c_str()); return false; } diff --git a/src/digest.cc b/src/digest.cc index 17896c1f6a..651338bf96 100644 --- a/src/digest.cc +++ b/src/digest.cc @@ -38,11 +38,11 @@ EVP_MD_CTX* hash_init(HashAlgorithm alg) md = EVP_sha512(); break; default: - reporter->InternalError("Unknown hash algorithm passed to hash_init"); + zeek::reporter->InternalError("Unknown hash algorithm passed to hash_init"); } if ( ! EVP_DigestInit_ex(c, md, NULL) ) - reporter->InternalError("EVP_DigestInit failed"); + zeek::reporter->InternalError("EVP_DigestInit failed"); return c; } @@ -50,13 +50,13 @@ EVP_MD_CTX* hash_init(HashAlgorithm alg) void hash_update(EVP_MD_CTX* c, const void* data, unsigned long len) { if ( ! EVP_DigestUpdate(c, data, len) ) - reporter->InternalError("EVP_DigestUpdate failed"); + zeek::reporter->InternalError("EVP_DigestUpdate failed"); } void hash_final(EVP_MD_CTX* c, u_char* md) { if ( ! EVP_DigestFinal(c, md, NULL) ) - reporter->InternalError("EVP_DigestFinal failed"); + zeek::reporter->InternalError("EVP_DigestFinal failed"); EVP_MD_CTX_free(c); } diff --git a/src/file_analysis/AnalyzerSet.cc b/src/file_analysis/AnalyzerSet.cc index 042f7b029a..4b2bb43358 100644 --- a/src/file_analysis/AnalyzerSet.cc +++ b/src/file_analysis/AnalyzerSet.cc @@ -162,7 +162,7 @@ std::unique_ptr AnalyzerSet::GetKey(const file_analysis::Tag& t, auto key = analyzer_hash->MakeHashKey(*lv, true); if ( ! key ) - reporter->InternalError("AnalyzerArgs type mismatch"); + zeek::reporter->InternalError("AnalyzerArgs type mismatch"); return key; } @@ -174,9 +174,9 @@ file_analysis::Analyzer* AnalyzerSet::InstantiateAnalyzer(const Tag& tag, if ( ! a ) { - reporter->Error("[%s] Failed file analyzer %s instantiation", - file->GetID().c_str(), - file_mgr->GetComponentName(tag).c_str()); + zeek::reporter->Error("[%s] Failed file analyzer %s instantiation", + file->GetID().c_str(), + file_mgr->GetComponentName(tag).c_str()); return nullptr; } diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index 15b8c3e6ab..f6782d969d 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -175,8 +175,8 @@ int File::Idx(const std::string& field, const zeek::RecordType* type) int rval = type->FieldOffset(field.c_str()); if ( rval < 0 ) - reporter->InternalError("Unknown %s field: %s", type->GetName().c_str(), - field.c_str()); + zeek::reporter->InternalError("Unknown %s field: %s", type->GetName().c_str(), + field.c_str()); return rval; } diff --git a/src/file_analysis/Manager.cc b/src/file_analysis/Manager.cc index 2e97c9aa58..ce31e0ceb1 100644 --- a/src/file_analysis/Manager.cc +++ b/src/file_analysis/Manager.cc @@ -465,9 +465,9 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, if ( ! c ) { - reporter->InternalWarning( - "unknown file analyzer instantiation request: %s", - tag.AsString().c_str()); + zeek::reporter->InternalWarning( + "unknown file analyzer instantiation request: %s", + tag.AsString().c_str()); return nullptr; } @@ -482,13 +482,13 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, a = c->factory(args.get(), f); else { - reporter->InternalWarning("file analyzer %s cannot be instantiated " - "dynamically", c->CanonicalName().c_str()); + zeek::reporter->InternalWarning("file analyzer %s cannot be instantiated " + "dynamically", c->CanonicalName().c_str()); return nullptr; } if ( ! a ) - reporter->InternalError("file analyzer instantiation failed"); + zeek::reporter->InternalError("file analyzer instantiation failed"); a->SetAnalyzerTag(tag); @@ -500,7 +500,7 @@ zeek::detail::RuleMatcher::MIME_Matches* Manager::DetectMIME( zeek::detail::RuleMatcher::MIME_Matches* rval) const { if ( ! magic_state ) - reporter->InternalError("file magic signature state not initialized"); + zeek::reporter->InternalError("file magic signature state not initialized"); rval = zeek::detail::rule_matcher->Match(magic_state, data, len, rval); zeek::detail::rule_matcher->ClearFileMagicState(magic_state); diff --git a/src/file_analysis/analyzer/extract/Extract.cc b/src/file_analysis/analyzer/extract/Extract.cc index 23db79deb3..a84f78e377 100644 --- a/src/file_analysis/analyzer/extract/Extract.cc +++ b/src/file_analysis/analyzer/extract/Extract.cc @@ -23,7 +23,7 @@ Extract::Extract(zeek::RecordValPtr args, File* file, fd = 0; char buf[128]; bro_strerror_r(errno, buf, sizeof(buf)); - reporter->Error("cannot open %s: %s", filename.c_str(), buf); + zeek::reporter->Error("cannot open %s: %s", filename.c_str(), buf); } } @@ -39,7 +39,7 @@ static const zeek::ValPtr& get_extract_field_val(const zeek::RecordValPtr& args, const auto& rval = args->GetField(name); if ( ! rval ) - reporter->Error("File extraction analyzer missing arg field: %s", name); + zeek::reporter->Error("File extraction analyzer missing arg field: %s", name); return rval; } diff --git a/src/file_analysis/analyzer/x509/OCSP.cc b/src/file_analysis/analyzer/x509/OCSP.cc index c77b23fafd..78700dbf91 100644 --- a/src/file_analysis/analyzer/x509/OCSP.cc +++ b/src/file_analysis/analyzer/x509/OCSP.cc @@ -79,7 +79,7 @@ static bool ocsp_add_cert_id(const OCSP_CERTID* cert_id, zeek::Args* vl, BIO* bi if ( ! res ) { - reporter->Weird("OpenSSL failed to get OCSP_CERTID info"); + zeek::reporter->Weird("OpenSSL failed to get OCSP_CERTID info"); vl->emplace_back(zeek::val_mgr->EmptyString()); vl->emplace_back(zeek::val_mgr->EmptyString()); vl->emplace_back(zeek::val_mgr->EmptyString()); @@ -154,7 +154,7 @@ bool file_analysis::OCSP::EndOfFile() if (!req) { - reporter->Weird(GetFile(), "openssl_ocsp_request_parse_error"); + zeek::reporter->Weird(GetFile(), "openssl_ocsp_request_parse_error"); return false; } @@ -167,7 +167,7 @@ bool file_analysis::OCSP::EndOfFile() if (!resp) { - reporter->Weird(GetFile(), "openssl_ocsp_response_parse_error"); + zeek::reporter->Weird(GetFile(), "openssl_ocsp_response_parse_error"); return false; } @@ -506,7 +506,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) } else { - reporter->Weird("OpenSSL failed to get OCSP responder id"); + zeek::reporter->Weird("OpenSSL failed to get OCSP responder id"); vl.emplace_back(zeek::val_mgr->EmptyString()); } @@ -517,7 +517,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) produced_at = OCSP_resp_get0_produced_at(basic_resp); #endif - vl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(produced_at, GetFile(), reporter))); + vl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(produced_at, GetFile(), zeek::reporter))); // responses @@ -557,7 +557,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) const_cast(cert_id), &status, &reason, &revoke_time, &this_update, &next_update) ) - reporter->Weird("OpenSSL failed to find status of OCSP response"); + zeek::reporter->Weird("OpenSSL failed to find status of OCSP response"); const char* cert_status_str = OCSP_cert_status_str(status); rvl.emplace_back(zeek::make_intrusive(strlen(cert_status_str), cert_status_str)); @@ -565,7 +565,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) // revocation time and reason if revoked if ( status == V_OCSP_CERTSTATUS_REVOKED ) { - rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(revoke_time, GetFile(), reporter))); + rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(revoke_time, GetFile(), zeek::reporter))); if ( reason != OCSP_REVOKED_STATUS_NOSTATUS ) { @@ -582,12 +582,12 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) } if ( this_update ) - rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(this_update, GetFile(), reporter))); + rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(this_update, GetFile(), zeek::reporter))); else rvl.emplace_back(zeek::make_intrusive(0.0)); if ( next_update ) - rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(next_update, GetFile(), reporter))); + rvl.emplace_back(zeek::make_intrusive(GetTimeFromAsn1(next_update, GetFile(), zeek::reporter))); else rvl.emplace_back(zeek::make_intrusive(0.0)); @@ -638,7 +638,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp) if (this_cert) certs_vector->Assign(i, zeek::make_intrusive(this_cert)); else - reporter->Weird("OpenSSL returned null certificate"); + zeek::reporter->Weird("OpenSSL returned null certificate"); } } diff --git a/src/file_analysis/analyzer/x509/X509.cc b/src/file_analysis/analyzer/x509/X509.cc index a978762b07..7e6f9b1769 100644 --- a/src/file_analysis/analyzer/x509/X509.cc +++ b/src/file_analysis/analyzer/x509/X509.cc @@ -75,7 +75,7 @@ bool file_analysis::X509::EndOfFile() ::X509* ssl_cert = d2i_X509(NULL, &cert_char, cert_data.size()); if ( ! ssl_cert ) { - reporter->Weird(GetFile(), "x509_cert_parse_error"); + zeek::reporter->Weird(GetFile(), "x509_cert_parse_error"); return false; } @@ -160,8 +160,8 @@ zeek::RecordValPtr file_analysis::X509::ParseCertificate(X509Val* cert_val, File pX509Cert->Assign(3, zeek::make_intrusive(len, buf)); BIO_free(bio); - pX509Cert->Assign(5, zeek::make_intrusive(GetTimeFromAsn1(X509_get_notBefore(ssl_cert), f, reporter))); - pX509Cert->Assign(6, zeek::make_intrusive(GetTimeFromAsn1(X509_get_notAfter(ssl_cert), f, reporter))); + pX509Cert->Assign(5, zeek::make_intrusive(GetTimeFromAsn1(X509_get_notBefore(ssl_cert), f, zeek::reporter))); + pX509Cert->Assign(6, zeek::make_intrusive(GetTimeFromAsn1(X509_get_notAfter(ssl_cert), f, zeek::reporter))); // we only read 255 bytes because byte 256 is always 0. // if the string is longer than 255, that will be our null-termination, @@ -306,7 +306,7 @@ void file_analysis::X509::ParseBasicConstraints(X509_EXTENSION* ex) } else - reporter->Weird(GetFile(), "x509_invalid_basic_constraint"); + zeek::reporter->Weird(GetFile(), "x509_invalid_basic_constraint"); } void file_analysis::X509::ParseExtensionsSpecific(X509_EXTENSION* ex, bool global, ASN1_OBJECT* ext_asn, const char* oid) @@ -336,7 +336,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext) GENERAL_NAMES *altname = (GENERAL_NAMES*)X509V3_EXT_d2i(ext); if ( ! altname ) { - reporter->Weird(GetFile(), "x509_san_parse_error"); + zeek::reporter->Weird(GetFile(), "x509_san_parse_error"); return; } @@ -356,7 +356,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext) { if ( ASN1_STRING_type(gen->d.ia5) != V_ASN1_IA5STRING ) { - reporter->Weird(GetFile(), "x509_san_non_string"); + zeek::reporter->Weird(GetFile(), "x509_san_non_string"); continue; } @@ -407,14 +407,14 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext) else { - reporter->Weird(GetFile(), "x509_san_ip_length", fmt("%d", gen->d.ip->length)); + zeek::reporter->Weird(GetFile(), "x509_san_ip_length", fmt("%d", gen->d.ip->length)); continue; } } else { - // reporter->Error("Subject alternative name contained unsupported fields. fuid %s", GetFile()->GetID().c_str()); + // zeek::reporter->Error("Subject alternative name contained unsupported fields. fuid %s", GetFile()->GetID().c_str()); // This happens quite often - just mark it otherfields = true; continue; @@ -524,7 +524,7 @@ unsigned int file_analysis::X509::KeyLength(EVP_PKEY *key) return 0; // unknown public key type } - reporter->InternalError("cannot be reached"); + zeek::reporter->InternalError("cannot be reached"); } X509Val::X509Val(::X509* arg_certificate) : OpaqueVal(x509_opaque_type) diff --git a/src/file_analysis/analyzer/x509/X509Common.cc b/src/file_analysis/analyzer/x509/X509Common.cc index 27d8098833..45361efee6 100644 --- a/src/file_analysis/analyzer/x509/X509Common.cc +++ b/src/file_analysis/analyzer/x509/X509Common.cc @@ -25,12 +25,12 @@ X509Common::X509Common(const file_analysis::Tag& arg_tag, static void EmitWeird(const char* name, File* file, const char* addl = "") { if ( file ) - reporter->Weird(file, name, addl); + zeek::reporter->Weird(file, name, addl); else - reporter->Weird(name); + zeek::reporter->Weird(name); } -double X509Common::GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter) +double X509Common::GetTimeFromAsn1(const ASN1_TIME* atime, File* f, zeek::Reporter* reporter) { time_t lResult = 0; @@ -205,7 +205,7 @@ void file_analysis::X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION* ASN1_OCTET_STRING* inner = d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**) &ext_val_copy, ext_val->length); if ( !inner ) { - reporter->Error("X509::ParseSignedCertificateTimestamps could not parse inner octet string"); + zeek::reporter->Error("X509::ParseSignedCertificateTimestamps could not parse inner octet string"); return; } @@ -219,7 +219,7 @@ void file_analysis::X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION* catch( const binpac::Exception& e ) { // throw a warning or sth - reporter->Error("X509::ParseSignedCertificateTimestamps could not parse SCT"); + zeek::reporter->Error("X509::ParseSignedCertificateTimestamps could not parse SCT"); } ASN1_OCTET_STRING_free(inner); @@ -325,7 +325,7 @@ zeek::StringValPtr file_analysis::X509Common::GetExtensionFromBIO(BIO* bio, File { // Just emit an error here and try to continue instead of aborting // because it's unclear the length value is very reliable. - reporter->Error("X509::GetExtensionFromBIO malloc(%d) failed", length); + zeek::reporter->Error("X509::GetExtensionFromBIO malloc(%d) failed", length); BIO_free_all(bio); return nullptr; } diff --git a/src/file_analysis/analyzer/x509/X509Common.h b/src/file_analysis/analyzer/x509/X509Common.h index dfe9a8100f..e6577fb783 100644 --- a/src/file_analysis/analyzer/x509/X509Common.h +++ b/src/file_analysis/analyzer/x509/X509Common.h @@ -11,8 +11,8 @@ #include class EventHandlerPtr; -class Reporter; +ZEEK_FORWARD_DECLARE_NAMESPACED(Reporter, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek); namespace zeek { @@ -42,7 +42,7 @@ public: */ static zeek::StringValPtr GetExtensionFromBIO(BIO* bio, File* f = nullptr); - static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter); + static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, zeek::Reporter* reporter); protected: X509Common(const file_analysis::Tag& arg_tag, diff --git a/src/file_analysis/analyzer/x509/functions.bif b/src/file_analysis/analyzer/x509/functions.bif index bb50e67b8b..05d06bf9b2 100644 --- a/src/file_analysis/analyzer/x509/functions.bif +++ b/src/file_analysis/analyzer/x509/functions.bif @@ -225,7 +225,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c zeek::VectorVal *certs_vec = certs->AsVectorVal(); if ( certs_vec->Size() < 1 ) { - reporter->Error("No certificates given in vector"); + zeek::reporter->Error("No certificates given in vector"); return x509_result_record(-1, "no certificates"); } @@ -511,7 +511,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str zeek::VectorVal *certs_vec = certs->AsVectorVal(); if ( ! certs_vec || certs_vec->Size() < 1 ) { - reporter->Error("No certificates given in vector"); + zeek::reporter->Error("No certificates given in vector"); return x509_result_record(-1, "no certificates"); } @@ -551,7 +551,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str if ( ! chain ) { - reporter->Error("Encountered valid chain that could not be resolved"); + zeek::reporter->Error("Encountered valid chain that could not be resolved"); sk_X509_pop_free(chain, X509_free); goto x509_verify_chainerror; } @@ -568,7 +568,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str chainVector->Assign(i, zeek::make_intrusive(currcert)); else { - reporter->InternalWarning("OpenSSL returned null certificate"); + zeek::reporter->InternalWarning("OpenSSL returned null certificate"); sk_X509_pop_free(chain, X509_free); goto x509_verify_chainerror; } @@ -623,7 +623,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa bool precert = issuer_key_hash->Len() > 0; if ( precert && issuer_key_hash->Len() != 32) { - reporter->Error("Invalid issuer_key_hash length"); + zeek::reporter->Error("Invalid issuer_key_hash length"); return zeek::val_mgr->False(); } @@ -647,7 +647,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa int pos = X509_get_ext_by_NID(x, NID_ct_precert_scts, -1); if ( pos < 0 ) { - reporter->Error("NID_ct_precert_scts not found"); + zeek::reporter->Error("NID_ct_precert_scts not found"); return zeek::val_mgr->False(); } #else @@ -751,7 +751,7 @@ sct_verify_err: if (key) EVP_PKEY_free(key); - reporter->Error("%s", errstr.c_str()); + zeek::reporter->Error("%s", errstr.c_str()); return zeek::val_mgr->False(); %} @@ -768,7 +768,7 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne if ( type > 2 ) { - reporter->InternalError("Unknown type in x509_entity_hash"); + zeek::reporter->InternalError("Unknown type in x509_entity_hash"); return nullptr; } diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 01fbffc56c..f4bf89d6da 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -204,7 +204,7 @@ ReaderBackend* Manager::CreateBackend(ReaderFrontend* frontend, zeek::EnumVal* t if ( ! c ) { - reporter->Error("The reader that was requested was not found and could not be initialized."); + zeek::reporter->Error("The reader that was requested was not found and could not be initialized."); return nullptr; } @@ -222,7 +222,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description) || same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) || same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) ) { - reporter->Error("Stream description argument not of right type for new input stream"); + zeek::reporter->Error("Stream description argument not of right type for new input stream"); return false; } @@ -230,8 +230,8 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description) if ( Stream *i = FindStream(name) ) { - reporter->Error("Trying create already existing input stream %s", - name.c_str()); + zeek::reporter->Error("Trying create already existing input stream %s", + name.c_str()); return false; } @@ -263,7 +263,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description) break; default: - reporter->InternalWarning("unknown input reader mode"); + zeek::reporter->InternalWarning("unknown input reader mode"); return false; } @@ -308,7 +308,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) zeek::RecordType* rtype = fval->GetType()->AsRecordType(); if ( ! same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) ) { - reporter->Error("EventDescription argument not of right type"); + zeek::reporter->Error("EventDescription argument not of right type"); return false; } @@ -328,7 +328,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) { - reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); return false; } @@ -336,19 +336,19 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) if ( args.size() < 2 ) { - reporter->Error("Input stream %s: Event does not take enough arguments", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Event does not take enough arguments", stream_name.c_str()); return false; } if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) ) { - reporter->Error("Input stream %s: Event's second attribute must be of type Input::Event", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Event's second attribute must be of type Input::Event", stream_name.c_str()); return false; } if ( ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) ) { - reporter->Error("Input stream %s: Event's first attribute must be of type Input::EventDescription", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Event's first attribute must be of type Input::EventDescription", stream_name.c_str()); return false; } @@ -356,7 +356,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) { if ( static_cast(args.size()) != fields->NumFields() + 2 ) { - reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); return false; } @@ -369,10 +369,10 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) args[i + 2]->Describe(&desc1); fields->GetFieldType(i)->Describe(&desc2); - reporter->Error("Input stream %s: Incompatible type for event in field %d. Need type '%s':%s, got '%s':%s", - stream_name.c_str(), i + 3, - zeek::type_name(fields->GetFieldType(i)->Tag()), desc2.Description(), - zeek::type_name(args[i + 2]->Tag()), desc1.Description()); + zeek::reporter->Error("Input stream %s: Incompatible type for event in field %d. Need type '%s':%s, got '%s':%s", + stream_name.c_str(), i + 3, + zeek::type_name(fields->GetFieldType(i)->Tag()), desc2.Description(), + zeek::type_name(args[i + 2]->Tag()), desc1.Description()); return false; } @@ -384,7 +384,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) { if ( args.size() != 3 ) { - reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); return false; } @@ -394,10 +394,10 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) ODesc desc2; args[2]->Describe(&desc1); fields->Describe(&desc2); - reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n", - stream_name.c_str(), - zeek::type_name(args[2]->Tag()), desc1.Description(), - zeek::type_name(fields->Tag()), desc2.Description()); + zeek::reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n", + stream_name.c_str(), + zeek::type_name(args[2]->Tag()), desc1.Description(), + zeek::type_name(fields->Tag()), desc2.Description()); return false; } @@ -420,7 +420,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) if ( status ) { - reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); for ( auto& f : fieldsV ) delete f; return false; } @@ -462,7 +462,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) zeek::RecordType* rtype = fval->GetType()->AsRecordType(); if ( ! same_type(rtype, zeek::BifType::Record::Input::TableDescription, false) ) { - reporter->Error("TableDescription argument not of right type"); + zeek::reporter->Error("TableDescription argument not of right type"); return false; } @@ -489,7 +489,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) { if ( j >= num ) { - reporter->Error("Input stream %s: Table type has more indexes than index definition", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Table type has more indexes than index definition", stream_name.c_str()); return false; } @@ -500,9 +500,10 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) idx->GetFieldType(j)->Describe(&desc1); tl[j]->Describe(&desc2); - reporter->Error("Input stream %s: Table type does not match index type. Need type '%s':%s, got '%s':%s", stream_name.c_str(), - zeek::type_name(idx->GetFieldType(j)->Tag()), desc1.Description(), - zeek::type_name(tl[j]->Tag()), desc2.Description()); + zeek::reporter->Error("Input stream %s: Table type does not match index type. Need type '%s':%s, got '%s':%s", + stream_name.c_str(), + zeek::type_name(idx->GetFieldType(j)->Tag()), desc1.Description(), + zeek::type_name(tl[j]->Tag()), desc2.Description()); return false; } @@ -510,7 +511,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( num != j ) { - reporter->Error("Input stream %s: Table has less elements than index definition", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Table has less elements than index definition", stream_name.c_str()); return false; } @@ -521,10 +522,10 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) { if ( destination_is_set ) { - reporter->Error("Input stream %s: 'destination' field is a set, " - "but the 'val' field was also specified " - "(did you mean to use a table instead of a set?)", - stream_name.data()); + zeek::reporter->Error("Input stream %s: 'destination' field is a set, " + "but the 'val' field was also specified " + "(did you mean to use a table instead of a set?)", + stream_name.data()); return false; } else @@ -538,8 +539,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) ODesc desc2; compare_type->Describe(&desc1); table_yield->Describe(&desc2); - reporter->Error("Input stream %s: Table type does not match value type. Need type '%s', got '%s'", - stream_name.c_str(), desc1.Description(), desc2.Description()); + zeek::reporter->Error("Input stream %s: Table type does not match value type. Need type '%s', got '%s'", + stream_name.c_str(), desc1.Description(), desc2.Description()); return false; } } @@ -548,10 +549,10 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) { if ( ! destination_is_set ) { - reporter->Error("Input stream %s: 'destination' field is a table," - " but 'val' field is not provided" - " (did you mean to use a set instead of a table?)", - stream_name.c_str()); + zeek::reporter->Error("Input stream %s: 'destination' field is a table," + " but 'val' field is not provided" + " (did you mean to use a set instead of a table?)", + stream_name.c_str()); return false; } } @@ -565,7 +566,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) { - reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); return false; } @@ -574,20 +575,22 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( args.size() != required_arg_count ) { - reporter->Error("Input stream %s: Table event must take %zu arguments", - stream_name.c_str(), required_arg_count); + zeek::reporter->Error("Input stream %s: Table event must take %zu arguments", + stream_name.c_str(), required_arg_count); return false; } if ( ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) ) { - reporter->Error("Input stream %s: Table event's first attribute must be of type Input::TableDescription", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Table event's first attribute must be of type Input::TableDescription", + stream_name.c_str()); return false; } if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) ) { - reporter->Error("Input stream %s: Table event's second attribute must be of type Input::Event", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Table event's second attribute must be of type Input::Event", + stream_name.c_str()); return false; } @@ -597,8 +600,9 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) ODesc desc2; idx->Describe(&desc1); args[2]->Describe(&desc2); - reporter->Error("Input stream %s: Table event's index attributes do not match. Need '%s', got '%s'", stream_name.c_str(), - desc1.Description(), desc2.Description()); + zeek::reporter->Error("Input stream %s: Table event's index attributes do not match. Need '%s', got '%s'", + stream_name.c_str(), + desc1.Description(), desc2.Description()); return false; } @@ -610,8 +614,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) ODesc desc2; val->Describe(&desc1); args[3]->Describe(&desc2); - reporter->Error("Input stream %s: Table event's value attributes do not match. Need '%s', got '%s'", - stream_name.c_str(), desc1.Description(), desc2.Description()); + zeek::reporter->Error("Input stream %s: Table event's value attributes do not match. Need '%s', got '%s'", + stream_name.c_str(), desc1.Description(), desc2.Description()); return false; } else if ( want_record->InternalInt() == 0 && @@ -621,13 +625,13 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) ODesc desc2; val->GetFieldType(0)->Describe(&desc1); args[3]->Describe(&desc2); - reporter->Error("Input stream %s: Table event's value attribute does not match. Need '%s', got '%s'", - stream_name.c_str(), desc1.Description(), desc2.Description()); + zeek::reporter->Error("Input stream %s: Table event's value attribute does not match. Need '%s', got '%s'", + stream_name.c_str(), desc1.Description(), desc2.Description()); return false; } else if ( ! val ) { - reporter->Error("Encountered a null value when creating a table stream"); + zeek::reporter->Error("Encountered a null value when creating a table stream"); } } @@ -653,7 +657,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( (valfields > 1) && (want_record->InternalInt() != 1) ) { - reporter->Error("Input stream %s: Stream does not want a record (want_record=F), but has more then one value field.", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Stream does not want a record (want_record=F), but has more then one value field.", + stream_name.c_str()); for ( auto& f : fieldsV ) delete f; return false; } @@ -663,7 +668,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( status ) { - reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); for ( auto& f : fieldsV ) delete f; return false; } @@ -717,7 +722,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const zeek::F if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) { - reporter->Error("Input stream %s: Error event is a function, not an event", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event is a function, not an event", stream_name.c_str()); return false; } @@ -725,31 +730,35 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const zeek::F if ( args.size() != 3 ) { - reporter->Error("Input stream %s: Error event must take 3 arguments", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event must take 3 arguments", stream_name.c_str()); return false; } if ( table && ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) ) { - reporter->Error("Input stream %s: Error event's first attribute must be of type Input::TableDescription", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event's first attribute must be of type Input::TableDescription", + stream_name.c_str()); return false; } if ( ! table && ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) ) { - reporter->Error("Input stream %s: Error event's first attribute must be of type Input::EventDescription", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event's first attribute must be of type Input::EventDescription", + stream_name.c_str()); return false; } if ( args[1]->Tag() != zeek::TYPE_STRING ) { - reporter->Error("Input stream %s: Error event's second attribute must be of type string", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event's second attribute must be of type string", + stream_name.c_str()); return false; } if ( ! same_type(args[2], zeek::BifType::Enum::Reporter::Level, false) ) { - reporter->Error("Input stream %s: Error event's third attribute must be of type Reporter::Level", stream_name.c_str()); + zeek::reporter->Error("Input stream %s: Error event's third attribute must be of type Reporter::Level", + stream_name.c_str()); return false; } @@ -762,7 +771,7 @@ bool Manager::CreateAnalysisStream(zeek::RecordVal* fval) if ( ! same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) { - reporter->Error("AnalysisDescription argument not of right type"); + zeek::reporter->Error("AnalysisDescription argument not of right type"); return false; } @@ -849,7 +858,7 @@ bool Manager::RemoveStream(Stream *i) if ( i->removed ) { - reporter->Warning("Stream %s is already queued for removal. Ignoring remove.", i->name.c_str()); + zeek::reporter->Warning("Stream %s is already queued for removal. Ignoring remove.", i->name.c_str()); return true; } @@ -881,7 +890,7 @@ bool Manager::RemoveStreamContinuation(ReaderFrontend* reader) if ( i == nullptr ) { - reporter->Error("Stream not found in RemoveStreamContinuation"); + zeek::reporter->Error("Stream not found in RemoveStreamContinuation"); return false; } @@ -915,13 +924,14 @@ bool Manager::UnrollRecordType(vector *fields, const zeek::RecordType *r rec->GetFieldType(i)->Tag() == zeek::TYPE_OPAQUE ) && rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) { - reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); + zeek::reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", + zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); continue; } } - reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend", - zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); + zeek::reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend", + zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); return false; } @@ -931,7 +941,7 @@ bool Manager::UnrollRecordType(vector *fields, const zeek::RecordType *r if ( rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) { - reporter->Info("The input framework does not support optional record fields: \"%s\"", rec->FieldName(i)); + zeek::reporter->Info("The input framework does not support optional record fields: \"%s\"", rec->FieldName(i)); return false; } @@ -986,13 +996,13 @@ bool Manager::ForceUpdate(const string &name) Stream *i = FindStream(name); if ( i == nullptr ) { - reporter->Error("Stream %s not found", name.c_str()); + zeek::reporter->Error("Stream %s not found", name.c_str()); return false; } if ( i->removed ) { - reporter->Error("Stream %s is already queued for removal. Ignoring force update.", name.c_str()); + zeek::reporter->Error("Stream %s is already queued for removal. Ignoring force update.", name.c_str()); return false; } @@ -1070,8 +1080,8 @@ void Manager::SendEntry(ReaderFrontend* reader, Value* *vals) Stream *i = FindStream(reader); if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in SendEntry", - reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in SendEntry", + reader->Name()); return; } @@ -1258,7 +1268,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) auto k = stream->tab->MakeHashKey(*idxval); if ( ! k ) - reporter->InternalError("could not hash"); + zeek::reporter->InternalError("could not hash"); InputHash* ih = new InputHash(); ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash()); @@ -1310,8 +1320,8 @@ void Manager::EndCurrentSend(ReaderFrontend* reader) if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in EndCurrentSend", - reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in EndCurrentSend", + reader->Name()); return; } @@ -1409,8 +1419,8 @@ void Manager::SendEndOfData(ReaderFrontend* reader) if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in SendEndOfData", - reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in SendEndOfData", + reader->Name()); return; } @@ -1436,7 +1446,7 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals) Stream *i = FindStream(reader); if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in Put", reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in Put", reader->Name()); return; } @@ -1664,8 +1674,8 @@ void Manager::Clear(ReaderFrontend* reader) Stream *i = FindStream(reader); if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in Clear", - reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in Clear", + reader->Name()); return; } @@ -1686,7 +1696,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals) Stream *i = FindStream(reader); if ( i == nullptr ) { - reporter->InternalWarning("Unknown reader %s in Delete", reader->Name()); + zeek::reporter->InternalWarning("Unknown reader %s in Delete", reader->Name()); return false; } @@ -1995,7 +2005,7 @@ int Manager::GetValueLength(const Value* val) const } default: - reporter->InternalError("unsupported type %d for GetValueLength", val->type); + zeek::reporter->InternalError("unsupported type %d for GetValueLength", val->type); } return length; @@ -2127,7 +2137,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const } default: - reporter->InternalError("unsupported type %d for CopyValue", val->type); + zeek::reporter->InternalError("unsupported type %d for CopyValue", val->type); return 0; } @@ -2189,7 +2199,7 @@ zeek::Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* re if ( request_type->Tag() != zeek::TYPE_ANY && request_type->Tag() != val->type ) { - reporter->InternalError("Typetags don't match: %d vs %d in stream %s", request_type->Tag(), val->type, i->name.c_str()); + zeek::reporter->InternalError("Typetags don't match: %d vs %d in stream %s", request_type->Tag(), val->type, i->name.c_str()); return nullptr; } @@ -2334,7 +2344,7 @@ zeek::Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* re } default: - reporter->InternalError("Unsupported type for input_read in stream %s", i->name.c_str()); + zeek::reporter->InternalError("Unsupported type for input_read in stream %s", i->name.c_str()); } assert(false); @@ -2381,7 +2391,7 @@ void Manager::Info(ReaderFrontend* reader, const char* msg) const Stream *i = FindStream(reader); if ( !i ) { - reporter->Error("Stream not found in Info; lost message: %s", msg); + zeek::reporter->Error("Stream not found in Info; lost message: %s", msg); return; } @@ -2393,7 +2403,7 @@ void Manager::Warning(ReaderFrontend* reader, const char* msg) const Stream *i = FindStream(reader); if ( !i ) { - reporter->Error("Stream not found in Warning; lost message: %s", msg); + zeek::reporter->Error("Stream not found in Warning; lost message: %s", msg); return; } @@ -2405,7 +2415,7 @@ void Manager::Error(ReaderFrontend* reader, const char* msg) const Stream *i = FindStream(reader); if ( !i ) { - reporter->Error("Stream not found in Error; lost message: %s", msg); + zeek::reporter->Error("Stream not found in Error; lost message: %s", msg); return; } @@ -2451,7 +2461,7 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co int n = vasprintf(&buf, fmt, ap); if ( n < 0 || buf == nullptr ) { - reporter->InternalError("Could not format error message %s for stream %s", fmt, i->name.c_str()); + zeek::reporter->InternalError("Could not format error message %s for stream %s", fmt, i->name.c_str()); return; } @@ -2474,7 +2484,7 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co break; default: - reporter->InternalError("Unknown error type while trying to report input error %s", fmt); + zeek::reporter->InternalError("Unknown error type while trying to report input error %s", fmt); __builtin_unreachable(); } @@ -2487,19 +2497,19 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co switch (et) { case ErrorType::INFO: - reporter->Info("%s", buf); + zeek::reporter->Info("%s", buf); break; case ErrorType::WARNING: - reporter->Warning("%s", buf); + zeek::reporter->Warning("%s", buf); break; case ErrorType::ERROR: - reporter->Error("%s", buf); + zeek::reporter->Error("%s", buf); break; default: - reporter->InternalError("Unknown error type while trying to report input error %s", fmt); + zeek::reporter->InternalError("Unknown error type while trying to report input error %s", fmt); } } diff --git a/src/input/ReaderFrontend.cc b/src/input/ReaderFrontend.cc index 17d3f6ff49..e25d92dfeb 100644 --- a/src/input/ReaderFrontend.cc +++ b/src/input/ReaderFrontend.cc @@ -69,7 +69,7 @@ void ReaderFrontend::Init(const int arg_num_fields, return; if ( initialized ) - reporter->InternalError("reader initialize twice"); + zeek::reporter->InternalError("reader initialize twice"); num_fields = arg_num_fields; fields = arg_fields; @@ -85,7 +85,7 @@ void ReaderFrontend::Update() if ( ! initialized ) { - reporter->Error("Tried to call update on uninitialized reader"); + zeek::reporter->Error("Tried to call update on uninitialized reader"); return; } diff --git a/src/input/readers/raw/Raw.cc b/src/input/readers/raw/Raw.cc index fb2a009bc1..3e29ac8908 100644 --- a/src/input/readers/raw/Raw.cc +++ b/src/input/readers/raw/Raw.cc @@ -108,7 +108,7 @@ std::unique_lock Raw::AcquireForkMutex() catch ( const std::system_error& e ) { - reporter->FatalErrorWithCore("cannot lock fork mutex: %s", e.what()); + zeek::reporter->FatalErrorWithCore("cannot lock fork mutex: %s", e.what()); } return lock; diff --git a/src/iosource/Component.cc b/src/iosource/Component.cc index 1fa8fbbc85..efcf13a4bc 100644 --- a/src/iosource/Component.cc +++ b/src/iosource/Component.cc @@ -102,7 +102,7 @@ void PktSrcComponent::DoDescribe(ODesc* d) const break; default: - reporter->InternalError("unknown PkrSrc type"); + zeek::reporter->InternalError("unknown PkrSrc type"); } } diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index a8f20ee43e..db4a636eb3 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -25,7 +25,7 @@ using namespace iosource; Manager::WakeupHandler::WakeupHandler() { if ( ! iosource_mgr->RegisterFd(flare.FD(), this) ) - reporter->FatalError("Failed to register WakeupHandler's fd with iosource_mgr"); + zeek::reporter->FatalError("Failed to register WakeupHandler's fd with iosource_mgr"); } Manager::WakeupHandler::~WakeupHandler() @@ -48,7 +48,7 @@ Manager::Manager() { event_queue = kqueue(); if ( event_queue == -1 ) - reporter->FatalError("Failed to initialize kqueue: %s", strerror(errno)); + zeek::reporter->FatalError("Failed to initialize kqueue: %s", strerror(errno)); } Manager::~Manager() @@ -195,7 +195,7 @@ void Manager::Poll(std::vector* ready, double timeout, IOSource* time // Ignore interrupts since we may catch one during shutdown and we don't want the // error to get printed. if ( errno != EINTR ) - reporter->InternalWarning("Error calling kevent: %s", strerror(errno)); + zeek::reporter->InternalWarning("Error calling kevent: %s", strerror(errno)); } else if ( ret == 0 ) { @@ -251,7 +251,7 @@ bool Manager::RegisterFd(int fd, IOSource* src) } else { - reporter->Error("Failed to register fd %d from %s: %s", fd, src->Tag(), strerror(errno)); + zeek::reporter->Error("Failed to register fd %d from %s: %s", fd, src->Tag(), strerror(errno)); return false; } } @@ -273,7 +273,7 @@ bool Manager::UnregisterFd(int fd, IOSource* src) } else { - reporter->Error("Attempted to unregister an unknown file descriptor %d from %s", fd, src->Tag()); + zeek::reporter->Error("Attempted to unregister an unknown file descriptor %d from %s", fd, src->Tag()); return false; } } @@ -364,7 +364,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live) if ( ! component ) - reporter->FatalError("type of packet source '%s' not recognized, or mode not supported", prefix.c_str()); + zeek::reporter->FatalError("type of packet source '%s' not recognized, or mode not supported", prefix.c_str()); // Instantiate packet source. @@ -399,7 +399,7 @@ PktDumper* Manager::OpenPktDumper(const std::string& path, bool append) } if ( ! component ) - reporter->FatalError("type of packet dumper '%s' not recognized", prefix.c_str()); + zeek::reporter->FatalError("type of packet dumper '%s' not recognized", prefix.c_str()); // Instantiate packet dumper. diff --git a/src/iosource/PktSrc.cc b/src/iosource/PktSrc.cc index 8c0432425b..60c3479a7f 100644 --- a/src/iosource/PktSrc.cc +++ b/src/iosource/PktSrc.cc @@ -120,7 +120,7 @@ void PktSrc::Opened(const Properties& arg_props) // data to read. if ( props.selectable_fd != -1 ) if ( ! iosource_mgr->RegisterFd(props.selectable_fd, this) ) - reporter->FatalError("Failed to register pktsrc fd with iosource_mgr"); + zeek::reporter->FatalError("Failed to register pktsrc fd with iosource_mgr"); } DBG_LOG(DBG_PKTIO, "Opened source %s", props.path.c_str()); @@ -148,7 +148,7 @@ void PktSrc::Error(const std::string& msg) void PktSrc::Info(const std::string& msg) { - reporter->Info("%s", msg.c_str()); + zeek::reporter->Info("%s", msg.c_str()); } void PktSrc::Weird(const std::string& msg, const Packet* p) @@ -158,7 +158,7 @@ void PktSrc::Weird(const std::string& msg, const Packet* p) void PktSrc::InternalError(const std::string& msg) { - reporter->InternalError("%s", msg.c_str()); + zeek::reporter->InternalError("%s", msg.c_str()); } void PktSrc::ContinueAfterSuspend() diff --git a/src/iosource/pcap/Source.cc b/src/iosource/pcap/Source.cc index a35e65b83a..3a811e56b1 100644 --- a/src/iosource/pcap/Source.cc +++ b/src/iosource/pcap/Source.cc @@ -210,11 +210,11 @@ bool PcapSource::ExtractNextPacket(Packet* pkt) case PCAP_ERROR: // -1 // Error occurred while reading the packet. if ( props.is_live ) - reporter->Error("failed to read a packet from %s: %s", - props.path.data(), pcap_geterr(pd)); + zeek::reporter->Error("failed to read a packet from %s: %s", + props.path.data(), pcap_geterr(pd)); else - reporter->FatalError("failed to read a packet from %s: %s", - props.path.data(), pcap_geterr(pd)); + zeek::reporter->FatalError("failed to read a packet from %s: %s", + props.path.data(), pcap_geterr(pd)); return false; case 0: // Read from live interface timed out (ok). @@ -223,7 +223,7 @@ bool PcapSource::ExtractNextPacket(Packet* pkt) // Read a packet without problem. break; default: - reporter->InternalError("unhandled pcap_next_ex return value: %d", res); + zeek::reporter->InternalError("unhandled pcap_next_ex return value: %d", res); return false; } diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 8183369243..1c53fa97a3 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -153,7 +153,7 @@ WriterBackend* Manager::CreateBackend(WriterFrontend* frontend, zeek::EnumVal* t if ( ! c ) { - reporter->Error("unknown writer type requested"); + zeek::reporter->Error("unknown writer type requested"); return nullptr; } @@ -237,7 +237,7 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) { if ( ! same_type(sval->GetType(), zeek::BifType::Record::Log::Stream, false) ) { - reporter->Error("sval argument not of right type"); + zeek::reporter->Error("sval argument not of right type"); return false; } @@ -253,8 +253,8 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) if ( ! threading::Value::IsCompatibleType(columns->GetFieldType(i).get()) ) { - reporter->Error("type of field '%s' is not support for logging output", - columns->FieldName(i)); + zeek::reporter->Error("type of field '%s' is not support for logging output", + columns->FieldName(i)); return false; } @@ -264,7 +264,7 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) if ( ! log_attr_present ) { - reporter->Error("logged record type does not have any &log attributes"); + zeek::reporter->Error("logged record type does not have any &log attributes"); return false; } @@ -278,7 +278,7 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) { - reporter->Error("stream event is a function, not an event"); + zeek::reporter->Error("stream event is a function, not an event"); return false; } @@ -286,13 +286,13 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval) if ( args.size() != 1 ) { - reporter->Error("stream event must take a single argument"); + zeek::reporter->Error("stream event must take a single argument"); return false; } if ( ! same_type(args[0], columns) ) { - reporter->Error("stream event's argument type does not match column record type"); + zeek::reporter->Error("stream event's argument type does not match column record type"); return false; } } @@ -474,7 +474,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, zeek::RecordType* r else { - reporter->Error("unsupported field type for log column"); + zeek::reporter->Error("unsupported field type for log column"); return false; } } @@ -508,7 +508,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, zeek::RecordType* r if ( ! tmp ) { - reporter->Error("out of memory in add_filter"); + zeek::reporter->Error("out of memory in add_filter"); return false; } @@ -535,7 +535,7 @@ bool Manager::AddFilter(zeek::EnumVal* id, zeek::RecordVal* fval) { if ( ! same_type(fval->GetType(), zeek::BifType::Record::Log::Filter, false) ) { - reporter->Error("filter argument not of right type"); + zeek::reporter->Error("filter argument not of right type"); return false; } @@ -597,8 +597,8 @@ bool Manager::AddFilter(zeek::EnumVal* id, zeek::RecordVal* fval) } else { - reporter->Error("Return value of log_ext is not a record (got %s)", - zeek::type_name(filter->ext_func->GetType()->Yield()->Tag())); + zeek::reporter->Error("Return value of log_ext is not a record (got %s)", + zeek::type_name(filter->ext_func->GetType()->Yield()->Tag())); delete filter; return false; } @@ -705,7 +705,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) if ( ! columns ) { - reporter->Error("incompatible log record type"); + zeek::reporter->Error("incompatible log record type"); return false; } @@ -761,7 +761,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) if ( v->GetType()->Tag() != zeek::TYPE_STRING ) { - reporter->Error("path_func did not return string"); + zeek::reporter->Error("path_func did not return string"); return false; } @@ -804,10 +804,11 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg) Unref(filter->path_val); filter->path_val = new zeek::StringVal(new_path.c_str()); - reporter->Warning("Write using filter '%s' on path '%s' changed to" - " use new path '%s' to avoid conflict with filter '%s'", - filter->name.c_str(), path.c_str(), new_path.c_str(), - instantiator.c_str()); + zeek::reporter->Warning( + "Write using filter '%s' on path '%s' changed to" + " use new path '%s' to avoid conflict with filter '%s'", + filter->name.c_str(), path.c_str(), new_path.c_str(), + instantiator.c_str()); path = filter->path = filter->path_val->AsString()->CheckString(); } @@ -1045,7 +1046,7 @@ threading::Value* Manager::ValToLogVal(zeek::Val* val, zeek::Type* ty) } default: - reporter->InternalError("unsupported type %s for log_write", zeek::type_name(lval->type)); + zeek::reporter->InternalError("unsupported type %s for log_write", zeek::type_name(lval->type)); } return lval; @@ -1199,8 +1200,8 @@ WriterFrontend* Manager::CreateWriter(zeek::EnumVal* id, zeek::EnumVal* writer, if ( func ) winfo->postprocessor = func.get(); else - reporter->Warning("failed log postprocessor function lookup: %s\n", - winfo->info->post_proc_func); + zeek::reporter->Warning("failed log postprocessor function lookup: %s\n", + winfo->info->post_proc_func); } } @@ -1484,7 +1485,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo) timer_mgr->Add(winfo->rotation_timer); DBG_LOG(DBG_LOGGING, "Scheduled rotation timer for %s to %.6f", - winfo->writer->Name(), winfo->rotation_timer->Time()); + winfo->writer->Name(), winfo->rotation_timer->Time()); } } @@ -1523,10 +1524,10 @@ std::string Manager::FormatRotationPath(zeek::EnumValPtr writer, if ( ! streq(dir, "") && ! ensure_intermediate_dirs(dir) ) { - reporter->Error("Failed to create dir '%s' returned by " - "Log::rotation_format_func for path %.*s: %s", - dir, static_cast(path.size()), path.data(), - strerror(errno)); + zeek::reporter->Error("Failed to create dir '%s' returned by " + "Log::rotation_format_func for path %.*s: %s", + dir, static_cast(path.size()), path.data(), + strerror(errno)); dir = ""; } @@ -1536,14 +1537,14 @@ std::string Manager::FormatRotationPath(zeek::EnumValPtr writer, rval = fmt("%s/%s", dir, prefix); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { auto rot_str = format_rotation_time_fallback((time_t)open); rval = fmt("%.*s-%s", static_cast(path.size()), path.data(), rot_str.data()); - reporter->Error("Failed to call Log::rotation_format_func for path %.*s " - "continuing with rotation to: ./%s", - static_cast(path.size()), path.data(), rval.data()); + zeek::reporter->Error("Failed to call Log::rotation_format_func for path %.*s " + "continuing with rotation to: ./%s", + static_cast(path.size()), path.data(), rval.data()); } return rval; diff --git a/src/logging/WriterFrontend.cc b/src/logging/WriterFrontend.cc index 15432117c3..60c432b07e 100644 --- a/src/logging/WriterFrontend.cc +++ b/src/logging/WriterFrontend.cc @@ -163,7 +163,7 @@ void WriterFrontend::Init(int arg_num_fields, const Field* const * arg_fields) return; if ( initialized ) - reporter->InternalError("writer initialize twice"); + zeek::reporter->InternalError("writer initialize twice"); num_fields = arg_num_fields; fields = arg_fields; @@ -201,7 +201,8 @@ void WriterFrontend::Write(int arg_num_fields, Value** vals) if ( arg_num_fields != num_fields ) { - reporter->Warning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.", name, num_fields, arg_num_fields); + zeek::reporter->Warning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.", + name, num_fields, arg_num_fields); DeleteVals(arg_num_fields, vals); return; } diff --git a/src/logging/writers/ascii/Ascii.cc b/src/logging/writers/ascii/Ascii.cc index 21c3751e36..bd38d3e520 100644 --- a/src/logging/writers/ascii/Ascii.cc +++ b/src/logging/writers/ascii/Ascii.cc @@ -724,8 +724,8 @@ static std::vector find_leftover_logs() if ( ll->error.empty() ) rval.emplace_back(std::move(*ll)); else - reporter->Error("failed to process leftover log '%s': %s", - log_name.data(), ll->error.data()); + zeek::reporter->Error("failed to process leftover log '%s': %s", + log_name.data(), ll->error.data()); } } else @@ -735,7 +735,7 @@ static std::vector find_leftover_logs() for ( const auto& f : stale_shadow_files ) if ( unlink(f.data()) != 0 ) - reporter->Error("cannot unlink %s: %s", f.data(), strerror(errno)); + zeek::reporter->Error("cannot unlink %s: %s", f.data(), strerror(errno)); closedir(d); return rval; @@ -777,10 +777,10 @@ void Ascii::RotateLeftoverLogs() if ( func ) ppf = std::move(func); else - reporter->Warning("Could not postprocess log '%s' with intended " - "postprocessor function '%s', proceeding " - " with the default function", - ll.filename.data(), ll.post_proc_func.data()); + zeek::reporter->Warning("Could not postprocess log '%s' with intended " + "postprocessor function '%s', proceeding " + " with the default function", + ll.filename.data(), ll.post_proc_func.data()); } auto rotation_path = log_mgr->FormatRotationPath( @@ -797,25 +797,25 @@ void Ascii::RotateLeftoverLogs() rot_info->Assign(5, zeek::val_mgr->False()); if ( rename(ll.filename.data(), rotation_path.data()) != 0 ) - reporter->FatalError("Found leftover/unprocessed log '%s', but " - "failed to rotate it: %s", - ll.filename.data(), strerror(errno)); + zeek::reporter->FatalError("Found leftover/unprocessed log '%s', but " + "failed to rotate it: %s", + ll.filename.data(), strerror(errno)); if ( ! ll.DeleteShadow() ) // Unusual failure to report, but not strictly fatal. - reporter->Warning("Failed to unlink %s: %s", - ll.shadow_filename.data(), strerror(errno)); + zeek::reporter->Warning("Failed to unlink %s: %s", + ll.shadow_filename.data(), strerror(errno)); try { ppf->Invoke(std::move(rot_info)); - reporter->Info("Rotated/postprocessed leftover log '%s' -> '%s' ", + zeek::reporter->Info("Rotated/postprocessed leftover log '%s' -> '%s' ", ll.filename.data(), rotation_path.data()); } - catch ( InterpreterException& e ) + catch ( zeek::InterpreterException& e ) { - reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", - ppf->Name(), ll.filename.data()); + zeek::reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", + ppf->Name(), ll.filename.data()); } } } diff --git a/src/parse.y b/src/parse.y index 7ef211e354..099e923140 100644 --- a/src/parse.y +++ b/src/parse.y @@ -146,7 +146,7 @@ static void parser_new_enum (void) if ( cur_decl_type_id ) cur_enum_type = new zeek::EnumType(cur_decl_type_id->Name()); else - reporter->FatalError("incorrect syntax for enum type declaration"); + zeek::reporter->FatalError("incorrect syntax for enum type declaration"); } static void parser_redef_enum (zeek::detail::ID *id) @@ -157,11 +157,11 @@ static void parser_redef_enum (zeek::detail::ID *id) // abort on errors; enums need to be accessible to continue parsing if ( ! id->GetType() ) - reporter->FatalError("unknown enum identifier \"%s\"", id->Name()); + zeek::reporter->FatalError("unknown enum identifier \"%s\"", id->Name()); else { if ( ! id->GetType() || id->GetType()->Tag() != zeek::TYPE_ENUM ) - reporter->FatalError("identifier \"%s\" is not an enum", id->Name()); + zeek::reporter->FatalError("identifier \"%s\" is not an enum", id->Name()); cur_enum_type = id->GetType()->AsEnumType(); } } @@ -458,9 +458,9 @@ expr: zeek::detail::set_location(@1, @3); if ( $1->Tag() == zeek::detail::EXPR_INDEX && $1->AsIndexExpr()->IsSlice() ) - reporter->Error("index slice assignment may not be used" - " in arbitrary expression contexts, only" - " as a statement"); + zeek::reporter->Error("index slice assignment may not be used" + " in arbitrary expression contexts, only" + " as a statement"); $$ = zeek::detail::get_assign_expr({zeek::AdoptRef{}, $1}, {zeek::AdoptRef{}, $3}, in_init).release(); } @@ -681,7 +681,7 @@ expr: else { if ( id->IsDeprecated() ) - reporter->Warning("%s", id->GetDeprecationWarning().c_str()); + zeek::reporter->Warning("%s", id->GetDeprecationWarning().c_str()); if ( ! id->GetType() ) { @@ -695,7 +695,7 @@ expr: zeek::EnumType* t = id->GetType()->AsEnumType(); auto intval = t->Lookup(id->ModuleName(), id->Name()); if ( intval < 0 ) - reporter->InternalError("enum value not found for %s", id->Name()); + zeek::reporter->InternalError("enum value not found for %s", id->Name()); $$ = new zeek::detail::ConstExpr(t->GetEnumVal(intval)); } else @@ -801,7 +801,7 @@ enum_body_elem: assert(cur_enum_type); if ( $3->GetType()->Tag() != zeek::TYPE_COUNT ) - reporter->Error("enumerator is not a count constant"); + zeek::reporter->Error("enumerator is not a count constant"); else cur_enum_type->AddName(zeek::detail::current_module, $1, $3->InternalUnsigned(), is_export, $4); @@ -813,7 +813,7 @@ enum_body_elem: error message if users triy to use a negative integer (will also catch other cases, but that's fine.) */ - reporter->Error("enumerator is not a count constant"); + zeek::reporter->Error("enumerator is not a count constant"); } | TOK_ID opt_deprecated @@ -920,7 +920,7 @@ type: | TOK_UNION '{' type_list '}' { zeek::detail::set_location(@1, @4); - reporter->Error("union type not implemented"); + zeek::reporter->Error("union type not implemented"); $$ = 0; } @@ -935,7 +935,7 @@ type: { zeek::detail::set_location(@1); // $$ = new TypeList(); - reporter->Error("list type not implemented"); + zeek::reporter->Error("list type not implemented"); $$ = 0; } @@ -943,7 +943,7 @@ type: { zeek::detail::set_location(@1); // $$ = new TypeList($3); - reporter->Error("list type not implemented"); + zeek::reporter->Error("list type not implemented"); $$ = 0; } @@ -1003,7 +1003,7 @@ type: Ref($$); if ( $1->IsDeprecated() ) - reporter->Warning("%s", $1->GetDeprecationWarning().c_str()); + zeek::reporter->Warning("%s", $1->GetDeprecationWarning().c_str()); } } ; @@ -1190,7 +1190,7 @@ func_hdr: if ( streq("bro_init", name) || streq("bro_done", name) || streq("bro_script_loaded", name) ) { auto base = std::string(name).substr(4); - reporter->Error("event %s() is no longer available, use zeek_%s() instead", name, base.c_str()); + zeek::reporter->Error("event %s() is no longer available, use zeek_%s() instead", name, base.c_str()); } begin_func({zeek::NewRef{}, $2}, zeek::detail::current_module.c_str(), @@ -1330,7 +1330,7 @@ index_slice: zeek::detail::ExprPtr{zeek::NewRef{}, $1}); if ( ! zeek::IsIntegral(low->GetType()->Tag()) || ! zeek::IsIntegral(high->GetType()->Tag()) ) - reporter->Error("slice notation must have integral values as indexes"); + zeek::reporter->Error("slice notation must have integral values as indexes"); auto le = zeek::make_intrusive(std::move(low)); le->Append(std::move(high)); @@ -1403,8 +1403,8 @@ attr: ODesc d; $3->Describe(&d); Unref($3); - reporter->Error("'&deprecated=%s' must use a string literal", - d.Description()); + zeek::reporter->Error("'&deprecated=%s' must use a string literal", + d.Description()); $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEPRECATED); } } @@ -1628,7 +1628,7 @@ event: } if ( id->IsDeprecated() ) - reporter->Warning("%s", id->GetDeprecationWarning().c_str()); + zeek::reporter->Warning("%s", id->GetDeprecationWarning().c_str()); } $$ = new zeek::detail::EventExpr($1, {zeek::AdoptRef{}, $3}); @@ -1840,7 +1840,7 @@ global_or_event_id: if ( t->Tag() != zeek::TYPE_FUNC || t->AsFuncType()->Flavor() != zeek::FUNC_FLAVOR_FUNCTION ) - reporter->Warning("%s", $$->GetDeprecationWarning().c_str()); + zeek::reporter->Warning("%s", $$->GetDeprecationWarning().c_str()); } delete [] $1; @@ -1867,7 +1867,7 @@ resolve_id: $$ = id.release(); if ( ! $$ ) - reporter->Error("identifier not defined: %s", $1); + zeek::reporter->Error("identifier not defined: %s", $1); delete [] $1; } @@ -1897,8 +1897,8 @@ opt_deprecated: { ODesc d; $3->Describe(&d); - reporter->Error("'&deprecated=%s' must use a string literal", - d.Description()); + zeek::reporter->Error("'&deprecated=%s' must use a string literal", + d.Description()); $$ = new zeek::detail::ConstExpr(zeek::make_intrusive("")); } } @@ -1913,22 +1913,22 @@ int yyerror(const char msg[]) g_curr_debug_error = copy_string(msg); if ( last_tok[0] == '\n' ) - reporter->Error("%s, on previous line", msg); + zeek::reporter->Error("%s, on previous line", msg); else if ( last_tok[0] == '\0' ) { if ( last_filename ) - reporter->Error("%s, at end of file %s", msg, last_filename); + zeek::reporter->Error("%s, at end of file %s", msg, last_filename); else - reporter->Error("%s, at end of file", msg); + zeek::reporter->Error("%s, at end of file", msg); } else { if ( last_last_tok_filename && last_tok_filename && ! streq(last_last_tok_filename, last_tok_filename) ) - reporter->Error("%s, at or near \"%s\" or end of file %s", - msg, last_tok, last_last_tok_filename); + zeek::reporter->Error("%s, at or near \"%s\" or end of file %s", + msg, last_tok, last_last_tok_filename); else - reporter->Error("%s, at or near \"%s\"", msg, last_tok); + zeek::reporter->Error("%s, at or near \"%s\"", msg, last_tok); } return 0; diff --git a/src/probabilistic/BloomFilter.cc b/src/probabilistic/BloomFilter.cc index f31762dcf4..1517801356 100644 --- a/src/probabilistic/BloomFilter.cc +++ b/src/probabilistic/BloomFilter.cc @@ -110,13 +110,13 @@ bool BasicBloomFilter::Merge(const BloomFilter* other) if ( ! hasher->Equals(o->hasher) ) { - reporter->Error("incompatible hashers in BasicBloomFilter merge"); + zeek::reporter->Error("incompatible hashers in BasicBloomFilter merge"); return false; } else if ( bits->Size() != o->bits->Size() ) { - reporter->Error("different bitvector size in BasicBloomFilter merge"); + zeek::reporter->Error("different bitvector size in BasicBloomFilter merge"); return false; } @@ -229,13 +229,13 @@ bool CountingBloomFilter::Merge(const BloomFilter* other) if ( ! hasher->Equals(o->hasher) ) { - reporter->Error("incompatible hashers in CountingBloomFilter merge"); + zeek::reporter->Error("incompatible hashers in CountingBloomFilter merge"); return false; } else if ( cells->Size() != o->cells->Size() ) { - reporter->Error("different bitvector size in CountingBloomFilter merge"); + zeek::reporter->Error("different bitvector size in CountingBloomFilter merge"); return false; } diff --git a/src/probabilistic/CardinalityCounter.cc b/src/probabilistic/CardinalityCounter.cc index dd058ba7a3..13bdc02e15 100644 --- a/src/probabilistic/CardinalityCounter.cc +++ b/src/probabilistic/CardinalityCounter.cc @@ -50,11 +50,11 @@ void CardinalityCounter::Init(uint64_t size) alpha_m = 0.7213 / (1 + 1.079 / m); else - reporter->InternalError("Invalid size %" PRIu64 ". Size either has to be 16, 32, 64 or bigger than 128", size); + zeek::reporter->InternalError("Invalid size %" PRIu64 ". Size either has to be 16, 32, 64 or bigger than 128", size); double calc_p = log2(m); if ( trunc(calc_p) != calc_p ) - reporter->InternalError("Invalid size %" PRIu64 ". Size either has to be a power of 2", size); + zeek::reporter->InternalError("Invalid size %" PRIu64 ". Size either has to be a power of 2", size); p = calc_p; diff --git a/src/probabilistic/Topk.cc b/src/probabilistic/Topk.cc index b09dafe54b..ce5b370ca4 100644 --- a/src/probabilistic/Topk.cc +++ b/src/probabilistic/Topk.cc @@ -87,7 +87,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune) { if ( ! same_type(type, value->type) ) { - reporter->Error("Cannot merge top-k elements of differing types."); + zeek::reporter->Error("Cannot merge top-k elements of differing types."); return; } } @@ -186,7 +186,7 @@ zeek::VectorValPtr TopkVal::GetTopK(int k) const // returns vector { if ( numElements == 0 ) { - reporter->Error("Cannot return topk of empty"); + zeek::reporter->Error("Cannot return topk of empty"); return nullptr; } @@ -228,7 +228,7 @@ uint64_t TopkVal::GetCount(Val* value) const if ( e == nullptr ) { - reporter->Error("GetCount for element that is not in top-k"); + zeek::reporter->Error("GetCount for element that is not in top-k"); return 0; } @@ -243,7 +243,7 @@ uint64_t TopkVal::GetEpsilon(Val* value) const if ( e == nullptr ) { - reporter->Error("GetEpsilon for element that is not in top-k"); + zeek::reporter->Error("GetEpsilon for element that is not in top-k"); return 0; } @@ -263,7 +263,7 @@ uint64_t TopkVal::GetSum() const } if ( pruned ) - reporter->Warning("TopkVal::GetSum() was used on a pruned data structure. Result values do not represent total element count"); + zeek::reporter->Warning("TopkVal::GetSum() was used on a pruned data structure. Result values do not represent total element count"); return sum; } @@ -277,7 +277,7 @@ void TopkVal::Encountered(zeek::ValPtr encountered) else if ( ! same_type(type, encountered->GetType()) ) { - reporter->Error("Trying to add element to topk with differing type from other elements"); + zeek::reporter->Error("Trying to add element to topk with differing type from other elements"); return; } diff --git a/src/re-parse.y b/src/re-parse.y index ad267bf6cc..d6529734f1 100644 --- a/src/re-parse.y +++ b/src/re-parse.y @@ -140,8 +140,8 @@ singleton : singleton '*' if ( sym < 0 || ( sym >= NUM_SYM && sym != SYM_EPSILON ) ) { - reporter->Error("bad symbol %d (compiling pattern /%s/)", sym, - zeek::detail::RE_parse_input); + zeek::reporter->Error("bad symbol %d (compiling pattern /%s/)", sym, + zeek::detail::RE_parse_input); return 1; } @@ -257,7 +257,7 @@ int clower(int sym) void synerr(const char str[]) { syntax_error = true; - reporter->Error("%s (compiling pattern /%s/)", str, RE_parse_input); + zeek::reporter->Error("%s (compiling pattern /%s/)", str, RE_parse_input); } } // namespace zeek::detail diff --git a/src/rule-parse.y b/src/rule-parse.y index 8bc5a8948c..eb79250bf5 100644 --- a/src/rule-parse.y +++ b/src/rule-parse.y @@ -207,7 +207,7 @@ rule_attr: | TOK_PATTERN_TYPE '[' rangeopt ']' pattern { if ( $3.offset > 0 ) - reporter->Warning("Offsets are currently ignored for patterns"); + zeek::reporter->Warning("Offsets are currently ignored for patterns"); current_rule->AddPattern($5, $1, 0, $3.len); } @@ -428,23 +428,23 @@ pattern: void rules_error(const char* msg) { - reporter->Error("Error in signature (%s:%d): %s\n", - current_rule_file, rules_line_number+1, msg); + zeek::reporter->Error("Error in signature (%s:%d): %s\n", + current_rule_file, rules_line_number+1, msg); zeek::detail::rule_matcher->SetParseError(); } void rules_error(const char* msg, const char* addl) { - reporter->Error("Error in signature (%s:%d): %s (%s)\n", - current_rule_file, rules_line_number+1, msg, addl); + zeek::reporter->Error("Error in signature (%s:%d): %s (%s)\n", + current_rule_file, rules_line_number+1, msg, addl); zeek::detail::rule_matcher->SetParseError(); } void rules_error(zeek::detail::Rule* r, const char* msg) { const zeek::detail::Location& l = r->GetLocation(); - reporter->Error("Error in signature %s (%s:%d): %s\n", - r->ID(), l.filename, l.first_line, msg); + zeek::reporter->Error("Error in signature %s (%s:%d): %s\n", + r->ID(), l.filename, l.first_line, msg); zeek::detail::rule_matcher->SetParseError(); } diff --git a/src/scan.l b/src/scan.l index 03aa5ad712..a9ae381404 100644 --- a/src/scan.l +++ b/src/scan.l @@ -68,11 +68,11 @@ char last_tok[128]; // a read fails. #define YY_INPUT(buf,result,max_size) \ if ( ((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin) ) \ - reporter->Error("read failed with \"%s\"", strerror(errno)); + zeek::reporter->Error("read failed with \"%s\"", strerror(errno)); static void deprecated_attr(const char* attr) { - reporter->Warning("Use of deprecated attribute: %s", attr); + zeek::reporter->Warning("Use of deprecated attribute: %s", attr); } static std::string find_relative_file(const std::string& filename, const std::string& ext) @@ -297,13 +297,13 @@ when return TOK_WHEN; auto lf = file_stack[num_files - 1]; if ( lf->name ) - reporter->Warning("deprecated script loaded from %s:%d %s", + zeek::reporter->Warning("deprecated script loaded from %s:%d %s", lf->name, lf->line, comment); else - reporter->Warning("deprecated script loaded from command line arguments %s", comment); + zeek::reporter->Warning("deprecated script loaded from command line arguments %s", comment); } else - reporter->Warning("deprecated script loaded %s", comment); + zeek::reporter->Warning("deprecated script loaded %s", comment); } @DEBUG return TOK_DEBUG; // marks input for debugger @@ -316,7 +316,7 @@ when return TOK_WHEN; char path[MAXPATHLEN]; if ( ! getcwd(path, MAXPATHLEN) ) - reporter->InternalError("getcwd failed: %s", strerror(errno)); + zeek::reporter->InternalError("getcwd failed: %s", strerror(errno)); else rval = std::string(path) + "/" + rval; } @@ -345,15 +345,15 @@ when return TOK_WHEN; case -1: // No plugin in charge of this file. if ( path.empty() ) - reporter->Error("failed to find file associated with @load-sigs %s", - file); + zeek::reporter->Error("failed to find file associated with @load-sigs %s", + file); else sig_files.push_back(copy_string(path.c_str())); break; case 0: - if ( ! reporter->Errors() ) - reporter->Error("Plugin reported error loading signatures %s", file); + if ( ! zeek::reporter->Errors() ) + zeek::reporter->Error("Plugin reported error loading signatures %s", file); exit(1); break; @@ -379,8 +379,8 @@ when return TOK_WHEN; break; case 0: - if ( ! reporter->Errors() ) - reporter->Error("Plugin reported error loading plugin %s", plugin); + if ( ! zeek::reporter->Errors() ) + zeek::reporter->Error("Plugin reported error loading plugin %s", plugin); exit(1); break; @@ -401,7 +401,7 @@ when return TOK_WHEN; std::string path = find_relative_script_file(file); if ( path.empty() ) - reporter->Error("failed find file associated with @unload %s", file); + zeek::reporter->Error("failed find file associated with @unload %s", file); else { // All we have to do is pretend we've already scanned it. @@ -460,7 +460,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) uint32_t p = atoi(yytext); if ( p > 65535 ) { - reporter->Error("bad port number - %s", yytext); + zeek::reporter->Error("bad port number - %s", yytext); p = 0; } RET_CONST(zeek::val_mgr->Port(p, TRANSPORT_TCP)->Ref()) @@ -469,7 +469,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) uint32_t p = atoi(yytext); if ( p > 65535 ) { - reporter->Error("bad port number - %s", yytext); + zeek::reporter->Error("bad port number - %s", yytext); p = 0; } RET_CONST(zeek::val_mgr->Port(p, TRANSPORT_UDP)->Ref()) @@ -478,7 +478,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) uint32_t p = atoi(yytext); if ( p > 255 ) { - reporter->Error("bad port number - %s", yytext); + zeek::reporter->Error("bad port number - %s", yytext); p = 0; } RET_CONST(zeek::val_mgr->Port(p, TRANSPORT_ICMP)->Ref()) @@ -487,7 +487,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) uint32_t p = atoi(yytext); if ( p > 255 ) { - reporter->Error("bad port number - %s", yytext); + zeek::reporter->Error("bad port number - %s", yytext); p = 0; } RET_CONST(zeek::val_mgr->Port(p, TRANSPORT_UNKNOWN)->Ref()) @@ -524,13 +524,13 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) { s[i++] = *text; if ( i >= len ) - reporter->InternalError("bad string length computation"); + zeek::reporter->InternalError("bad string length computation"); } } // Get rid of trailing quote. if ( s[i-1] != '"' ) - reporter->InternalError("string scanning confused"); + zeek::reporter->InternalError("string scanning confused"); s[i-1] = '\0'; @@ -556,7 +556,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) [\\\n] return yytext[0]; // should cause a parse error -<*>. reporter->Error("unrecognized character - %s", yytext); +<*>. zeek::reporter->Error("unrecognized character - %s", yytext); <> last_tok[0] = '\0'; return EOF; @@ -584,11 +584,11 @@ static int load_files(const char* orig_file) if ( rc == 0 ) { - if ( ! reporter->Errors() ) + if ( ! zeek::reporter->Errors() ) // This is just in case the plugin failed to report // the error itself, in which case we want to at // least tell the user that something went wrong. - reporter->Error("Plugin reported error loading %s", orig_file); + zeek::reporter->Error("Plugin reported error loading %s", orig_file); exit(1); } @@ -612,7 +612,7 @@ static int load_files(const char* orig_file) else { if ( file_path.empty() ) - reporter->FatalError("can't find %s", orig_file); + zeek::reporter->FatalError("can't find %s", orig_file); if ( is_dir(file_path.c_str()) ) f = open_package(file_path); @@ -620,7 +620,7 @@ static int load_files(const char* orig_file) f = open_file(file_path); if ( ! f ) - reporter->FatalError("can't open %s", file_path.c_str()); + zeek::reporter->FatalError("can't open %s", file_path.c_str()); } ScannedFile sf(file_stack.length(), file_path); @@ -750,7 +750,7 @@ void do_atifndef(const char *id) void do_atelse() { if ( current_depth == 0 ) - reporter->Error("@else without @if..."); + zeek::reporter->Error("@else without @if..."); if ( ! if_stack.empty() && current_depth > if_stack.back() ) return; @@ -770,7 +770,7 @@ void do_atelse() void do_atendif() { if ( current_depth == 0 ) - reporter->Error("unbalanced @if... @endif"); + zeek::reporter->Error("unbalanced @if... @endif"); if ( current_depth == if_stack.back() ) { @@ -790,7 +790,7 @@ static zeek::name_list essential_input_files; void add_essential_input_file(const char* file) { if ( ! file ) - reporter->InternalError("empty filename"); + zeek::reporter->InternalError("empty filename"); if ( ! filename ) (void) load_files(file); @@ -801,7 +801,7 @@ void add_essential_input_file(const char* file) void add_input_file(const char* file) { if ( ! file ) - reporter->InternalError("empty filename"); + zeek::reporter->InternalError("empty filename"); if ( ! filename ) (void) load_files(file); @@ -812,7 +812,7 @@ void add_input_file(const char* file) void add_input_file_at_front(const char* file) { if ( ! file ) - reporter->InternalError("empty filename"); + zeek::reporter->InternalError("empty filename"); if ( ! filename ) (void) load_files(file); @@ -841,7 +841,7 @@ int yywrap() { last_filename = ::filename; - if ( reporter->Errors() > 0 ) + if ( zeek::reporter->Errors() > 0 ) return 1; if ( ! did_builtin_init && file_stack.length() == 1 ) @@ -947,8 +947,8 @@ int yywrap() if ( ! id ) { - reporter->Error("unknown identifier '%s' in command-line options", - id_str.data()); + zeek::reporter->Error("unknown identifier '%s' in command-line options", + id_str.data()); continue; } @@ -958,15 +958,15 @@ int yywrap() if ( ! type ) { - reporter->Error("can't set value of '%s' in command-line " - "options: unknown type", id_str.data()); + zeek::reporter->Error("can't set value of '%s' in command-line " + "options: unknown type", id_str.data()); continue; } if ( val_str.empty() && ! zeek::IsString(type->Tag()) ) { - reporter->Error("must assign non-empty value to '%s' in " - "command-line options", id_str.data()); + zeek::reporter->Error("must assign non-empty value to '%s' in " + "command-line options", id_str.data()); continue; } @@ -1046,8 +1046,8 @@ ScannedFile::ScannedFile(int arg_include_level, auto res = realpath(name.data(), buf); if ( ! res ) - reporter->FatalError("failed to get realpath() of %s: %s", - name.data(), strerror(errno)); + zeek::reporter->FatalError("failed to get realpath() of %s: %s", + name.data(), strerror(errno)); canonical_path = res; } diff --git a/src/strings.bif b/src/strings.bif index 6fbb37084d..cdafe1ef16 100644 --- a/src/strings.bif +++ b/src/strings.bif @@ -251,7 +251,7 @@ static zeek::VectorValPtr do_split_string(zeek::StringVal* str_val, s += offset + end_of_match;; if ( s > end_of_s ) - reporter->InternalError("RegMatch in split goes beyond the string"); + zeek::reporter->InternalError("RegMatch in split goes beyond the string"); } return rval; @@ -308,7 +308,7 @@ zeek::Val* do_split(zeek::StringVal* str_val, zeek::RE_Matcher* re, int incl_sep s += offset + end_of_match;; if ( s > end_of_s ) - reporter->InternalError("RegMatch in split goes beyond the string"); + zeek::reporter->InternalError("RegMatch in split goes beyond the string"); } return a; diff --git a/src/threading/BasicThread.cc b/src/threading/BasicThread.cc index c447051bab..0c7a6ead3b 100644 --- a/src/threading/BasicThread.cc +++ b/src/threading/BasicThread.cc @@ -142,7 +142,7 @@ void BasicThread::Join() } catch ( const std::system_error& e ) { - reporter->FatalError("Failure joining thread %s with error %s", name, e.what()); + zeek::reporter->FatalError("Failure joining thread %s with error %s", name, e.what()); } DBG_LOG(DBG_THREADING, "Joined with thread %s", name); diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index 416716d02c..ce2fd83f93 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -138,7 +138,7 @@ bool Manager::SendEvent(MsgThread* thread, const std::string& name, const int nu EventHandler* handler = event_registry->Lookup(name); if ( handler == nullptr ) { - reporter->Warning("Thread %s: Event %s not found", thread->Name(), name.c_str()); + zeek::reporter->Warning("Thread %s: Event %s not found", thread->Name(), name.c_str()); Value::delete_value_ptr_array(vals, num_vals); return false; } @@ -152,7 +152,7 @@ bool Manager::SendEvent(MsgThread* thread, const std::string& name, const int nu int num_event_vals = type->NumFields(); if ( num_vals != num_event_vals ) { - reporter->Warning("Thread %s: Wrong number of values for event %s", thread->Name(), name.c_str()); + zeek::reporter->Warning("Thread %s: Wrong number of values for event %s", thread->Name(), name.c_str()); Value::delete_value_ptr_array(vals, num_vals); return false; } @@ -216,7 +216,7 @@ void Manager::Flush() else { - reporter->Error("%s failed, terminating thread", msg->Name()); + zeek::reporter->Error("%s failed, terminating thread", msg->Name()); t->SignalStop(); } diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index f1fd2897d2..4f22dbe162 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -140,7 +140,7 @@ public: bool success = thread_mgr->SendEvent(Object(), name, num_vals, val); if ( ! success ) - reporter->Error("SendEvent for event %s failed", name); + zeek::reporter->Error("SendEvent for event %s failed", name); return true; // We do not want to die if sendEvent fails because the event did not return. } @@ -163,35 +163,35 @@ bool ReporterMessage::Process() switch ( type ) { case INFO: - reporter->Info("%s: %s", Object()->Name(), msg); + zeek::reporter->Info("%s: %s", Object()->Name(), msg); break; case WARNING: - reporter->Warning("%s: %s", Object()->Name(), msg); + zeek::reporter->Warning("%s: %s", Object()->Name(), msg); break; case ERROR: - reporter->Error("%s: %s", Object()->Name(), msg); + zeek::reporter->Error("%s: %s", Object()->Name(), msg); break; case FATAL_ERROR: - reporter->FatalError("%s: %s", Object()->Name(), msg); + zeek::reporter->FatalError("%s: %s", Object()->Name(), msg); break; case FATAL_ERROR_WITH_CORE: - reporter->FatalErrorWithCore("%s: %s", Object()->Name(), msg); + zeek::reporter->FatalErrorWithCore("%s: %s", Object()->Name(), msg); break; case INTERNAL_WARNING: - reporter->InternalWarning("%s: %s", Object()->Name(), msg); + zeek::reporter->InternalWarning("%s: %s", Object()->Name(), msg); break; case INTERNAL_ERROR : - reporter->InternalError("%s: %s", Object()->Name(), msg); + zeek::reporter->InternalError("%s: %s", Object()->Name(), msg); break; default: - reporter->InternalError("unknown ReporterMessage type %d", type); + zeek::reporter->InternalError("unknown ReporterMessage type %d", type); } return true; @@ -207,7 +207,7 @@ MsgThread::MsgThread() : BasicThread(), queue_in(this, nullptr), queue_out(nullp thread_mgr->AddMsgThread(this); if ( ! iosource_mgr->RegisterFd(flare.FD(), this) ) - reporter->FatalError("Failed to register MsgThread fd with iosource_mgr"); + zeek::reporter->FatalError("Failed to register MsgThread fd with iosource_mgr"); SetClosed(false); } @@ -276,7 +276,7 @@ void MsgThread::OnWaitForStop() assert ( msg ); if ( ! msg->Process() ) - reporter->Error("%s failed during thread termination", msg->Name()); + zeek::reporter->Error("%s failed during thread termination", msg->Name()); delete msg; } @@ -476,7 +476,7 @@ void MsgThread::Process() if ( ! msg->Process() ) { - reporter->Error("%s failed, terminating thread", msg->Name()); + zeek::reporter->Error("%s failed, terminating thread", msg->Name()); SignalStop(); } diff --git a/src/threading/Queue.h b/src/threading/Queue.h index ad59f15268..1840540ac6 100644 --- a/src/threading/Queue.h +++ b/src/threading/Queue.h @@ -127,7 +127,7 @@ inline static std::unique_lock acquire_lock(std::mutex& m) } catch ( const std::system_error& e ) { - reporter->FatalErrorWithCore("cannot lock mutex: %s", e.what()); + zeek::reporter->FatalErrorWithCore("cannot lock mutex: %s", e.what()); // Never gets here. throw std::exception(); } @@ -218,7 +218,7 @@ inline std::vector> Queue::LocksForAllQueues() catch ( const std::system_error& e ) { - reporter->FatalErrorWithCore("cannot lock all mutexes: %s", e.what()); + zeek::reporter->FatalErrorWithCore("cannot lock all mutexes: %s", e.what()); // Never gets here. throw std::exception(); } diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index 6ce90bc121..1711c4f320 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -316,8 +316,8 @@ bool Value::Read(SerializationFormat* fmt) } default: - reporter->InternalError("unsupported type %s in Value::Read", - zeek::type_name(type)); + zeek::reporter->InternalError("unsupported type %s in Value::Read", + zeek::type_name(type)); } return false; @@ -420,8 +420,8 @@ bool Value::Write(SerializationFormat* fmt) const } default: - reporter->InternalError("unsupported type %s in Value::Write", - zeek::type_name(type)); + zeek::reporter->InternalError("unsupported type %s in Value::Write", + zeek::type_name(type)); } // unreachable @@ -546,8 +546,8 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool& if ( ! enum_id ) { - reporter->Warning("Value '%s' of source '%s' is not a valid enum.", - enum_name.data(), source.c_str()); + zeek::reporter->Warning("Value '%s' of source '%s' is not a valid enum.", + enum_name.data(), source.c_str()); have_error = true; return nullptr; @@ -611,8 +611,8 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool& if ( ! id || ! id->IsEnumConst() ) { - reporter->Warning("Value '%s' for source '%s' is not a valid enum.", - enum_string.c_str(), source.c_str()); + zeek::reporter->Warning("Value '%s' for source '%s' is not a valid enum.", + enum_string.c_str(), source.c_str()); have_error = true; return nullptr; @@ -622,8 +622,8 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool& int intval = t->Lookup(id->ModuleName(), id->Name()); if ( intval < 0 ) { - reporter->Warning("Enum value '%s' for source '%s' not found.", - enum_string.c_str(), source.c_str()); + zeek::reporter->Warning("Enum value '%s' for source '%s' not found.", + enum_string.c_str(), source.c_str()); have_error = true; return nullptr; @@ -634,7 +634,7 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool& } default: - reporter->InternalError("Unsupported type in SerialTypes::ValueToVal from source %s", source.c_str()); + zeek::reporter->InternalError("Unsupported type in SerialTypes::ValueToVal from source %s", source.c_str()); } assert(false); diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index c44c1d5cf4..f7ee529829 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -201,7 +201,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na } default: - reporter->Warning("Unhandled type in JSON::BuildJSON"); + zeek::reporter->Warning("Unhandled type in JSON::BuildJSON"); break; } } diff --git a/src/util.cc b/src/util.cc index 61fe2df55d..ce1ff6f6ab 100644 --- a/src/util.cc +++ b/src/util.cc @@ -343,7 +343,7 @@ int expand_escape(const char*& s) if ( result < 0 ) { - reporter->Error("bad octal escape: %s", start); + zeek::reporter->Error("bad octal escape: %s", start); return 0; } @@ -378,7 +378,7 @@ int expand_escape(const char*& s) if ( result < 0 ) { - reporter->Error("bad hexadecimal escape: %s", start); + zeek::reporter->Error("bad hexadecimal escape: %s", start); return 0; } @@ -538,7 +538,7 @@ unsigned char encode_hex(int h) if ( h < 0 || h > 15 ) { - reporter->InternalWarning("illegal value for encode_hex: %d", h); + zeek::reporter->InternalWarning("illegal value for encode_hex: %d", h); return 'X'; } @@ -842,7 +842,7 @@ const char* vfmt(const char* format, va_list al) n = vsnprintf(buf, buf_len, format, alc); if ( (unsigned int) n >= buf_len ) - reporter->InternalError("confusion reformatting in fmt()"); + zeek::reporter->InternalError("confusion reformatting in fmt()"); } va_end(alc); @@ -866,7 +866,7 @@ const char* fmt_access_time(double t) if ( ! localtime_r(&time, &ts) ) { - reporter->InternalError("unable to get time"); + zeek::reporter->InternalError("unable to get time"); } strftime(buf, sizeof(buf), "%d/%m-%H:%M", &ts); @@ -911,15 +911,15 @@ bool ensure_dir(const char *dirname) { // Show the original failure reason for mkdir() since nothing's there // or we can't even tell what is now. - reporter->Warning("can't create directory %s: %s", - dirname, strerror(mkdir_errno)); + zeek::reporter->Warning("can't create directory %s: %s", + dirname, strerror(mkdir_errno)); return false; } if ( S_ISDIR(st.st_mode) ) return true; - reporter->Warning("%s exists but is not a directory", dirname); + zeek::reporter->Warning("%s exists but is not a directory", dirname); return false; } @@ -929,7 +929,7 @@ bool is_dir(const std::string& path) if ( stat(path.c_str(), &st) < 0 ) { if ( errno != ENOENT ) - reporter->Warning("can't stat %s: %s", path.c_str(), strerror(errno)); + zeek::reporter->Warning("can't stat %s: %s", path.c_str(), strerror(errno)); return false; } @@ -943,7 +943,7 @@ bool is_file(const std::string& path) if ( stat(path.c_str(), &st) < 0 ) { if ( errno != ENOENT ) - reporter->Warning("can't stat %s: %s", path.c_str(), strerror(errno)); + zeek::reporter->Warning("can't stat %s: %s", path.c_str(), strerror(errno)); return false; } @@ -998,7 +998,7 @@ std::string strstrip(std::string s) void hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16]) { if ( ! KeyedHash::seeds_initialized ) - reporter->InternalError("HMAC-MD5 invoked before the HMAC key is set"); + zeek::reporter->InternalError("HMAC-MD5 invoked before the HMAC key is set"); internal_md5(bytes, size, digest); @@ -1015,8 +1015,8 @@ static bool read_random_seeds(const char* read_file, uint32_t* seed, if ( ! (f = fopen(read_file, "r")) ) { - reporter->Warning("Could not open seed file '%s': %s", - read_file, strerror(errno)); + zeek::reporter->Warning("Could not open seed file '%s': %s", + read_file, strerror(errno)); return false; } @@ -1051,8 +1051,8 @@ static bool write_random_seeds(const char* write_file, uint32_t seed, if ( ! (f = fopen(write_file, "w+")) ) { - reporter->Warning("Could not create seed file '%s': %s", - write_file, strerror(errno)); + zeek::reporter->Warning("Could not create seed file '%s': %s", + write_file, strerror(errno)); return false; } @@ -1102,8 +1102,8 @@ void init_random_seed(const char* read_file, const char* write_file, if ( read_file ) { if ( ! read_random_seeds(read_file, &seed, buf) ) - reporter->FatalError("Could not load seeds from file '%s'.\n", - read_file); + zeek::reporter->FatalError("Could not load seeds from file '%s'.\n", + read_file); else seeds_done = true; } @@ -1148,7 +1148,7 @@ void init_random_seed(const char* read_file, const char* write_file, #endif if ( pos < KeyedHash::SEED_INIT_SIZE ) - reporter->FatalError("Could not read enough random data. Wanted %d, got %lu", KeyedHash::SEED_INIT_SIZE, pos); + zeek::reporter->FatalError("Could not read enough random data. Wanted %d, got %lu", KeyedHash::SEED_INIT_SIZE, pos); if ( ! seed ) { @@ -1174,8 +1174,8 @@ void init_random_seed(const char* read_file, const char* write_file, KeyedHash::InitializeSeeds(buf); if ( write_file && ! write_random_seeds(write_file, seed, buf) ) - reporter->Error("Could not write seeds to file '%s'.\n", - write_file); + zeek::reporter->Error("Could not write seeds to file '%s'.\n", + write_file); } unsigned int initial_seed() @@ -1335,7 +1335,7 @@ void warn_if_legacy_script(std::string_view filename) if ( ends_with(filename, ".bro") ) { std::string x(filename); - reporter->Warning("Loading script '%s' with legacy extension, support for '.bro' will be removed in Zeek v4.1", x.c_str()); + zeek::reporter->Warning("Loading script '%s' with legacy extension, support for '.bro' will be removed in Zeek v4.1", x.c_str()); } } @@ -1366,7 +1366,7 @@ FILE* open_file(const string& path, const string& mode) { char buf[256]; bro_strerror_r(errno, buf, sizeof(buf)); - reporter->Error("Failed to open file %s: %s", filename, buf); + zeek::reporter->Error("Failed to open file %s: %s", filename, buf); } return rval; @@ -1395,8 +1395,8 @@ FILE* open_package(string& path, const string& mode) path.append(script_extensions[0]); string package_loader = "__load__" + script_extensions[0]; - reporter->Error("Failed to open package '%s': missing '%s' file", - arg_path.c_str(), package_loader.c_str()); + zeek::reporter->Error("Failed to open package '%s': missing '%s' file", + arg_path.c_str(), package_loader.c_str()); return nullptr; } @@ -1437,8 +1437,8 @@ void SafePathOp::CheckValid(const char* op_result, const char* path, else { if ( error_aborts ) - reporter->InternalError("Path operation failed on %s: %s", - path ? path : "", strerror(errno)); + zeek::reporter->InternalError("Path operation failed on %s: %s", + path ? path : "", strerror(errno)); else error = true; } @@ -1861,7 +1861,7 @@ FILE* rotate_file(const char* name, zeek::RecordVal* rotate_info) FILE* newf = fopen(tmpname, "w"); if ( ! newf ) { - reporter->Error("rotate_file: can't open %s: %s", tmpname, strerror(errno)); + zeek::reporter->Error("rotate_file: can't open %s: %s", tmpname, strerror(errno)); return nullptr; } @@ -1870,7 +1870,7 @@ FILE* rotate_file(const char* name, zeek::RecordVal* rotate_info) struct stat dummy; if ( link(name, newname) < 0 || stat(newname, &dummy) < 0 ) { - reporter->Error("rotate_file: can't move %s to %s: %s", name, newname, strerror(errno)); + zeek::reporter->Error("rotate_file: can't move %s to %s: %s", name, newname, strerror(errno)); fclose(newf); unlink(newname); unlink(tmpname); @@ -1880,7 +1880,7 @@ FILE* rotate_file(const char* name, zeek::RecordVal* rotate_info) // Close current file, and move the tmp to its place. if ( unlink(name) < 0 || link(tmpname, name) < 0 || unlink(tmpname) < 0 ) { - reporter->Error("rotate_file: can't move %s to %s: %s", tmpname, name, strerror(errno)); + zeek::reporter->Error("rotate_file: can't move %s to %s: %s", tmpname, name, strerror(errno)); exit(1); // hard to fix, but shouldn't happen anyway... } @@ -1910,7 +1910,7 @@ double parse_rotate_base_time(const char* rotate_base_time) { struct tm t; if ( ! strptime(rotate_base_time, "%H:%M", &t) ) - reporter->Error("calc_next_rotate(): can't parse rotation base time"); + zeek::reporter->Error("calc_next_rotate(): can't parse rotation base time"); else base = t.tm_min * 60 + t.tm_hour * 60 * 60; } @@ -1922,7 +1922,7 @@ double calc_next_rotate(double current, double interval, double base) { if ( ! interval ) { - reporter->Error("calc_next_rotate(): interval is zero, falling back to 24hrs"); + zeek::reporter->Error("calc_next_rotate(): interval is zero, falling back to 24hrs"); interval = 86400; } @@ -1932,7 +1932,7 @@ double calc_next_rotate(double current, double interval, double base) struct tm t; if ( ! localtime_r(&teatime, &t) ) { - reporter->Error("calc_next_rotate(): failure processing current time (%.6f)", current); + zeek::reporter->Error("calc_next_rotate(): failure processing current time (%.6f)", current); // fall back to the method used if no base time is given base = -1; @@ -1980,12 +1980,12 @@ void set_processing_status(const char* status, const char* reason) { char buf[256]; bro_strerror_r(errno, buf, sizeof(buf)); - if ( reporter ) - reporter->Error("Failed to open process status file '%s': %s", - proc_status_file, buf); + if ( zeek::reporter ) + zeek::reporter->Error("Failed to open process status file '%s': %s", + proc_status_file, buf); else fprintf(stderr, "Failed to open process status file '%s': %s\n", - proc_status_file, buf); + proc_status_file, buf); errno = old_errno; return; } @@ -2020,7 +2020,7 @@ double current_time(bool real) { struct timeval tv; if ( gettimeofday(&tv, 0) < 0 ) - reporter->InternalError("gettimeofday failed in current_time()"); + zeek::reporter->InternalError("gettimeofday failed in current_time()"); double t = double(tv.tv_sec) + double(tv.tv_usec) / 1e6; @@ -2088,7 +2088,7 @@ uint64_t calculate_unique_id(size_t pool) uid_pool.resize(pool + 1); else { - reporter->Warning("pool passed to calculate_unique_id() too large, using default"); + zeek::reporter->Warning("pool passed to calculate_unique_id() too large, using default"); pool = UID_POOL_DEFAULT_INTERNAL; } } @@ -2214,9 +2214,9 @@ extern "C" void out_of_memory(const char* where) { fprintf(stderr, "out of memory in %s.\n", where); - if ( reporter ) + if ( zeek::reporter ) // Guess that might fail here if memory is really tight ... - reporter->FatalError("out of memory in %s.\n", where); + zeek::reporter->FatalError("out of memory in %s.\n", where); abort(); } @@ -2396,8 +2396,8 @@ char* zeekenv(const char* name) if ( val && starts_with(it->second, "BRO_") ) { - if ( reporter ) - reporter->Warning("Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead", it->second, name); + if ( zeek::reporter ) + zeek::reporter->Warning("Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead", it->second, name); else fprintf(stderr, "Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead\n", it->second, name); } diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index b684e31297..50a78a5444 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -315,20 +315,20 @@ void terminate_bro() delete iosource_mgr; delete event_registry; delete log_mgr; - delete reporter; + delete zeek::reporter; delete zeek::plugin_mgr; delete zeek::val_mgr; // free the global scope zeek::detail::pop_scope(); - reporter = nullptr; + zeek::reporter = nullptr; } void zeek_terminate_loop(const char* reason) { set_processing_status("TERMINATING", reason); - reporter->Info("%s", reason); + zeek::reporter->Info("%s", reason); net_get_final_stats(); done_with_network(); @@ -522,7 +522,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, int r = sqlite3_initialize(); if ( r != SQLITE_OK ) - reporter->Error("Failed to initialize sqlite3: %s", sqlite3_errstr(r)); + zeek::reporter->Error("Failed to initialize sqlite3: %s", sqlite3_errstr(r)); #ifdef USE_IDMEF char* libidmef_dtd_path_cstr = new char[options.libidmef_dtd_file.size() + 1]; @@ -596,7 +596,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, } if ( missing_plugin ) - reporter->FatalError("Failed to activate requested dynamic plugin(s)."); + zeek::reporter->FatalError("Failed to activate requested dynamic plugin(s)."); zeek::plugin_mgr->ActivateDynamicPlugins(! options.bare_mode); @@ -648,7 +648,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, zeek::plugin_mgr->InitBifs(); - if ( reporter->Errors() > 0 ) + if ( zeek::reporter->Errors() > 0 ) exit(1); iosource_mgr->InitPostScript(); @@ -674,7 +674,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, if ( options.parse_only ) { - int rc = (reporter->Errors() > 0 ? 1 : 0); + int rc = (zeek::reporter->Errors() > 0 ? 1 : 0); exit(rc); } @@ -682,13 +682,13 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, } #endif - if ( reporter->Errors() > 0 ) + if ( zeek::reporter->Errors() > 0 ) { delete zeek::detail::dns_mgr; exit(1); } - reporter->InitOptions(); + zeek::reporter->InitOptions(); KeyedHash::InitOptions(); zeekygen_mgr->GenerateDocs(); @@ -697,7 +697,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, const auto& id = global_scope()->Find("cmd_line_bpf_filter"); if ( ! id ) - reporter->InternalError("global cmd_line_bpf_filter not defined"); + zeek::reporter->InternalError("global cmd_line_bpf_filter not defined"); id->SetVal(zeek::make_intrusive(*options.pcap_filter)); } @@ -766,7 +766,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, zeek::detail::dns_mgr->Resolve(); if ( ! zeek::detail::dns_mgr->Save() ) - reporter->FatalError("can't update DNS cache"); + zeek::reporter->FatalError("can't update DNS cache"); mgr.Drain(); delete zeek::detail::dns_mgr; @@ -778,7 +778,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, { const auto& id = global_scope()->Find(*options.identifier_to_print); if ( ! id ) - reporter->FatalError("No such ID: %s\n", options.identifier_to_print->data()); + zeek::reporter->FatalError("No such ID: %s\n", options.identifier_to_print->data()); ODesc desc; desc.SetQuotes(true); @@ -813,7 +813,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, if ( ! dead_handlers.empty() && check_for_unused_event_handlers ) { for ( const string& handler : dead_handlers ) - reporter->Warning("event handler never invoked: %s", handler.c_str()); + zeek::reporter->Warning("event handler never invoked: %s", handler.c_str()); } // Enable LeakSanitizer before zeek_init() and even before executing @@ -835,7 +835,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, } catch ( InterpreterException& ) { - reporter->FatalError("failed to execute script statements at top-level scope"); + zeek::reporter->FatalError("failed to execute script statements at top-level scope"); } g_frame_stack.pop_back(); @@ -858,16 +858,16 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, } } - reporter->ReportViaEvents(true); + zeek::reporter->ReportViaEvents(true); // Drain the event queue here to support the protocols framework configuring DPM mgr.Drain(); - if ( reporter->Errors() > 0 && ! zeekenv("ZEEK_ALLOW_INIT_ERRORS") ) - reporter->FatalError("errors occurred while initializing"); + if ( zeek::reporter->Errors() > 0 && ! zeekenv("ZEEK_ALLOW_INIT_ERRORS") ) + zeek::reporter->FatalError("errors occurred while initializing"); broker_mgr->ZeekInitDone(); - reporter->ZeekInitDone(); + zeek::reporter->ZeekInitDone(); zeek::analyzer_mgr->DumpDebug(); have_pending_timers = ! reading_traces && timer_mgr->Size() > 0; diff --git a/src/zeek.bif b/src/zeek.bif index 0c75205c26..dfde91e3ed 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -520,7 +520,7 @@ function piped_exec%(program: string, to_write: string%): bool FILE* f = popen(prog, "w"); if ( ! f ) { - reporter->Error("Failed to popen %s", prog); + zeek::reporter->Error("Failed to popen %s", prog); return zeek::val_mgr->False(); } @@ -533,7 +533,7 @@ function piped_exec%(program: string, to_write: string%): bool if ( bytes_written != input_data_len ) { - reporter->Error("Failed to write all given data to %s", prog); + zeek::reporter->Error("Failed to write all given data to %s", prog); return zeek::val_mgr->False(); } @@ -807,7 +807,7 @@ function paraglob_init%(v: any%) : opaque of paraglob v->GetType()->Yield()->Tag() != zeek::TYPE_STRING ) { // reporter->Error will throw an exception. - reporter->Error("paraglob requires a vector of strings for initialization."); + zeek::reporter->Error("paraglob requires a vector of strings for initialization."); return nullptr; } @@ -827,7 +827,7 @@ function paraglob_init%(v: any%) : opaque of paraglob // Thrown if paraglob fails to add a pattern. catch (const paraglob::add_error& e) { - reporter->Error("Paraglob failed to add pattern: %s", e.what()); + zeek::reporter->Error("Paraglob failed to add pattern: %s", e.what()); return nullptr; } %} @@ -959,7 +959,7 @@ function srand%(seed: count%): any ## s: The string to log via syslog function syslog%(s: string%): any %{ - reporter->Syslog("%s", s->CheckString()); + zeek::reporter->Syslog("%s", s->CheckString()); return nullptr; %} @@ -978,7 +978,7 @@ function syslog%(s: string%): any function identify_data%(data: string, return_mime: bool &default=T%): string %{ if ( ! return_mime ) - reporter->Warning("identify_data() builtin-function only returns MIME types, but verbose file info requested"); + zeek::reporter->Warning("identify_data() builtin-function only returns MIME types, but verbose file info requested"); string strongest_match = file_mgr->DetectMIME(data->Bytes(), data->Len()); @@ -1175,7 +1175,7 @@ function matching_subnets%(search: subnet, t: any%): subnet_vec %{ if ( t->GetType()->Tag() != zeek::TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() ) { - reporter->Error("matching_subnets needs to be called on a set[subnet]/table[subnet]."); + zeek::reporter->Error("matching_subnets needs to be called on a set[subnet]/table[subnet]."); return nullptr; } @@ -1194,7 +1194,7 @@ function filter_subnet_table%(search: subnet, t: any%): any %{ if ( t->GetType()->Tag() != zeek::TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() ) { - reporter->Error("filter_subnet_table needs to be called on a set[subnet]/table[subnet]."); + zeek::reporter->Error("filter_subnet_table needs to be called on a set[subnet]/table[subnet]."); return nullptr; } @@ -1214,14 +1214,14 @@ function check_subnet%(search: subnet, t: any%): bool %{ if ( t->GetType()->Tag() != zeek::TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() ) { - reporter->Error("check_subnet needs to be called on a set[subnet]/table[subnet]."); + zeek::reporter->Error("check_subnet needs to be called on a set[subnet]/table[subnet]."); return nullptr; } const PrefixTable* pt = t->AsTableVal()->Subnets(); if ( ! pt ) { - reporter->Error("check_subnet encountered nonexisting prefix table."); + zeek::reporter->Error("check_subnet encountered nonexisting prefix table."); return nullptr; } @@ -1737,7 +1737,7 @@ function sqrt%(x: double%): double %{ if ( x < 0 ) { - reporter->Error("negative sqrt argument"); + zeek::reporter->Error("negative sqrt argument"); return zeek::make_intrusive(-1.0); } @@ -2002,7 +2002,7 @@ function record_fields%(rec: any%): record_field_table if ( ! id || ! id->IsType() || id->GetType()->Tag() != zeek::TYPE_RECORD ) { - reporter->Error("record_fields string argument does not name a record type"); + zeek::reporter->Error("record_fields string argument does not name a record type"); return zeek::make_intrusive(record_field_table); } @@ -2237,7 +2237,7 @@ function routing0_data_to_addrs%(s: string%): addr_vec len -= 4; if ( ( len % 16 ) != 0 ) - reporter->Warning("Bad ip6_routing data length: %d", s->Len()); + zeek::reporter->Warning("Bad ip6_routing data length: %d", s->Len()); while ( len > 0 ) { @@ -2893,7 +2893,7 @@ function hexstr_to_bytestring%(hexstr: string%): string bro_uint_t len = hexstr->AsString()->Len(); if ( len % 2 != 0 ) { - reporter->Error("Hex string '%s' has invalid length (not divisible by 2)", hexstr->CheckString()); + zeek::reporter->Error("Hex string '%s' has invalid length (not divisible by 2)", hexstr->CheckString()); return zeek::val_mgr->EmptyString(); } @@ -2909,13 +2909,13 @@ function hexstr_to_bytestring%(hexstr: string%): string if ( res == EOF ) { - reporter->Error("Hex string %s contains invalid input: %s", hexstr->CheckString(), strerror(errno)); + zeek::reporter->Error("Hex string %s contains invalid input: %s", hexstr->CheckString(), strerror(errno)); return zeek::val_mgr->EmptyString(); } else if ( res != 1 ) { - reporter->Error("Could not read hex element from input %s", hexstr->CheckString()); + zeek::reporter->Error("Could not read hex element from input %s", hexstr->CheckString()); return zeek::val_mgr->EmptyString(); } @@ -2941,7 +2941,7 @@ function encode_base64%(s: string, a: string &default=""%): string return zeek::make_intrusive(t); else { - reporter->Error("Broker query has an invalid data store"); + zeek::reporter->Error("Broker query has an invalid data store"); return zeek::val_mgr->EmptyString(); } %} @@ -2963,7 +2963,7 @@ function decode_base64%(s: string, a: string &default=""%): string return zeek::make_intrusive(t); else { - reporter->Error("error in decoding string %s", s->CheckString()); + zeek::reporter->Error("error in decoding string %s", s->CheckString()); return zeek::val_mgr->EmptyString(); } %} @@ -2996,7 +2996,7 @@ function decode_base64_conn%(cid: conn_id, s: string, a: string &default=""%): s return zeek::make_intrusive(t); else { - reporter->Error("error in decoding string %s", s->CheckString()); + zeek::reporter->Error("error in decoding string %s", s->CheckString()); return zeek::val_mgr->EmptyString(); } %} @@ -3156,7 +3156,7 @@ function strptime%(fmt: string, d: string%) : time if ( ! localtime_r(&timeval, &t) || ! strptime(d->CheckString(), fmt->CheckString(), &t) ) { - reporter->Warning("strptime conversion failed: fmt:%s d:%s", fmt->CheckString(), d->CheckString()); + zeek::reporter->Warning("strptime conversion failed: fmt:%s d:%s", fmt->CheckString(), d->CheckString()); return zeek::make_intrusive(0.0); } @@ -3266,7 +3266,7 @@ static zeek::EnumValPtr map_conn_type(TransportProto tp) return zeek::id::transport_proto->GetEnumVal(3); default: - reporter->InternalError("bad connection type in map_conn_type()"); + zeek::reporter->InternalError("bad connection type in map_conn_type()"); } // Cannot be reached; @@ -3700,7 +3700,7 @@ static void report_mmdb_msg(const char* format, ...) std::string msg = fmt(format, al); va_end(al); - reporter->Info("%s", msg.data()); + zeek::reporter->Info("%s", msg.data()); } class MMDB { @@ -4324,7 +4324,7 @@ function disable_analyzer%(cid: conn_id, aid: count, err_if_no_conn: bool &defau Connection* c = sessions->FindConnection(cid); if ( ! c ) { - reporter->Error("cannot find connection"); + zeek::reporter->Error("cannot find connection"); return zeek::val_mgr->False(); } @@ -4332,7 +4332,7 @@ function disable_analyzer%(cid: conn_id, aid: count, err_if_no_conn: bool &defau if ( ! a ) { if ( err_if_no_conn ) - reporter->Error("connection does not have analyzer specified to disable"); + zeek::reporter->Error("connection does not have analyzer specified to disable"); return zeek::val_mgr->False(); } diff --git a/src/zeekygen/Configuration.cc b/src/zeekygen/Configuration.cc index 3e7708dd6a..7cd885c110 100644 --- a/src/zeekygen/Configuration.cc +++ b/src/zeekygen/Configuration.cc @@ -36,8 +36,8 @@ Config::Config(const string& arg_file, const string& delim) ifstream f(file.c_str()); if ( ! f.is_open() ) - reporter->FatalError("failed to open Zeekygen config file '%s': %s", - file.c_str(), strerror(errno)); + zeek::reporter->FatalError("failed to open Zeekygen config file '%s': %s", + file.c_str(), strerror(errno)); string line; unsigned int line_number = 0; @@ -58,21 +58,21 @@ Config::Config(const string& arg_file, const string& delim) continue; if ( tokens.size() != 3 ) - reporter->FatalError("malformed Zeekygen target in %s:%u: %s", - file.c_str(), line_number, line.c_str()); + zeek::reporter->FatalError("malformed Zeekygen target in %s:%u: %s", + file.c_str(), line_number, line.c_str()); Target* target = target_factory.Create(tokens[0], tokens[2], tokens[1]); if ( ! target ) - reporter->FatalError("unknown Zeekygen target type: %s", - tokens[0].c_str()); + zeek::reporter->FatalError("unknown Zeekygen target type: %s", + tokens[0].c_str()); targets.push_back(target); } if ( f.bad() ) - reporter->InternalError("error reading Zeekygen config file '%s': %s", - file.c_str(), strerror(errno)); + zeek::reporter->InternalError("error reading Zeekygen config file '%s': %s", + file.c_str(), strerror(errno)); } Config::~Config() diff --git a/src/zeekygen/Manager.cc b/src/zeekygen/Manager.cc index 297365e07f..a79b818e38 100644 --- a/src/zeekygen/Manager.cc +++ b/src/zeekygen/Manager.cc @@ -17,13 +17,13 @@ using namespace std; static void DbgAndWarn(const char* msg) { - if ( reporter->Errors() ) + if ( zeek::reporter->Errors() ) // We've likely already reported to real source of the problem // as an error, avoid adding an additional warning which may // be confusing. return; - reporter->Warning("%s", msg); + zeek::reporter->Warning("%s", msg); DBG_LOG(DBG_ZEEKYGEN, "%s", msg); } @@ -88,8 +88,9 @@ Manager::Manager(const string& arg_config, const string& bro_command) // a PATH component that starts with a tilde (such as "~/bin"). A simple // workaround is to just run bro with a relative or absolute path. if ( path_to_bro.empty() || stat(path_to_bro.c_str(), &s) < 0 ) - reporter->InternalError("Zeekygen can't get mtime of zeek binary %s (try again by specifying the absolute or relative path to Zeek): %s", - path_to_bro.c_str(), strerror(errno)); + zeek::reporter->InternalError( + "Zeekygen can't get mtime of zeek binary %s (try again by specifying the absolute or relative path to Zeek): %s", + path_to_bro.c_str(), strerror(errno)); // Internal error will abort above in the case that stat isn't initialized // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) diff --git a/src/zeekygen/Manager.h b/src/zeekygen/Manager.h index f5162131ea..e026ffe529 100644 --- a/src/zeekygen/Manager.h +++ b/src/zeekygen/Manager.h @@ -245,8 +245,8 @@ bool Manager::IsUpToDate(const std::string& target_file, // Doesn't exist. return false; - reporter->InternalError("Zeekygen failed to stat target file '%s': %s", - target_file.c_str(), strerror(errno)); + zeek::reporter->InternalError("Zeekygen failed to stat target file '%s': %s", + target_file.c_str(), strerror(errno)); } if ( difftime(bro_mtime, s.st_mtime) > 0 ) diff --git a/src/zeekygen/PackageInfo.cc b/src/zeekygen/PackageInfo.cc index 4fe1ba8ad9..c995c8e758 100644 --- a/src/zeekygen/PackageInfo.cc +++ b/src/zeekygen/PackageInfo.cc @@ -23,8 +23,8 @@ PackageInfo::PackageInfo(const string& arg_name) ifstream f(readme_file.c_str()); if ( ! f.is_open() ) - reporter->InternalWarning("Zeekygen failed to open '%s': %s", - readme_file.c_str(), strerror(errno)); + zeek::reporter->InternalWarning("Zeekygen failed to open '%s': %s", + readme_file.c_str(), strerror(errno)); string line; @@ -32,8 +32,8 @@ PackageInfo::PackageInfo(const string& arg_name) readme.push_back(line); if ( f.bad() ) - reporter->InternalWarning("Zeekygen error reading '%s': %s", - readme_file.c_str(), strerror(errno)); + zeek::reporter->InternalWarning("Zeekygen error reading '%s': %s", + readme_file.c_str(), strerror(errno)); } string PackageInfo::DoReStructuredText(bool roles_only) const diff --git a/src/zeekygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc index 9f16010fbc..15d35911a9 100644 --- a/src/zeekygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -211,7 +211,7 @@ void ScriptInfo::DoInitPostScript() functions.push_back(info); break; default: - reporter->InternalError("Invalid function flavor"); + zeek::reporter->InternalError("Invalid function flavor"); break; } @@ -377,8 +377,8 @@ time_t ScriptInfo::DoGetModificationTime() const } if ( ! info ) - reporter->InternalWarning("Zeekygen failed to get mtime of %s", - it->c_str()); + zeek::reporter->InternalWarning("Zeekygen failed to get mtime of %s", + it->c_str()); continue; } diff --git a/src/zeekygen/Target.cc b/src/zeekygen/Target.cc index b3c53f9c0a..379aec1f2d 100644 --- a/src/zeekygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -39,7 +39,7 @@ static void write_analyzer_component(FILE* f, const zeek::analyzer::Component* c string tag = fmt("ANALYZER_%s", c->CanonicalName().c_str()); if ( atag->Lookup("Analyzer", tag.c_str()) < 0 ) - reporter->InternalError("missing analyzer tag for %s", tag.c_str()); + zeek::reporter->InternalError("missing analyzer tag for %s", tag.c_str()); fprintf(f, ":zeek:enum:`Analyzer::%s`\n\n", tag.c_str()); } @@ -50,7 +50,7 @@ static void write_analyzer_component(FILE* f, const file_analysis::Component* c) string tag = fmt("ANALYZER_%s", c->CanonicalName().c_str()); if ( atag->Lookup("Files", tag.c_str()) < 0 ) - reporter->InternalError("missing analyzer tag for %s", tag.c_str()); + zeek::reporter->InternalError("missing analyzer tag for %s", tag.c_str()); fprintf(f, ":zeek:enum:`Files::%s`\n\n", tag.c_str()); } @@ -73,7 +73,7 @@ static void write_plugin_components(FILE* f, const zeek::plugin::Plugin* p) if ( c ) write_analyzer_component(f, c); else - reporter->InternalError("component type mismatch"); + zeek::reporter->InternalError("component type mismatch"); } break; @@ -85,18 +85,18 @@ static void write_plugin_components(FILE* f, const zeek::plugin::Plugin* p) if ( c ) write_analyzer_component(f, c); else - reporter->InternalError("component type mismatch"); + zeek::reporter->InternalError("component type mismatch"); } break; case zeek::plugin::component::READER: - reporter->InternalError("docs for READER component unimplemented"); + zeek::reporter->InternalError("docs for READER component unimplemented"); case zeek::plugin::component::WRITER: - reporter->InternalError("docs for WRITER component unimplemented"); + zeek::reporter->InternalError("docs for WRITER component unimplemented"); default: - reporter->InternalError("docs for unknown component unimplemented"); + zeek::reporter->InternalError("docs for unknown component unimplemented"); } } } @@ -131,8 +131,8 @@ static void write_plugin_bif_items(FILE* f, const zeek::plugin::Plugin* p, if ( doc ) fprintf(f, "%s\n\n", doc->ReStructuredText().c_str()); else - reporter->InternalWarning("Zeekygen ID lookup failed: %s\n", - it->GetID().c_str()); + zeek::reporter->InternalWarning("Zeekygen ID lookup failed: %s\n", + it->GetID().c_str()); } } @@ -143,8 +143,8 @@ static void WriteAnalyzerTagDefn(FILE* f, const string& module) zeekygen::IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(tag_id); if ( ! doc ) - reporter->InternalError("Zeekygen failed analyzer tag lookup: %s", - tag_id.c_str()); + zeek::reporter->InternalError("Zeekygen failed analyzer tag lookup: %s", + tag_id.c_str()); fprintf(f, "%s\n", doc->ReStructuredText().c_str()); } @@ -196,15 +196,15 @@ TargetFile::TargetFile(const string& arg_name) string dir = SafeDirname(name).result; if ( ! ensure_intermediate_dirs(dir.c_str()) ) - reporter->FatalError("Zeekygen failed to make dir %s", - dir.c_str()); + zeek::reporter->FatalError("Zeekygen failed to make dir %s", + dir.c_str()); } f = fopen(name.c_str(), "w"); if ( ! f ) - reporter->FatalError("Zeekygen failed to open '%s' for writing: %s", - name.c_str(), strerror(errno)); + zeek::reporter->FatalError("Zeekygen failed to open '%s' for writing: %s", + name.c_str(), strerror(errno)); } TargetFile::~TargetFile() @@ -251,8 +251,8 @@ void AnalyzerTarget::DoGenerate() const return; if ( Pattern() != "*" ) - reporter->InternalWarning("Zeekygen only implements analyzer target" - " pattern '*'"); + zeek::reporter->InternalWarning("Zeekygen only implements analyzer target" + " pattern '*'"); TargetFile file(Name()); CreateAnalyzerDoc(file.f); @@ -315,8 +315,8 @@ void PackageTarget::DoFindDependencies(const vector& infos) pkg_deps = filter_matches(infos, this); if ( pkg_deps.empty() ) - reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", - Name().c_str(), Pattern().c_str()); + zeek::reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", + Name().c_str(), Pattern().c_str()); for ( size_t i = 0; i < infos.size(); ++i ) { @@ -384,8 +384,8 @@ void PackageIndexTarget::DoFindDependencies(const vector& infos) pkg_deps = filter_matches(infos, this); if ( pkg_deps.empty() ) - reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", - Name().c_str(), Pattern().c_str()); + zeek::reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", + Name().c_str(), Pattern().c_str()); } void PackageIndexTarget::DoGenerate() const @@ -404,8 +404,8 @@ void ScriptTarget::DoFindDependencies(const vector& infos) script_deps = filter_matches(infos, this); if ( script_deps.empty() ) - reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", - Name().c_str(), Pattern().c_str()); + zeek::reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", + Name().c_str(), Pattern().c_str()); if ( ! IsDir() ) return; @@ -443,7 +443,7 @@ vector dir_contents_recursive(string dir) if ( ! fts ) { - reporter->Error("fts_open failure: %s", strerror(errno)); + zeek::reporter->Error("fts_open failure: %s", strerror(errno)); delete [] scan_path; delete [] dir_copy; return rval; @@ -458,10 +458,10 @@ vector dir_contents_recursive(string dir) } if ( errno ) - reporter->Error("fts_read failure: %s", strerror(errno)); + zeek::reporter->Error("fts_read failure: %s", strerror(errno)); if ( fts_close(fts) < 0 ) - reporter->Error("fts_close failure: %s", strerror(errno)); + zeek::reporter->Error("fts_close failure: %s", strerror(errno)); delete [] scan_path; delete [] dir_copy; @@ -507,8 +507,8 @@ void ScriptTarget::DoGenerate() const continue; if ( unlink(f.c_str()) < 0 ) - reporter->Warning("Failed to unlink %s: %s", f.c_str(), - strerror(errno)); + zeek::reporter->Warning("Failed to unlink %s: %s", f.c_str(), + strerror(errno)); DBG_LOG(DBG_ZEEKYGEN, "Delete stale script file %s", f.c_str()); } @@ -579,8 +579,8 @@ void IdentifierTarget::DoFindDependencies(const vector& infos) id_deps = filter_matches(infos, this); if ( id_deps.empty() ) - reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", - Name().c_str(), Pattern().c_str()); + zeek::reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", + Name().c_str(), Pattern().c_str()); } void IdentifierTarget::DoGenerate() const diff --git a/src/zeekygen/utils.cc b/src/zeekygen/utils.cc index fb016270b4..88a6385f36 100644 --- a/src/zeekygen/utils.cc +++ b/src/zeekygen/utils.cc @@ -89,8 +89,8 @@ time_t zeekygen::get_mtime(const string& filename) struct stat s; if ( stat(filename.c_str(), &s) < 0 ) - reporter->InternalError("Zeekygen failed to stat file '%s': %s", - filename.c_str(), strerror(errno)); + zeek::reporter->InternalError("Zeekygen failed to stat file '%s': %s", + filename.c_str(), strerror(errno)); return s.st_mtime; }