Integrate review feedback

* Add deprecation for MIME_Entity::ContentType(), use GetContentType()

* Add deprecation for MIME_Entity::ContentSubType(), use GetContentSubType()

* Add deprecation for MIME_Message::BuildHeaderVal(), use ToHeaderVal()

* Add deprecation for MIME_Message::BuildHeaderTable(), use ToHeaderTable()

* Add deprecation for mime::new_string_val(), use mime::to_stringval()

* Add deprecation for ARP_Analyzer::ConstructAddrVal(), use ToAddrVal()

* Add deprecation for ARP_Analyzer::EthAddrToStr(), use ToEthAddrStr()

* Change the Func::Call() replacement to be named Func::Invoke()
This commit is contained in:
Jon Siwek 2020-05-29 19:04:00 -07:00
parent 82ce64ca70
commit 9c133b9b10
22 changed files with 137 additions and 95 deletions

6
NEWS
View file

@ -114,9 +114,9 @@ Deprecated Functionality
method to now use is called ``HookFunctionCall`` and uses ``IntrusivePtr`` method to now use is called ``HookFunctionCall`` and uses ``IntrusivePtr``
arguments and return value. arguments and return value.
- The ``Func::Call(val_list*, ...)`` method is now deprecated. Use operator() - The ``Func::Call(val_list*, ...)`` method is now deprecated. Use ``Invoke()``
instead which takes a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``). instead which takes a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``).
There's also a variadic template for operator() that forwards all arguments There's also a variadic template for ``Invoke()`` that forwards all arguments
into a ``zeek::Args`` for you. into a ``zeek::Args`` for you.
- The ``EventMgr::QueueEvent()`` and EventMgr::QueueEventFast()`` methods - The ``EventMgr::QueueEvent()`` and EventMgr::QueueEventFast()`` methods
@ -151,7 +151,7 @@ Deprecated Functionality
- Various methods of converting protocol structures, like IP or packet headers, - Various methods of converting protocol structures, like IP or packet headers,
to associated ``Val`` type are now deprecated, the deprecation warning to associated ``Val`` type are now deprecated, the deprecation warning
message will advice what new method to use instead. message will advise what new method to use instead.
- Various methods of ``Tag`` classes are deprecated with the warning - Various methods of ``Tag`` classes are deprecated with the warning
message advising what new method to use instead. message advising what new method to use instead.

View file

@ -43,7 +43,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
try try
{ {
discard_packet = check_ip->operator()(&args)->AsBool(); discard_packet = check_ip->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )
@ -98,7 +98,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
try try
{ {
discard_packet = check_tcp->operator()(&args)->AsBool(); discard_packet = check_tcp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )
@ -122,7 +122,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
try try
{ {
discard_packet = check_udp->operator()(&args)->AsBool(); discard_packet = check_udp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )
@ -142,7 +142,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
try try
{ {
discard_packet = check_icmp->operator()(&args)->AsBool(); discard_packet = check_icmp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )

View file

@ -98,7 +98,7 @@ void EventHandler::Call(zeek::Args* vl, bool no_remote)
if ( local ) if ( local )
// No try/catch here; we pass exceptions upstream. // No try/catch here; we pass exceptions upstream.
local->operator()(vl); local->Invoke(vl);
} }
void EventHandler::NewEvent(zeek::Args* vl) void EventHandler::NewEvent(zeek::Args* vl)

View file

@ -4131,7 +4131,7 @@ IntrusivePtr<Val> CallExpr::Eval(Frame* f) const
f->SetCall(this); f->SetCall(this);
auto& args = *v; auto& args = *v;
ret = funcv->operator()(&args, f); ret = funcv->Invoke(&args, f);
if ( f ) if ( f )
f->SetCall(current_call); f->SetCall(current_call);

View file

@ -301,10 +301,10 @@ bool BroFunc::IsPure() const
Val* Func::Call(val_list* args, Frame* parent) const Val* Func::Call(val_list* args, Frame* parent) const
{ {
auto zargs = zeek::val_list_to_args(*args); auto zargs = zeek::val_list_to_args(*args);
return operator()(&zargs, parent).release(); return Invoke(&zargs, parent).release();
}; };
IntrusivePtr<Val> BroFunc::operator()(zeek::Args* args, Frame* parent) const IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
{ {
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());
@ -614,7 +614,7 @@ bool BuiltinFunc::IsPure() const
return is_pure; return is_pure;
} }
IntrusivePtr<Val> BuiltinFunc::operator()(zeek::Args* args, Frame* parent) const IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
{ {
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());

View file

@ -51,7 +51,7 @@ public:
const std::vector<Body>& GetBodies() const { return bodies; } const std::vector<Body>& GetBodies() const { return bodies; }
bool HasBodies() const { return bodies.size(); } bool HasBodies() const { return bodies.size(); }
[[deprecated("Remove in v4.1. Use operator() instead.")]] [[deprecated("Remove in v4.1. Use Invoke() instead.")]]
Val* Call(val_list* args, Frame* parent = nullptr) const; Val* Call(val_list* args, Frame* parent = nullptr) const;
/** /**
@ -60,21 +60,21 @@ public:
* @param parent the frame from which the function is being called. * @param parent the frame from which the function is being called.
* @return the return value of the function call. * @return the return value of the function call.
*/ */
virtual IntrusivePtr<Val> operator()(zeek::Args* args, virtual IntrusivePtr<Val> Invoke(zeek::Args* args,
Frame* parent = nullptr) const = 0; Frame* parent = nullptr) const = 0;
/** /**
* A version of operator() taking a variable number of individual arguments. * A version of Invoke() taking a variable number of individual arguments.
*/ */
template <class... Args> template <class... Args>
std::enable_if_t< std::enable_if_t<
std::is_convertible_v<std::tuple_element_t<0, std::tuple<Args...>>, std::is_convertible_v<std::tuple_element_t<0, std::tuple<Args...>>,
IntrusivePtr<Val>>, IntrusivePtr<Val>>,
IntrusivePtr<Val>> IntrusivePtr<Val>>
operator()(Args&&... args) const Invoke(Args&&... args) const
{ {
auto zargs = zeek::Args{std::forward<Args>(args)...}; auto zargs = zeek::Args{std::forward<Args>(args)...};
return operator()(&zargs); return Invoke(&zargs);
} }
// Add a new event handler to an existing function (event). // Add a new event handler to an existing function (event).
@ -136,7 +136,7 @@ public:
~BroFunc() override; ~BroFunc() override;
bool IsPure() const override; bool IsPure() const override;
IntrusivePtr<Val> operator()(zeek::Args* args, Frame* parent) const override; IntrusivePtr<Val> Invoke(zeek::Args* args, Frame* parent) const override;
/** /**
* Adds adds a closure to the function. Closures are cloned and * Adds adds a closure to the function. Closures are cloned and
@ -234,7 +234,7 @@ public:
~BuiltinFunc() override; ~BuiltinFunc() override;
bool IsPure() const override; bool IsPure() const override;
IntrusivePtr<Val> operator()(zeek::Args* args, Frame* parent) const override; IntrusivePtr<Val> Invoke(zeek::Args* args, Frame* parent) const override;
built_in_func TheFunc() const { return func; } built_in_func TheFunc() const { return func; }
void Describe(ODesc* d) const override; void Describe(ODesc* d) const override;

View file

@ -30,9 +30,9 @@ class BroString;
class Val; class Val;
class Frame; class Frame;
class BifReturnVal; class BifReturnVal;
namespace zeek { namespace BifFunc { namespace zeek::BifFunc {
extern BifReturnVal md5_hmac_bif(Frame* frame, const zeek::Args*); extern BifReturnVal md5_hmac_bif(Frame* frame, const zeek::Args*);
}} }
typedef uint64_t hash_t; typedef uint64_t hash_t;
typedef uint64_t hash64_t; typedef uint64_t hash64_t;

View file

@ -164,7 +164,7 @@ protected:
}; };
namespace zeek { namespace id { namespace zeek::id {
/** /**
* Lookup an ID in the global module and return it, if one exists; * Lookup an ID in the global module and return it, if one exists;
@ -254,4 +254,4 @@ void init();
} // namespace zeek::id::detail } // namespace zeek::id::detail
}} // namespace zeek::id } // namespace zeek::id

View file

@ -181,7 +181,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
try try
{ {
auto val = id->GetVal()->AsFunc()->operator()(&args); auto val = id->GetVal()->AsFunc()->Invoke(&args);
result = val && val->AsBool(); result = val && val->AsBool();
} }

View file

@ -1879,7 +1879,7 @@ IntrusivePtr<Val> TableVal::Default(const IntrusivePtr<Val>& index)
try try
{ {
result = f->operator()(&vl); result = f->Invoke(&vl);
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )
@ -2088,7 +2088,7 @@ void TableVal::CallChangeFunc(const Val* index,
vl.emplace_back(old_value); vl.emplace_back(old_value);
in_change_func = true; in_change_func = true;
f->operator()(&vl); f->Invoke(&vl);
} }
catch ( InterpreterException& e ) catch ( InterpreterException& e )
{ {
@ -2546,7 +2546,7 @@ double TableVal::CallExpireFunc(IntrusivePtr<ListVal> idx)
vl.emplace_back(std::move(idx)); vl.emplace_back(std::move(idx));
} }
auto result = f->operator()(&vl); auto result = f->Invoke(&vl);
if ( result ) if ( result )
secs = result->AsInterval(); secs = result->AsInterval();

View file

@ -192,10 +192,10 @@ void ARP_Analyzer::BadARP(const struct arp_pkthdr* hdr, const char* msg)
return; return;
mgr.Enqueue(bad_arp, mgr.Enqueue(bad_arp,
ConstructAddrVal(ar_spa(hdr)), ToAddrVal(ar_spa(hdr)),
EthAddrToStr((const u_char*) ar_sha(hdr)), ToEthAddrStr((const u_char*) ar_sha(hdr)),
ConstructAddrVal(ar_tpa(hdr)), ToAddrVal(ar_tpa(hdr)),
EthAddrToStr((const u_char*) ar_tha(hdr)), ToEthAddrStr((const u_char*) ar_tha(hdr)),
make_intrusive<StringVal>(msg) make_intrusive<StringVal>(msg)
); );
} }
@ -214,22 +214,28 @@ void ARP_Analyzer::RREvent(EventHandlerPtr e,
return; return;
mgr.Enqueue(e, mgr.Enqueue(e,
EthAddrToStr(src), ToEthAddrStr(src),
EthAddrToStr(dst), ToEthAddrStr(dst),
ConstructAddrVal(spa), ToAddrVal(spa),
EthAddrToStr((const u_char*) sha), ToEthAddrStr((const u_char*) sha),
ConstructAddrVal(tpa), ToAddrVal(tpa),
EthAddrToStr((const u_char*) tha) ToEthAddrStr((const u_char*) tha)
); );
} }
IntrusivePtr<AddrVal> ARP_Analyzer::ConstructAddrVal(const void* addr) AddrVal* ARP_Analyzer::ConstructAddrVal(const void* addr)
{ return ToAddrVal(addr).release(); }
IntrusivePtr<AddrVal> ARP_Analyzer::ToAddrVal(const void* addr)
{ {
// ### For now, we only handle IPv4 addresses. // ### For now, we only handle IPv4 addresses.
return make_intrusive<AddrVal>(*(const uint32_t*) addr); return make_intrusive<AddrVal>(*(const uint32_t*) addr);
} }
IntrusivePtr<StringVal> ARP_Analyzer::EthAddrToStr(const u_char* addr) StringVal* ARP_Analyzer::EthAddrToStr(const u_char* addr)
{ return ToEthAddrStr(addr).release(); }
IntrusivePtr<StringVal> ARP_Analyzer::ToEthAddrStr(const u_char* addr)
{ {
char buf[1024]; char buf[1024];
snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x",

View file

@ -45,8 +45,14 @@ public:
const char* tpa, const char* tha); const char* tpa, const char* tha);
protected: protected:
IntrusivePtr<AddrVal> ConstructAddrVal(const void* addr);
IntrusivePtr<StringVal> EthAddrToStr(const u_char* addr); [[deprecated("Remove in v4.1. Use ToAddrVal().")]]
AddrVal* ConstructAddrVal(const void* addr);
[[deprecated("Remove in v4.1. Use ToEthAddrStr().")]]
StringVal* EthAddrToStr(const u_char* addr);
IntrusivePtr<AddrVal> ToAddrVal(const void* addr);
IntrusivePtr<StringVal> ToEthAddrStr(const u_char* addr);
void BadARP(const struct arp_pkthdr* hdr, const char* string); void BadARP(const struct arp_pkthdr* hdr, const char* string);
void Corrupted(const char* string); void Corrupted(const char* string);
}; };

View file

@ -738,15 +738,15 @@ void HTTP_Message::SubmitAllHeaders(mime::MIME_HeaderList& hlist)
analyzer->EnqueueConnEvent(http_all_headers, analyzer->EnqueueConnEvent(http_all_headers,
analyzer->ConnVal(), analyzer->ConnVal(),
val_mgr->Bool(is_orig), val_mgr->Bool(is_orig),
BuildHeaderTable(hlist) ToHeaderTable(hlist)
); );
if ( http_content_type ) if ( http_content_type )
analyzer->EnqueueConnEvent(http_content_type, analyzer->EnqueueConnEvent(http_content_type,
analyzer->ConnVal(), analyzer->ConnVal(),
val_mgr->Bool(is_orig), val_mgr->Bool(is_orig),
current_entity->ContentType(), current_entity->GetContentType(),
current_entity->ContentSubType() current_entity->GetContentSubType()
); );
} }
@ -928,7 +928,7 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
return; return;
} }
// HTTP_Event("HTTP line", new_string_val(length, line)); // HTTP_Event("HTTP line", to_string_val(length, line));
if ( is_orig ) if ( is_orig )
{ {
@ -961,7 +961,7 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
{ {
if ( ! RequestExpected() ) if ( ! RequestExpected() )
HTTP_Event("crud_trailing_HTTP_request", HTTP_Event("crud_trailing_HTTP_request",
mime::new_string_val(line, end_of_line)); mime::to_string_val(line, end_of_line));
else else
{ {
// We do see HTTP requests with a // We do see HTTP requests with a
@ -1304,10 +1304,10 @@ bool HTTP_Analyzer::ParseRequest(const char* line, const char* end_of_line)
version_end = version_start + 3; version_end = version_start + 3;
if ( skip_whitespace(version_end, end_of_line) != end_of_line ) if ( skip_whitespace(version_end, end_of_line) != end_of_line )
HTTP_Event("crud after HTTP version is ignored", HTTP_Event("crud after HTTP version is ignored",
mime::new_string_val(line, end_of_line)); mime::to_string_val(line, end_of_line));
} }
else else
HTTP_Event("bad_HTTP_version", mime::new_string_val(line, end_of_line)); HTTP_Event("bad_HTTP_version", mime::to_string_val(line, end_of_line));
} }
// NormalizeURI(line, end_of_uri); // NormalizeURI(line, end_of_uri);
@ -1333,7 +1333,7 @@ HTTP_Analyzer::HTTP_VersionNumber HTTP_Analyzer::HTTP_Version(int len, const cha
} }
else else
{ {
HTTP_Event("bad_HTTP_version", mime::new_string_val(len, data)); HTTP_Event("bad_HTTP_version", mime::to_string_val(len, data));
return {}; return {};
} }
} }
@ -1509,7 +1509,7 @@ int HTTP_Analyzer::HTTP_ReplyLine(const char* line, const char* end_of_line)
// ##TODO: some server replies with an HTML document // ##TODO: some server replies with an HTML document
// without a status line and a MIME header, when the // without a status line and a MIME header, when the
// request is malformed. // request is malformed.
HTTP_Event("bad_HTTP_reply", mime::new_string_val(line, end_of_line)); HTTP_Event("bad_HTTP_reply", mime::to_string_val(line, end_of_line));
return 0; return 0;
} }
@ -1522,7 +1522,7 @@ int HTTP_Analyzer::HTTP_ReplyLine(const char* line, const char* end_of_line)
if ( rest >= end_of_line ) if ( rest >= end_of_line )
{ {
HTTP_Event("HTTP_reply_code_missing", HTTP_Event("HTTP_reply_code_missing",
mime::new_string_val(line, end_of_line)); mime::to_string_val(line, end_of_line));
return 0; return 0;
} }
@ -1531,7 +1531,7 @@ int HTTP_Analyzer::HTTP_ReplyLine(const char* line, const char* end_of_line)
if ( rest + 3 > end_of_line ) if ( rest + 3 > end_of_line )
{ {
HTTP_Event("HTTP_reply_code_missing", HTTP_Event("HTTP_reply_code_missing",
mime::new_string_val(line, end_of_line)); mime::to_string_val(line, end_of_line));
return 0; return 0;
} }
@ -1544,7 +1544,7 @@ int HTTP_Analyzer::HTTP_ReplyLine(const char* line, const char* end_of_line)
if ( rest >= end_of_line ) if ( rest >= end_of_line )
{ {
HTTP_Event("HTTP_reply_reason_phrase_missing", HTTP_Event("HTTP_reply_reason_phrase_missing",
mime::new_string_val(line, end_of_line)); mime::to_string_val(line, end_of_line));
// Tolerate missing reason phrase? // Tolerate missing reason phrase?
return 1; return 1;
} }
@ -1635,15 +1635,15 @@ void HTTP_Analyzer::HTTP_Header(bool is_orig, mime::MIME_Header* h)
if ( DEBUG_http ) if ( DEBUG_http )
DEBUG_MSG("%.6f http_header\n", network_time); DEBUG_MSG("%.6f http_header\n", network_time);
auto upper_hn = mime::new_string_val(h->get_name()); auto upper_hn = mime::to_string_val(h->get_name());
upper_hn->ToUpper(); upper_hn->ToUpper();
EnqueueConnEvent(http_header, EnqueueConnEvent(http_header,
ConnVal(), ConnVal(),
val_mgr->Bool(is_orig), val_mgr->Bool(is_orig),
mime::new_string_val(h->get_name()), mime::to_string_val(h->get_name()),
std::move(upper_hn), std::move(upper_hn),
mime::new_string_val(h->get_value()) mime::to_string_val(h->get_value())
); );
} }
} }

View file

@ -108,19 +108,28 @@ bool is_lws(char ch)
return ch == 9 || ch == 32; return ch == 9 || ch == 32;
} }
IntrusivePtr<StringVal> new_string_val(int length, const char* data) StringVal* new_string_val(int length, const char* data)
{ return to_string_val(length, data).release(); }
StringVal* new_string_val(const char* data, const char* end_of_data)
{ return to_string_val(data, end_of_data).release(); }
StringVal* new_string_val(const data_chunk_t buf)
{ return to_string_val(buf).release(); }
IntrusivePtr<StringVal> to_string_val(int length, const char* data)
{ {
return make_intrusive<StringVal>(length, data); return make_intrusive<StringVal>(length, data);
} }
IntrusivePtr<StringVal> new_string_val(const char* data, const char* end_of_data) IntrusivePtr<StringVal> to_string_val(const char* data, const char* end_of_data)
{ {
return make_intrusive<StringVal>(end_of_data - data, data); return make_intrusive<StringVal>(end_of_data - data, data);
} }
IntrusivePtr<StringVal> new_string_val(const data_chunk_t buf) IntrusivePtr<StringVal> to_string_val(const data_chunk_t buf)
{ {
return new_string_val(buf.length, buf.data); return to_string_val(buf.length, buf.data);
} }
static data_chunk_t get_data_chunk(BroString* s) static data_chunk_t get_data_chunk(BroString* s)
@ -1287,19 +1296,25 @@ void MIME_Entity::DebugPrintHeaders()
#endif #endif
} }
IntrusivePtr<RecordVal> MIME_Message::BuildHeaderVal(MIME_Header* h) RecordVal* MIME_Message::BuildHeaderVal(MIME_Header* h)
{ return ToHeaderVal(h).release(); }
IntrusivePtr<RecordVal> MIME_Message::ToHeaderVal(MIME_Header* h)
{ {
static auto mime_header_rec = zeek::id::find_type<RecordType>("mime_header_rec"); static auto mime_header_rec = zeek::id::find_type<RecordType>("mime_header_rec");
auto header_record = make_intrusive<RecordVal>(mime_header_rec); auto header_record = make_intrusive<RecordVal>(mime_header_rec);
header_record->Assign(0, new_string_val(h->get_name())); header_record->Assign(0, to_string_val(h->get_name()));
auto upper_hn = new_string_val(h->get_name()); auto upper_hn = to_string_val(h->get_name());
upper_hn->ToUpper(); upper_hn->ToUpper();
header_record->Assign(1, std::move(upper_hn)); header_record->Assign(1, std::move(upper_hn));
header_record->Assign(2, new_string_val(h->get_value())); header_record->Assign(2, to_string_val(h->get_value()));
return header_record; return header_record;
} }
IntrusivePtr<TableVal> MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist) TableVal* MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
{ return ToHeaderTable(hlist).release(); }
IntrusivePtr<TableVal> MIME_Message::ToHeaderTable(MIME_HeaderList& hlist)
{ {
static auto mime_header_list = zeek::id::find_type<TableType>("mime_header_list"); static auto mime_header_list = zeek::id::find_type<TableType>("mime_header_list");
auto t = make_intrusive<TableVal>(mime_header_list); auto t = make_intrusive<TableVal>(mime_header_list);
@ -1308,7 +1323,7 @@ IntrusivePtr<TableVal> MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
{ {
auto index = val_mgr->Count(i + 1); // index starting from 1 auto index = val_mgr->Count(i + 1); // index starting from 1
MIME_Header* h = hlist[i]; MIME_Header* h = hlist[i];
t->Assign(std::move(index), BuildHeaderVal(h)); t->Assign(std::move(index), ToHeaderVal(h));
} }
return t; return t;
@ -1427,7 +1442,7 @@ void MIME_Mail::SubmitHeader(MIME_Header* h)
if ( mime_one_header ) if ( mime_one_header )
analyzer->EnqueueConnEvent(mime_one_header, analyzer->EnqueueConnEvent(mime_one_header,
analyzer->ConnVal(), analyzer->ConnVal(),
BuildHeaderVal(h) ToHeaderVal(h)
); );
} }
@ -1436,7 +1451,7 @@ void MIME_Mail::SubmitAllHeaders(MIME_HeaderList& hlist)
if ( mime_all_headers ) if ( mime_all_headers )
analyzer->EnqueueConnEvent(mime_all_headers, analyzer->EnqueueConnEvent(mime_all_headers,
analyzer->ConnVal(), analyzer->ConnVal(),
BuildHeaderTable(hlist) ToHeaderTable(hlist)
); );
} }

View file

@ -97,8 +97,12 @@ public:
MIME_Entity* Parent() const { return parent; } MIME_Entity* Parent() const { return parent; }
int MIMEContentType() const { return content_type; } int MIMEContentType() const { return content_type; }
const IntrusivePtr<StringVal>& ContentType() const { return content_type_str; } [[deprecated("Remove in v4.1. Use GetContentType().")]]
const IntrusivePtr<StringVal>& ContentSubType() const { return content_subtype_str; } StringVal* ContentType() const { return content_type_str.get(); }
[[deprecated("Remove in v4.1. Use GetContentSubType().")]]
StringVal* ContentSubType() const { return content_subtype_str.get(); }
const IntrusivePtr<StringVal>& GetContentType() const { return content_type_str; }
const IntrusivePtr<StringVal>& GetContentSubType() const { return content_subtype_str; }
int ContentTransferEncoding() const { return content_encoding; } int ContentTransferEncoding() const { return content_encoding; }
protected: protected:
@ -225,8 +229,13 @@ protected:
MIME_Entity* top_level; MIME_Entity* top_level;
bool finished; bool finished;
IntrusivePtr<RecordVal> BuildHeaderVal(MIME_Header* h); [[deprecated("Remove in v4.1. Use ToHeaderVal().")]]
IntrusivePtr<TableVal> BuildHeaderTable(MIME_HeaderList& hlist); RecordVal* BuildHeaderVal(MIME_Header* h);
[[deprecated("Remove in v4.1. Use ToHeaderTable().")]]
TableVal* BuildHeaderTable(MIME_HeaderList& hlist);
IntrusivePtr<RecordVal> ToHeaderVal(MIME_Header* h);
IntrusivePtr<TableVal> ToHeaderTable(MIME_HeaderList& hlist);
}; };
class MIME_Mail final : public MIME_Message { class MIME_Mail final : public MIME_Message {
@ -265,9 +274,15 @@ protected:
extern bool is_null_data_chunk(data_chunk_t b); extern bool is_null_data_chunk(data_chunk_t b);
extern IntrusivePtr<StringVal> new_string_val(int length, const char* data); [[deprecated("Remove in v4.1. Use analyzer::mime::to_string_val().")]]
extern IntrusivePtr<StringVal> new_string_val(const char* data, const char* end_of_data); extern StringVal* new_string_val(int length, const char* data);
extern IntrusivePtr<StringVal> new_string_val(const data_chunk_t buf); [[deprecated("Remove in v4.1. Use analyzer::mime::to_string_val().")]]
extern StringVal* new_string_val(const char* data, const char* end_of_data);
[[deprecated("Remove in v4.1. Use analyzer::mime::to_string_val().")]]
extern StringVal* new_string_val(const data_chunk_t buf);
extern IntrusivePtr<StringVal> to_string_val(int length, const char* data);
extern IntrusivePtr<StringVal> to_string_val(const char* data, const char* end_of_data);
extern IntrusivePtr<StringVal> to_string_val(const data_chunk_t buf);
extern int fputs(data_chunk_t b, FILE* fp); extern int fputs(data_chunk_t b, FILE* fp);
extern bool istrequal(data_chunk_t s, const char* t); extern bool istrequal(data_chunk_t s, const char* t);
extern bool is_lws(char ch); extern bool is_lws(char ch);

View file

@ -552,7 +552,7 @@ bool Manager::PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int
std::string serial_data(data, len); std::string serial_data(data, len);
free(data); free(data);
auto v = log_topic_func->operator()(IntrusivePtr{NewRef{}, stream}, auto v = log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream},
make_intrusive<StringVal>(path)); make_intrusive<StringVal>(path));
if ( ! v ) if ( ! v )

View file

@ -188,7 +188,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
topic_func = global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc(); topic_func = global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc();
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}}; zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
auto topic = topic_func->operator()(&vl); auto topic = topic_func->Invoke(&vl);
if ( ! topic->AsString()->Len() ) if ( ! topic->AsString()->Len() )
return val_mgr->False(); return val_mgr->False();
@ -225,7 +225,7 @@ function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
topic_func = global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc(); topic_func = global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc();
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}}; zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
auto topic = topic_func->operator()(&vl); auto topic = topic_func->Invoke(&vl);
if ( ! topic->AsString()->Len() ) if ( ! topic->AsString()->Len() )
return val_mgr->False(); return val_mgr->False();

View file

@ -62,7 +62,7 @@ bool file_analysis::X509::EndOfFile()
return false; return false;
// yup, let's call the callback. // yup, let's call the callback.
cache_hit_callback->operator()(GetFile()->ToVal(), entry, cache_hit_callback->Invoke(GetFile()->ToVal(), entry,
make_intrusive<StringVal>(cert_sha256)); make_intrusive<StringVal>(cert_sha256));
return false; return false;
} }

View file

@ -480,11 +480,11 @@ bool Manager::CreateTableStream(RecordVal* fval)
auto dst = fval->GetFieldOrDefault("destination"); auto dst = fval->GetFieldOrDefault("destination");
// check if index fields match table description // check if index fields match table description
int num = idx->NumFields(); size_t num = idx->NumFields();
const auto& tl = dst->GetType()->AsTableType()->IndexTypes(); const auto& tl = dst->GetType()->AsTableType()->IndexTypes();
int j; size_t j;
for ( j = 0; j < static_cast<int>(tl.size()); ++j ) for ( j = 0; j < tl.size(); ++j )
{ {
if ( j >= num ) if ( j >= num )
{ {
@ -1768,7 +1768,7 @@ bool Manager::CallPred(Func* pred_func, const int numvals, ...) const
va_end(lP); va_end(lP);
auto v = pred_func->operator()(&vl); auto v = pred_func->Invoke(&vl);
if ( v ) if ( v )
result = v->AsBool(); result = v->AsBool();

View file

@ -717,7 +717,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
// See whether the predicates indicates that we want // See whether the predicates indicates that we want
// to log this record. // to log this record.
int result = 1; int result = 1;
auto v = filter->pred->operator()(columns); auto v = filter->pred->Invoke(columns);
if ( v ) if ( v )
result = v->AsBool(); result = v->AsBool();
@ -744,7 +744,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
// Can be TYPE_ANY here. // Can be TYPE_ANY here.
rec_arg = columns; rec_arg = columns;
auto v = filter->path_func->operator()(IntrusivePtr{NewRef{}, id}, auto v = filter->path_func->Invoke(IntrusivePtr{NewRef{}, id},
std::move(path_arg), std::move(path_arg),
std::move(rec_arg)); std::move(rec_arg));
@ -1050,7 +1050,7 @@ threading::Value** Manager::RecordToFilterVals(Stream* stream, Filter* filter,
if ( filter->num_ext_fields > 0 ) if ( filter->num_ext_fields > 0 )
{ {
auto res = filter->ext_func->operator()(IntrusivePtr{NewRef{}, filter->path_val}); auto res = filter->ext_func->Invoke(IntrusivePtr{NewRef{}, filter->path_val});
if ( res ) if ( res )
ext_rec = {AdoptRef{}, res.release()->AsRecordVal()}; ext_rec = {AdoptRef{}, res.release()->AsRecordVal()};
@ -1527,7 +1527,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
// Call the postprocessor function. // Call the postprocessor function.
int result = 0; int result = 0;
auto v = func->operator()(std::move(info)); auto v = func->Invoke(std::move(info));
if ( v ) if ( v )
result = v->AsBool(); result = v->AsBool();

View file

@ -24,7 +24,7 @@ static bool call_option_handlers_and_set_value(StringVal* name, const IntrusiveP
if ( add_loc ) if ( add_loc )
vl.emplace_back(NewRef{}, location); vl.emplace_back(NewRef{}, location);
val = handler_function->operator()(&vl); // consumed by next call. val = handler_function->Invoke(&vl); // consumed by next call.
if ( ! val ) if ( ! val )
{ {

View file

@ -1338,7 +1338,7 @@ bool sort_function(const IntrusivePtr<Val>& a, const IntrusivePtr<Val>& b)
if ( ! b ) if ( ! b )
return 1; return 1;
auto result = sort_function_comp->operator()(a, b); auto result = sort_function_comp->Invoke(a, b);
int int_result = result->CoerceToInt(); int int_result = result->CoerceToInt();
return int_result < 0; return int_result < 0;
@ -1516,7 +1516,7 @@ function order%(v: any, ...%) : index_vec
if ( comp ) if ( comp )
{ {
const auto& comp_type = comp->GetType()->AsFuncType(); const auto& comp_type = comp->GetType();
if ( comp_type->Yield()->Tag() != TYPE_INT || if ( comp_type->Yield()->Tag() != TYPE_INT ||
! comp_type->ParamList()->AllMatch(elt_type, 0) ) ! comp_type->ParamList()->AllMatch(elt_type, 0) )
{ {