mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
clang-format: Set penalty for breaking after assignment operator
This commit is contained in:
parent
4423574d26
commit
9af6b2f48d
54 changed files with 255 additions and 247 deletions
|
@ -70,6 +70,10 @@ SpacesInParentheses: false
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
UseTab: AlignWithSpaces
|
UseTab: AlignWithSpaces
|
||||||
|
|
||||||
|
# Setting this to a high number causes clang-format to prefer breaking somewhere else
|
||||||
|
# over breaking after the assignment operator in a line that's over the column limit
|
||||||
|
PenaltyBreakAssignment: 100
|
||||||
|
|
||||||
IncludeBlocks: Regroup
|
IncludeBlocks: Regroup
|
||||||
|
|
||||||
# Include categories go like this:
|
# Include categories go like this:
|
||||||
|
|
|
@ -1167,15 +1167,15 @@ void DNS_Mgr::IssueAsyncRequests()
|
||||||
if ( req->IsAddrReq() )
|
if ( req->IsAddrReq() )
|
||||||
success = DoRequest(nb_dns, new DNS_Mgr_Request(req->host));
|
success = DoRequest(nb_dns, new DNS_Mgr_Request(req->host));
|
||||||
else if ( req->is_txt )
|
else if ( req->is_txt )
|
||||||
success =
|
success = DoRequest(nb_dns,
|
||||||
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
|
new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If only one request type succeeds, don't consider it a failure.
|
// If only one request type succeeds, don't consider it a failure.
|
||||||
success =
|
success = DoRequest(nb_dns,
|
||||||
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
|
new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
|
||||||
success =
|
success = DoRequest(nb_dns,
|
||||||
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET6, req->is_txt)) ||
|
new DNS_Mgr_Request(req->name.c_str(), AF_INET6, req->is_txt)) ||
|
||||||
success;
|
success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1060,8 +1060,8 @@ int Dictionary::LookupIndex(const void* key, int key_size, detail::hash_t hash,
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int linear_position = LinearLookupIndex(key, key_size, hash);
|
int linear_position = LinearLookupIndex(key, key_size, hash);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
int position =
|
int position = LookupIndex(key, key_size, hash, bucket, Capacity(), insert_position,
|
||||||
LookupIndex(key, key_size, hash, bucket, Capacity(), insert_position, insert_distance);
|
insert_distance);
|
||||||
if ( position >= 0 )
|
if ( position >= 0 )
|
||||||
{
|
{
|
||||||
ASSERT(position == linear_position); // same as linearLookup
|
ASSERT(position == linear_position); // same as linearLookup
|
||||||
|
|
|
@ -72,8 +72,8 @@ bool Discarder::NextPacket(const std::unique_ptr<IP_Hdr>& ip, int len, int caple
|
||||||
|
|
||||||
bool is_tcp = (proto == IPPROTO_TCP);
|
bool is_tcp = (proto == IPPROTO_TCP);
|
||||||
bool is_udp = (proto == IPPROTO_UDP);
|
bool is_udp = (proto == IPPROTO_UDP);
|
||||||
int min_hdr_len =
|
int min_hdr_len = is_tcp ? sizeof(struct tcphdr)
|
||||||
is_tcp ? sizeof(struct tcphdr) : (is_udp ? sizeof(struct udphdr) : sizeof(struct icmp));
|
: (is_udp ? sizeof(struct udphdr) : sizeof(struct icmp));
|
||||||
|
|
||||||
if ( len < min_hdr_len || caplen < min_hdr_len )
|
if ( len < min_hdr_len || caplen < min_hdr_len )
|
||||||
// we don't have a complete protocol header
|
// we don't have a complete protocol header
|
||||||
|
|
|
@ -32,8 +32,8 @@ const FuncTypePtr& EventHandler::GetType(bool check_export)
|
||||||
if ( type )
|
if ( type )
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
const auto& id =
|
const auto& id = detail::lookup_ID(name.data(), detail::current_module.c_str(), false, false,
|
||||||
detail::lookup_ID(name.data(), detail::current_module.c_str(), false, false, check_export);
|
check_export);
|
||||||
|
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return FuncType::nil;
|
return FuncType::nil;
|
||||||
|
|
46
src/Expr.cc
46
src/Expr.cc
|
@ -277,8 +277,8 @@ void Expr::AssignToIndex(ValPtr v1, ValPtr v2, ValPtr v3) const
|
||||||
{
|
{
|
||||||
bool iterators_invalidated;
|
bool iterators_invalidated;
|
||||||
|
|
||||||
auto error_msg =
|
auto error_msg = assign_to_index(std::move(v1), std::move(v2), std::move(v3),
|
||||||
assign_to_index(std::move(v1), std::move(v2), std::move(v3), iterators_invalidated);
|
iterators_invalidated);
|
||||||
|
|
||||||
if ( iterators_invalidated )
|
if ( iterators_invalidated )
|
||||||
{
|
{
|
||||||
|
@ -718,8 +718,8 @@ ValPtr UnaryExpr::Fold(Val* v) const
|
||||||
|
|
||||||
void UnaryExpr::ExprDescribe(ODesc* d) const
|
void UnaryExpr::ExprDescribe(ODesc* d) const
|
||||||
{
|
{
|
||||||
bool is_coerce =
|
bool is_coerce = Tag() == EXPR_ARITH_COERCE || Tag() == EXPR_RECORD_COERCE ||
|
||||||
Tag() == EXPR_ARITH_COERCE || Tag() == EXPR_RECORD_COERCE || Tag() == EXPR_TABLE_COERCE;
|
Tag() == EXPR_TABLE_COERCE;
|
||||||
|
|
||||||
if ( d->IsReadable() )
|
if ( d->IsReadable() )
|
||||||
{
|
{
|
||||||
|
@ -1084,8 +1084,8 @@ ValPtr BinaryExpr::PatternFold(Val* v1, Val* v2) const
|
||||||
if ( tag != EXPR_AND && tag != EXPR_OR )
|
if ( tag != EXPR_AND && tag != EXPR_OR )
|
||||||
BadTag("BinaryExpr::PatternFold");
|
BadTag("BinaryExpr::PatternFold");
|
||||||
|
|
||||||
RE_Matcher* res =
|
RE_Matcher* res = tag == EXPR_AND ? RE_Matcher_conjunction(re1, re2)
|
||||||
tag == EXPR_AND ? RE_Matcher_conjunction(re1, re2) : RE_Matcher_disjunction(re1, re2);
|
: RE_Matcher_disjunction(re1, re2);
|
||||||
|
|
||||||
return make_intrusive<PatternVal>(res);
|
return make_intrusive<PatternVal>(res);
|
||||||
}
|
}
|
||||||
|
@ -2860,8 +2860,8 @@ IndexExpr::IndexExpr(ExprPtr arg_op1, ListExprPtr arg_op2, bool arg_is_slice)
|
||||||
|
|
||||||
if ( match_type == DOES_NOT_MATCH_INDEX )
|
if ( match_type == DOES_NOT_MATCH_INDEX )
|
||||||
{
|
{
|
||||||
std::string error_msg =
|
std::string error_msg = util::fmt(
|
||||||
util::fmt("expression with type '%s' is not a type that can be indexed",
|
"expression with type '%s' is not a type that can be indexed",
|
||||||
type_name(op1->GetType()->Tag()));
|
type_name(op1->GetType()->Tag()));
|
||||||
SetError(error_msg.data());
|
SetError(error_msg.data());
|
||||||
}
|
}
|
||||||
|
@ -3995,8 +3995,8 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, RecordTypePtr r)
|
||||||
if ( ! is_arithmetic_promotable(sup_t_i.get(), sub_t_i.get()) &&
|
if ( ! is_arithmetic_promotable(sup_t_i.get(), sub_t_i.get()) &&
|
||||||
! is_record_promotable(sup_t_i.get(), sub_t_i.get()) )
|
! is_record_promotable(sup_t_i.get(), sub_t_i.get()) )
|
||||||
{
|
{
|
||||||
std::string error_msg =
|
std::string error_msg = util::fmt("type clash for field \"%s\"",
|
||||||
util::fmt("type clash for field \"%s\"", sub_r->FieldName(i));
|
sub_r->FieldName(i));
|
||||||
Error(error_msg.c_str(), sub_t_i.get());
|
Error(error_msg.c_str(), sub_t_i.get());
|
||||||
SetError();
|
SetError();
|
||||||
break;
|
break;
|
||||||
|
@ -4015,8 +4015,8 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, RecordTypePtr r)
|
||||||
{
|
{
|
||||||
if ( ! t_r->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) )
|
if ( ! t_r->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) )
|
||||||
{
|
{
|
||||||
std::string error_msg =
|
std::string error_msg = util::fmt("non-optional field \"%s\" missing",
|
||||||
util::fmt("non-optional field \"%s\" missing", t_r->FieldName(i));
|
t_r->FieldName(i));
|
||||||
Error(error_msg.c_str());
|
Error(error_msg.c_str());
|
||||||
SetError();
|
SetError();
|
||||||
break;
|
break;
|
||||||
|
@ -4101,8 +4101,8 @@ RecordValPtr coerce_to_record(RecordTypePtr rt, Val* v, const std::vector<int>&
|
||||||
if ( rhs_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
|
if ( rhs_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
|
||||||
! same_type(rhs_type, field_type) )
|
! same_type(rhs_type, field_type) )
|
||||||
{
|
{
|
||||||
if ( auto new_val =
|
if ( auto new_val = rhs->AsRecordVal()->CoerceTo(
|
||||||
rhs->AsRecordVal()->CoerceTo(cast_intrusive<RecordType>(field_type)) )
|
cast_intrusive<RecordType>(field_type)) )
|
||||||
rhs = std::move(new_val);
|
rhs = std::move(new_val);
|
||||||
}
|
}
|
||||||
else if ( BothArithmetic(rhs_type->Tag(), field_type->Tag()) &&
|
else if ( BothArithmetic(rhs_type->Tag(), field_type->Tag()) &&
|
||||||
|
@ -4125,8 +4125,8 @@ RecordValPtr coerce_to_record(RecordTypePtr rt, Val* v, const std::vector<int>&
|
||||||
if ( def_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
|
if ( def_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
|
||||||
! same_type(def_type, field_type) )
|
! same_type(def_type, field_type) )
|
||||||
{
|
{
|
||||||
auto tmp =
|
auto tmp = def_val->AsRecordVal()->CoerceTo(
|
||||||
def_val->AsRecordVal()->CoerceTo(cast_intrusive<RecordType>(field_type));
|
cast_intrusive<RecordType>(field_type));
|
||||||
|
|
||||||
if ( tmp )
|
if ( tmp )
|
||||||
def_val = std::move(tmp);
|
def_val = std::move(tmp);
|
||||||
|
@ -4567,9 +4567,9 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing, IDPList ar
|
||||||
|
|
||||||
// Install a dummy version of the function globally for use only
|
// Install a dummy version of the function globally for use only
|
||||||
// when broker provides a closure.
|
// when broker provides a closure.
|
||||||
auto dummy_func =
|
auto dummy_func = make_intrusive<ScriptFunc>(ingredients->id, ingredients->body,
|
||||||
make_intrusive<ScriptFunc>(ingredients->id, ingredients->body, ingredients->inits,
|
ingredients->inits, ingredients->frame_size,
|
||||||
ingredients->frame_size, ingredients->priority);
|
ingredients->priority);
|
||||||
|
|
||||||
dummy_func->SetOuterIDs(outer_ids);
|
dummy_func->SetOuterIDs(outer_ids);
|
||||||
|
|
||||||
|
@ -4880,8 +4880,8 @@ TypePtr ListExpr::InitType() const
|
||||||
// Collapse any embedded sets or lists.
|
// Collapse any embedded sets or lists.
|
||||||
if ( ti->IsSet() || ti->Tag() == TYPE_LIST )
|
if ( ti->IsSet() || ti->Tag() == TYPE_LIST )
|
||||||
{
|
{
|
||||||
TypeList* til =
|
TypeList* til = ti->IsSet() ? ti->AsSetType()->GetIndices().get()
|
||||||
ti->IsSet() ? ti->AsSetType()->GetIndices().get() : ti->AsTypeList();
|
: ti->AsTypeList();
|
||||||
|
|
||||||
if ( ! til->IsPure() || ! til->AllMatch(til->GetPureType(), true) )
|
if ( ! til->IsPure() || ! til->AllMatch(til->GetPureType(), true) )
|
||||||
tl->Append({NewRef{}, til});
|
tl->Append({NewRef{}, til});
|
||||||
|
@ -5164,8 +5164,8 @@ RecordAssignExpr::RecordAssignExpr(const ExprPtr& record, const ExprPtr& init_li
|
||||||
if ( field >= 0 && same_type(lhs->GetFieldType(field), t->GetFieldType(j)) )
|
if ( field >= 0 && same_type(lhs->GetFieldType(field), t->GetFieldType(j)) )
|
||||||
{
|
{
|
||||||
auto fe_lhs = make_intrusive<FieldExpr>(record, field_name);
|
auto fe_lhs = make_intrusive<FieldExpr>(record, field_name);
|
||||||
auto fe_rhs =
|
auto fe_rhs = make_intrusive<FieldExpr>(IntrusivePtr{NewRef{}, init},
|
||||||
make_intrusive<FieldExpr>(IntrusivePtr{NewRef{}, init}, field_name);
|
field_name);
|
||||||
Append(get_assign_expr(std::move(fe_lhs), std::move(fe_rhs), is_init));
|
Append(get_assign_expr(std::move(fe_lhs), std::move(fe_rhs), is_init));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,8 +656,8 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
|
||||||
if ( homeAddr )
|
if ( homeAddr )
|
||||||
reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts");
|
reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts");
|
||||||
else
|
else
|
||||||
homeAddr =
|
homeAddr = new IPAddr(
|
||||||
new IPAddr(*((const in6_addr*)(data + sizeof(struct ip6_opt))));
|
*((const in6_addr*)(data + sizeof(struct ip6_opt))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len");
|
reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len");
|
||||||
|
|
|
@ -292,8 +292,8 @@ void init_net_var()
|
||||||
|
|
||||||
udp_content_deliver_all_orig = bool(id::find_val("udp_content_deliver_all_orig")->AsBool());
|
udp_content_deliver_all_orig = bool(id::find_val("udp_content_deliver_all_orig")->AsBool());
|
||||||
udp_content_deliver_all_resp = bool(id::find_val("udp_content_deliver_all_resp")->AsBool());
|
udp_content_deliver_all_resp = bool(id::find_val("udp_content_deliver_all_resp")->AsBool());
|
||||||
udp_content_delivery_ports_use_resp =
|
udp_content_delivery_ports_use_resp = bool(
|
||||||
bool(id::find_val("udp_content_delivery_ports_use_resp")->AsBool());
|
id::find_val("udp_content_delivery_ports_use_resp")->AsBool());
|
||||||
|
|
||||||
dns_session_timeout = id::find_val("dns_session_timeout")->AsInterval();
|
dns_session_timeout = id::find_val("dns_session_timeout")->AsInterval();
|
||||||
rpc_timeout = id::find_val("rpc_timeout")->AsInterval();
|
rpc_timeout = id::find_val("rpc_timeout")->AsInterval();
|
||||||
|
|
|
@ -94,8 +94,8 @@ std::list<std::tuple<IPPrefix, void*>> PrefixTable::FindAll(const SubNetVal* val
|
||||||
void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
|
void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
|
||||||
{
|
{
|
||||||
prefix_t* prefix = MakePrefix(addr, width);
|
prefix_t* prefix = MakePrefix(addr, width);
|
||||||
patricia_node_t* node =
|
patricia_node_t* node = exact ? patricia_search_exact(tree, prefix)
|
||||||
exact ? patricia_search_exact(tree, prefix) : patricia_search_best(tree, prefix);
|
: patricia_search_best(tree, prefix);
|
||||||
|
|
||||||
int elems = 0;
|
int elems = 0;
|
||||||
patricia_node_t** list = nullptr;
|
patricia_node_t** list = nullptr;
|
||||||
|
|
|
@ -600,10 +600,10 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Conne
|
||||||
if ( locations.size() )
|
if ( locations.size() )
|
||||||
{
|
{
|
||||||
auto locs = locations.back();
|
auto locs = locations.back();
|
||||||
raise_event =
|
raise_event = PLUGIN_HOOK_WITH_RESULT(HOOK_REPORTER,
|
||||||
PLUGIN_HOOK_WITH_RESULT(HOOK_REPORTER,
|
|
||||||
HookReporter(prefix, event, conn, addl, location,
|
HookReporter(prefix, event, conn, addl, location,
|
||||||
locs.first, locs.second, time, buffer),
|
locs.first, locs.second, time,
|
||||||
|
buffer),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -663,8 +663,8 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, const u
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug_logger.IsEnabled(DBG_RULES) )
|
if ( debug_logger.IsEnabled(DBG_RULES) )
|
||||||
{
|
{
|
||||||
const char* s =
|
const char* s = util::fmt_bytes(reinterpret_cast<const char*>(data),
|
||||||
util::fmt_bytes(reinterpret_cast<const char*>(data), min(40, static_cast<int>(len)));
|
min(40, static_cast<int>(len)));
|
||||||
DBG_LOG(DBG_RULES, "Matching %s rules on |%s%s|", Rule::TypeToString(Rule::FILE_MAGIC), s,
|
DBG_LOG(DBG_RULES, "Matching %s rules on |%s%s|", Rule::TypeToString(Rule::FILE_MAGIC), s,
|
||||||
len > 40 ? "..." : "");
|
len > 40 ? "..." : "");
|
||||||
}
|
}
|
||||||
|
@ -806,8 +806,8 @@ RuleEndpointState* RuleMatcher::InitEndpoint(analyzer::Analyzer* analyzer, const
|
||||||
case RuleHdrTest::ICMPv6:
|
case RuleHdrTest::ICMPv6:
|
||||||
case RuleHdrTest::TCP:
|
case RuleHdrTest::TCP:
|
||||||
case RuleHdrTest::UDP:
|
case RuleHdrTest::UDP:
|
||||||
match =
|
match = compare(*h->vals, getval(ip->Payload() + h->offset, h->size),
|
||||||
compare(*h->vals, getval(ip->Payload() + h->offset, h->size), h->comp);
|
h->comp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RuleHdrTest::IPSrc:
|
case RuleHdrTest::IPSrc:
|
||||||
|
@ -1405,8 +1405,8 @@ void RuleMatcherState::InitEndpointMatcher(analyzer::Analyzer* analyzer, const I
|
||||||
delete orig_match_state;
|
delete orig_match_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_match_state =
|
orig_match_state = rule_matcher->InitEndpoint(analyzer, ip, caplen, resp_match_state,
|
||||||
rule_matcher->InitEndpoint(analyzer, ip, caplen, resp_match_state, from_orig, pia);
|
from_orig, pia);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1417,8 +1417,8 @@ void RuleMatcherState::InitEndpointMatcher(analyzer::Analyzer* analyzer, const I
|
||||||
delete resp_match_state;
|
delete resp_match_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
resp_match_state =
|
resp_match_state = rule_matcher->InitEndpoint(analyzer, ip, caplen, orig_match_state,
|
||||||
rule_matcher->InitEndpoint(analyzer, ip, caplen, orig_match_state, from_orig, pia);
|
from_orig, pia);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,8 +386,9 @@ void get_final_stats()
|
||||||
{
|
{
|
||||||
iosource::PktSrc::Stats s;
|
iosource::PktSrc::Stats s;
|
||||||
ps->Statistics(&s);
|
ps->Statistics(&s);
|
||||||
double dropped_pct =
|
double dropped_pct = s.dropped > 0.0
|
||||||
s.dropped > 0.0 ? ((double)s.dropped / ((double)s.received + (double)s.dropped)) * 100.0
|
? ((double)s.dropped / ((double)s.received + (double)s.dropped)) *
|
||||||
|
100.0
|
||||||
: 0.0;
|
: 0.0;
|
||||||
reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped",
|
reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped",
|
||||||
s.received, ps->Path().c_str(), s.dropped, dropped_pct);
|
s.received, ps->Path().c_str(), s.dropped, dropped_pct);
|
||||||
|
|
|
@ -111,8 +111,8 @@ const IDPtr& lookup_ID(const char* name, const char* curr_module, bool no_global
|
||||||
std::string fullname = make_full_var_name(curr_module, name);
|
std::string fullname = make_full_var_name(curr_module, name);
|
||||||
|
|
||||||
std::string ID_module = extract_module_name(fullname.c_str());
|
std::string ID_module = extract_module_name(fullname.c_str());
|
||||||
bool need_export =
|
bool need_export = check_export &&
|
||||||
check_export && (ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module);
|
(ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module);
|
||||||
|
|
||||||
for ( auto s_i = scopes.rbegin(); s_i != scopes.rend(); ++s_i )
|
for ( auto s_i = scopes.rbegin(); s_i != scopes.rend(); ++s_i )
|
||||||
{
|
{
|
||||||
|
|
14
src/Stats.cc
14
src/Stats.cc
|
@ -392,13 +392,15 @@ void SegmentProfiler::Report()
|
||||||
struct rusage final_rusage;
|
struct rusage final_rusage;
|
||||||
getrusage(RUSAGE_SELF, &final_rusage);
|
getrusage(RUSAGE_SELF, &final_rusage);
|
||||||
|
|
||||||
double start_time =
|
double start_time = double(initial_rusage.ru_utime.tv_sec) +
|
||||||
double(initial_rusage.ru_utime.tv_sec) + double(initial_rusage.ru_utime.tv_usec) / 1e6 +
|
double(initial_rusage.ru_utime.tv_usec) / 1e6 +
|
||||||
double(initial_rusage.ru_stime.tv_sec) + double(initial_rusage.ru_stime.tv_usec) / 1e6;
|
double(initial_rusage.ru_stime.tv_sec) +
|
||||||
|
double(initial_rusage.ru_stime.tv_usec) / 1e6;
|
||||||
|
|
||||||
double stop_time =
|
double stop_time = double(final_rusage.ru_utime.tv_sec) +
|
||||||
double(final_rusage.ru_utime.tv_sec) + double(final_rusage.ru_utime.tv_usec) / 1e6 +
|
double(final_rusage.ru_utime.tv_usec) / 1e6 +
|
||||||
double(final_rusage.ru_stime.tv_sec) + double(final_rusage.ru_stime.tv_usec) / 1e6;
|
double(final_rusage.ru_stime.tv_sec) +
|
||||||
|
double(final_rusage.ru_stime.tv_usec) / 1e6;
|
||||||
|
|
||||||
int start_mem = initial_rusage.ru_maxrss * 1024;
|
int start_mem = initial_rusage.ru_maxrss * 1024;
|
||||||
int stop_mem = initial_rusage.ru_maxrss * 1024;
|
int stop_mem = initial_rusage.ru_maxrss * 1024;
|
||||||
|
|
|
@ -345,8 +345,8 @@ void do_print_stmt(const std::vector<ValPtr>& vals)
|
||||||
++offset;
|
++offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto print_log_type =
|
static auto print_log_type = static_cast<BifEnum::Log::PrintLogType>(
|
||||||
static_cast<BifEnum::Log::PrintLogType>(id::find_val("Log::print_to_log")->AsEnum());
|
id::find_val("Log::print_to_log")->AsEnum());
|
||||||
|
|
||||||
switch ( print_log_type )
|
switch ( print_log_type )
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,8 +103,8 @@ void TimerMgr::Process()
|
||||||
|
|
||||||
// Just advance the timer manager based on the current network time. This won't actually
|
// Just advance the timer manager based on the current network time. This won't actually
|
||||||
// change the time, but will dispatch any timers that need dispatching.
|
// change the time, but will dispatch any timers that need dispatching.
|
||||||
run_state::current_dispatched +=
|
run_state::current_dispatched += Advance(run_state::network_time,
|
||||||
Advance(run_state::network_time, max_timer_expires - run_state::current_dispatched);
|
max_timer_expires - run_state::current_dispatched);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerMgr::InitPostScript()
|
void TimerMgr::InitPostScript()
|
||||||
|
|
14
src/Type.cc
14
src/Type.cc
|
@ -520,8 +520,8 @@ TableType::TableType(TypeListPtr ind, TypePtr yield)
|
||||||
|
|
||||||
if ( ! is_supported_index_type(tli, &unsupported_type_name) )
|
if ( ! is_supported_index_type(tli, &unsupported_type_name) )
|
||||||
{
|
{
|
||||||
auto msg =
|
auto msg = util::fmt("index type containing '%s' is not supported",
|
||||||
util::fmt("index type containing '%s' is not supported", unsupported_type_name);
|
unsupported_type_name);
|
||||||
Error(msg, tli.get());
|
Error(msg, tli.get());
|
||||||
SetError();
|
SetError();
|
||||||
break;
|
break;
|
||||||
|
@ -1720,8 +1720,8 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
if ( doc->GetDeclaringScript() )
|
if ( doc->GetDeclaringScript() )
|
||||||
enum_from_script = doc->GetDeclaringScript()->Name();
|
enum_from_script = doc->GetDeclaringScript()->Name();
|
||||||
|
|
||||||
zeekygen::detail::IdentifierInfo* type_doc =
|
zeekygen::detail::IdentifierInfo* type_doc = detail::zeekygen_mgr->GetIdentifierInfo(
|
||||||
detail::zeekygen_mgr->GetIdentifierInfo(GetName());
|
GetName());
|
||||||
|
|
||||||
if ( type_doc && type_doc->GetDeclaringScript() )
|
if ( type_doc && type_doc->GetDeclaringScript() )
|
||||||
type_from_script = type_doc->GetDeclaringScript()->Name();
|
type_from_script = type_doc->GetDeclaringScript()->Name();
|
||||||
|
@ -2310,10 +2310,10 @@ TypePtr merge_types(const TypePtr& arg_t1, const TypePtr& arg_t2)
|
||||||
// actually see those changes from the redef.
|
// actually see those changes from the redef.
|
||||||
return id->GetType();
|
return id->GetType();
|
||||||
|
|
||||||
std::string msg =
|
std::string msg = util::fmt("incompatible enum types: '%s' and '%s'"
|
||||||
util::fmt("incompatible enum types: '%s' and '%s'"
|
|
||||||
" ('%s' enum type ID is invalid)",
|
" ('%s' enum type ID is invalid)",
|
||||||
t1->GetName().data(), t2->GetName().data(), t1->GetName().data());
|
t1->GetName().data(), t2->GetName().data(),
|
||||||
|
t1->GetName().data());
|
||||||
t1->Error(msg.data(), t2);
|
t1->Error(msg.data(), t2);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1839,8 +1839,8 @@ ValPtr TableVal::Default(const ValPtr& index)
|
||||||
record_promotion_compatible(dtype->AsRecordType(), ytype->AsRecordType()) )
|
record_promotion_compatible(dtype->AsRecordType(), ytype->AsRecordType()) )
|
||||||
{
|
{
|
||||||
auto rt = cast_intrusive<RecordType>(ytype);
|
auto rt = cast_intrusive<RecordType>(ytype);
|
||||||
auto coerce =
|
auto coerce = make_intrusive<detail::RecordCoerceExpr>(def_attr->GetExpr(),
|
||||||
make_intrusive<detail::RecordCoerceExpr>(def_attr->GetExpr(), std::move(rt));
|
std::move(rt));
|
||||||
|
|
||||||
def_val = coerce->Eval(nullptr);
|
def_val = coerce->Eval(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,8 +271,8 @@ public:
|
||||||
static constexpr bro_uint_t PREALLOCATED_COUNTS = 4096;
|
static constexpr bro_uint_t PREALLOCATED_COUNTS = 4096;
|
||||||
static constexpr bro_uint_t PREALLOCATED_INTS = 512;
|
static constexpr bro_uint_t PREALLOCATED_INTS = 512;
|
||||||
static constexpr bro_int_t PREALLOCATED_INT_LOWEST = -255;
|
static constexpr bro_int_t PREALLOCATED_INT_LOWEST = -255;
|
||||||
static constexpr bro_int_t PREALLOCATED_INT_HIGHEST =
|
static constexpr bro_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST +
|
||||||
PREALLOCATED_INT_LOWEST + PREALLOCATED_INTS - 1;
|
PREALLOCATED_INTS - 1;
|
||||||
|
|
||||||
ValManager();
|
ValManager();
|
||||||
|
|
||||||
|
|
|
@ -865,8 +865,8 @@ bool DNS_Interpreter::ParseRR_EDNS(detail::DNS_MsgInfo* msg, const u_char*& data
|
||||||
|
|
||||||
if ( server_cookie_len >= 8 )
|
if ( server_cookie_len >= 8 )
|
||||||
{
|
{
|
||||||
cookie.server_cookie =
|
cookie.server_cookie = ExtractStream(data, server_cookie_len,
|
||||||
ExtractStream(data, server_cookie_len, server_cookie_len);
|
server_cookie_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzer->EnqueueConnEvent(dns_EDNS_cookie, analyzer->ConnVal(), msg->BuildHdrVal(),
|
analyzer->EnqueueConnEvent(dns_EDNS_cookie, analyzer->ConnVal(), msg->BuildHdrVal(),
|
||||||
|
|
|
@ -330,8 +330,8 @@ void HTTP_Entity::SubmitData(int len, const char* buf)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( send_size && content_length > 0 )
|
if ( send_size && content_length > 0 )
|
||||||
precomputed_file_id =
|
precomputed_file_id = file_mgr->SetSize(
|
||||||
file_mgr->SetSize(content_length, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(),
|
content_length, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(),
|
||||||
http_message->MyHTTP_Analyzer()->Conn(), http_message->IsOrig(),
|
http_message->MyHTTP_Analyzer()->Conn(), http_message->IsOrig(),
|
||||||
precomputed_file_id);
|
precomputed_file_id);
|
||||||
|
|
||||||
|
@ -894,8 +894,8 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
|
||||||
const char* line = reinterpret_cast<const char*>(data);
|
const char* line = reinterpret_cast<const char*>(data);
|
||||||
const char* end_of_line = line + len;
|
const char* end_of_line = line + len;
|
||||||
|
|
||||||
analyzer::tcp::ContentLine_Analyzer* content_line =
|
analyzer::tcp::ContentLine_Analyzer* content_line = is_orig ? content_line_orig
|
||||||
is_orig ? content_line_orig : content_line_resp;
|
: content_line_resp;
|
||||||
|
|
||||||
if ( content_line->IsPlainDelivery() )
|
if ( content_line->IsPlainDelivery() )
|
||||||
{
|
{
|
||||||
|
@ -1063,8 +1063,8 @@ void HTTP_Analyzer::Undelivered(uint64_t seq, int len, bool is_orig)
|
||||||
|
|
||||||
HTTP_Message* msg = is_orig ? request_message : reply_message;
|
HTTP_Message* msg = is_orig ? request_message : reply_message;
|
||||||
|
|
||||||
analyzer::tcp::ContentLine_Analyzer* content_line =
|
analyzer::tcp::ContentLine_Analyzer* content_line = is_orig ? content_line_orig
|
||||||
is_orig ? content_line_orig : content_line_resp;
|
: content_line_resp;
|
||||||
|
|
||||||
if ( ! content_line->IsSkippedContents(seq, len) )
|
if ( ! content_line->IsSkippedContents(seq, len) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1461,9 +1461,9 @@ void MIME_Mail::SubmitData(int len, const char* buf)
|
||||||
make_intrusive<StringVal>(data_len, data));
|
make_intrusive<StringVal>(data_len, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_entity_id =
|
cur_entity_id = file_mgr->DataIn(reinterpret_cast<const u_char*>(buf), len,
|
||||||
file_mgr->DataIn(reinterpret_cast<const u_char*>(buf), len, analyzer->GetAnalyzerTag(),
|
analyzer->GetAnalyzerTag(), analyzer->Conn(), is_orig,
|
||||||
analyzer->Conn(), is_orig, cur_entity_id);
|
cur_entity_id);
|
||||||
|
|
||||||
cur_entity_len += len;
|
cur_entity_len += len;
|
||||||
buffer_start = (buf + len) - (char*)data_buffer->Bytes();
|
buffer_start = (buf + len) - (char*)data_buffer->Bytes();
|
||||||
|
|
|
@ -382,11 +382,11 @@ void PIA_TCP::ActivateAnalyzer(analyzer::Tag tag, const zeek::detail::Rule* rule
|
||||||
|
|
||||||
auto* tcp = static_cast<packet_analysis::TCP::TCPSessionAdapter*>(Parent());
|
auto* tcp = static_cast<packet_analysis::TCP::TCPSessionAdapter*>(Parent());
|
||||||
|
|
||||||
auto* reass_orig =
|
auto* reass_orig = new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct,
|
||||||
new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct, tcp->Orig());
|
tcp->Orig());
|
||||||
|
|
||||||
auto* reass_resp =
|
auto* reass_resp = new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct,
|
||||||
new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct, tcp->Resp());
|
tcp->Resp());
|
||||||
|
|
||||||
uint64_t orig_seq = 0;
|
uint64_t orig_seq = 0;
|
||||||
uint64_t resp_seq = 0;
|
uint64_t resp_seq = 0;
|
||||||
|
|
|
@ -585,9 +585,9 @@ void POP3_Analyzer::ProcessReply(int length, const char* line)
|
||||||
|
|
||||||
if ( multiLine == true )
|
if ( multiLine == true )
|
||||||
{
|
{
|
||||||
bool terminator =
|
bool terminator = line[0] == '.' &&
|
||||||
line[0] == '.' &&
|
(length == 1 ||
|
||||||
(length == 1 || (length > 1 && (line[1] == '\n' ||
|
(length > 1 && (line[1] == '\n' ||
|
||||||
(length > 2 && line[1] == '\r' && line[2] == '\n'))));
|
(length > 2 && line[1] == '\r' && line[2] == '\n'))));
|
||||||
|
|
||||||
if ( terminator )
|
if ( terminator )
|
||||||
|
|
|
@ -69,8 +69,8 @@ RPC_CallInfo::RPC_CallInfo(uint32_t arg_xid, const u_char*& buf, int& n, double
|
||||||
stamp = extract_XDR_uint32(cred_opaque, cred_opaque_n);
|
stamp = extract_XDR_uint32(cred_opaque, cred_opaque_n);
|
||||||
int machinename_n;
|
int machinename_n;
|
||||||
constexpr auto max_machinename_len = 255;
|
constexpr auto max_machinename_len = 255;
|
||||||
auto mnp =
|
auto mnp = extract_XDR_opaque(cred_opaque, cred_opaque_n, machinename_n,
|
||||||
extract_XDR_opaque(cred_opaque, cred_opaque_n, machinename_n, max_machinename_len);
|
max_machinename_len);
|
||||||
|
|
||||||
if ( ! mnp )
|
if ( ! mnp )
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,14 +42,14 @@ TCP_Reassembler::TCP_Reassembler(analyzer::Analyzer* arg_dst_analyzer,
|
||||||
|
|
||||||
if ( ::tcp_contents )
|
if ( ::tcp_contents )
|
||||||
{
|
{
|
||||||
static auto tcp_content_delivery_ports_orig =
|
static auto tcp_content_delivery_ports_orig = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("tcp_content_delivery_ports_orig");
|
"tcp_content_delivery_ports_orig");
|
||||||
static auto tcp_content_delivery_ports_resp =
|
static auto tcp_content_delivery_ports_resp = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("tcp_content_delivery_ports_resp");
|
"tcp_content_delivery_ports_resp");
|
||||||
const auto& dst_port_val =
|
const auto& dst_port_val = val_mgr->Port(ntohs(tcp_analyzer->Conn()->RespPort()),
|
||||||
val_mgr->Port(ntohs(tcp_analyzer->Conn()->RespPort()), TRANSPORT_TCP);
|
TRANSPORT_TCP);
|
||||||
const auto& ports =
|
const auto& ports = IsOrig() ? tcp_content_delivery_ports_orig
|
||||||
IsOrig() ? tcp_content_delivery_ports_orig : tcp_content_delivery_ports_resp;
|
: tcp_content_delivery_ports_resp;
|
||||||
auto result = ports->FindOrDefault(dst_port_val);
|
auto result = ports->FindOrDefault(dst_port_val);
|
||||||
|
|
||||||
if ( (IsOrig() && zeek::detail::tcp_content_deliver_all_orig) ||
|
if ( (IsOrig() && zeek::detail::tcp_content_deliver_all_orig) ||
|
||||||
|
@ -519,9 +519,9 @@ void TCP_Reassembler::AckReceived(uint64_t seq)
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool test_active =
|
bool test_active = ! skip_deliveries && ! tcp_analyzer->Skipping() &&
|
||||||
! skip_deliveries && ! tcp_analyzer->Skipping() &&
|
(BifConst::report_gaps_for_partial ||
|
||||||
(BifConst::report_gaps_for_partial || (endp->state == TCP_ENDPOINT_ESTABLISHED &&
|
(endp->state == TCP_ENDPOINT_ESTABLISHED &&
|
||||||
endp->peer->state == TCP_ENDPOINT_ESTABLISHED));
|
endp->peer->state == TCP_ENDPOINT_ESTABLISHED));
|
||||||
|
|
||||||
uint64_t num_missing = TrimToSeq(seq);
|
uint64_t num_missing = TrimToSeq(seq);
|
||||||
|
|
|
@ -364,8 +364,8 @@ struct val_converter
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
for ( auto& item : a )
|
for ( auto& item : a )
|
||||||
{
|
{
|
||||||
auto item_val =
|
auto item_val = data_to_val(move(item),
|
||||||
data_to_val(move(item), pure ? lt->GetPureType().get() : types[pos].get());
|
pure ? lt->GetPureType().get() : types[pos].get());
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
if ( ! item_val )
|
if ( ! item_val )
|
||||||
|
|
|
@ -376,8 +376,8 @@ void Manager::InitializeBrokerStoreForwarding()
|
||||||
if ( id->HasVal() && id->GetAttr(zeek::detail::ATTR_BACKEND) )
|
if ( id->HasVal() && id->GetAttr(zeek::detail::ATTR_BACKEND) )
|
||||||
{
|
{
|
||||||
const auto& attr = id->GetAttr(zeek::detail::ATTR_BACKEND);
|
const auto& attr = id->GetAttr(zeek::detail::ATTR_BACKEND);
|
||||||
auto e =
|
auto e = static_cast<BifEnum::Broker::BackendType>(
|
||||||
static_cast<BifEnum::Broker::BackendType>(attr->GetExpr()->Eval(nullptr)->AsEnum());
|
attr->GetExpr()->Eval(nullptr)->AsEnum());
|
||||||
auto storename = std::string("___sync_store_") + global.first;
|
auto storename = std::string("___sync_store_") + global.first;
|
||||||
id->GetVal()->AsTableVal()->SetBrokerStore(storename);
|
id->GetVal()->AsTableVal()->SetBrokerStore(storename);
|
||||||
AddForwardedStore(storename, cast_intrusive<TableVal>(id->GetVal()));
|
AddForwardedStore(storename, cast_intrusive<TableVal>(id->GetVal()));
|
||||||
|
@ -739,8 +739,8 @@ 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 =
|
auto v = log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream},
|
||||||
log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream}, make_intrusive<StringVal>(path));
|
make_intrusive<StringVal>(path));
|
||||||
|
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
{
|
{
|
||||||
|
@ -1797,8 +1797,8 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const detail::Stor
|
||||||
if ( its.size() == 1 )
|
if ( its.size() == 1 )
|
||||||
zeek_key = detail::data_to_val(key, its[0].get());
|
zeek_key = detail::data_to_val(key, its[0].get());
|
||||||
else
|
else
|
||||||
zeek_key =
|
zeek_key = detail::data_to_val(key,
|
||||||
detail::data_to_val(key, table->GetType()->AsTableType()->GetIndices().get());
|
table->GetType()->AsTableType()->GetIndices().get());
|
||||||
|
|
||||||
if ( ! zeek_key )
|
if ( ! zeek_key )
|
||||||
{
|
{
|
||||||
|
|
|
@ -177,8 +177,8 @@ RecordValPtr X509::ParseCertificate(X509Val* cert_val, file_analysis::File* f)
|
||||||
|
|
||||||
if ( OBJ_obj2nid(algorithm) == NID_md5WithRSAEncryption )
|
if ( OBJ_obj2nid(algorithm) == NID_md5WithRSAEncryption )
|
||||||
{
|
{
|
||||||
ASN1_OBJECT* copy =
|
ASN1_OBJECT* copy = OBJ_dup(
|
||||||
OBJ_dup(algorithm); // the next line will destroy the original algorithm.
|
algorithm); // the next line will destroy the original algorithm.
|
||||||
X509_PUBKEY_set0_param(X509_get_X509_PUBKEY(ssl_cert), OBJ_nid2obj(NID_rsaEncryption), 0,
|
X509_PUBKEY_set0_param(X509_get_X509_PUBKEY(ssl_cert), OBJ_nid2obj(NID_rsaEncryption), 0,
|
||||||
NULL, NULL, 0);
|
NULL, NULL, 0);
|
||||||
algorithm = copy;
|
algorithm = copy;
|
||||||
|
@ -288,8 +288,8 @@ void X509::ParseBasicConstraints(X509_EXTENSION* ex)
|
||||||
{
|
{
|
||||||
if ( x509_ext_basic_constraints )
|
if ( x509_ext_basic_constraints )
|
||||||
{
|
{
|
||||||
auto pBasicConstraint =
|
auto pBasicConstraint = make_intrusive<RecordVal>(
|
||||||
make_intrusive<RecordVal>(BifType::Record::X509::BasicConstraints);
|
BifType::Record::X509::BasicConstraints);
|
||||||
pBasicConstraint->Assign(0, constr->ca);
|
pBasicConstraint->Assign(0, constr->ca);
|
||||||
|
|
||||||
if ( constr->pathlen )
|
if ( constr->pathlen )
|
||||||
|
|
|
@ -205,8 +205,8 @@ void X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION* ext)
|
||||||
unsigned char* ext_val_second_pointer = ext_val_copy;
|
unsigned char* ext_val_second_pointer = ext_val_copy;
|
||||||
memcpy(ext_val_copy, ext_val->data, ext_val->length);
|
memcpy(ext_val_copy, ext_val->data, ext_val->length);
|
||||||
|
|
||||||
ASN1_OCTET_STRING* inner =
|
ASN1_OCTET_STRING* inner = d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**)&ext_val_copy,
|
||||||
d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**)&ext_val_copy, ext_val->length);
|
ext_val->length);
|
||||||
if ( ! inner )
|
if ( ! inner )
|
||||||
{
|
{
|
||||||
reporter->Error(
|
reporter->Error(
|
||||||
|
|
|
@ -1179,8 +1179,8 @@ int Manager::SendEntryTable(Stream* i, const Value* const* vals)
|
||||||
zeek::detail::hash_t valhash = 0;
|
zeek::detail::hash_t valhash = 0;
|
||||||
if ( stream->num_val_fields > 0 )
|
if ( stream->num_val_fields > 0 )
|
||||||
{
|
{
|
||||||
if ( zeek::detail::HashKey* valhashkey =
|
if ( zeek::detail::HashKey* valhashkey = HashValues(stream->num_val_fields,
|
||||||
HashValues(stream->num_val_fields, vals + stream->num_idx_fields) )
|
vals + stream->num_idx_fields) )
|
||||||
{
|
{
|
||||||
valhash = valhashkey->Hash();
|
valhash = valhashkey->Hash();
|
||||||
delete (valhashkey);
|
delete (valhashkey);
|
||||||
|
@ -1681,8 +1681,8 @@ int Manager::PutTable(Stream* i, const Value* const* vals)
|
||||||
{
|
{
|
||||||
// in case of update send back the old value.
|
// in case of update send back the old value.
|
||||||
assert(stream->num_val_fields > 0);
|
assert(stream->num_val_fields > 0);
|
||||||
auto ev =
|
auto ev = BifType::Enum::Input::Event->GetEnumVal(
|
||||||
BifType::Enum::Input::Event->GetEnumVal(BifEnum::Input::EVENT_CHANGED);
|
BifEnum::Input::EVENT_CHANGED);
|
||||||
assert(oldval != nullptr);
|
assert(oldval != nullptr);
|
||||||
SendEvent(stream->event, 4, stream->description->Ref(), ev.release(), predidx,
|
SendEvent(stream->event, 4, stream->description->Ref(), ev.release(), predidx,
|
||||||
oldval.release());
|
oldval.release());
|
||||||
|
@ -1746,8 +1746,8 @@ bool Manager::Delete(ReaderFrontend* reader, Value** vals)
|
||||||
{
|
{
|
||||||
TableStream* stream = (TableStream*)i;
|
TableStream* stream = (TableStream*)i;
|
||||||
bool convert_error = false;
|
bool convert_error = false;
|
||||||
Val* idxval =
|
Val* idxval = ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals,
|
||||||
ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals, convert_error);
|
convert_error);
|
||||||
readVals = stream->num_idx_fields + stream->num_val_fields;
|
readVals = stream->num_idx_fields + stream->num_val_fields;
|
||||||
bool streamresult = true;
|
bool streamresult = true;
|
||||||
|
|
||||||
|
@ -1772,8 +1772,8 @@ bool Manager::Delete(ReaderFrontend* reader, Value** vals)
|
||||||
Unref(predidx);
|
Unref(predidx);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto ev =
|
auto ev = BifType::Enum::Input::Event->GetEnumVal(
|
||||||
BifType::Enum::Input::Event->GetEnumVal(BifEnum::Input::EVENT_REMOVED);
|
BifEnum::Input::EVENT_REMOVED);
|
||||||
|
|
||||||
streamresult = CallPred(stream->pred, 3, ev.release(), predidx,
|
streamresult = CallPred(stream->pred, 3, ev.release(), predidx,
|
||||||
IntrusivePtr{val}.release());
|
IntrusivePtr{val}.release());
|
||||||
|
@ -1906,8 +1906,8 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType* request_type,
|
||||||
|
|
||||||
Val* fieldVal = nullptr;
|
Val* fieldVal = nullptr;
|
||||||
if ( request_type->GetFieldType(i)->Tag() == TYPE_RECORD )
|
if ( request_type->GetFieldType(i)->Tag() == TYPE_RECORD )
|
||||||
fieldVal =
|
fieldVal = ListValToRecordVal(list, request_type->GetFieldType(i)->AsRecordType(),
|
||||||
ListValToRecordVal(list, request_type->GetFieldType(i)->AsRecordType(), position);
|
position);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldVal = list->Idx(*position).get();
|
fieldVal = list->Idx(*position).get();
|
||||||
|
|
|
@ -419,8 +419,8 @@ bool Ascii::DoUpdate()
|
||||||
assert(val->type == TYPE_PORT);
|
assert(val->type == TYPE_PORT);
|
||||||
// Error(Fmt("Got type %d != PORT with secondary position!", val->type));
|
// Error(Fmt("Got type %d != PORT with secondary position!", val->type));
|
||||||
|
|
||||||
val->val.port_val.proto =
|
val->val.port_val.proto = formatter->ParseProto(
|
||||||
formatter->ParseProto(stringfields[(*fit).secondary_position]);
|
stringfields[(*fit).secondary_position]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fields[fpos] = val;
|
fields[fpos] = val;
|
||||||
|
|
|
@ -69,8 +69,8 @@ bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const*
|
||||||
BifConst::InputConfig::empty_field->Len());
|
BifConst::InputConfig::empty_field->Len());
|
||||||
|
|
||||||
threading::formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
|
threading::formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
|
||||||
formatter =
|
formatter = std::unique_ptr<threading::Formatter>(
|
||||||
std::unique_ptr<threading::Formatter>(new threading::formatter::Ascii(this, sep_info));
|
new threading::formatter::Ascii(this, sep_info));
|
||||||
|
|
||||||
return DoUpdate();
|
return DoUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,8 +256,8 @@ bool Raw::Execute()
|
||||||
|
|
||||||
if ( use_stderr )
|
if ( use_stderr )
|
||||||
{
|
{
|
||||||
stderrfile =
|
stderrfile = std::unique_ptr<FILE, int (*)(FILE*)>(fdopen(pipes[stderr_in], "r"),
|
||||||
std::unique_ptr<FILE, int (*)(FILE*)>(fdopen(pipes[stderr_in], "r"), fclose);
|
fclose);
|
||||||
|
|
||||||
if ( ! stderrfile )
|
if ( ! stderrfile )
|
||||||
{
|
{
|
||||||
|
@ -359,8 +359,8 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
||||||
fname = source.substr(0, fname.length() - 1);
|
fname = source.substr(0, fname.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReaderInfo::config_map::const_iterator it =
|
ReaderInfo::config_map::const_iterator it = info.config.find(
|
||||||
info.config.find("stdin"); // data that is sent to the child process
|
"stdin"); // data that is sent to the child process
|
||||||
if ( it != info.config.end() )
|
if ( it != info.config.end() )
|
||||||
{
|
{
|
||||||
stdin_string = it->second;
|
stdin_string = it->second;
|
||||||
|
@ -486,8 +486,8 @@ int64_t Raw::GetLine(FILE* arg_file)
|
||||||
repeats++;
|
repeats++;
|
||||||
// bah, we cannot use realloc because we would have to change the delete in the manager
|
// bah, we cannot use realloc because we would have to change the delete in the manager
|
||||||
// to a free.
|
// to a free.
|
||||||
std::unique_ptr<char[]> newbuf =
|
std::unique_ptr<char[]> newbuf = std::unique_ptr<char[]>(
|
||||||
std::unique_ptr<char[]>(new char[block_size * repeats]);
|
new char[block_size * repeats]);
|
||||||
memcpy(newbuf.get(), buf.get(), block_size * (repeats - 1));
|
memcpy(newbuf.get(), buf.get(), block_size * (repeats - 1));
|
||||||
buf = std::move(newbuf);
|
buf = std::move(newbuf);
|
||||||
offset = block_size * (repeats - 1);
|
offset = block_size * (repeats - 1);
|
||||||
|
|
|
@ -526,8 +526,8 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tab
|
||||||
|
|
||||||
bool optional = (bool)rtype->FieldDecl(i)->GetAttr(detail::ATTR_OPTIONAL);
|
bool optional = (bool)rtype->FieldDecl(i)->GetAttr(detail::ATTR_OPTIONAL);
|
||||||
|
|
||||||
filter->fields[filter->num_fields - 1] =
|
filter->fields[filter->num_fields - 1] = new threading::Field(new_path.c_str(), nullptr,
|
||||||
new threading::Field(new_path.c_str(), nullptr, t->Tag(), st, optional);
|
t->Tag(), st, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -868,8 +868,8 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
||||||
if ( const auto& val = filter->field_name_map->Find(fn) )
|
if ( const auto& val = filter->field_name_map->Find(fn) )
|
||||||
{
|
{
|
||||||
delete[] filter->fields[j]->name;
|
delete[] filter->fields[j]->name;
|
||||||
filter->fields[j]->name =
|
filter->fields[j]->name = util::copy_string(
|
||||||
util::copy_string(val->AsStringVal()->CheckString());
|
val->AsStringVal()->CheckString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arg_fields[j] = new threading::Field(*filter->fields[j]);
|
arg_fields[j] = new threading::Field(*filter->fields[j]);
|
||||||
|
@ -1049,8 +1049,8 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty)
|
||||||
|
|
||||||
for ( bro_int_t i = 0; i < lval->val.vector_val.size; i++ )
|
for ( bro_int_t i = 0; i < lval->val.vector_val.size; i++ )
|
||||||
{
|
{
|
||||||
lval->val.vector_val.vals[i] =
|
lval->val.vector_val.vals[i] = ValToLogVal(vec->ValAt(i).get(),
|
||||||
ValToLogVal(vec->ValAt(i).get(), vec->GetType()->Yield().get());
|
vec->GetType()->Yield().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1153,8 +1153,8 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::WriterMap::iterator w =
|
Stream::WriterMap::iterator w = stream->writers.find(
|
||||||
stream->writers.find(Stream::WriterPathPair(writer->AsEnum(), info->path));
|
Stream::WriterPathPair(writer->AsEnum(), info->path));
|
||||||
|
|
||||||
if ( w != stream->writers.end() )
|
if ( w != stream->writers.end() )
|
||||||
{
|
{
|
||||||
|
@ -1279,8 +1279,8 @@ bool Manager::WriteFromRemote(EnumVal* id, EnumVal* writer, const string& path,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::WriterMap::iterator w =
|
Stream::WriterMap::iterator w = stream->writers.find(
|
||||||
stream->writers.find(Stream::WriterPathPair(writer->AsEnum(), path));
|
Stream::WriterPathPair(writer->AsEnum(), path));
|
||||||
|
|
||||||
if ( w == stream->writers.end() )
|
if ( w == stream->writers.end() )
|
||||||
{
|
{
|
||||||
|
@ -1478,11 +1478,11 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
|
||||||
static auto base_time = log_rotate_base_time->AsString()->CheckString();
|
static auto base_time = log_rotate_base_time->AsString()->CheckString();
|
||||||
|
|
||||||
double base = util::detail::parse_rotate_base_time(base_time);
|
double base = util::detail::parse_rotate_base_time(base_time);
|
||||||
double delta_t =
|
double delta_t = util::detail::calc_next_rotate(run_state::network_time,
|
||||||
util::detail::calc_next_rotate(run_state::network_time, rotation_interval, base);
|
rotation_interval, base);
|
||||||
|
|
||||||
winfo->rotation_timer =
|
winfo->rotation_timer = new RotationTimer(run_state::network_time + delta_t, winfo,
|
||||||
new RotationTimer(run_state::network_time + delta_t, winfo, true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::detail::timer_mgr->Add(winfo->rotation_timer);
|
zeek::detail::timer_mgr->Add(winfo->rotation_timer);
|
||||||
|
@ -1561,9 +1561,9 @@ void Manager::Rotate(WriterInfo* winfo)
|
||||||
else
|
else
|
||||||
ppf = default_ppf;
|
ppf = default_ppf;
|
||||||
|
|
||||||
auto rotation_path =
|
auto rotation_path = FormatRotationPath({NewRef{}, winfo->type}, winfo->writer->Info().path,
|
||||||
FormatRotationPath({NewRef{}, winfo->type}, winfo->writer->Info().path, winfo->open_time,
|
winfo->open_time, run_state::network_time,
|
||||||
run_state::network_time, run_state::terminating, std::move(ppf));
|
run_state::terminating, std::move(ppf));
|
||||||
|
|
||||||
winfo->writer->Rotate(rotation_path.data(), winfo->open_time, run_state::network_time,
|
winfo->writer->Rotate(rotation_path.data(), winfo->open_time, run_state::network_time,
|
||||||
run_state::terminating);
|
run_state::terminating);
|
||||||
|
|
|
@ -239,8 +239,8 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals)
|
||||||
if ( vals[j][i]->type != fields[i]->type )
|
if ( vals[j][i]->type != fields[i]->type )
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const char* msg =
|
const char* msg = Fmt(
|
||||||
Fmt("Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)", i,
|
"Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)", i,
|
||||||
vals[j][i]->type, fields[i]->type);
|
vals[j][i]->type, fields[i]->type);
|
||||||
Debug(DBG_LOGGING, msg);
|
Debug(DBG_LOGGING, msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -101,8 +101,8 @@ public:
|
||||||
WriterInfo(const WriterInfo& other)
|
WriterInfo(const WriterInfo& other)
|
||||||
{
|
{
|
||||||
path = other.path ? util::copy_string(other.path) : nullptr;
|
path = other.path ? util::copy_string(other.path) : nullptr;
|
||||||
post_proc_func =
|
post_proc_func = other.post_proc_func ? util::copy_string(other.post_proc_func)
|
||||||
other.post_proc_func ? util::copy_string(other.post_proc_func) : nullptr;
|
: nullptr;
|
||||||
rotation_interval = other.rotation_interval;
|
rotation_interval = other.rotation_interval;
|
||||||
rotation_base = other.rotation_base;
|
rotation_base = other.rotation_base;
|
||||||
network_time = other.network_time;
|
network_time = other.network_time;
|
||||||
|
|
|
@ -105,8 +105,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
||||||
|
|
||||||
if ( ! sf_stream )
|
if ( ! sf_stream )
|
||||||
{
|
{
|
||||||
rval.error =
|
rval.error = util::fmt("Failed to open %s: %s", rval.shadow_filename.data(),
|
||||||
util::fmt("Failed to open %s: %s", rval.shadow_filename.data(), strerror(errno));
|
strerror(errno));
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
||||||
|
|
||||||
if ( sf_len == -1 )
|
if ( sf_len == -1 )
|
||||||
{
|
{
|
||||||
rval.error =
|
rval.error = util::fmt("Failed to ftell() on %s: %s", rval.shadow_filename.data(),
|
||||||
util::fmt("Failed to ftell() on %s: %s", rval.shadow_filename.data(), strerror(errno));
|
strerror(errno));
|
||||||
fclose(sf_stream);
|
fclose(sf_stream);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
||||||
// Use shadow file's modification time as creation time.
|
// Use shadow file's modification time as creation time.
|
||||||
if ( stat(rval.shadow_filename.data(), &st) != 0 )
|
if ( stat(rval.shadow_filename.data(), &st) != 0 )
|
||||||
{
|
{
|
||||||
rval.error =
|
rval.error = util::fmt("Failed to stat %s: %s", rval.shadow_filename.data(),
|
||||||
util::fmt("Failed to stat %s: %s", rval.shadow_filename.data(), strerror(errno));
|
strerror(errno));
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,8 +454,8 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
|
||||||
|
|
||||||
fname += ext;
|
fname += ext;
|
||||||
|
|
||||||
bool use_shadow =
|
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation &&
|
||||||
BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
|
Info().rotation_interval > 0;
|
||||||
|
|
||||||
if ( use_shadow )
|
if ( use_shadow )
|
||||||
{
|
{
|
||||||
|
@ -676,8 +676,8 @@ bool Ascii::DoRotate(const char* rotated_path, double open, double close, bool t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_shadow =
|
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation &&
|
||||||
BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
|
Info().rotation_interval > 0;
|
||||||
|
|
||||||
if ( use_shadow )
|
if ( use_shadow )
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,11 +49,11 @@ bool ICMPAnalyzer::BuildConnTuple(size_t len, const uint8_t* data, Packet* packe
|
||||||
tuple.src_port = htons(icmpp->icmp_type);
|
tuple.src_port = htons(icmpp->icmp_type);
|
||||||
|
|
||||||
if ( packet->proto == IPPROTO_ICMP )
|
if ( packet->proto == IPPROTO_ICMP )
|
||||||
tuple.dst_port =
|
tuple.dst_port = htons(
|
||||||
htons(ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
|
ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
|
||||||
else if ( packet->proto == IPPROTO_ICMPV6 )
|
else if ( packet->proto == IPPROTO_ICMPV6 )
|
||||||
tuple.dst_port =
|
tuple.dst_port = htons(
|
||||||
htons(ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
|
ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
|
||||||
else
|
else
|
||||||
reporter->InternalError("Reached ICMP packet analyzer with unknown packet protocol %x",
|
reporter->InternalError("Reached ICMP packet analyzer with unknown packet protocol %x",
|
||||||
packet->proto);
|
packet->proto);
|
||||||
|
@ -280,11 +280,11 @@ TransportProto ICMPAnalyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32_t*
|
||||||
*src_port = ntohs(icmpp->icmp_type);
|
*src_port = ntohs(icmpp->icmp_type);
|
||||||
|
|
||||||
if ( ip4 )
|
if ( ip4 )
|
||||||
*dst_port =
|
*dst_port = ntohs(
|
||||||
ntohs(ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
|
ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
|
||||||
else
|
else
|
||||||
*dst_port =
|
*dst_port = ntohs(
|
||||||
ntohs(ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
|
ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,8 @@ zeek::Connection* IPBasedAnalyzer::NewConn(const ConnTuple* id, const detail::Co
|
||||||
if ( ! WantConnection(src_h, dst_h, pkt->ip_hdr->Payload(), flip) )
|
if ( ! WantConnection(src_h, dst_h, pkt->ip_hdr->Payload(), flip) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
Connection* conn =
|
Connection* conn = new Connection(key, run_state::processing_start_time, id,
|
||||||
new Connection(key, run_state::processing_start_time, id, pkt->ip_hdr->FlowLabel(), pkt);
|
pkt->ip_hdr->FlowLabel(), pkt);
|
||||||
conn->SetTransport(transport);
|
conn->SetTransport(transport);
|
||||||
|
|
||||||
if ( flip )
|
if ( flip )
|
||||||
|
@ -293,7 +293,7 @@ void IPBasedAnalyzer::SetIgnoreChecksumsNets(TableValPtr t)
|
||||||
TableValPtr IPBasedAnalyzer::GetIgnoreChecksumsNets()
|
TableValPtr IPBasedAnalyzer::GetIgnoreChecksumsNets()
|
||||||
{
|
{
|
||||||
if ( ! IPBasedAnalyzer::ignore_checksums_nets_table )
|
if ( ! IPBasedAnalyzer::ignore_checksums_nets_table )
|
||||||
IPBasedAnalyzer::ignore_checksums_nets_table =
|
IPBasedAnalyzer::ignore_checksums_nets_table = zeek::id::find_val<TableVal>(
|
||||||
zeek::id::find_val<TableVal>("ignore_checksums_nets");
|
"ignore_checksums_nets");
|
||||||
return IPBasedAnalyzer::ignore_checksums_nets_table;
|
return IPBasedAnalyzer::ignore_checksums_nets_table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,8 +636,8 @@ void TCPSessionAdapter::Process(bool is_orig, const struct tcphdr* tp, int len,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool ack_underflow = false;
|
bool ack_underflow = false;
|
||||||
rel_ack =
|
rel_ack = get_relative_seq(peer, ack_seq, peer->AckSeq(), peer->AckWraps(),
|
||||||
get_relative_seq(peer, ack_seq, peer->AckSeq(), peer->AckWraps(), &ack_underflow);
|
&ack_underflow);
|
||||||
|
|
||||||
if ( ack_underflow )
|
if ( ack_underflow )
|
||||||
{
|
{
|
||||||
|
@ -1614,10 +1614,10 @@ void TCPSessionAdapter::AddExtraAnalyzers(Connection* conn)
|
||||||
|
|
||||||
if ( tcp_contents && ! reass )
|
if ( tcp_contents && ! reass )
|
||||||
{
|
{
|
||||||
static auto tcp_content_delivery_ports_orig =
|
static auto tcp_content_delivery_ports_orig = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("tcp_content_delivery_ports_orig");
|
"tcp_content_delivery_ports_orig");
|
||||||
static auto tcp_content_delivery_ports_resp =
|
static auto tcp_content_delivery_ports_resp = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("tcp_content_delivery_ports_resp");
|
"tcp_content_delivery_ports_resp");
|
||||||
const auto& dport = val_mgr->Port(ntohs(Conn()->RespPort()), TRANSPORT_TCP);
|
const auto& dport = val_mgr->Port(ntohs(Conn()->RespPort()), TRANSPORT_TCP);
|
||||||
|
|
||||||
if ( ! reass )
|
if ( ! reass )
|
||||||
|
@ -1821,8 +1821,8 @@ int TCPSessionAdapter::ParseTCPOptions(const struct tcphdr* tcp, bool is_orig)
|
||||||
void TCPSessionAdapter::CheckRecording(bool need_contents, analyzer::tcp::TCP_Flags flags)
|
void TCPSessionAdapter::CheckRecording(bool need_contents, analyzer::tcp::TCP_Flags flags)
|
||||||
{
|
{
|
||||||
bool record_current_content = need_contents || Conn()->RecordContents();
|
bool record_current_content = need_contents || Conn()->RecordContents();
|
||||||
bool record_current_packet =
|
bool record_current_packet = Conn()->RecordPackets() || flags.SYN() || flags.FIN() ||
|
||||||
Conn()->RecordPackets() || flags.SYN() || flags.FIN() || flags.RST();
|
flags.RST();
|
||||||
|
|
||||||
Conn()->SetRecordCurrentContent(record_current_content);
|
Conn()->SetRecordCurrentContent(record_current_content);
|
||||||
Conn()->SetRecordCurrentPacket(record_current_packet);
|
Conn()->SetRecordCurrentPacket(record_current_packet);
|
||||||
|
|
|
@ -102,9 +102,10 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
|
||||||
|
|
||||||
int chksum = up->uh_sum;
|
int chksum = up->uh_sum;
|
||||||
|
|
||||||
auto validate_checksum =
|
auto validate_checksum = ! run_state::current_pkt->l3_checksummed &&
|
||||||
! run_state::current_pkt->l3_checksummed && ! zeek::detail::ignore_checksums &&
|
! zeek::detail::ignore_checksums &&
|
||||||
! GetIgnoreChecksumsNets()->Contains(ip->IPHeaderSrcAddr()) && remaining >= len;
|
! GetIgnoreChecksumsNets()->Contains(ip->IPHeaderSrcAddr()) &&
|
||||||
|
remaining >= len;
|
||||||
|
|
||||||
constexpr auto vxlan_len = 8;
|
constexpr auto vxlan_len = 8;
|
||||||
constexpr auto eth_len = 14;
|
constexpr auto eth_len = 14;
|
||||||
|
@ -159,10 +160,10 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
|
||||||
if ( udp_contents )
|
if ( udp_contents )
|
||||||
{
|
{
|
||||||
static auto udp_content_ports = id::find_val<TableVal>("udp_content_ports");
|
static auto udp_content_ports = id::find_val<TableVal>("udp_content_ports");
|
||||||
static auto udp_content_delivery_ports_orig =
|
static auto udp_content_delivery_ports_orig = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("udp_content_delivery_ports_orig");
|
"udp_content_delivery_ports_orig");
|
||||||
static auto udp_content_delivery_ports_resp =
|
static auto udp_content_delivery_ports_resp = id::find_val<TableVal>(
|
||||||
id::find_val<TableVal>("udp_content_delivery_ports_resp");
|
"udp_content_delivery_ports_resp");
|
||||||
bool do_udp_contents = false;
|
bool do_udp_contents = false;
|
||||||
const auto& sport_val = val_mgr->Port(ntohs(up->uh_sport), TRANSPORT_UDP);
|
const auto& sport_val = val_mgr->Port(ntohs(up->uh_sport), TRANSPORT_UDP);
|
||||||
const auto& dport_val = val_mgr->Port(ntohs(up->uh_dport), TRANSPORT_UDP);
|
const auto& dport_val = val_mgr->Port(ntohs(up->uh_dport), TRANSPORT_UDP);
|
||||||
|
@ -172,8 +173,8 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
|
||||||
do_udp_contents = true;
|
do_udp_contents = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint16_t p =
|
uint16_t p = zeek::detail::udp_content_delivery_ports_use_resp ? c->RespPort()
|
||||||
zeek::detail::udp_content_delivery_ports_use_resp ? c->RespPort() : up->uh_dport;
|
: up->uh_dport;
|
||||||
const auto& port_val = zeek::val_mgr->Port(ntohs(p), TRANSPORT_UDP);
|
const auto& port_val = zeek::val_mgr->Port(ntohs(p), TRANSPORT_UDP);
|
||||||
|
|
||||||
if ( is_orig )
|
if ( is_orig )
|
||||||
|
|
|
@ -193,8 +193,8 @@ template <class T, class C> T ComponentManager<T, C>::GetComponentTag(Val* v) co
|
||||||
|
|
||||||
template <class T, class C> C* ComponentManager<T, C>::Lookup(const std::string& name) const
|
template <class T, class C> C* ComponentManager<T, C>::Lookup(const std::string& name) const
|
||||||
{
|
{
|
||||||
typename std::map<std::string, C*>::const_iterator i =
|
typename std::map<std::string, C*>::const_iterator i = components_by_name.find(
|
||||||
components_by_name.find(util::to_upper(name));
|
util::to_upper(name));
|
||||||
return i != components_by_name.end() ? i->second : 0;
|
return i != components_by_name.end() ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
block_type excess = extra_bits();
|
block_type excess = extra_bits();
|
||||||
typename std::iterator_traits<ForwardIterator>::difference_type delta =
|
typename std::iterator_traits<ForwardIterator>::difference_type delta = std::distance(first,
|
||||||
std::distance(first, last);
|
last);
|
||||||
|
|
||||||
bits.reserve(Blocks() + delta);
|
bits.reserve(Blocks() + delta);
|
||||||
|
|
||||||
|
|
|
@ -244,8 +244,8 @@ string CPPCompile::GenIncrExpr(const Expr* e, GenType gt, bool is_incr, bool top
|
||||||
// twice, so easiest is to just transform this node
|
// twice, so easiest is to just transform this node
|
||||||
// into the expanded equivalent.
|
// into the expanded equivalent.
|
||||||
auto op = e->GetOp1();
|
auto op = e->GetOp1();
|
||||||
auto one =
|
auto one = e->GetType()->InternalType() == TYPE_INTERNAL_INT ? val_mgr->Int(1)
|
||||||
e->GetType()->InternalType() == TYPE_INTERNAL_INT ? val_mgr->Int(1) : val_mgr->Count(1);
|
: val_mgr->Count(1);
|
||||||
auto one_e = make_intrusive<ConstExpr>(one);
|
auto one_e = make_intrusive<ConstExpr>(one);
|
||||||
|
|
||||||
ExprPtr rhs;
|
ExprPtr rhs;
|
||||||
|
|
|
@ -187,8 +187,8 @@ void CPPCompile::GenFuncVarInits()
|
||||||
|
|
||||||
hashes += "}";
|
hashes += "}";
|
||||||
|
|
||||||
auto init =
|
auto init = string("lookup_func__CPP(\"") + fn + "\", " + hashes + ", " + GenTypeName(ft) +
|
||||||
string("lookup_func__CPP(\"") + fn + "\", " + hashes + ", " + GenTypeName(ft) + ")";
|
")";
|
||||||
|
|
||||||
AddInit(fv, const_name, init);
|
AddInit(fv, const_name, init);
|
||||||
}
|
}
|
||||||
|
@ -226,8 +226,8 @@ void CPPCompile::GenPreInit(const Type* t)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_FILE:
|
case TYPE_FILE:
|
||||||
pre_init =
|
pre_init = string("make_intrusive<FileType>(") + GenTypeName(t->AsFileType()->Yield()) +
|
||||||
string("make_intrusive<FileType>(") + GenTypeName(t->AsFileType()->Yield()) + ")";
|
")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_OPAQUE:
|
case TYPE_OPAQUE:
|
||||||
|
|
|
@ -402,8 +402,8 @@ ExprPtr Expr::AssignToTemporary(ExprPtr e, Reducer* c, StmtPtr& red_stmt)
|
||||||
{
|
{
|
||||||
auto result_tmp = c->GenTemporaryExpr(GetType(), e);
|
auto result_tmp = c->GenTemporaryExpr(GetType(), e);
|
||||||
|
|
||||||
auto a_e =
|
auto a_e = make_intrusive<AssignExpr>(result_tmp->MakeLvalue(), e, false, nullptr, nullptr,
|
||||||
make_intrusive<AssignExpr>(result_tmp->MakeLvalue(), e, false, nullptr, nullptr, false);
|
false);
|
||||||
a_e->SetIsTemp();
|
a_e->SetIsTemp();
|
||||||
a_e->SetOriginal(ThisPtr());
|
a_e->SetOriginal(ThisPtr());
|
||||||
|
|
||||||
|
|
|
@ -837,8 +837,8 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
|
||||||
|
|
||||||
if ( value_var )
|
if ( value_var )
|
||||||
{
|
{
|
||||||
ZOp op =
|
ZOp op = no_loop_vars ? OP_NEXT_TABLE_ITER_VAL_VAR_NO_VARS_VVV
|
||||||
no_loop_vars ? OP_NEXT_TABLE_ITER_VAL_VAR_NO_VARS_VVV : OP_NEXT_TABLE_ITER_VAL_VAR_VVV;
|
: OP_NEXT_TABLE_ITER_VAL_VAR_VVV;
|
||||||
z = ZInstI(op, FrameSlot(value_var), iter_slot, 0);
|
z = ZInstI(op, FrameSlot(value_var), iter_slot, 0);
|
||||||
z.CheckIfManaged(value_var->GetType());
|
z.CheckIfManaged(value_var->GetType());
|
||||||
z.op_type = OP_VVV_I2_I3;
|
z.op_type = OP_VVV_I2_I3;
|
||||||
|
|
|
@ -59,8 +59,8 @@ public:
|
||||||
telemetry::IntCounterFamily total_family = telemetry_mgr->CounterFamily(
|
telemetry::IntCounterFamily total_family = telemetry_mgr->CounterFamily(
|
||||||
"zeek", "total-sessions", {"protocol"}, "Total number of sessions", "1", true);
|
"zeek", "total-sessions", {"protocol"}, "Total number of sessions", "1", true);
|
||||||
|
|
||||||
auto [it, inserted] =
|
auto [it, inserted] = entries.insert(
|
||||||
entries.insert({protocol, Protocol{active_family, total_family, protocol}});
|
{protocol, Protocol{active_family, total_family, protocol}});
|
||||||
|
|
||||||
if ( inserted )
|
if ( inserted )
|
||||||
return it;
|
return it;
|
||||||
|
|
|
@ -544,8 +544,8 @@ void zeek::detail::LineBufferedPipe::Emit(const char* msg) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto res =
|
auto res = hook->Invoke(make_intrusive<StringVal>(node_len, node),
|
||||||
hook->Invoke(make_intrusive<StringVal>(node_len, node), make_intrusive<StringVal>(msg));
|
make_intrusive<StringVal>(msg));
|
||||||
do_print = res->AsBool();
|
do_print = res->AsBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ IntHistogramFamily Manager::IntHistoFam(std::string_view prefix, std::string_vie
|
||||||
[&, this](auto xs)
|
[&, this](auto xs)
|
||||||
{
|
{
|
||||||
auto bounds = caf::span<const int64_t>{ubounds.data(), ubounds.size()};
|
auto bounds = caf::span<const int64_t>{ubounds.data(), ubounds.size()};
|
||||||
auto ptr =
|
auto ptr = deref(pimpl).histogram_family(prefix, name, xs, bounds, helptext, unit,
|
||||||
deref(pimpl).histogram_family(prefix, name, xs, bounds, helptext, unit, is_sum);
|
is_sum);
|
||||||
return IntHistogramFamily{opaque(ptr)};
|
return IntHistogramFamily{opaque(ptr)};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,8 @@ SCENARIO("telemetry managers provide access to counter families")
|
||||||
}
|
}
|
||||||
WHEN("retrieving a DblCounter family")
|
WHEN("retrieving a DblCounter family")
|
||||||
{
|
{
|
||||||
auto family =
|
auto family = mgr.CounterFamily<double>("zeek", "runtime", {"query"}, "test", "seconds",
|
||||||
mgr.CounterFamily<double>("zeek", "runtime", {"query"}, "test", "seconds", true);
|
true);
|
||||||
THEN("the family object stores the parameters")
|
THEN("the family object stores the parameters")
|
||||||
{
|
{
|
||||||
CHECK_EQ(family.Prefix(), "zeek"sv);
|
CHECK_EQ(family.Prefix(), "zeek"sv);
|
||||||
|
@ -338,8 +338,8 @@ SCENARIO("telemetry managers provide access to gauge families")
|
||||||
}
|
}
|
||||||
WHEN("retrieving a DblGauge family")
|
WHEN("retrieving a DblGauge family")
|
||||||
{
|
{
|
||||||
auto family =
|
auto family = mgr.GaugeFamily<double>("zeek", "water-level", {"river"}, "test",
|
||||||
mgr.GaugeFamily<double>("zeek", "water-level", {"river"}, "test", "meters");
|
"meters");
|
||||||
THEN("the family object stores the parameters")
|
THEN("the family object stores the parameters")
|
||||||
{
|
{
|
||||||
CHECK_EQ(family.Prefix(), "zeek"sv);
|
CHECK_EQ(family.Prefix(), "zeek"sv);
|
||||||
|
@ -461,8 +461,8 @@ SCENARIO("telemetry managers provide access to histogram families")
|
||||||
WHEN("retrieving an IntHistogram family")
|
WHEN("retrieving an IntHistogram family")
|
||||||
{
|
{
|
||||||
int64_t buckets[] = {10, 20};
|
int64_t buckets[] = {10, 20};
|
||||||
auto family =
|
auto family = mgr.HistogramFamily("zeek", "payload-size", {"protocol"}, buckets, "test",
|
||||||
mgr.HistogramFamily("zeek", "payload-size", {"protocol"}, buckets, "test", "bytes");
|
"bytes");
|
||||||
THEN("the family object stores the parameters")
|
THEN("the family object stores the parameters")
|
||||||
{
|
{
|
||||||
CHECK_EQ(family.Prefix(), "zeek"sv);
|
CHECK_EQ(family.Prefix(), "zeek"sv);
|
||||||
|
|
|
@ -890,8 +890,8 @@ double calc_next_rotate(double current, double interval, double base)
|
||||||
double startofday = mktime(&t);
|
double startofday = mktime(&t);
|
||||||
|
|
||||||
// current < startofday + base + i * interval <= current + interval
|
// current < startofday + base + i * interval <= current + interval
|
||||||
double delta_t =
|
double delta_t = startofday + base + ceil((current - startofday - base) / interval) * interval -
|
||||||
startofday + base + ceil((current - startofday - base) / interval) * interval - current;
|
current;
|
||||||
return delta_t > 0.0 ? delta_t : interval;
|
return delta_t > 0.0 ? delta_t : interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,8 +371,8 @@ static std::vector<std::string> get_script_signature_files()
|
||||||
std::vector<std::string> rval;
|
std::vector<std::string> rval;
|
||||||
|
|
||||||
// Parse rule files defined on the script level.
|
// Parse rule files defined on the script level.
|
||||||
char* script_signature_files =
|
char* script_signature_files = util::copy_string(
|
||||||
util::copy_string(id::find_val("signature_files")->AsString()->CheckString());
|
id::find_val("signature_files")->AsString()->CheckString());
|
||||||
|
|
||||||
char* tmp = script_signature_files;
|
char* tmp = script_signature_files;
|
||||||
char* s;
|
char* s;
|
||||||
|
@ -921,8 +921,8 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
packet_mgr->DumpDebug();
|
packet_mgr->DumpDebug();
|
||||||
analyzer_mgr->DumpDebug();
|
analyzer_mgr->DumpDebug();
|
||||||
|
|
||||||
run_state::detail::have_pending_timers =
|
run_state::detail::have_pending_timers = ! run_state::reading_traces &&
|
||||||
! run_state::reading_traces && timer_mgr->Size() > 0;
|
timer_mgr->Size() > 0;
|
||||||
|
|
||||||
return {0, std::move(options)};
|
return {0, std::move(options)};
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ PackageInfo::PackageInfo(const string& arg_name) : Info(), pkg_name(arg_name), r
|
||||||
|
|
||||||
string PackageInfo::DoReStructuredText(bool roles_only) const
|
string PackageInfo::DoReStructuredText(bool roles_only) const
|
||||||
{
|
{
|
||||||
string rval =
|
string rval = util::fmt(":doc:`%s </scripts/%s/index>`\n\n", pkg_name.c_str(),
|
||||||
util::fmt(":doc:`%s </scripts/%s/index>`\n\n", pkg_name.c_str(), pkg_name.c_str());
|
pkg_name.c_str());
|
||||||
|
|
||||||
for ( size_t i = 0; i < readme.size(); ++i )
|
for ( size_t i = 0; i < readme.size(); ++i )
|
||||||
rval += " " + readme[i] + "\n";
|
rval += " " + readme[i] + "\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue