Commit graph

125 commits

Author SHA1 Message Date
Arne Welzel
2e30f87e33 btest/broker/publish-errors: Avoid exit(0)
Calling exit() doesn't properly shutdown the manager instances and TSAN reports a
leaked thread. Just avoid this for now by using terminate() instead.
2025-06-24 19:06:52 +02:00
Arne Welzel
07e9870f34 broker: Handle Broker::publish() with non Broker::Event
Closes #4571
2025-06-22 15:45:31 +02:00
Arne Welzel
96f2d5d369 Event/init-bare: Add add_missing_remote_network_timestamp logic
Make defaulting to the local network timestamp for remote events opt-in.
2025-06-02 17:31:36 +02:00
Arne Welzel
53b0f0ad64 Event: Deprecate default network timestamp metadata
This deprecates the Event constructor and the ``ts`` parameter of Enqueue()
Instead, versions are introduced that take a detail::MetadataVectorPtr which
can hold the network timestamp metadata and is meant to be allocated by the
caller instead of automatically during Enqueue() or within the Event
constructor.

This also introduces a BifConst ``EventMetadata::add_network_timestamp`` to
opt-in adding network timestamps to events globally. It's disabled by
default as there are not a lot of known use cases that need this.
2025-05-23 19:32:23 +02:00
Arne Welzel
f9ff396acf btest/broker: Use generic cluster-layout.zeek 2025-05-20 20:30:01 +02:00
Christian Kreibich
68fadd0464 Lower listen/connect retry intervals in Broker and the cluster framework to 1sec
The former defaults (30sec, 1min) can slow down cluster startup and recovery
considerably, and other systems have more aggressive intervals still.
2025-04-25 10:22:35 -07:00
Christian Kreibich
35ab9d5c80 Add basic btest to verify that Broker peering telemetry is available. 2025-04-25 09:15:17 -07:00
Christian Kreibich
b430d5235c Expand Broker APIs to allow tracking directionality of peering establishment
This provides ways to figure out for a given peer, or a given address/port pair,
whether the local node originally established the peering.
2025-04-21 14:08:42 -07:00
Arne Welzel
85b8c8866b testing/btest/*zeek: Comment all @TEST lines 2025-04-17 16:30:23 +02:00
Arne Welzel
fa7ffaf8c1 btest/brokerstore-attr-persistence-clone: Add BTEST_BG_RUN_SLEEP=1
This test has become flaky after #4295. It hasn't been failing regularly
enough locally to make it approachable. Annotate with
BTEST_BG_RUN_SLEEP=1 to revert to pre #4295 behavior, hopefully
fixing the flakiness as a side-effect.
2025-04-09 18:10:35 +02:00
Dominik Charousset
30615f425e Hook into Broker logs via its new API
The new Broker API allows us to provide a custom logger to Broker that
pulls previously unattainable context information out of Broker to put
them into broker.log for users of Zeek.

Since Broker log events happen asynchronously, we cache them in a queue
and use a flare to notify Zeek of activity. Furthermore, the Broker
manager now implements the `ProcessFd` function to avoid unnecessary
polling of the new log queue. As a side effect, data stores are polled
less as well.
2025-02-08 16:28:02 +01:00
Tim Wojtulewicz
6b5d0491aa Return a warning and fail if creating a store at global scope 2024-12-17 11:32:43 -07:00
Arne Welzel
831614f907 broker/Publish: Use event time instead of network time
Discussed with @J-Gras, calling Broker::publish() within a scheduled
should use the "intended timestamp" implicitly.

This is subtle, but supposedly more expected when running
a pcap replay cluster.
2024-11-14 12:59:22 +01:00
Arne Welzel
455e05bc2e btest: Remove Broker::auto_publish() usages
The ones that seemed to test Broker::auto_publish() were annotated
for removal.
2024-11-14 12:59:22 +01:00
Arne Welzel
91c03cd988 broker: Support publish() of unspecified set() / table()
Calling Broker::make_event(..., table()) or Broker::publish(..., table())
caused runtime type errors as same_type() would result in false.
2024-11-06 15:27:26 +01:00
Arne Welzel
d88b147ac9 cluster: Deprecate the Cluster::Node$interface field
This field isn't required by a worker and it's certainly not used by a
worker to listen on that specific interface. It also isn't required to
be set consistently and its use in-tree limited to the old load-balancing
script.

There's a bif called packet_source() which on a worker will provide
information about the actually used packet source.

Relates to zeek/zeek#2877.
2023-11-07 16:06:16 +01:00
Jan Grashoefer
bba07cea8b Add btest for brokerstore delete with complex index.
Slightly adapted. I wasn't sure how much guarantee we have around the
change propagation when calling terminate() right after the delete.
Flipped it around a bit, having the worker outlive the manger instead.
2023-09-28 18:31:34 +02:00
Vern Paxson
35a6efbfa7 increase BTest wait time to abide ZAM compilation times 2023-07-26 13:32:00 -07:00
Tim Wojtulewicz
38a3385daa Merge remote-tracking branch 'origin/topic/vern/CPP-Jun23-maint'
* origin/topic/vern/CPP-Jun23-maint:
  -O gen-C++ refinements for BiF failures, negative vector indices, boolean vector operations
2023-06-15 16:25:58 -07:00
Vern Paxson
18be4ba91b -O gen-C++ refinements for BiF failures, negative vector indices, boolean vector operations 2023-06-15 15:07:18 -07:00
Vern Paxson
cae5d30c62 tweak for Broker BTest that needs a delay for ZAM 2023-06-14 17:37:46 -07:00
Arne Welzel
03be610684 remote_event_ts_compat: Fix NETWORK_TIMESTAMP to NetworkTimestamp 2023-05-11 14:58:37 +02:00
Jan Grashoefer
1780d4cc2f Add compatibility tests for timestamped events.
This adds compatibility tests for receiving non-timestamped events as
well as providing timestamps via broker websockets.

Co-authored-by: Arne Welzel <arne.welzel@corelight.com>
2023-05-11 12:54:11 +02:00
Jan Grashoefer
1e807a9f0a Add timestamps to auto published broker events. 2023-05-11 12:54:11 +02:00
Jan Grashoefer
c12640b048 Add timestamps to manually published broker events. 2023-05-11 12:53:52 +02:00
Arne Welzel
cd0d55e3d6 btest/broker: Add test using Python bindings and zeek -r
This came up in community.zeek.org as a use-case and there
were a few gaps and holes, so add a test showing minimally
the current behavior.
2023-03-27 21:13:03 +02:00
Arne Welzel
bb80d80218 Stmt: Error on deprecated when/local usage
This has been around since Zeek v4.1, so it was warned about in Zeek 5.0
LTS and we could've removed it with 5.1.

Also removed merge_top_scope() from the zeek::detail namespace, it's
unused now.

Updated the when-aggregates test somehow. I'm not quite sure what had
been tested there :-/
2023-03-20 21:35:53 +01:00
Arne Welzel
f35cf228dc broker/store: Extend SQLiteOptions around data safety and performance
Add configurability of synchronous and journal_mode for SQLite backed
Broker data stores. Setting these to synchronous=normal and journal_mode=wal
can significantly improve throughput at the cost of some durability in
the presence of power loss or OS crash. In the context of Zeek, this is
likely more than acceptable.

Additionally, add integrity_check and failure_mode options to support deleting
and re-opening a corrupted SQLite database at store creation.

Closes #2698
2023-01-30 10:25:37 +01:00
Arne Welzel
21cc5f9132 EventRegistry/Func: Disable events when all bodies are disabled
This is just a small optimization on top of what is there.

Add state to Func for tracking if any enabled bodies exist which
allows us to propagate it up to the EventHandler::bool() operator.
In turn, when all bodies of an event's Func have been runtime disabled,
the event itself will not be invoked anymore.

Experiments have shown that this allows runtime toggling of new_event()
without performance impact when disabled. This could enable use-cases
where new_packet() handlers are enabled for a split second once in a
while to either dump or sample raw packet data at runtime.
2023-01-05 12:03:58 +01:00
Tim Wojtulewicz
1ed15fb807 Merge remote-tracking branch 'origin/topic/neverlord/web-socket-events-warning'
* origin/topic/neverlord/web-socket-events-warning:
  Fix warning in broker.web-socket-events btest
2022-11-18 09:41:18 -07:00
Dominik Charousset
1b1af51bdc Fix warning in broker.web-socket-events btest 2022-11-17 12:13:30 +01:00
Josh Soref
74af1ebe16 Spelling testing
* alphabet
* another
* associated
* avoiding
* base
* because
* constructors
* defining
* deterministic
* directly
* endlessly
* entity
* function
* indefinitely
* initial
* interpreter
* into
* modifying
* negotiate
* nonexistent
* observations
* occasional
* omission
* orphaned
* overridden
* passing
* primitive
* produces
* reassembly
* repository
* restore
* shouldn't
* something
* statement
* the
* therefore
* transferred
* uninitialized
* unsuccessful

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-16 20:05:03 -05:00
Dominik Charousset
456efd8082 Revert to regular peering fn for ssl_auth_failure
With the fixed Broker version, the `ssl_auth_failure` btest can use the
regular `peer` function again.
2022-08-26 17:00:45 +02:00
Tim Wojtulewicz
c88a362d1b Avoid race conditions in broker.ssl_auth_failure btest 2022-08-24 12:10:42 -07:00
Dominik Charousset
d3ad3c618a Avoid race conditions in broker.ssl-mismatch test 2022-07-10 15:47:43 +02:00
Christian Kreibich
26692c1249 Make broker.web-socket-events test require the Python websockets package 2022-06-02 13:11:06 -07:00
Robin Sommer
d99f041ac5
Add WebSocket support for exchanging events with external clients.
This exposes Broker's new WebSocket support in Zeek. To enable it,
call `Broker::listen_websocket()`. Zeek will then start listening on
port 9997 for incoming WebSocket connections.

See the Broker documentation for a description of the message format
expected over these WebSocket connections.
2022-06-02 10:31:52 +02:00
Tim Wojtulewicz
aaaca5d5a6 Merge remote-tracking branch 'origin/topic/bbannier/spicy'
* origin/topic/bbannier/spicy:
  Add NEWS item for new requirements due to default-enabled Spicy support.
  Include headers in binary dir before other headers.
  Increase memory in CI.
  Add tests for bundled Spicy infrastructure.
  Include spicy in build.
  Add `bare_mode` bif.
  Change test so included plugins can load notice framework.
  Do not log function arguments in test.
2022-05-17 08:50:33 -07:00
Benjamin Bannier
95aff9a1e3 Include spicy in build. 2022-05-16 09:07:11 +02:00
Vern Paxson
8928aa57e7 add some missing "when" closures 2022-05-12 13:39:26 -07:00
Dominik Charousset
4ea1a593a9 Port Zeek to latest Broker API 2022-04-27 23:02:27 +02:00
Vern Paxson
b59ee83979 update existing test suite usage of "when" statements to include captures 2022-01-07 14:54:06 -08:00
Christian Kreibich
fa38d81a7b Fix addr/string type confusion in Broker::peers()
Broker::NetworkInfo$address is of type string. The Broker::peers() BiF treated
it as an address, which caused ZVal's type validation to flag a
mismatch and abort.

Includes a small tweak to the broker.unpeer test that makes it invoke
Broker::peers(), which breaks in absence of the fix.
2021-08-18 15:16:58 -07:00
Tim Wojtulewicz
67b45bc502 Merge remote-tracking branch 'origin/topic/vern/ZAM-prep'
* origin/topic/vern/ZAM-prep: (45 commits)
  whoops overlooked the need to canonicalize filenames
  another set of tweaks per review comments
  addressed a number of code review comments
  baseline updates for merge
  support "any" coercions for "-O gen-C++"
  better descriptions for named record constructors
  test suite baseline updates for "-a opt" optimize-AST alternative
  test suite baseline updates for "-a xform" alternative / AST transformation
  error propagation fix for AST reduction
  updates to "-a inline" test suite alternative baseline
  updates for the main test suite baseline
  updates to test suite tests for compatibility with upcoming ZAM functionality
  "-O compile-all" option to specify compilation of inlined functions
  compile inlined functions if they're also used indirectly
  provide ZAM-generated code with low-level access to record fields
  fix for cloning records with fields of type "any"
  direct access for ZAM to VectorVal internal vector
  ZVal constructors, accessors & methods in support of ZAM
  switch ZVal representation of types from Type objects to TypeVal's
  revised error-reporting interface for ZVal's, to accommodate ZAM inner loop
  ...
2021-06-28 11:03:13 -07:00
Christian Kreibich
0b55c55140 Remove unnecessary -B arguments from Zeek invocations in testsuite
Now that Zeek no longer silently accepts -B when not compiled in debug
mode, these tests were failing.
2021-06-24 17:05:32 -07:00
Christian Kreibich
0f0104293c Remove a double-defined TLS cert from a Broker btest 2021-06-21 13:16:06 -07:00
Vern Paxson
b6e9776a11 updates to test suite tests for compatibility with upcoming ZAM functionality 2021-06-01 09:25:30 -07:00
Jon Siwek
f176da200e Merge remote-tracking branch 'origin/topic/jsiwek/gh-1506-fix-broker-func-indices'
- Extended a btest to cover tables/sets with index types
  (this was originally broken until fixed by GH-1514)

* origin/topic/jsiwek/gh-1506-fix-broker-func-indices:
  GH-1506: Fix Broker unserialization of set/table function indices
2021-04-16 16:03:29 -07:00
Jon Siwek
d3ace9b7ac GH-1506: Fix Broker unserialization of set/table function indices
Zeek function types are serialized as a broker::vector, but the
unserialization logic for Zeek set/table types that use a function for
as an index incorrectly identified it as a composite-index, which also
use broker::vector, rather than a singleton-index, and makes such
unserialization fail.

A general example where this failure can happen in practice is when
trying to unserialize a connection record for which there's a
Conn::RemovalHook, since that's a set[function], and a specific case of
that is use of the Intel Framework in a Zeek cluster.
2021-04-15 01:13:51 -07:00
Jon Siwek
6af436aad3 GH-1426: Improve handling of Broker data store creation failures
Broker::create_master() and Broker::create_clone() now return
a valid value even when there's a failure to open the backend database
(e.g. SQLite filesystem error).  In that case, the returned value can
still be passed into other data store operations, but they'll fail
immediately with an error.  Broker::is_closed() can now also be used to
determine whether the data store creation calls failed.
2021-03-06 02:32:29 -08:00