mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Deprecate RecordVal::Lookup(int), replace with GetField(int)
This commit is contained in:
parent
377779bb2a
commit
f729247778
20 changed files with 78 additions and 60 deletions
2
NEWS
2
NEWS
|
@ -197,6 +197,8 @@ Deprecated Functionality
|
||||||
- ``RecordVal::Assign(int, Val*)`` is deprecated, use the overload taking
|
- ``RecordVal::Assign(int, Val*)`` is deprecated, use the overload taking
|
||||||
``IntrusivePtr``.
|
``IntrusivePtr``.
|
||||||
|
|
||||||
|
- ``RecordVal::Lookup(int)`` is deprecated, use ``RecordVal::GetField(int)``.
|
||||||
|
|
||||||
Zeek 3.1.0
|
Zeek 3.1.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
|
|
||||||
for ( int i = 0; i < num_fields; ++i )
|
for ( int i = 0; i < num_fields; ++i )
|
||||||
{
|
{
|
||||||
auto rv_i = rv->Lookup(i);
|
auto rv_i = rv->GetField(i).get();
|
||||||
|
|
||||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||||
bool optional = (a && a->FindAttr(ATTR_OPTIONAL));
|
bool optional = (a && a->FindAttr(ATTR_OPTIONAL));
|
||||||
|
@ -518,7 +518,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
bool optional = (a && a->FindAttr(ATTR_OPTIONAL));
|
bool optional = (a && a->FindAttr(ATTR_OPTIONAL));
|
||||||
|
|
||||||
sz = SingleTypeKeySize(rt->GetFieldType(i).get(),
|
sz = SingleTypeKeySize(rt->GetFieldType(i).get(),
|
||||||
rv ? rv->Lookup(i) : nullptr,
|
rv ? rv->GetField(i).get() : nullptr,
|
||||||
type_check, sz, optional,
|
type_check, sz, optional,
|
||||||
calc_static_size);
|
calc_static_size);
|
||||||
if ( ! sz )
|
if ( ! sz )
|
||||||
|
|
|
@ -430,7 +430,7 @@ void Connection::AppendAddl(const char* str)
|
||||||
{
|
{
|
||||||
const auto& cv = ConnVal();
|
const auto& cv = ConnVal();
|
||||||
|
|
||||||
const char* old = cv->Lookup(6)->AsString()->CheckString();
|
const char* old = cv->GetField(6)->AsString()->CheckString();
|
||||||
const char* format = *old ? "%s %s" : "%s%s";
|
const char* format = *old ? "%s %s" : "%s%s";
|
||||||
|
|
||||||
cv->Assign(6, make_intrusive<StringVal>(fmt(format, old, str)));
|
cv->Assign(6, make_intrusive<StringVal>(fmt(format, old, str)));
|
||||||
|
@ -699,7 +699,7 @@ void Connection::CheckFlowLabel(bool is_orig, uint32_t flow_label)
|
||||||
{
|
{
|
||||||
if ( conn_val )
|
if ( conn_val )
|
||||||
{
|
{
|
||||||
RecordVal *endp = conn_val->Lookup(is_orig ? 1 : 2)->AsRecordVal();
|
RecordVal* endp = conn_val->GetField(is_orig ? 1 : 2)->AsRecordVal();
|
||||||
endp->Assign(4, val_mgr->Count(flow_label));
|
endp->Assign(4, val_mgr->Count(flow_label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/Expr.cc
10
src/Expr.cc
|
@ -2897,8 +2897,8 @@ void FieldExpr::Delete(Frame* f)
|
||||||
|
|
||||||
IntrusivePtr<Val> FieldExpr::Fold(Val* v) const
|
IntrusivePtr<Val> FieldExpr::Fold(Val* v) const
|
||||||
{
|
{
|
||||||
if ( Val* result = v->AsRecordVal()->Lookup(field) )
|
if ( const auto& result = v->AsRecordVal()->GetField(field) )
|
||||||
return {NewRef{}, result};
|
return result;
|
||||||
|
|
||||||
// Check for &default.
|
// Check for &default.
|
||||||
const Attr* def_attr = td ? td->FindAttr(ATTR_DEFAULT) : nullptr;
|
const Attr* def_attr = td ? td->FindAttr(ATTR_DEFAULT) : nullptr;
|
||||||
|
@ -2959,7 +2959,7 @@ HasFieldExpr::~HasFieldExpr()
|
||||||
IntrusivePtr<Val> HasFieldExpr::Fold(Val* v) const
|
IntrusivePtr<Val> HasFieldExpr::Fold(Val* v) const
|
||||||
{
|
{
|
||||||
auto rv = v->AsRecordVal();
|
auto rv = v->AsRecordVal();
|
||||||
return val_mgr->Bool(rv->Lookup(field));
|
return val_mgr->Bool(rv->GetField(field) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HasFieldExpr::ExprDescribe(ODesc* d) const
|
void HasFieldExpr::ExprDescribe(ODesc* d) const
|
||||||
|
@ -3659,7 +3659,7 @@ IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
|
||||||
{
|
{
|
||||||
if ( map[i] >= 0 )
|
if ( map[i] >= 0 )
|
||||||
{
|
{
|
||||||
IntrusivePtr<Val> rhs{NewRef{}, rv->Lookup(map[i])};
|
auto rhs = rv->GetField(map[i]);
|
||||||
|
|
||||||
if ( ! rhs )
|
if ( ! rhs )
|
||||||
{
|
{
|
||||||
|
@ -4830,7 +4830,7 @@ IntrusivePtr<Val> CastExpr::Eval(Frame* f) const
|
||||||
d.Add("'");
|
d.Add("'");
|
||||||
|
|
||||||
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) &&
|
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) &&
|
||||||
! v->AsRecordVal()->Lookup(0) )
|
! v->AsRecordVal()->GetField(0) )
|
||||||
d.Add(" (nil $data field)");
|
d.Add(" (nil $data field)");
|
||||||
|
|
||||||
RuntimeError(d.Description());
|
RuntimeError(d.Description());
|
||||||
|
|
|
@ -107,19 +107,19 @@ BroSubstring::Vec* BroSubstring::VecFromPolicy(VectorVal* vec)
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const BroString* str = v->AsRecordVal()->Lookup(0)->AsString();
|
const BroString* str = v->AsRecordVal()->GetField(0)->AsString();
|
||||||
BroSubstring* substr = new BroSubstring(*str);
|
BroSubstring* substr = new BroSubstring(*str);
|
||||||
|
|
||||||
const VectorVal* aligns = v->AsRecordVal()->Lookup(1)->AsVectorVal();
|
const VectorVal* aligns = v->AsRecordVal()->GetField(1)->AsVectorVal();
|
||||||
for ( unsigned int j = 1; j <= aligns->Size(); ++j )
|
for ( unsigned int j = 1; j <= aligns->Size(); ++j )
|
||||||
{
|
{
|
||||||
const RecordVal* align = aligns->AsVectorVal()->Lookup(j)->AsRecordVal();
|
const RecordVal* align = aligns->AsVectorVal()->Lookup(j)->AsRecordVal();
|
||||||
const BroString* str = align->Lookup(0)->AsString();
|
const BroString* str = align->GetField(0)->AsString();
|
||||||
int index = align->Lookup(1)->AsCount();
|
int index = align->GetField(1)->AsCount();
|
||||||
substr->AddAlignment(str, index);
|
substr->AddAlignment(str, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool new_alignment = v->AsRecordVal()->Lookup(2)->AsBool();
|
bool new_alignment = v->AsRecordVal()->GetField(2)->AsBool();
|
||||||
substr->MarkNewAlignment(new_alignment);
|
substr->MarkNewAlignment(new_alignment);
|
||||||
|
|
||||||
result->push_back(substr);
|
result->push_back(substr);
|
||||||
|
|
|
@ -804,10 +804,10 @@ IntrusivePtr<TableVal> RecordType::GetRecordFieldsVal(const RecordVal* rv) const
|
||||||
{
|
{
|
||||||
const auto& ft = GetFieldType(i);
|
const auto& ft = GetFieldType(i);
|
||||||
const TypeDecl* fd = FieldDecl(i);
|
const TypeDecl* fd = FieldDecl(i);
|
||||||
Val* fv = nullptr;
|
IntrusivePtr<Val> fv;
|
||||||
|
|
||||||
if ( rv )
|
if ( rv )
|
||||||
fv = rv->Lookup(i);
|
fv = rv->GetField(i);
|
||||||
|
|
||||||
bool logged = (fd->attrs && fd->FindAttr(ATTR_LOG) != nullptr);
|
bool logged = (fd->attrs && fd->FindAttr(ATTR_LOG) != nullptr);
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ IntrusivePtr<TableVal> RecordType::GetRecordFieldsVal(const RecordVal* rv) const
|
||||||
string s = container_type_name(ft.get());
|
string s = container_type_name(ft.get());
|
||||||
nr->Assign(0, make_intrusive<StringVal>(s));
|
nr->Assign(0, make_intrusive<StringVal>(s));
|
||||||
nr->Assign(1, val_mgr->Bool(logged));
|
nr->Assign(1, val_mgr->Bool(logged));
|
||||||
nr->Assign(2, {NewRef{}, fv});
|
nr->Assign(2, std::move(fv));
|
||||||
nr->Assign(3, FieldDefault(i));
|
nr->Assign(3, FieldDefault(i));
|
||||||
Val* field_name = new StringVal(FieldName(i));
|
Val* field_name = new StringVal(FieldName(i));
|
||||||
rval->Assign(field_name, std::move(nr));
|
rval->Assign(field_name, std::move(nr));
|
||||||
|
|
23
src/Val.cc
23
src/Val.cc
|
@ -2741,11 +2741,6 @@ void RecordVal::Assign(int field, Val* new_val)
|
||||||
Assign(field, {AdoptRef{}, new_val});
|
Assign(field, {AdoptRef{}, new_val});
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* RecordVal::Lookup(int field) const
|
|
||||||
{
|
|
||||||
return (*AsRecord())[field].get();
|
|
||||||
}
|
|
||||||
|
|
||||||
IntrusivePtr<Val> RecordVal::LookupWithDefault(int field) const
|
IntrusivePtr<Val> RecordVal::LookupWithDefault(int field) const
|
||||||
{
|
{
|
||||||
const auto& val = (*AsRecord())[field];
|
const auto& val = (*AsRecord())[field];
|
||||||
|
@ -2793,7 +2788,7 @@ IntrusivePtr<Val> RecordVal::Lookup(const char* field, bool with_default) const
|
||||||
if ( idx < 0 )
|
if ( idx < 0 )
|
||||||
reporter->InternalError("missing record field: %s", field);
|
reporter->InternalError("missing record field: %s", field);
|
||||||
|
|
||||||
return with_default ? LookupWithDefault(idx) : IntrusivePtr{NewRef{}, Lookup(idx)};
|
return with_default ? LookupWithDefault(idx) : GetField(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||||
|
@ -2827,7 +2822,7 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* v = Lookup(i);
|
const auto& v = GetField(i);
|
||||||
|
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
// Check for allowable optional fields is outside the loop, below.
|
// Check for allowable optional fields is outside the loop, below.
|
||||||
|
@ -2837,18 +2832,18 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||||
|
|
||||||
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft.get(), v->GetType().get()) )
|
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft.get(), v->GetType().get()) )
|
||||||
{
|
{
|
||||||
auto rhs = make_intrusive<ConstExpr>(IntrusivePtr{NewRef{}, v});
|
auto rhs = make_intrusive<ConstExpr>(v);
|
||||||
auto e = make_intrusive<RecordCoerceExpr>(std::move(rhs),
|
auto e = make_intrusive<RecordCoerceExpr>(std::move(rhs),
|
||||||
cast_intrusive<RecordType>(ft));
|
cast_intrusive<RecordType>(ft));
|
||||||
aggr->Assign(t_i, e->Eval(nullptr));
|
aggr->Assign(t_i, e->Eval(nullptr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
aggr->Assign(t_i, {NewRef{}, v});
|
aggr->Assign(t_i, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < ar_t->NumFields(); ++i )
|
for ( i = 0; i < ar_t->NumFields(); ++i )
|
||||||
if ( ! aggr->Lookup(i) &&
|
if ( ! aggr->GetField(i) &&
|
||||||
! ar_t->FieldDecl(i)->FindAttr(ATTR_OPTIONAL) )
|
! ar_t->FieldDecl(i)->FindAttr(ATTR_OPTIONAL) )
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
@ -3390,12 +3385,12 @@ IntrusivePtr<Val> cast_value_to_type(Val* v, BroType* t)
|
||||||
|
|
||||||
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
||||||
{
|
{
|
||||||
auto dv = v->AsRecordVal()->Lookup(0);
|
const auto& dv = v->AsRecordVal()->GetField(0);
|
||||||
|
|
||||||
if ( ! dv )
|
if ( ! dv )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return static_cast<bro_broker::DataVal*>(dv)->castTo(t);
|
return static_cast<bro_broker::DataVal*>(dv.get())->castTo(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -3416,12 +3411,12 @@ bool can_cast_value_to_type(const Val* v, BroType* t)
|
||||||
|
|
||||||
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
||||||
{
|
{
|
||||||
auto dv = v->AsRecordVal()->Lookup(0);
|
const auto& dv = v->AsRecordVal()->GetField(0);
|
||||||
|
|
||||||
if ( ! dv )
|
if ( ! dv )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return static_cast<const bro_broker::DataVal *>(dv)->canCastTo(t);
|
return static_cast<const bro_broker::DataVal *>(dv.get())->canCastTo(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
22
src/Val.h
22
src/Val.h
|
@ -965,7 +965,27 @@ public:
|
||||||
void Assign(int field, std::nullptr_t)
|
void Assign(int field, std::nullptr_t)
|
||||||
{ Assign(field, IntrusivePtr<Val>{}); }
|
{ Assign(field, IntrusivePtr<Val>{}); }
|
||||||
|
|
||||||
Val* Lookup(int field) const; // Does not Ref() value.
|
[[deprecated("Remove in v4.1. Use GetField().")]]
|
||||||
|
Val* Lookup(int field) const // Does not Ref() value.
|
||||||
|
{ return (*AsRecord())[field].get(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field index.
|
||||||
|
* @param field The field index to retrieve.
|
||||||
|
* @return The value at the given field index.
|
||||||
|
*/
|
||||||
|
const IntrusivePtr<Val>& GetField(int field) const
|
||||||
|
{ return (*AsRecord())[field]; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field index as cast to type @c T.
|
||||||
|
* @param field The field index to retrieve.
|
||||||
|
* @return The value at the given field index cast to type @c T.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
IntrusivePtr<T> GetField(int field) const
|
||||||
|
{ return cast_intrusive<T>(GetField(field)); }
|
||||||
|
|
||||||
IntrusivePtr<Val> LookupWithDefault(int field) const;
|
IntrusivePtr<Val> LookupWithDefault(int field) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -263,7 +263,7 @@ refine connection KRB_Conn += {
|
||||||
rv->Assign(1, val_mgr->Bool(${msg.ap_options.mutual_required}));
|
rv->Assign(1, val_mgr->Bool(${msg.ap_options.mutual_required}));
|
||||||
|
|
||||||
auto rvticket = proc_ticket(${msg.ticket});
|
auto rvticket = proc_ticket(${msg.ticket});
|
||||||
auto authenticationinfo = bro_analyzer()->GetAuthenticationInfo(rvticket->Lookup(2)->AsString(), rvticket->Lookup(4)->AsString(), rvticket->Lookup(3)->AsCount());
|
auto authenticationinfo = bro_analyzer()->GetAuthenticationInfo(rvticket->GetField(2)->AsString(), rvticket->GetField(4)->AsString(), rvticket->GetField(3)->AsCount());
|
||||||
|
|
||||||
if ( authenticationinfo )
|
if ( authenticationinfo )
|
||||||
rvticket->Assign(5, authenticationinfo);
|
rvticket->Assign(5, authenticationinfo);
|
||||||
|
|
|
@ -175,7 +175,7 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status,
|
||||||
|
|
||||||
case BifEnum::NFS3::PROC_READ:
|
case BifEnum::NFS3::PROC_READ:
|
||||||
bro_uint_t offset;
|
bro_uint_t offset;
|
||||||
offset = c->RequestVal()->AsRecordVal()->Lookup(1)->AsCount();
|
offset = c->RequestVal()->AsRecordVal()->GetField(1)->AsCount();
|
||||||
reply = nfs3_read_reply(buf, n, nfs_status, offset);
|
reply = nfs3_read_reply(buf, n, nfs_status, offset);
|
||||||
event = nfs_proc_read;
|
event = nfs_proc_read;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
RecordVal* rv = c->RequestVal()->AsRecordVal();
|
RecordVal* rv = c->RequestVal()->AsRecordVal();
|
||||||
Val* is_tcp = rv->Lookup(2);
|
const auto& is_tcp = rv->GetField(2);
|
||||||
reply = val_mgr->Port(CheckPort(port), is_tcp->IsOne() ?
|
reply = val_mgr->Port(CheckPort(port), is_tcp->IsOne() ?
|
||||||
TRANSPORT_TCP : TRANSPORT_UDP);
|
TRANSPORT_TCP : TRANSPORT_UDP);
|
||||||
event = pm_request_getport;
|
event = pm_request_getport;
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ void TCP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
{
|
{
|
||||||
syn_weirds(flags, endpoint, len);
|
syn_weirds(flags, endpoint, len);
|
||||||
RecordVal* SYN_vals = build_syn_packet_val(is_orig, ip, tp);
|
RecordVal* SYN_vals = build_syn_packet_val(is_orig, ip, tp);
|
||||||
init_window(endpoint, peer, flags, SYN_vals->Lookup(5)->CoerceToInt(),
|
init_window(endpoint, peer, flags, SYN_vals->GetField(5)->CoerceToInt(),
|
||||||
base_seq, ack_seq);
|
base_seq, ack_seq);
|
||||||
|
|
||||||
if ( connection_SYN_packet )
|
if ( connection_SYN_packet )
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ IntrusivePtr<EnumVal> bro_broker::get_data_type(RecordVal* v, Frame* frame)
|
||||||
|
|
||||||
broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f)
|
broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f)
|
||||||
{
|
{
|
||||||
Val* d = v->Lookup(0);
|
const auto& d = v->GetField(0);
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
|
reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
|
||||||
|
@ -1132,7 +1132,7 @@ broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f)
|
||||||
|
|
||||||
// RuntimeError throws an exception which causes this line to never exceute.
|
// RuntimeError throws an exception which causes this line to never exceute.
|
||||||
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
|
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
|
||||||
return static_cast<DataVal*>(d)->data;
|
return static_cast<DataVal*>(d.get())->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bro_broker::DataVal::ValDescribe(ODesc* d) const
|
void bro_broker::DataVal::ValDescribe(ODesc* d) const
|
||||||
|
|
|
@ -386,18 +386,18 @@ bool Manager::PublishEvent(string topic, RecordVal* args)
|
||||||
if ( peer_count == 0 )
|
if ( peer_count == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( ! args->Lookup(0) )
|
if ( ! args->GetField(0) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto event_name = args->Lookup(0)->AsString()->CheckString();
|
auto event_name = args->GetField(0)->AsString()->CheckString();
|
||||||
auto vv = args->Lookup(1)->AsVectorVal();
|
auto vv = args->GetField(1)->AsVectorVal();
|
||||||
broker::vector xs;
|
broker::vector xs;
|
||||||
xs.reserve(vv->Size());
|
xs.reserve(vv->Size());
|
||||||
|
|
||||||
for ( auto i = 0u; i < vv->Size(); ++i )
|
for ( auto i = 0u; i < vv->Size(); ++i )
|
||||||
{
|
{
|
||||||
auto val = vv->Lookup(i)->AsRecordVal()->Lookup(0);
|
const auto& val = vv->Lookup(i)->AsRecordVal()->GetField(0);
|
||||||
auto data_val = static_cast<DataVal*>(val);
|
auto data_val = static_cast<DataVal*>(val.get());
|
||||||
xs.emplace_back(data_val->data);
|
xs.emplace_back(data_val->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
||||||
else
|
else
|
||||||
data_val = make_data_val((*args)[i]);
|
data_val = make_data_val((*args)[i]);
|
||||||
|
|
||||||
if ( ! data_val->Lookup(0) )
|
if ( ! data_val->GetField(0) )
|
||||||
{
|
{
|
||||||
rval->Assign(0, nullptr);
|
rval->Assign(0, nullptr);
|
||||||
Error("failed to convert param #%d of type %s to broker data",
|
Error("failed to convert param #%d of type %s to broker data",
|
||||||
|
|
|
@ -104,15 +104,15 @@ broker::backend_options to_backend_options(broker::backend backend,
|
||||||
switch ( backend ) {
|
switch ( backend ) {
|
||||||
case broker::sqlite:
|
case broker::sqlite:
|
||||||
{
|
{
|
||||||
auto path = options->Lookup(0)->AsRecordVal()
|
auto path = options->GetField(0)->AsRecordVal()
|
||||||
->Lookup(0)->AsStringVal()->CheckString();
|
->GetField(0)->AsStringVal()->CheckString();
|
||||||
return {{"path", path}};
|
return {{"path", path}};
|
||||||
}
|
}
|
||||||
|
|
||||||
case broker::rocksdb:
|
case broker::rocksdb:
|
||||||
{
|
{
|
||||||
auto path = options->Lookup(1)->AsRecordVal()
|
auto path = options->GetField(1)->AsRecordVal()
|
||||||
->Lookup(0)->AsStringVal()->CheckString();
|
->GetField(0)->AsStringVal()->CheckString();
|
||||||
return {{"path", path}};
|
return {{"path", path}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
using namespace file_analysis;
|
using namespace file_analysis;
|
||||||
|
|
||||||
static IntrusivePtr<Val> empty_connection_table()
|
static IntrusivePtr<TableVal> empty_connection_table()
|
||||||
{
|
{
|
||||||
auto tbl_index = make_intrusive<TypeList>(zeek::id::conn_id);
|
auto tbl_index = make_intrusive<TypeList>(zeek::id::conn_id);
|
||||||
tbl_index->Append(zeek::id::conn_id);
|
tbl_index->Append(zeek::id::conn_id);
|
||||||
|
@ -121,7 +121,7 @@ void File::UpdateLastActivityTime()
|
||||||
|
|
||||||
double File::GetLastActivityTime() const
|
double File::GetLastActivityTime() const
|
||||||
{
|
{
|
||||||
return val->Lookup(last_active_idx)->AsTime();
|
return val->GetField(last_active_idx)->AsTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
|
bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
|
||||||
|
@ -129,7 +129,7 @@ bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
|
||||||
if ( ! conn )
|
if ( ! conn )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Val* conns = val->Lookup(conns_idx);
|
Val* conns = val->GetField(conns_idx).get();
|
||||||
|
|
||||||
if ( ! conns )
|
if ( ! conns )
|
||||||
{
|
{
|
||||||
|
@ -184,7 +184,7 @@ int File::Idx(const std::string& field, const RecordType* type)
|
||||||
|
|
||||||
std::string File::GetSource() const
|
std::string File::GetSource() const
|
||||||
{
|
{
|
||||||
Val* v = val->Lookup(source_idx);
|
const auto& v = val->GetField(source_idx);
|
||||||
|
|
||||||
return v ? v->AsString()->CheckString() : std::string();
|
return v ? v->AsString()->CheckString() : std::string();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,8 @@ void File::SetTotalBytes(uint64_t size)
|
||||||
|
|
||||||
bool File::IsComplete() const
|
bool File::IsComplete() const
|
||||||
{
|
{
|
||||||
Val* total = val->Lookup(total_bytes_idx);
|
const auto& total = val->GetField(total_bytes_idx);
|
||||||
|
|
||||||
if ( ! total )
|
if ( ! total )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -308,7 +309,7 @@ void File::InferMetadata()
|
||||||
{
|
{
|
||||||
did_metadata_inference = true;
|
did_metadata_inference = true;
|
||||||
|
|
||||||
Val* bof_buffer_val = val->Lookup(bof_buffer_idx);
|
Val* bof_buffer_val = val->GetField(bof_buffer_idx).get();
|
||||||
|
|
||||||
if ( ! bof_buffer_val )
|
if ( ! bof_buffer_val )
|
||||||
{
|
{
|
||||||
|
@ -317,7 +318,7 @@ void File::InferMetadata()
|
||||||
|
|
||||||
BroString* bs = concatenate(bof_buffer.chunks);
|
BroString* bs = concatenate(bof_buffer.chunks);
|
||||||
val->Assign<StringVal>(bof_buffer_idx, bs);
|
val->Assign<StringVal>(bof_buffer_idx, bs);
|
||||||
bof_buffer_val = val->Lookup(bof_buffer_idx);
|
bof_buffer_val = val->GetField(bof_buffer_idx).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! FileEventAvailable(file_sniff) )
|
if ( ! FileEventAvailable(file_sniff) )
|
||||||
|
|
|
@ -1089,7 +1089,7 @@ threading::Value** Manager::RecordToFilterVals(Stream* stream, Filter* filter,
|
||||||
|
|
||||||
for ( list<int>::iterator j = indices.begin(); j != indices.end(); ++j )
|
for ( list<int>::iterator j = indices.begin(); j != indices.end(); ++j )
|
||||||
{
|
{
|
||||||
val = val->AsRecordVal()->Lookup(*j);
|
val = val->AsRecordVal()->GetField(*j).get();
|
||||||
|
|
||||||
if ( ! val )
|
if ( ! val )
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,7 +81,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
|
||||||
|
|
||||||
if ( same_type(val->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
if ( same_type(val->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
|
||||||
{
|
{
|
||||||
auto dv = static_cast<bro_broker::DataVal*>(val->AsRecordVal()->Lookup(0));
|
auto dv = static_cast<bro_broker::DataVal*>(val->AsRecordVal()->GetField(0).get());
|
||||||
auto val_from_data = dv->castTo(i->GetType().get());
|
auto val_from_data = dv->castTo(i->GetType().get());
|
||||||
|
|
||||||
if ( ! val_from_data )
|
if ( ! val_from_data )
|
||||||
|
|
|
@ -138,7 +138,7 @@ function Reporter::conn_weird%(name: string, c: connection, addl: string &defaul
|
||||||
## Returns: true if the file was still valid, else false.
|
## Returns: true if the file was still valid, else false.
|
||||||
function Reporter::file_weird%(name: string, f: fa_file, addl: string &default=""%): bool
|
function Reporter::file_weird%(name: string, f: fa_file, addl: string &default=""%): bool
|
||||||
%{
|
%{
|
||||||
auto fuid = f->AsRecordVal()->Lookup(0)->AsStringVal();
|
auto fuid = f->AsRecordVal()->GetField(0)->AsStringVal();
|
||||||
auto file = file_mgr->LookupFile(fuid->CheckString());
|
auto file = file_mgr->LookupFile(fuid->CheckString());
|
||||||
|
|
||||||
if ( ! file )
|
if ( ! file )
|
||||||
|
|
|
@ -681,8 +681,8 @@ function string_to_ascii_hex%(s: string%): string
|
||||||
## Returns: The result of the Smith-Waterman algorithm calculation.
|
## Returns: The result of the Smith-Waterman algorithm calculation.
|
||||||
function str_smith_waterman%(s1: string, s2: string, params: sw_params%) : sw_substring_vec
|
function str_smith_waterman%(s1: string, s2: string, params: sw_params%) : sw_substring_vec
|
||||||
%{
|
%{
|
||||||
SWParams sw_params(params->AsRecordVal()->Lookup(0)->AsCount(),
|
SWParams sw_params(params->AsRecordVal()->GetField(0)->AsCount(),
|
||||||
SWVariant(params->AsRecordVal()->Lookup(1)->AsCount()));
|
SWVariant(params->AsRecordVal()->GetField(1)->AsCount()));
|
||||||
|
|
||||||
BroSubstring::Vec* subseq =
|
BroSubstring::Vec* subseq =
|
||||||
smith_waterman(s1->AsString(), s2->AsString(), sw_params);
|
smith_waterman(s1->AsString(), s2->AsString(), sw_params);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue