Merge remote-tracking branch 'origin/topic/timw/include-cleanup-part-1'

* origin/topic/timw/include-cleanup-part-1:
  Remove including <cinttypes> from util.h
  Remove telemetry #includes from OpaqueVal.h
  Reduce includes in plugin/Component.h
  Remove zeek/Stats.h include from NetVar.h
  Include StmtBase/StmtEnums in Func.h instead of Stmt.h
  Use modern names for standard headers
  Remove fix for CentOS 7 from TCP_Flags.h
  Fix usage of std::string in http analyzer
  Reorder top section of net_util.h to batch includes together
  Use quotes instead of <> for zeek includes
  Fix Obj.h include in IntrusivePtr.h to have full path
This commit is contained in:
Tim Wojtulewicz 2025-05-16 10:27:27 -07:00
commit 9683e88795
96 changed files with 269 additions and 139 deletions

27
CHANGES
View file

@ -1,3 +1,30 @@
8.0.0-dev.118 | 2025-05-16 10:27:27 -0700
* Remove including <cinttypes> from util.h (Tim Wojtulewicz, Corelight)
* Remove telemetry #includes from OpaqueVal.h (Tim Wojtulewicz, Corelight)
* Reduce includes in plugin/Component.h (Tim Wojtulewicz, Corelight)
* Remove zeek/Stats.h include from NetVar.h (Tim Wojtulewicz, Corelight)
* Include StmtBase/StmtEnums in Func.h instead of Stmt.h (Tim Wojtulewicz, Corelight)
This requires changes in lots of other files that were depending on Func.h
to provide that include for them.
* Use modern names for standard headers (Tim Wojtulewicz, Corelight)
* Remove fix for CentOS 7 from TCP_Flags.h (Tim Wojtulewicz, Corelight)
* Fix usage of std::string in http analyzer (Tim Wojtulewicz, Corelight)
* Reorder top section of net_util.h to batch includes together (Tim Wojtulewicz, Corelight)
* Use quotes instead of <> for zeek includes (Tim Wojtulewicz, Corelight)
* Fix Obj.h include in IntrusivePtr.h to have full path (Tim Wojtulewicz, Corelight)
8.0.0-dev.106 | 2025-05-16 13:39:56 +0200 8.0.0-dev.106 | 2025-05-16 13:39:56 +0200
* Generate --event-trace output explicitly rather than in EventTraceMgr destructor (Vern Paxson, Corelight) * Generate --event-trace output explicitly rather than in EventTraceMgr destructor (Vern Paxson, Corelight)

4
NEWS
View file

@ -11,6 +11,10 @@ We would like to thank ... for their contributions to this release.
Breaking Changes Breaking Changes
---------------- ----------------
- The code base underwent a big cleanup of #include usage, across almost all of the
files. We tested builds of all of the existing third-party packages and only noticed one
or two failures, but there is a possibility for breakage related to this cleanup.
New Functionality New Functionality
----------------- -----------------

View file

@ -1 +1 @@
8.0.0-dev.106 8.0.0-dev.118

View file

@ -8,7 +8,9 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "zeek/Dict.h"
#include "zeek/Func.h" #include "zeek/Func.h"
#include "zeek/Hash.h"
#include "zeek/IPAddr.h" #include "zeek/IPAddr.h"
#include "zeek/RE.h" #include "zeek/RE.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"

View file

@ -3,6 +3,7 @@
#include "zeek/DNS_Mapping.h" #include "zeek/DNS_Mapping.h"
#include <ares_nameser.h> #include <ares_nameser.h>
#include <cinttypes>
#include "zeek/DNS_Mgr.h" #include "zeek/DNS_Mgr.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"

View file

@ -9,7 +9,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <stdio.h> #include <cstdio>
#include <set> #include <set>
#include <string> #include <string>

View file

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <cinttypes>
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <stdio.h> #include <cstdio>
namespace zeek::detail { namespace zeek::detail {

View file

@ -30,6 +30,7 @@
#include "zeek/RunState.h" #include "zeek/RunState.h"
#include "zeek/Scope.h" #include "zeek/Scope.h"
#include "zeek/ScriptProfile.h" #include "zeek/ScriptProfile.h"
#include "zeek/Stats.h"
#include "zeek/Stmt.h" #include "zeek/Stmt.h"
#include "zeek/Traverse.h" #include "zeek/Traverse.h"
#include "zeek/Var.h" #include "zeek/Var.h"
@ -524,6 +525,8 @@ void ScriptFunc::CreateCaptures(std::unique_ptr<std::vector<ZVal>> cvec) {
} }
} }
void ScriptFunc::SetCapturesVec(std::unique_ptr<std::vector<ZVal>> cv) { captures_vec = std::move(cv); }
void ScriptFunc::SetCaptures(Frame* f) { void ScriptFunc::SetCaptures(Frame* f) {
const auto& captures = type->GetCaptures(); const auto& captures = type->GetCaptures();
ASSERT(captures); ASSERT(captures);

View file

@ -11,9 +11,16 @@
#include "zeek/Obj.h" #include "zeek/Obj.h"
#include "zeek/Scope.h" #include "zeek/Scope.h"
#include "zeek/Stmt.h" #include "zeek/StmtBase.h"
#include "zeek/StmtEnums.h"
#include "zeek/TraverseTypes.h" #include "zeek/TraverseTypes.h"
#include "zeek/Type.h" /* for function_flavor */ #include "zeek/Type.h" /* for FunctionFlavor */
// This is needed in order to chain-include ZVal.h, which is what's
// actually needed by Func.h. If you don't include Val.h along with
// ZVal.h, Windows fails to build because of the forward declarations
// in ZVal.h.
#include "zeek/Val.h"
#include "zeek/ZeekArgs.h" #include "zeek/ZeekArgs.h"
#include "zeek/ZeekList.h" #include "zeek/ZeekList.h"
@ -223,7 +230,7 @@ public:
* *
* @param cv The value used for captures_vec. * @param cv The value used for captures_vec.
*/ */
void SetCapturesVec(std::unique_ptr<std::vector<ZVal>> cv) { captures_vec = std::move(cv); } void SetCapturesVec(std::unique_ptr<std::vector<ZVal>> cv);
// Same definition as in Frame.h. // Same definition as in Frame.h.
using OffsetMap = std::unordered_map<std::string, int>; using OffsetMap = std::unordered_map<std::string, int>;

View file

@ -2,11 +2,10 @@
#include "zeek/Hash.h" #include "zeek/Hash.h"
#include "zeek/zeek-config.h"
#include <highwayhash/highwayhash_target.h> #include <highwayhash/highwayhash_target.h>
#include <highwayhash/instruction_sets.h> #include <highwayhash/instruction_sets.h>
#include <highwayhash/sip_hash.h> #include <highwayhash/sip_hash.h>
#include <cinttypes>
#include "zeek/DebugLogger.h" #include "zeek/DebugLogger.h"
#include "zeek/Desc.h" #include "zeek/Desc.h"

View file

@ -6,6 +6,7 @@
#include "zeek/Attr.h" #include "zeek/Attr.h"
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/EventRegistry.h" #include "zeek/EventRegistry.h"
#include "zeek/Expr.h" #include "zeek/Expr.h"
#include "zeek/File.h" #include "zeek/File.h"

View file

@ -6,7 +6,7 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "Obj.h" #include "zeek/Obj.h"
namespace zeek { namespace zeek {

View file

@ -21,11 +21,10 @@
// Entries must be either a pointer to the data or nonzero data with // Entries must be either a pointer to the data or nonzero data with
// sizeof(data) <= sizeof(void*). // sizeof(data) <= sizeof(void*).
#include <stdarg.h>
#include <cassert> #include <cassert>
#include <cstdarg>
#include <initializer_list> #include <initializer_list>
#include <iterator> #include <iterator>
#include <utility>
#include "zeek/util.h" #include "zeek/util.h"

View file

@ -3,7 +3,6 @@
#pragma once #pragma once
#include "zeek/EventRegistry.h" #include "zeek/EventRegistry.h"
#include "zeek/Stats.h"
#include "zeek/Val.h" #include "zeek/Val.h"
namespace zeek::detail { namespace zeek::detail {

View file

@ -15,9 +15,6 @@
#include "zeek/RandTest.h" #include "zeek/RandTest.h"
#include "zeek/Val.h" #include "zeek/Val.h"
#include "zeek/digest.h" #include "zeek/digest.h"
#include "zeek/telemetry/Counter.h"
#include "zeek/telemetry/Gauge.h"
#include "zeek/telemetry/Histogram.h"
namespace broker { namespace broker {
class data; class data;

View file

@ -5,6 +5,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <algorithm> #include <algorithm>
#include <cinttypes>
#include <limits> #include <limits>
#include "zeek/Desc.h" #include "zeek/Desc.h"

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <stdarg.h> #include <cstdarg>
#include <list> #include <list>
#include <map> #include <map>
#include <string> #include <string>

View file

@ -4,6 +4,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <algorithm> #include <algorithm>
#include <cinttypes>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>

View file

@ -3,6 +3,7 @@
#include "zeek/SerializationFormat.h" #include "zeek/SerializationFormat.h"
#include <cctype> #include <cctype>
#include <cinttypes>
#include "zeek/DebugLogger.h" #include "zeek/DebugLogger.h"
#include "zeek/IPAddr.h" #include "zeek/IPAddr.h"

View file

@ -8,6 +8,7 @@
#include "zeek/Conn.h" #include "zeek/Conn.h"
#include "zeek/DNS_Mgr.h" #include "zeek/DNS_Mgr.h"
#include "zeek/Dict.h"
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/File.h" #include "zeek/File.h"
#include "zeek/Func.h" #include "zeek/Func.h"

View file

@ -2,6 +2,8 @@
#include "zeek/Tag.h" #include "zeek/Tag.h"
#include <cinttypes>
#include "zeek/Val.h" #include "zeek/Val.h"
namespace zeek { namespace zeek {

View file

@ -4,6 +4,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <cinttypes>
#include <list> #include <list>
#include <map> #include <map>
#include <string> #include <string>

View file

@ -2,11 +2,8 @@
#include "zeek/analyzer/protocol/http/HTTP.h" #include "zeek/analyzer/protocol/http/HTTP.h"
#include "zeek/zeek-config.h"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <cmath>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
@ -346,9 +343,9 @@ void HTTP_Entity::SubmitHeader(analyzer::mime::MIME_Header* h) {
else if ( analyzer::mime::istrequal(h->get_name(), "content-range") && else if ( analyzer::mime::istrequal(h->get_name(), "content-range") &&
http_message->MyHTTP_Analyzer()->HTTP_ReplyCode() == 206 ) { http_message->MyHTTP_Analyzer()->HTTP_ReplyCode() == 206 ) {
data_chunk_t vt = h->get_value_token(); data_chunk_t vt = h->get_value_token();
string byte_unit(vt.data, vt.length); std::string byte_unit(vt.data, vt.length);
vt = h->get_value_after_token(); vt = h->get_value_after_token();
string byte_range(vt.data, vt.length); std::string byte_range(vt.data, vt.length);
byte_range.erase(remove(byte_range.begin(), byte_range.end(), ' '), byte_range.end()); byte_range.erase(remove(byte_range.begin(), byte_range.end(), ' '), byte_range.end());
if ( byte_unit != "bytes" ) { if ( byte_unit != "bytes" ) {
@ -357,22 +354,22 @@ void HTTP_Entity::SubmitHeader(analyzer::mime::MIME_Header* h) {
} }
size_t p = byte_range.find('/'); size_t p = byte_range.find('/');
if ( p == string::npos ) { if ( p == std::string::npos ) {
http_message->Weird("HTTP_content_range_cannot_parse"); http_message->Weird("HTTP_content_range_cannot_parse");
return; return;
} }
string byte_range_resp_spec = byte_range.substr(0, p); std::string byte_range_resp_spec = byte_range.substr(0, p);
string instance_length_str = byte_range.substr(p + 1); std::string instance_length_str = byte_range.substr(p + 1);
p = byte_range_resp_spec.find('-'); p = byte_range_resp_spec.find('-');
if ( p == string::npos ) { if ( p == std::string::npos ) {
http_message->Weird("HTTP_content_range_cannot_parse"); http_message->Weird("HTTP_content_range_cannot_parse");
return; return;
} }
string first_byte_pos = byte_range_resp_spec.substr(0, p); std::string first_byte_pos = byte_range_resp_spec.substr(0, p);
string last_byte_pos = byte_range_resp_spec.substr(p + 1); std::string last_byte_pos = byte_range_resp_spec.substr(p + 1);
if ( DEBUG_http ) if ( DEBUG_http )
DEBUG_MSG("Parsed Content-Range: %s %s-%s/%s\n", byte_unit.c_str(), first_byte_pos.c_str(), DEBUG_MSG("Parsed Content-Range: %s %s-%s/%s\n", byte_unit.c_str(), first_byte_pos.c_str(),

View file

@ -2,6 +2,9 @@
#pragma once #pragma once
#include <queue>
#include <string>
#include "zeek/IPAddr.h" #include "zeek/IPAddr.h"
#include "zeek/analyzer/protocol/http/events.bif.h" #include "zeek/analyzer/protocol/http/events.bif.h"
#include "zeek/analyzer/protocol/mime/MIME.h" #include "zeek/analyzer/protocol/mime/MIME.h"
@ -9,7 +12,6 @@
#include "zeek/analyzer/protocol/tcp/ContentLine.h" #include "zeek/analyzer/protocol/tcp/ContentLine.h"
#include "zeek/analyzer/protocol/tcp/TCP.h" #include "zeek/analyzer/protocol/tcp/TCP.h"
#include "zeek/analyzer/protocol/zip/ZIP.h" #include "zeek/analyzer/protocol/zip/ZIP.h"
#include "zeek/binpac_zeek.h"
namespace zeek::analyzer::http { namespace zeek::analyzer::http {
@ -43,7 +45,7 @@ public:
int64_t BodyLength() const { return body_length; } int64_t BodyLength() const { return body_length; }
int64_t HeaderLength() const { return header_length; } int64_t HeaderLength() const { return header_length; }
void SkipBody() { deliver_body = 0; } void SkipBody() { deliver_body = 0; }
const string& FileID() const { return precomputed_file_id; } const std::string& FileID() const { return precomputed_file_id; }
protected: protected:
class UncompressedOutput; class UncompressedOutput;

View file

@ -1,3 +1,7 @@
%extern{
#include "zeek/Dict.h"
%}
refine connection SMB_Conn += { refine connection SMB_Conn += {
function proc_smb1_nt_create_andx_request(header: SMB_Header, val: SMB1_nt_create_andx_request): bool function proc_smb1_nt_create_andx_request(header: SMB_Header, val: SMB1_nt_create_andx_request): bool
%{ %{

View file

@ -1,3 +1,7 @@
%extern{
#include "zeek/Dict.h"
%}
refine connection SMB_Conn += { refine connection SMB_Conn += {
function proc_smb2_create_request(h: SMB2_Header, val: SMB2_create_request): bool function proc_smb2_create_request(h: SMB2_Header, val: SMB2_create_request): bool

View file

@ -2,15 +2,9 @@
#pragma once #pragma once
// This needs to remain the first include in this file, or some defines aren't
// set correctly when netinet/tcp.h is included and the CentOS 7 build breaks.
// clang-format off
#include "zeek/net_util.h"
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <sys/types.h> #include <sys/types.h>
#include <string> #include <string>
// clang-format on
namespace zeek::analyzer::tcp { namespace zeek::analyzer::tcp {

View file

@ -7,6 +7,7 @@
#include "zeek/File.h" #include "zeek/File.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/RuleMatcher.h" #include "zeek/RuleMatcher.h"
#include "zeek/Stats.h"
#include "zeek/ZeekString.h" #include "zeek/ZeekString.h"
#include "zeek/analyzer/Analyzer.h" #include "zeek/analyzer/Analyzer.h"
#include "zeek/analyzer/protocol/tcp/TCP.h" #include "zeek/analyzer/protocol/tcp/TCP.h"

View file

@ -5,6 +5,7 @@
#include <broker/error.hh> #include <broker/error.hh>
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/File.h" #include "zeek/File.h"
#include "zeek/Func.h" #include "zeek/Func.h"
#include "zeek/ID.h" #include "zeek/ID.h"

View file

@ -10,22 +10,16 @@
#include <variant> #include <variant>
#include "zeek/EventHandler.h" #include "zeek/EventHandler.h"
#include "zeek/IntrusivePtr.h"
#include "zeek/Span.h" #include "zeek/Span.h"
#include "zeek/Tag.h" #include "zeek/Tag.h"
#include "zeek/Val.h"
#include "zeek/ZeekArgs.h"
#include "zeek/cluster/BifSupport.h"
#include "zeek/cluster/Serializer.h" #include "zeek/cluster/Serializer.h"
#include "zeek/logging/Types.h" #include "zeek/logging/Types.h"
namespace zeek { namespace zeek {
class FuncVal;
using FuncValPtr = IntrusivePtr<FuncVal>;
class Val;
using ValPtr = IntrusivePtr<Val>;
using ArgsSpan = Span<const ValPtr>;
namespace detail { namespace detail {
template<class Proc, class Work> template<class Proc, class Work>
class OnLoopProcess; class OnLoopProcess;

View file

@ -7,10 +7,11 @@
#pragma once #pragma once
#include <sys/types.h> // for u_char #include <sys/types.h> // for u_char
#include <zeek/util.h>
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
#include "zeek/util.h"
// Required buffer size for an MD5 digest. // Required buffer size for an MD5 digest.
#define ZEEK_MD5_DIGEST_LENGTH 16 #define ZEEK_MD5_DIGEST_LENGTH 16

View file

@ -7,6 +7,7 @@
#include "zeek/CompHash.h" #include "zeek/CompHash.h"
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/EventHandler.h" #include "zeek/EventHandler.h"
#include "zeek/Expr.h" #include "zeek/Expr.h"

View file

@ -4,6 +4,7 @@
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/Type.h"
namespace zeek::iosource { namespace zeek::iosource {

View file

@ -10,7 +10,7 @@
#include <pcap-int.h> #include <pcap-int.h>
#endif #endif
#include <stdio.h> #include <cstdio>
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/iosource/BPF_Program.h" #include "zeek/iosource/BPF_Program.h"

View file

@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/EventHandler.h" #include "zeek/EventHandler.h"
#include "zeek/File.h" #include "zeek/File.h"

View file

@ -3,8 +3,10 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <unistd.h> #include <unistd.h>
#include <cinttypes>
#include "zeek/RunState.h" #include "zeek/RunState.h"
#include "zeek/Stats.h"
#include "zeek/iosource/Manager.h" #include "zeek/iosource/Manager.h"
#include "zeek/supervisor/Supervisor.h" #include "zeek/supervisor/Supervisor.h"
#include "zeek/zeek-setup.h" #include "zeek/zeek-setup.h"

View file

@ -1,5 +1,5 @@
%%{ %%{
#include <zeek/MMDB.h> #include "zeek/MMDB.h"
%%} %%}
## Initializes MMDB for later use of lookup_location. ## Initializes MMDB for later use of lookup_location.

View file

@ -5,18 +5,9 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <cstdint> #include <cstdint>
#include <memory>
// Define first. #include <string>
enum TransportProto : uint8_t { #include <utility>
TRANSPORT_UNKNOWN,
TRANSPORT_TCP,
TRANSPORT_UDP,
TRANSPORT_ICMP,
};
extern const char* transport_proto_string(TransportProto proto);
enum IPFamily { IPv4, IPv6 };
// Force these files to stay in this order. Normally, clang-format // Force these files to stay in this order. Normally, clang-format
// wants to move sys/types.h to the end of this block, but that // wants to move sys/types.h to the end of this block, but that
@ -36,8 +27,6 @@ enum IPFamily { IPv4, IPv6 };
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netinet/udp.h> #include <netinet/udp.h>
#include "zeek/util.h"
#ifdef HAVE_NETINET_IP6_H #ifdef HAVE_NETINET_IP6_H
#include <netinet/ip6.h> #include <netinet/ip6.h>
@ -126,6 +115,18 @@ struct ip6_rthdr {
#define TCPOPT_TIMESTAMP TCPOPT_TSTAMP #define TCPOPT_TIMESTAMP TCPOPT_TSTAMP
#endif #endif
// Define first.
enum TransportProto : uint8_t {
TRANSPORT_UNKNOWN,
TRANSPORT_TCP,
TRANSPORT_UDP,
TRANSPORT_ICMP,
};
extern const char* transport_proto_string(TransportProto proto);
enum IPFamily { IPv4, IPv6 };
namespace zeek { namespace zeek {
class IPAddr; class IPAddr;

View file

@ -83,6 +83,7 @@
%{ %{
#include <cassert> #include <cassert>
#include <cinttypes>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <set> #include <set>

View file

@ -4,6 +4,8 @@
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/Type.h"
#include "zeek/Val.h"
namespace zeek::plugin { namespace zeek::plugin {
@ -16,6 +18,8 @@ Component::Component(component::Type arg_type, const std::string& arg_name, Tag:
canon_name_val = make_intrusive<StringVal>(canon_name); canon_name_val = make_intrusive<StringVal>(canon_name);
} }
Component::~Component() {}
void Component::Describe(ODesc* d) const { void Component::Describe(ODesc* d) const {
d->Add(" "); d->Add(" ");
d->Add("["); d->Add("[");
@ -95,4 +99,7 @@ void Component::SetEnabled(bool arg_enabled) {
break; break;
} }
} }
StringValPtr Component::CanonicalNameVal() const { return canon_name_val; }
} // namespace zeek::plugin } // namespace zeek::plugin

View file

@ -2,17 +2,20 @@
#pragma once #pragma once
#include "zeek/zeek-config.h"
#include <string> #include <string>
#include "zeek/IntrusivePtr.h"
#include "zeek/Tag.h" #include "zeek/Tag.h"
#include "zeek/Type.h"
#include "zeek/Val.h"
namespace zeek { namespace zeek {
class ODesc; class ODesc;
class EnumType;
using EnumTypePtr = IntrusivePtr<EnumType>;
class EnumVal;
using EnumValPtr = IntrusivePtr<EnumVal>;
class StringVal;
using StringValPtr = IntrusivePtr<StringVal>;
namespace plugin { namespace plugin {
namespace component { namespace component {
@ -69,7 +72,7 @@ public:
/** /**
* Destructor. * Destructor.
*/ */
virtual ~Component() = default; virtual ~Component();
// Disable. // Disable.
Component(const Component& other) = delete; Component(const Component& other) = delete;
@ -99,7 +102,7 @@ public:
* ID. * ID.
*/ */
const std::string& CanonicalName() const { return canon_name; } const std::string& CanonicalName() const { return canon_name; }
StringValPtr CanonicalNameVal() const { return canon_name_val; } StringValPtr CanonicalNameVal() const;
/** /**
* Returns a textual representation of the component. This goes into * Returns a textual representation of the component. This goes into

View file

@ -2,6 +2,7 @@
#include "zeek/probabilistic/BloomFilter.h" #include "zeek/probabilistic/BloomFilter.h"
#include <cinttypes>
#include <cmath> #include <cmath>
#include <limits> #include <limits>

View file

@ -2,6 +2,7 @@
#include "zeek/probabilistic/CardinalityCounter.h" #include "zeek/probabilistic/CardinalityCounter.h"
#include <cinttypes>
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <utility> #include <utility>

View file

@ -5,11 +5,11 @@
*/ */
%top{ %top{
// Include stdint.h at the start of the generated file. Typically // Include cstdint at the start of the generated file. Typically
// MSVC will include this header later, after the definitions of // MSVC will include this header later, after the definitions of
// the integral type macros. MSVC then complains that about the // the integral type macros. MSVC then complains that about the
// redefinition of the types. Including stdint.h early avoids this. // redefinition of the types. Including cstdint early avoids this.
#include <stdint.h> #include <cstdint>
} }
%{ %{

View file

@ -1,6 +1,6 @@
%{ %{
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <stdio.h> #include <cstdio>
#include <netinet/in.h> #include <netinet/in.h>
#include <vector> #include <vector>

View file

@ -1,9 +1,9 @@
%top{ %top{
// Include stdint.h at the start of the generated file. Typically // Include cstdint at the start of the generated file. Typically
// MSVC will include this header later, after the definitions of // MSVC will include this header later, after the definitions of
// the integral type macros. MSVC then complains that about the // the integral type macros. MSVC then complains that about the
// redefinition of the types. Including stdint.h early avoids this. // redefinition of the types. Including cstdint early avoids this.
#include <stdint.h> #include <cstdint>
} }
%{ %{

View file

@ -1,9 +1,9 @@
%top{ %top{
// Include stdint.h at the start of the generated file. Typically // Include cstdint at the start of the generated file. Typically
// MSVC will include this header later, after the definitions of // MSVC will include this header later, after the definitions of
// the integral type macros. MSVC then complains that about the // the integral type macros. MSVC then complains that about the
// redefinition of the types. Including stdint.h early avoids this. // redefinition of the types. Including cstdint early avoids this.
#include <stdint.h> #include <cstdint>
} }
%{ %{

View file

@ -15,10 +15,10 @@
#pragma once #pragma once
#include <zeek/Obj.h>
#include <unordered_map> #include <unordered_map>
#include "zeek/IntrusivePtr.h" #include "zeek/IntrusivePtr.h"
#include "zeek/Obj.h"
namespace zeek::detail { namespace zeek::detail {

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include "zeek/Dict.h"
#include "zeek/Val.h" #include "zeek/Val.h"
#include "zeek/ZeekString.h" #include "zeek/ZeekString.h"
#include "zeek/script_opt/ZAM/ZInstAux.h" #include "zeek/script_opt/ZAM/ZInstAux.h"

View file

@ -4,6 +4,7 @@
#include "zeek/Conn.h" #include "zeek/Conn.h"
#include "zeek/Desc.h" #include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/EventHandler.h" #include "zeek/EventHandler.h"
#include "zeek/File.h" #include "zeek/File.h"
#include "zeek/Frame.h" #include "zeek/Frame.h"

View file

@ -15,6 +15,7 @@
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/RuleMatcher.h" #include "zeek/RuleMatcher.h"
#include "zeek/RunState.h" #include "zeek/RunState.h"
#include "zeek/Stats.h"
#include "zeek/Timer.h" #include "zeek/Timer.h"
#include "zeek/TunnelEncapsulation.h" #include "zeek/TunnelEncapsulation.h"
#include "zeek/packet_analysis/Manager.h" #include "zeek/packet_analysis/Manager.h"

View file

@ -6,6 +6,7 @@
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/IP.h" #include "zeek/IP.h"
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/Stats.h"
#include "zeek/Val.h" #include "zeek/Val.h"
#include "zeek/analyzer/Analyzer.h" #include "zeek/analyzer/Analyzer.h"
#include "zeek/session/Manager.h" #include "zeek/session/Manager.h"

View file

@ -24,10 +24,9 @@
#include <hilti/autogen/config.h> #include <hilti/autogen/config.h>
#include <zeek/analyzer/Manager.h> #include "zeek/analyzer/Manager.h"
#include <zeek/file_analysis/Manager.h> #include "zeek/file_analysis/Manager.h"
#include <zeek/packet_analysis/Manager.h> #include "zeek/packet_analysis/Manager.h"
#include "zeek/spicy/file-analyzer.h" #include "zeek/spicy/file-analyzer.h"
#include "zeek/spicy/packet-analyzer.h" #include "zeek/spicy/packet-analyzer.h"
#include "zeek/spicy/protocol-analyzer.h" #include "zeek/spicy/protocol-analyzer.h"

View file

@ -2,6 +2,9 @@
#pragma once #pragma once
#include <memory>
#include "zeek/IntrusivePtr.h"
#include "zeek/plugin/Component.h" #include "zeek/plugin/Component.h"
namespace zeek::storage { namespace zeek::storage {

View file

@ -7,6 +7,8 @@
#include "zeek/RunState.h" #include "zeek/RunState.h"
#include "zeek/storage/ReturnCode.h" #include "zeek/storage/ReturnCode.h"
#include "const.bif.netvar_h"
std::atomic_flag expire_running; std::atomic_flag expire_running;
namespace zeek::storage { namespace zeek::storage {

View file

@ -3,6 +3,7 @@
#include "zeek/storage/backend/redis/Redis.h" #include "zeek/storage/backend/redis/Redis.h"
#include <algorithm> #include <algorithm>
#include <cinttypes>
#include "zeek/DebugLogger.h" #include "zeek/DebugLogger.h"
#include "zeek/Func.h" #include "zeek/Func.h"

View file

@ -26,6 +26,7 @@ extern "C" {
} }
#include "zeek/DebugLogger.h" #include "zeek/DebugLogger.h"
#include "zeek/Dict.h"
#include "zeek/Event.h" #include "zeek/Event.h"
#include "zeek/EventHandler.h" #include "zeek/EventHandler.h"
#include "zeek/ID.h" #include "zeek/ID.h"

View file

@ -2,6 +2,10 @@
#include "Opaques.h" #include "Opaques.h"
#include "zeek/telemetry/Counter.h"
#include "zeek/telemetry/Gauge.h"
#include "zeek/telemetry/Histogram.h"
using namespace zeek; using namespace zeek;
TelemetryVal::TelemetryVal(std::shared_ptr<telemetry::Counter>) : OpaqueVal(counter_metric_type) {} TelemetryVal::TelemetryVal(std::shared_ptr<telemetry::Counter>) : OpaqueVal(counter_metric_type) {}
@ -22,3 +26,33 @@ IMPLEMENT_OPAQUE_VALUE(GaugeMetricVal)
IMPLEMENT_OPAQUE_VALUE(GaugeMetricFamilyVal) IMPLEMENT_OPAQUE_VALUE(GaugeMetricFamilyVal)
IMPLEMENT_OPAQUE_VALUE(HistogramMetricVal) IMPLEMENT_OPAQUE_VALUE(HistogramMetricVal)
IMPLEMENT_OPAQUE_VALUE(HistogramMetricFamilyVal) IMPLEMENT_OPAQUE_VALUE(HistogramMetricFamilyVal)
template<>
const char* CounterMetricVal::OpaqueName() const {
return telemetry::Counter::OpaqueName;
}
template<>
const char* CounterMetricFamilyVal::OpaqueName() const {
return telemetry::CounterFamily::OpaqueName;
}
template<>
const char* GaugeMetricVal::OpaqueName() const {
return telemetry::Gauge::OpaqueName;
}
template<>
const char* GaugeMetricFamilyVal::OpaqueName() const {
return telemetry::GaugeFamily::OpaqueName;
}
template<>
const char* HistogramMetricVal::OpaqueName() const {
return telemetry::Histogram::OpaqueName;
}
template<>
const char* HistogramMetricFamilyVal::OpaqueName() const {
return telemetry::HistogramFamily::OpaqueName;
}

View file

@ -10,6 +10,17 @@
namespace zeek { namespace zeek {
namespace telemetry {
class Counter;
class CounterFamily;
class Gauge;
class GaugeFamily;
class Histogram;
class HistogramFamily;
} // namespace telemetry
/** /**
* Base class for metric handles. Handle types are not serializable. * Base class for metric handles. Handle types are not serializable.
*/ */
@ -43,7 +54,7 @@ public:
protected: protected:
ValPtr DoClone(CloneState*) override { return make_intrusive<TelemetryValImpl>(hdl); } ValPtr DoClone(CloneState*) override { return make_intrusive<TelemetryValImpl>(hdl); }
const char* OpaqueName() const override { return Handle::OpaqueName; } const char* OpaqueName() const override;
private: private:
HandleType hdl; HandleType hdl;

View file

@ -9,10 +9,10 @@
#include <libproc.h> #include <libproc.h>
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/task.h> #include <mach/task.h>
#include <math.h>
#include <stdlib.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <unistd.h> #include <unistd.h>
#include <cmath>
#include <cstdlib>
namespace zeek::telemetry::detail { namespace zeek::telemetry::detail {

View file

@ -5,6 +5,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <pthread.h> #include <pthread.h>
#include <cinttypes>
#include <csignal> #include <csignal>
#include "zeek/threading/Manager.h" #include "zeek/threading/Manager.h"

View file

@ -16,7 +16,6 @@
#include <libgen.h> #include <libgen.h>
#include <unistd.h> #include <unistd.h>
#include <cinttypes>
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
@ -63,8 +62,6 @@
extern HeapLeakChecker* heap_checker; extern HeapLeakChecker* heap_checker;
#endif #endif
#include <stdint.h>
extern "C" { extern "C" {
#include "zeek/3rdparty/modp_numtoa.h" #include "zeek/3rdparty/modp_numtoa.h"
} }

View file

@ -43,6 +43,7 @@
#include "zeek/Scope.h" #include "zeek/Scope.h"
#include "zeek/ScriptCoverageManager.h" #include "zeek/ScriptCoverageManager.h"
#include "zeek/Stats.h" #include "zeek/Stats.h"
#include "zeek/Stmt.h"
#include "zeek/Timer.h" #include "zeek/Timer.h"
#include "zeek/Traverse.h" #include "zeek/Traverse.h"
#include "zeek/Trigger.h" #include "zeek/Trigger.h"

View file

@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "zeek/Reporter.h" #include "zeek/Reporter.h"
#include "zeek/Type.h"
#include "zeek/zeekygen/utils.h" #include "zeek/zeekygen/utils.h"
using namespace std; using namespace std;

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <time.h> // for time_t #include <ctime> // for time_t
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <time.h> // for time_t #include <ctime> // for time_t
#include <list> #include <list>
#include <map> #include <map>
#include <string> #include <string>

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <time.h> // for time_t #include <ctime> // for time_t
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -4,7 +4,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <time.h> // for time_t #include <ctime> // for time_t
#include <list> #include <list>
#include <map> #include <map>
#include <set> #include <set>

View file

@ -2,7 +2,7 @@
#pragma once #pragma once
#include <time.h> // for time_t #include <ctime> // for time_t
#include <list> #include <list>
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -4,7 +4,7 @@
#include "zeek/zeek-config.h" #include "zeek/zeek-config.h"
#include <time.h> // for time_t #include <ctime> // for time_t
#include <optional> #include <optional>
#include <string> #include <string>

View file

@ -1,12 +1,14 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/ID.h> #include <cinttypes>
#include <zeek/Reporter.h>
#include <zeek/Type.h>
#include <zeek/Val.h>
#include <iostream> #include <iostream>
#include "zeek/ID.h"
#include "zeek/Reporter.h"
#include "zeek/Type.h"
#include "zeek/Val.h"
namespace btest::plugin::Demo_API { namespace btest::plugin::Demo_API {
Plugin plugin; Plugin plugin;
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_API { namespace btest::plugin::Demo_API {

View file

@ -1,7 +1,7 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/3rdparty/doctest.h> #include "zeek/3rdparty/doctest.h"
namespace btest::plugin::Demo_Doctest { namespace btest::plugin::Demo_Doctest {
Plugin plugin; Plugin plugin;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Doctest { namespace btest::plugin::Demo_Doctest {

View file

@ -1,9 +1,10 @@
#include "Foo.h" #include "Foo.h"
#include <zeek/file_analysis/File.h>
#include <zeek/file_analysis/Manager.h>
#include <algorithm> #include <algorithm>
#include "zeek/file_analysis/File.h"
#include "zeek/file_analysis/Manager.h"
#include "events.bif.h" #include "events.bif.h"
using namespace btest::plugin::Demo_Foo; using namespace btest::plugin::Demo_Foo;

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Foo { namespace btest::plugin::Demo_Foo {

View file

@ -1,12 +1,12 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/Conn.h> #include "zeek/Conn.h"
#include <zeek/Desc.h> #include "zeek/Desc.h"
#include <zeek/Event.h> #include "zeek/Event.h"
#include <zeek/Func.h> #include "zeek/Func.h"
#include <zeek/Val.h> #include "zeek/Val.h"
#include <zeek/threading/Formatter.h> #include "zeek/threading/Formatter.h"
namespace btest::plugin::Demo_Hooks { namespace btest::plugin::Demo_Hooks {
Plugin plugin; Plugin plugin;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Hooks { namespace btest::plugin::Demo_Hooks {

View file

@ -1,14 +1,15 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/Conn.h>
#include <zeek/Desc.h>
#include <zeek/Event.h>
#include <zeek/Func.h>
#include <zeek/RunState.h>
#include <zeek/threading/Formatter.h>
#include <cstring> #include <cstring>
#include <set> #include <set>
#include "zeek/Conn.h"
#include "zeek/Desc.h"
#include "zeek/Event.h"
#include "zeek/Func.h"
#include "zeek/RunState.h"
#include "zeek/threading/Formatter.h"
namespace btest::plugin::Demo_Hooks { namespace btest::plugin::Demo_Hooks {
Plugin plugin; Plugin plugin;
} }

View file

@ -1,7 +1,9 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include <string>
#include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Hooks { namespace btest::plugin::Demo_Hooks {

View file

@ -1,9 +1,10 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h>
#include <cstdio> #include <cstdio>
namespace btest::plugin::Demo_InitHooks { #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_InitHooks {
class Plugin : public zeek::plugin::Plugin { class Plugin : public zeek::plugin::Plugin {
protected: protected:

View file

@ -1,11 +1,12 @@
#pragma once #pragma once
#include <zeek/Flare.h>
#include <zeek/plugin/Plugin.h>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include "zeek/Flare.h"
#include "zeek/RunState.h"
#include "zeek/iosource/Manager.h" #include "zeek/iosource/Manager.h"
#include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Iosource { namespace btest::plugin::Demo_Iosource {

View file

@ -1,12 +1,13 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/Desc.h>
#include <zeek/Event.h>
#include <zeek/Func.h>
#include <zeek/threading/Formatter.h>
#include <cstdlib> #include <cstdlib>
#include "zeek/Desc.h"
#include "zeek/Event.h"
#include "zeek/Func.h"
#include "zeek/threading/Formatter.h"
namespace btest::plugin::Demo_Meta_Hooks { namespace btest::plugin::Demo_Meta_Hooks {
Plugin plugin; Plugin plugin;
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Meta_Hooks { namespace btest::plugin::Demo_Meta_Hooks {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Foo { namespace btest::plugin::Demo_Foo {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Foo { namespace btest::plugin::Demo_Foo {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_Plugin1 { namespace btest::plugin::Testing_Plugin1 {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_Plugin2 { namespace btest::plugin::Testing_Plugin2 {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_Plugin3 { namespace btest::plugin::Testing_Plugin3 {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_LoadFileExtended { namespace btest::plugin::Testing_LoadFileExtended {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_NoPatchVersion { namespace btest::plugin::Testing_NoPatchVersion {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Testing_WithPatchVersion { namespace btest::plugin::Testing_WithPatchVersion {

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h> #include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_Foo { namespace btest::plugin::Demo_Foo {

View file

@ -1,11 +1,12 @@
#include "Plugin.h" #include "Plugin.h"
#include <zeek/Desc.h>
#include <zeek/cluster/Backend.h>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include "zeek/Desc.h"
#include "zeek/cluster/Backend.h"
namespace btest::plugin::Demo_PublishEvent { namespace btest::plugin::Demo_PublishEvent {
Plugin plugin; Plugin plugin;
} }

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <zeek/plugin/Plugin.h>
#include <string> #include <string>
#include "zeek/plugin/Plugin.h"
namespace btest::plugin::Demo_PublishEvent { namespace btest::plugin::Demo_PublishEvent {
class Plugin : public zeek::plugin::Plugin { class Plugin : public zeek::plugin::Plugin {