Commit graph

3896 commits

Author SHA1 Message Date
Johanna Amann
e14eddeb97 SSL Analyzer: track connection direction by messages
This PR changes the way in which the SSL analyzer tracks the direction
of connections. So far, the SSL analyzer assumed that the originator of
a connection would send the client hello (and other associated
client-side events), and that the responder would be the SSL servers.

In some circumstances this is not true, and the initiator of a
connection is the server, with the responder being the client. So far
this confused some of the internal statekeeping logic and could lead to
mis-parsing of extensions.

This reversal of roles can happen in DTLS, if a connection uses STUN -
and potentially in some StartTLS protocols.

This PR tracks the direction of a TLS connection using the hello
request, client hello and server hello handshake messages. Furthermore,
it changes the SSL events from providing is_orig to providing is_client,
where is_client is true for the client_side of a connection. Since the
argument positioning in the event has not changed, old scripts will
continue to work seamlessly - the new semantics are what everyone
writing SSL scripts will have expected in any case.

There is a new event that is raised when a connection is flipped. A
weird is raised if a flip happens repeatedly.

Addresses GH-2198.
2022-06-24 18:35:44 +01:00
Christian Kreibich
3287b8b793 Merge branch 'topic/christian/management-restart'
* topic/christian/management-restart:
  Management framework: bump external cluster testsuite
  Management framework: bump zeek-client
  Management framework: edit pass over docstrings
  Management framework: node restart support
  Management framework: more consistent Supervisor interaction in the agent
  Management framework: log the controller's startup deployment attempt
  Management framework: bugfix for a get_id_value corner case
  Management framework: minor timeout bugfix
  Management framework: make "result" argument plural in multi-result response events
2022-06-23 12:27:19 -07:00
Christian Kreibich
ec25723283 Management framework: bump external cluster testsuite 2022-06-23 00:02:11 -07:00
Christian Kreibich
54f2f28047 Merge branch 'topic/christian/management-deploy'
* topic/christian/management-deploy: (21 commits)
  Management framework: bump external cluster testsuite
  Management framework: bump zeek-client
  Management framework: rename set_configuration events to stage_configuration
  Management framework: trigger deployment upon when instances are ready
  Management framework: more resilient node shutdown upon deployment
  Management framework: re-trigger deployment upon controller launch
  Management framework: move most deployment handling to internal function
  Management framework: distinguish internally and externally requested deployments
  Management framework: track instances by their Broker IDs
  Management framework: tweak Supervisor event logging
  Management framework: make helper function a local
  Management framework: rename "log_level" to "level"
  Management framework: add "finish" callback to requests
  Management framework: add a helper for rendering result vectors to a string
  Management framework: agents now skip re-deployment of current config
  Management framework: suppress notify_agent_hello upon Supervisor peering
  Management framework: introduce state machine for configs and persist them
  Management framework: introduce deployment API in controller
  Management framework: rename agent "set_configuration" to "deploy"
  Management framework: consistency fixes to the Result record
  ...
2022-06-22 22:59:53 -07:00
Christian Kreibich
661774eb6e Management framework: bump external cluster testsuite 2022-06-22 11:54:58 -07:00
Christian Kreibich
4deacefa4c Merge branch 'topic/christian/management-config-validation'
* topic/christian/management-config-validation:
  Management framework: bump external cluster testsuite
  Management framework: bump zeek-client
  Management framework: add config validation
  Management framework: improvements to port auto-enumeration
  Management framework: control output-to-console in Supervisor
  Management framework: handle no-instances corner case in set-config correctly
2022-06-21 16:59:32 -07:00
Christian Kreibich
09e412c941 Management framework: bump external cluster testsuite 2022-06-19 01:20:22 -07:00
Tim Wojtulewicz
e7a7b2923b Merge remote-tracking branch 'origin/topic/vern/history-tweak'
* origin/topic/vern/history-tweak:
  tie to revised private testing repo
  flip connections that begin with SYN-ACKs if subsequent acks or data seen
2022-06-16 15:57:44 -07:00
Vern Paxson
a94afdec47 tie to revised private testing repo 2022-06-16 14:33:11 -07:00
Christian Kreibich
e7f60d4128 Merge branch 'topic/christian/management-schedule-archiver'
* topic/christian/management-schedule-archiver:
  Management framework: bump external cluster testsuite
  Management framework: make agents support zeek-archiver invocations
  Management framework: fix module naming typo
2022-06-16 11:12:07 -07:00
Vern Paxson
847963e94d flip connections that begin with SYN-ACKs if subsequent acks or data seen 2022-06-15 14:01:32 -07:00
Christian Kreibich
e92c787987 Management framework: bump external cluster testsuite 2022-06-14 12:32:49 -07:00
Christian Kreibich
216aaa5774 Merge branch 'topic/christian/management-default-listen-interfaces'
* topic/christian/management-default-listen-interfaces:
  Management framework: bump external cluster testsuite
  Management framework: switch default network visibilities
2022-06-14 12:03:08 -07:00
Christian Kreibich
5a5c702967 Management framework: bump external cluster testsuite 2022-06-10 21:56:25 -07:00
Christian Kreibich
763b0c8d10 Merge branch 'topic/christian/management-auto-assign-ports'
* topic/christian/management-auto-assign-ports:
  Management framework: bump zeek-client to pull in relaxed port handling
  Management framework: bump external cluster testsuite
  Management framework: also use send_set_configuration_response_error elsewhere
  Management framework: minor log formatting tweak, for consistency
  Management framework: support auto-assignment of ports in cluster nodes
2022-06-08 13:44:29 -07:00
Christian Kreibich
c0a4bc3ade Management framework: bump external cluster testsuite 2022-06-08 13:29:25 -07:00
Vern Paxson
1724ddfebf ZAM test suite updates due to recent changes 2022-06-03 14:58:22 -07:00
Tim Wojtulewicz
48a858f5db Update local-compat test for 5.1 2022-06-03 12:38:20 -07:00
Christian Kreibich
ec4015e28c Management framework: bump external cluster testsuite 2022-06-03 10:38:31 -07:00
Tim Wojtulewicz
9964a46402 Fix hang in DNS analyzer with malformed packet
(cherry picked from commit dfc9f77b68f6d02d059ade322b9c132e32c26872)
2022-06-03 10:32:03 -07:00
Christian Kreibich
08d1f93292 Management framework: bump external cluster testsuite 2022-06-03 02:18:35 -07:00
Christian Kreibich
72acf24f52 Management framework: expand notify_agent_hello event arguments
This swaps the host event argument for the Broker ID. The latter is more useful,
since the sending agent doesn't necessarily know its IP address as visible to
the controller, and the controller can pull up the full Broker context via the
ID.

It also adds an explicit argument to the event to indicate whether the agent
connected to the controller or vice versa. This simplifies the controller's
internal logic.

Also minor tweaks to logging to show Broker IDs.
2022-06-03 02:12:19 -07:00
Christian Kreibich
26692c1249 Make broker.web-socket-events test require the Python websockets package 2022-06-02 13:11:06 -07:00
Christian Kreibich
1cebdd569d Merge branch 'topic/christian/gh-2134-fix-intel-test-races'
* topic/christian/gh-2134-fix-intel-test-races:
  Expand scripts.base.frameworks.intel.cluster-transparency test
  Fix races in scripts.base.frameworks.intel.cluster-transparency-with-proxy test
  Add Intel::send_store_on_node_up boolean to control min_data_store delivery
2022-06-02 12:20: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
Christian Kreibich
984d6c0136 Expand scripts.base.frameworks.intel.cluster-transparency test
This simply expands this test to match the behavior of
cluster-transparency-with-proxy, since the two are so similar. This test does
not seem to need disabling the worker's initial send of the data store.
2022-06-01 22:26:25 -07:00
Christian Kreibich
ed5d60f758 Fix races in scripts.base.frameworks.intel.cluster-transparency-with-proxy test
This test was unstable for two reasons:

- Nothing verified whether the two workers had checked in with the proxy,
meaning that messages between the workers and proxies could get lost. This adds
an extra node_up event that the proxy generates synthetically, with values
recognizable to the manager, once the proxy sees both workers connected. This is
a test-level workaround for what should really be a cluster-is-ready event in
the cluster framework proper.

- More subtle: the Intel framework makes the manager send its current
min_data_store to newly connected workers, which in the case of this tests
introduces a race: since the data store, arriving at the worker, replaces the
existing value, it could actually remove already established items if timing was
right. This would lead to the count in the test reaching 3, assuming that 3
intel items are available, when in reality it was less, causing the
Intel::seen() call to do nothing. We now disable the sending of the data store
upon connect, via the global added in the previous commit.

This also expands the test slightly so that both workers call Intel::seen() for
the items inserted by the other worker. This is added validation for the second
point above, because in the presence of that race one occasionally sees one log
entry make it, and the other fail.
2022-06-01 22:23:07 -07:00
Christian Kreibich
65589c9bcb Merge branch 'topic/christian/management-verify-nodestarts'
* topic/christian/management-verify-nodestarts:
  Management framework: bump external cluster testsuite
  Management framework: bump zeek-client to pull in set-config rendering
  Management framework: enable stdout/stderr reporting
  Management framework: Supervisor extensions for stdout/stderr handling
  Management framework: disambiguate redef field names in agent and controller
  Management framework: move to ResultVec in agent's set_configuration response
  Management framework: tune request timeout granularity and interval
  Management framework: verify node starts when deploying a configuration
  Management framework: a bit of debug-level logging for troubleshooting
2022-05-31 12:59:18 -07:00
Christian Kreibich
c13b367ede Management framework: bump external cluster testsuite 2022-05-31 12:55:21 -07:00
Christian Kreibich
24a495da42 Management framework: Supervisor extensions for stdout/stderr handling
This improves the framework's handling of Zeek node stdout and stderr by
extending the (script-layer) Supervisor functionality.

- The Supervisor _either_ directs Zeek nodes' stdout/stderr to files _or_ lets
you hook into it at the script level. We'd like both: files make sense to allow
inspection outside of the framework, and the framework would benefit from
tapping into the streams e.g. for error context. We now provide the file
redirection functionality in the Supervisor, in addition to the hook
mechanism. The hook mechanism also builds up rolling windows of up to
100 lines (configurable) into stdout/stderr.

- The new Mangement::Supervisor::API::notify_node_exit event notifies
subscribers (agents, really) that a particular node has exited (and is possibly
being restarted by the Supervisor). The event includes the name of the node,
plus its recent stdout/stderr context.
2022-05-31 12:55:21 -07:00
Christian Kreibich
93bed5a261 Merge branch 'topic/christian/node-status-notification'
* topic/christian/node-status-notification:
  Add Supervisor::node_status notification event
2022-05-31 12:53:18 -07:00
Christian Kreibich
14188fc7a7 Add Supervisor::node_status notification event
The Supervisor generates this event every time it receives a status update from
the stem, meaning a node got created or re-created. A corresponding
SupervisorControl::node_status event relays the same information for users
interacting with the Supervisor over Broker.
2022-05-30 21:36:35 -07:00
Tim Wojtulewicz
5ca0bb79c8 Fixes from review, post-rebase 2022-05-26 18:39:01 -07:00
Vern Paxson
9f05fe5bfa code formatting and more btest updates 2022-05-26 18:15:48 -07:00
Vern Paxson
a9f67f52a5 baseline & btest updates 2022-05-26 17:39:47 -07:00
Vern Paxson
a0fc8ca5e4 broader support for AST traversal, including Attr and Attributes objects 2022-05-26 17:38:34 -07:00
Christian Kreibich
415bbe17d6 Merge branch 'topic/christian/management-cluster-dirs'
* topic/christian/management-cluster-dirs:
  Management framework: bump zeek-client to pull in instance serialization fixes
  Management framework: bump external cluster testsuite
  Management framework: update agent-checkin test to reflect recent changes
  Management framework: place each Zeek process in its own working dir
  Management framework: set defaults for log rotation and persistent state
  Management framework: add spool and state directory config settings
  Management framework: establish stdout/stderr files also for cluster nodes
  Management framework: default to having agents check in with the (local) controller
  Management framework: move role variable from logging into framework-wide config
  Management framework: distinguish supervisor/supervisee when loading agent/controller
  Management framework: simplify agent and controller stdout/stderr files
  Management framework: prefix the management logs with "management-"
  Management framework: comment and layouting tweaks, no functional change
  Management framework: rename env var that labels agents/controllers
  Management framework: increase robustness of agent/controller naming
2022-05-26 16:10:14 -07:00
Christian Kreibich
aeb29413a2 Management framework: bump external cluster testsuite 2022-05-26 13:32:08 -07:00
Christian Kreibich
328e663060 Management framework: update agent-checkin test to reflect recent changes
This keeps logs produced locally and without rotation, and adopts the simpler
stdout/sterr file naming.
2022-05-26 12:57:13 -07:00
Christian Kreibich
d1cd409e59 Management framework: set defaults for log rotation and persistent state
This adds management/persistence.zeek to establish common configuration for log
rotation and persistent variable state. Log-writing Zeek processes initially
write locally in their working directory, and rotate into subdirectory
"log-queue" of the spool. Since agent and controller have no logger,
persistence.zeek puts in place compatible configurations for them.

Storage folders for Broker-backed tables and clusterized stores default to
subdirectories of the new Zeek-level state folder.

When setting the ZEEK_MANAGEMENT_TESTING environment variable, persistent state
is kept in the local directory, and log rotation remains disabled.

This also tweaks @loads a bit in favor of simply loading frameworks/management,
which is easier to keep track of.
2022-05-26 12:55:10 -07:00
Tim Wojtulewicz
271d3c4038 GH-2054: Allow nulls as separators for join_string_vec 2022-05-25 17:03:26 -07:00
Tim Wojtulewicz
f8bc23d3e1 Propagate BPF_Program error message to script land 2022-05-25 09:41:35 -07:00
Benjamin Bannier
3b7adde599 Clean up test spicy.spicyz-jit.
This test was created from a copy of `spicy.spicyz-aot`, but updated
incompletly. This patch removes the last ahead-of-time compilation bits.
2022-05-25 15:01:46 +02:00
Christian Kreibich
d4ecfa0a67 Merge branch 'topic/christian/installation-dirs-in-scriptland'
* topic/christian/installation-dirs-in-scriptland:
  Add scripts.base.misc.installation btest
  Add base/misc/installation.zeek, with Zeek installation directories
  Ensure presence of Zeek-related directories in toplevel CMakeLists.txt
2022-05-24 12:12:05 -07:00
Christian Kreibich
04c91736a1 Add scripts.base.misc.installation btest 2022-05-23 14:16:59 -07:00
Christian Kreibich
84a09debe3 Add base/misc/installation.zeek, with Zeek installation directories
This makes several of the installation's main directories available to the
script layer.
2022-05-23 14:16:59 -07:00
Tim Wojtulewicz
73273fc87b Merge remote-tracking branch 'origin/topic/vern/ZAM-inlining'
* origin/topic/vern/ZAM-inlining:
  speed up ZAM compilation by capping function size when inlining
2022-05-19 11:45:50 -07:00
Christian Kreibich
0641d032c3 Zeekify the scripts.base.utils.paths test 2022-05-19 09:51:36 -07:00
Christian Kreibich
9d59a48ae2 Expand build_path() function to handle empty dir arguments gracefully
When passing an empty string as a directory, the function would produce
filenames starting with a slash even when the given file_name is not an absolute
path. Defaulting to the root directory is likely never intended and might
conveivably be dangerous. The middle "/" is now skipped also if dir is an empty
string.
2022-05-19 09:45:52 -07: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