Commit graph

216 commits

Author SHA1 Message Date
Christian Kreibich
7563af4906 Make "-B all" apply to plugin streams as well. 2024-11-15 13:53:06 -08:00
Christian Kreibich
5e4942bcc0 Sort streams in "-B help" output, and match case-insensitively throughout
Matching of plugins' debug streams was still case-sensitive. Also contains some
minor output tweaks.

It'd be nice to only list plugin debug streams actually _used_ by plugins. I
didn't see a quick way to do that so that's for another time.
2024-11-15 12:50:13 -08:00
Arne Welzel
d18045ee16 testing: Add have-spicy-ssl helper and update tests 2024-10-29 09:30:01 +01:00
Johanna Amann
cf1074518e Spicy SSL analyzer - address feedback
Minor proposed changes from https://github.com/zeek/zeek/pull/3765,
mostly cosmetic.

Changes CI to be part of an already existing spicy CI job.
2024-09-11 11:30:16 +02:00
Johanna Amann
84c4d53a4e Spicy TLS - full test suite pass
With this commit, the entire Zeek test suite passes using spicy TLS.
Tests that either use a SSLv2 handshake, or DTLS are skipped, as the
parser currently does not support either.

Similarly, tests that rely on behavior we cannot replicate (baseline,
hooks, exact error messages) are passed. Other than that, all the
TLS-based tests pass with 100% the exact same baseline results.

This necessitated a couple of small tweaks to the spicy file - the
testcases uncovered several small problems.

This commit also enables cirrus tests for Spicy SSL/TLS.
2024-08-13 14:41:37 +01:00
Tim Wojtulewicz
9de1dd16d5 Remove variant from StdFunctionStmt
The variant ended up conflicting with std::bind, which resulted in failures
on the btest invoking it. Change back to a single function that takes a
flow, and default it to a value in Exec.
2024-03-19 09:07:45 -07:00
Tim Wojtulewicz
39890fda5e Add a method to register an event handler to a std::function via C++ 2024-03-18 16:36:25 -07:00
Dominik Charousset
cebb85b1e8 Fix unsafe and inefficient uses of copy_string
Add a new overload to `copy_string` that takes the input characters plus
size. The new overload avoids inefficient scanning of the input for the
null terminator in cases where we know the size beforehand. Furthermore,
this overload *must* be used when dealing with input character sequences
that may have no null terminator, e.g., when the input is from a
`std::string_view` object.
2023-11-03 15:25:38 +01:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Arne Welzel
07ac6fa074 btest/plugins/hooks: Run in bare mode
Motivation is basically the same as in 88bb527026.
For plugin.hooks, one example is that adding a new option in the default script
changes the baseline due registration of change handlers. Also, the connection
record is printed in various places, resulting in churn when the default
scripts change.
2023-10-09 16:13:59 +02:00
Benjamin Bannier
0896f09081 Exclude dot directories when searching ZEEK_PLUGIN_PATH
Dot directories rarely contain anything we would want to load as a
dynamic plugin. Even worse, they likely contain files with externally
controlled lifetimes which might be removed while we are using them
(see e.g., zeek/btest#98).

With this patch we do not search _discovered_ dot directories anymore.
We continue to load from a user-specified `ZEEK_PLUGIN_PATH`, even if
its name starts with a dot.

Since this patch changes previous behavior it is a **BREAKING CHANGE**.
2023-09-26 11:56:47 +02:00
Arne Welzel
5a9c6d4633 Merge remote-tracking branch 'origin/topic/awelzel/duplicate-plugin-no-debug'
* origin/topic/awelzel/duplicate-plugin-no-debug:
  plugin/Manager: Warn when plugin with the same name is found
2023-06-15 18:39:49 +02:00
Tim Wojtulewicz
4229af6820 Remove deprecations tagged for v6.1 2023-06-14 10:07:22 -07:00
Arne Welzel
fdd6dfd096 plugin/Manager: Warn when plugin with the same name is found
This was brought up on Slack as a potential source of confusion during
development as it's not visible when plugin directories are ignored outside
of looking into the plugin debug stream. I'd actually prefer to just
FatalError() this, but a warning seems reasonably visible for interactive
usage.
2023-06-14 17:36:18 +02:00
Robin Sommer
d8f7329227
Modernize plugin test.
Not using the `zeek/` include style could lead to path problems.
2023-05-15 16:08:47 +02:00
Arne Welzel
8c0e7cd8bc Merge remote-tracking branch 'origin/topic/neverlord/version-header'
* origin/topic/neverlord/version-header:
  testing/zeek-version-link: Assume nm is there
  Drop dependency for zeek_dynamic_plugin_base
  Fixup ifdef check in Plugin.h
  Update cmake_minimum_required() in test plugins
  testing: Add zeek-version-link tests
  Clean up ZEEK_CONFIG_SKIP_VERSION_H issues

cmake-format during merge
2023-05-10 23:33:11 +02:00
Arne Welzel
ca75834c83 testing/zeek-version-link: Assume nm is there 2023-05-10 17:37:32 +02:00
Arne Welzel
85934ec632 Update cmake_minimum_required() in test plugins 2023-05-10 15:53:13 +02:00
Arne Welzel
460dc16d32 testing: Add zeek-version-link tests 2023-05-10 15:53:10 +02:00
Tim Wojtulewicz
84e3f414a7 Use the same rules as cmake submodule to reformat Zeek 2023-05-09 08:31:43 -07:00
Tim Wojtulewicz
c5b8603218 Remove non-standard way of forwarding out of the Ethernet analyzer 2023-04-25 12:29:55 -07:00
Arne Welzel
f0b9c59adb Add experimental JavaScript support when libnode is available
zeek.on('zeek_init', () => {
        console.log('Hello, Zeek!');
    });

For interaction with external systems and HTTP APIs, JavaScript and the
Node.js ecosystem beat Zeek script. Make it more easily accessible by
including ZeekJS with Zeek directly.

When a recent enough libnode version is found on the build system, ZeekJS is
added as a builtin plugin. This behavior can be disabled via
``--disable-javascript``. Linux distributions providing such a package are
Ubuntu (22.10) and Debian (testing/bookworm) as libnode-dev.
Fedora provides it as nodejs-devel.

This plugin takes over loading of .js or .cjs files. When no such files
are provided to Zeek, Node and the V8 engine are not initialized and
should not get into the way.

This should be considered experimental.
2023-04-14 11:26:41 +02:00
Dominik Charousset
9aeed5284d Redesign subdir-libs and plugin scaffolding 2023-04-13 22:23:46 +02:00
Arne Welzel
38c4611c7e Add a new plugin test with verbose IO source output
This is mostly for documentation/verification purposes of how the IO loop
currently does draining and when it picks up FD based (non packet) IO
source. For example, it shows that currently FD based sources are processed
fairly delayed and that we now also process two timeout sources that are ready.
2023-03-21 09:15:39 +01:00
Arne Welzel
3be4712163 tests: Add regression tests for zeek/cmake#61 2023-02-24 19:37:52 +01:00
Arne Welzel
0ddfe69bed tests/bifs-and-scripts-install: Remove unused activate.zeek 2023-02-24 16:14:05 +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
Arne Welzel
fa956efa79 file_analysis/Analyzer: Limit maximum number of violations
Just the same as for protocol analyzers, prevent from violation event overload.
2022-11-08 16:44:39 -07:00
Christian Kreibich
3237ad0ba2 Merge remote-tracking branch 'origin/topic/awelzel/builtin-af-packet'
* origin/topic/awelzel/builtin-af-packet:
  Include in Jan's AF_PACKET plugin as builtin plugin
2022-10-26 16:48:37 -07:00
Tim Wojtulewicz
3656699e2f Merge remote-tracking branch 'origin/topic/awelzel/2403-reject-conflicting-plugins'
* origin/topic/awelzel/2403-reject-conflicting-plugins:
  plugins: Reject dynamic plugins matching names of built-in ones
2022-10-16 17:49:32 -07:00
Arne Welzel
0bc7d0905e Include in Jan's AF_PACKET plugin as builtin plugin
This has come up a few times and the motivation is mainly better "first timer"
experience with Zeek. Concretely, if one wants to run a Zeek cluster with
multiple workers and reasonable load balancing on Linux, AF_PACKET is a decent
start. Without AF_PACKET support being built into Zeek, however, a new user's
next experience is that of setting up a development environment in order
to compile an external plugin (think compiler, kernel headers, zkg, ...).
Only to get what could be termed basic functionality.

This is using the ZEEK_INCLUDE_PLUGINS infrastructure. I've used the all
upper case spelling of AF_PACKET in the help output because it seems everyone
else references/writes it like that. I think we should also write it
like that in the docs.
2022-10-13 13:29:27 +02:00
Arne Welzel
048f2201fb plugins: Reject dynamic plugins matching names of built-in ones
This goes the hard-exit on conflicts route as IMO it provides better
messaging that something is wrong, rather than defaulting to something
the user may not expect.

Fixes #2403
2022-10-12 18:45:17 +02:00
Arne Welzel
d5cd023dff file_analysis: Implement AnalyzerViolation() for file_analysis/Analyzer
Add a test parsing a malformed PE file showing that analyzer_violation_info
is raised with the fa_file object set.

It could be interesting to pass through an optional connection if one
exists, but access is provided through f$conns, too.
2022-09-27 17:49:58 +02:00
Vern Paxson
ce5d840800 annotated scripts to skip when testing compilation-to-C++ 2022-09-16 16:47:43 -07:00
Arne Welzel
3fe930dbf2 Introduce telemetry framework
Adds base/frameworks/telemetry with wrappers around telemetry.bif
and updates telemetry/Manager to support collecting metrics from
script land.

Add policy/frameworks/telemetry/log for logging of metrics data
into a new telemetry.log and telemetry_histogram.log and add into
local.zeek by default.
2022-08-05 11:43:44 +02:00
Benjamin Bannier
489534bd74 Use clang-format for all files in testing/btest/plugins.
This is a fixup commit for dc65b6248c.
2022-07-13 17:58:53 +02:00
Tim Wojtulewicz
1496b99a34 Deprecate HOOK_BRO_OBJ_DTOR and related methods 2022-07-12 12:01:23 -07:00
Tim Wojtulewicz
dc65b6248c Run clang-format on all of our plugin test c++ files 2022-07-12 11:59:55 -07:00
Robin Sommer
e8e6fa8fed Merge remote-tracking branch 'origin/topic/awelzel/913-plugin-debug-stream-validation'
One change: turns out that zeek-config isn't in PATH, so I prefixed it
with $BUILD.

* origin/topic/awelzel/913-plugin-debug-stream-validation:
  zeek-setup: Validate plugin debug streams during startup
2022-07-08 10:00:39 +02:00
Arne Welzel
d703033ae6 zeek-setup: Validate plugin debug streams during startup
Providing an unknown plugin debug stream with -B was previously silently
accepted. This caused user confusing as the behavior is "no output, but
seems to work".

Check the enabled debug streams once all plugins have been loaded and
exit early on for invalid streams.

    $ ZEEK_PLUGIN_PATH=./build zeek -B plugin-zeek-myplugin -e 'print zeek_version();'
    error in <command line>, line 3: No plugin debug stream 'plugin-zeek-myplugin' found

Closes #913.
2022-07-07 17:56:19 +02:00
Tim Wojtulewicz
fb16ce3711 Remove other general deprecations 2022-06-30 19:17:13 +00:00
Tim Wojtulewicz
644ed5d314 Remove deprecated protocol_confirmation/violation events and methods 2022-06-30 19:11:57 +00:00
Tim Wojtulewicz
7c4fd382d9 Code modernization: Convert from deprecated C standard library headers 2022-06-27 09:47:31 -07:00
Benjamin Bannier
95aff9a1e3 Include spicy in build. 2022-05-16 09:07:11 +02:00
Benjamin Bannier
1e4f368c68 Do not log function arguments in test.
This was excercising hooks to validate that they were called. For that
it uses pretty verbose logging. Since version numbers are not stable and
hard to canonify this script already unloads the version module (there
is e.g., code in `base/misc/version` which splits the version strings
and works on single components which might appear like pretty ordinary
floating point numbers in the log).

This test however worked under the assumption that nothing in bare mode
loads `base/misc/version` which is hard to guarantee, especially
considering that plugins can be embedded and might load that module
themself.

With this patch we now make the logging slightly less verbose so that
function call arguments are not logged anymore.
2022-05-16 09:07:11 +02:00
Christian Kreibich
2d93a19f45 Expand plugin.reporter-hook testcase to verify -NN output 2022-04-14 15:20:08 -07:00
Robin Sommer
fccb9ccab0
Re-instantiate providing location information to LoadFile hooks.
#1835 subtly changed the semantics of the `LoadFile` plugin hook to no
longer have the current script location available for signature files
being loaded through `@load-sigs`. This was undocumented behavior, so
it's technically not a regression, but since at least one external
plugin is depending on it, this change restores the old behavior.
2022-04-14 10:43:21 +02:00
Robin Sommer
9b0d525728
Let our TCP-based application analyzers operate without any TCP parent analyzer.
Conceptually, a TCP-based application analyzer should not need any
knowledge about the underlying TCP analysis; it's supposed to just
process its reassembled input stream as it's handed over. But our
analyzers break that assumption at a few places because sometimes
knowledge about the TCP state of the connection can be helpful for
heuristics. This is fine as long as there actually *is* a TCP parent
analyzer available. Sometimes, however, there isn't: if the payload
stream is encapsulated inside another application-layer protocol, the
semantic link to TCP is broken. And if the outer connection is even
UDP, then we don't have a TCP analyzer at all.

We didn't handle this situation well so far. Most analyzers needing
TCP state would just crash if there's no TCP analyzer (in debug mode
with an `assert`, in release mode with a null pointer deref ...). Only
HTTP did the right thing already: check if TCP is available and adapt
accordingly.

We know extend that check to all other analyzers as well: all accesses
to `TCP()` are guarded, with reasonable defaults if not available.
It's actually a pretty small change overall, which is evidence for how
little this layering violation actually matters.

The existing behavior is what's causing
https://github.com/corelight/zeek-spicy-openvpn/issues/3.
2022-01-28 16:25:27 +01:00
Tim Wojtulewicz
c105cbad6e Merge remote-tracking branch 'origin/topic/vern/ZAM-maint'
* origin/topic/vern/ZAM-maint:
  updates to ZAM to track recent changes in script semantics
2021-12-10 13:11:20 -07:00
Christian Kreibich
78803b04fc Add testcases for plugin with doctest usage 2021-12-06 12:17:22 -08:00