Commit graph

16055 commits

Author SHA1 Message Date
Arne Welzel
e56ef0fd9b packet_analysis: Avoid shared_ptr copying for analyzer lookups
For deeply encapsulated connections (think AWS traffic mirroring format
like IP,UDP,GENEVE,IP,UDP,VXLAN,ETH,IP,TCP), the Dispatcher::Lookup()
method is fairly visible in profiles when running in bare mode.

This changes the Analyzer::Lookup() and Dispatcher::Lookup() return value
breaking the API in favor of the performance improvement.

Relates to zeek/zeek#3379.
2023-11-01 12:03:02 +01:00
zeek-bot
a821604505 Update doc submodule [nomail] [skip ci] 2023-11-01 00:24:38 +00:00
Johanna Amann
3257c0e216 Merge remote-tracking branch 'origin/topic/johanna/its-time-to-add-more-tls-extension-types'
* origin/topic/johanna/its-time-to-add-more-tls-extension-types:
  SSL: Add new extension types and ECH test
2023-10-31 16:19:57 +00:00
zeek-bot
f1073fbc5f Update doc submodule [nomail] [skip ci] 2023-10-31 00:46:55 +00:00
Tim Wojtulewicz
d7cb384545 Merge remote-tracking branch 'origin/topic/bbannier/use-spicy-formatting-style'
* origin/topic/bbannier/use-spicy-formatting-style:
  Update `.git-blame-ignore-revs`
  Format JSON with clang-format
  Bump pre-commit hooks
  Reformat Zeek in Spicy style
2023-10-30 12:48:37 -07:00
Johanna Amann
ff27eb5a69 SSL: Add new extension types and ECH test
This commit adds a multitude of new extension types that were added in
the last few years; it also adds grease values to extensions, curves,
and ciphersuites.

Furthermore, it adds a test that contains a encrypted-client-hello
key-exchange (which uses several extension types that we do not have in
our baseline so far).
2023-10-30 14:19:16 +00:00
Benjamin Bannier
552c65a881 Merge remote-tracking branch 'origin/topic/bbannier/issue-3421' 2023-10-30 11:47:43 +01:00
Benjamin Bannier
49d7e638df Normalize version strings in test
Closes #3421.
2023-10-30 10:42:12 +01:00
Benjamin Bannier
09cd3745af Update .git-blame-ignore-revs 2023-10-30 09:42:39 +01:00
Benjamin Bannier
e6256446dd Format JSON with clang-format
We do not activate support for JavaScript at this time since most of our
JavaScript code is in BTest files to test zeekjs, but these files also
contain other languages which leads to largely misformated files.
2023-10-30 09:41:13 +01:00
Benjamin Bannier
26d04fd9fc Bump pre-commit hooks 2023-10-30 09:41:12 +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
zeek-bot
7b8e7ed72c Update doc submodule [nomail] [skip ci] 2023-10-28 00:26:57 +00:00
Tim Wojtulewicz
fd84b793c6 Update external testing baseline hashes 2023-10-27 11:26:09 -07:00
Tim Wojtulewicz
7852463b2f Merge remote-tracking branch 'security/topic/awelzel/195-ieee802-heap-buffer-overflow'
* security/topic/awelzel/195-ieee802-heap-buffer-overflow:
  IEEE802_11: Fix buffer-overflow due to not accounting for the amsdu header
2023-10-27 11:04:33 -07:00
Tim Wojtulewicz
091c849abe Merge remote-tracking branch 'security/topic/awelzel/200-pop-fuzzer-timeout'
* security/topic/awelzel/200-pop-fuzzer-timeout:
  ssl: Prevent unbounded ssl_history growth
  ssl: Cap number of alerts parsed from SSL record
2023-10-27 11:04:03 -07:00
Tim Wojtulewicz
d9534f687a Merge remote-tracking branch 'security/topic/awelzel/196-ftp-timeout-smaller-fix'
* security/topic/awelzel/196-ftp-timeout-smaller-fix:
  Update baselines
  ftp: Do not base seq on number of pending commands
2023-10-27 11:03:54 -07:00
Tim Wojtulewicz
c8363743a5 Merge remote-tracking branch 'security/topic/awelzel/205-x509-sct-leak'
* security/topic/awelzel/205-x509-sct-leak:
  X509Common/SCT parsing: Fix memory leak in error case
2023-10-27 11:03:44 -07:00
Arne Welzel
ab4576369f Merge remote-tracking branch 'origin/topic/awelzel/3398-protocol-analyzer-packet-fuzzing'
* origin/topic/awelzel/3398-protocol-analyzer-packet-fuzzing:
  fuzzers: Add DTLS fuzzer
  generic-analyzer-fuzzer: Support NextPacket() fuzzing
2023-10-27 19:20:32 +02:00
Arne Welzel
0b6832b1b4 fuzzers: Add DTLS fuzzer
Not sure it adds a lot over the SSL analyzer as they share code, but it
provides a distinct entry point at least.
2023-10-27 18:51:36 +02:00
Arne Welzel
5d781e54bd generic-analyzer-fuzzer: Support NextPacket() fuzzing
A number of analyzers that we've been fuzzing with the generic-analyzer-fuzzer
setup do not implement DeliverStream() and instead only work with DeliverPacket()
(ntp, syslog, sip, radius, ...). Calling DeliverStream() on those is
pretty much a noop and fuzzing not effective.

This change adds support to fuzz DeliverPacket(). Whether to use packet
or stream fuzzing is configured through a define via CMake.

This is still a bit limited in that for analyzers that support both,
DeliverPacket() and DeliverStream(), only one code path is fuzzed.

Closed #3398
2023-10-27 18:50:56 +02:00
Benjamin Bannier
4d3e9de3d3 Merge remote-tracking branch 'origin/topic/bbannier/monterey-truncate' 2023-10-26 17:02:09 +02:00
Benjamin Bannier
2b44cea141 Require truncate for a test using it
It looks like older versions of macOS like Monterey do not ship with
`truncate`. Make a recently added test require it to suppress spurious
failures.
2023-10-26 16:23:37 +02:00
Benjamin Bannier
05e4d1cfde Bump outdated baseline
This fixes an outdated baseline added with
caaffd0324.
2023-10-26 15:59:04 +02:00
Benjamin Bannier
48af171110 Merge remote-tracking branch 'origin/topic/bbannier/bump-spicy' 2023-10-26 15:51:12 +02:00
Benjamin Bannier
08d9a1934f Merge branch 'origin/topic/bbannier/fix-core.mmdb-tests' 2023-10-26 15:34:40 +02:00
Benjamin Bannier
caaffd0324 Fix tests so they work both with GNU and BSD tools
The GNU and BSD versions of `touch` and `truncate` allow slightly
different arguments, change the tests so they work in both versions.
2023-10-26 15:33:14 +02:00
Benjamin Bannier
dfba2d6df7 Install libmaxminddb in macOS CI 2023-10-26 14:47:59 +02:00
Benjamin Bannier
9a77f71808 Bump auxil/spicy to latest release 2023-10-26 14:08:33 +02:00
Arne Welzel
d999b74b99 Merge remote-tracking branch 'origin/topic/awelzel/generic-fuzzer-ux'
* origin/topic/awelzel/generic-fuzzer-ux:
  fuzzer-setup: Allow customization without recompiling
2023-10-25 17:02:44 +02:00
Arne Welzel
f0c2a7812a Merge remote-tracking branch 'origin/topic/awelzel/subdir-build-dir'
* origin/topic/awelzel/subdir-build-dir:
  subdir-btest: Allow setting build_dir
2023-10-25 17:01:48 +02:00
Arne Welzel
8b89f1cf8d Merge remote-tracking branch 'origin/topic/awelzel/3043-supervisor-safe-write-error'
* origin/topic/awelzel/3043-supervisor-safe-write-error:
  Supervisor: Handle EAGAIN error on stem pipe
2023-10-25 12:56:04 +02:00
Arne Welzel
92565d4739 Supervisor: Handle EAGAIN error on stem pipe
util::safe_write() calls abort() in case of EAGAIN errors. This is
easily observed when starting clusters with 32 workers or more.

Add a custom write_message() function handling EAGAIN by retrying
after a small sleep. It's not clear a more complicated poll() would be
much better: The pipe might be ready for writing, but then our message
might not actually fit in, resulting in another EAGAIN error. And even
poll() would introduce blocking/sleeping code.

Take some precautions against the stem and the supervisor dead-locking
when both pipes are full by draining the other end on EAGAIN errors.

Closes #3043
2023-10-25 12:53:37 +02:00
Arne Welzel
9530f73ec4 fuzzer-setup: Allow customization without recompiling
This change allows to invoke a reproducer with different script options
and extra scripts to ease debugging and investigation. For example, enabling
the DPD debug stream and adding misc/dump-events can be done as follows after
this change:

    ZEEK_DEBUG_LOG_STDERR=1 ../../build/src/fuzzers/zeek-pop3-fuzzer <test-case> -- -B dpd misc/dump-events
2023-10-25 12:28:44 +02:00
Arne Welzel
560f8a4a84 ssl: Prevent unbounded ssl_history growth
The ssl_history field may grow unbounded (e.g., ssl_alert event). Prevent this
by capping using a configurable limit (default 100) and raise a weird once reached.
2023-10-25 09:35:45 +02:00
Arne Welzel
c960d279a2 ssl: Cap number of alerts parsed from SSL record
Limit the number of events raised from an SSL record with content_type
alert (21) to a configurable maximum number (default 10). For TLS 1.3,
the limit is set to 1 as specified in the RFC. Add a new weird cases
where the limit is exceeded.

OSS-Fuzz managed to generate a reproducer that raised ~660k ssl_plaintext
and ssl_alert events given ~810kb of input data. This change prevents this
with hopefully no negative side-effect in the real-world.
2023-10-25 09:35:10 +02:00
Arne Welzel
8f9d4a296b subdir-btest: Allow setting build_dir
We have that functionality in btest.cfg and it's actually nice to use
it for toggling between a debug/asan and release build.
2023-10-25 09:17:11 +02:00
Arne Welzel
ddcf75e934 Merge remote-tracking branch 'origin/topic/timw/verbose-cluster-testing-btests'
* origin/topic/timw/verbose-cluster-testing-btests:
  CI: Pass -A flag to btest for cluster-testing builds
2023-10-25 09:15:31 +02:00
zeek-bot
21814e144f Update doc submodule [nomail] [skip ci] 2023-10-25 01:30:08 +00:00
Tim Wojtulewicz
ac7685c679 CI: Pass -A flag to btest for cluster-testing builds 2023-10-24 15:42:21 -07:00
Tim Wojtulewicz
e0182e17bf Merge remote-tracking branch 'origin/topic/neverlord/cmake-submodule-update'
* origin/topic/neverlord/cmake-submodule-update:
  Update CMake submodule for caching fix
2023-10-24 13:06:04 -07:00
Arne Welzel
a0ad0f6871 Update doc submodule [nomail] [skip ci] 2023-10-24 20:32:03 +02:00
Arne Welzel
22fb445a7f Merge remote-tracking branch 'origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix'
* origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix:
  event: Reinitialize EventMgr's flare after fork() from stem
2023-10-24 19:35:35 +02:00
Arne Welzel
a9b65cc6d9 Update baselines 2023-10-24 19:10:11 +02:00
Arne Welzel
ce4cbac1ef ftp: Do not base seq on number of pending commands
Previously, seq was computed as the result of |pending_commands|+1. This
opened the possibility to override queued commands, as well as logging
the same pending ftp reply multiple times.

For example, when commands 1, 2, 3 are pending, command 1 may be dequeued,
but the incoming command then receives seq 3 and overrides the already
pending command 3. The second scenario happens when ftp_reply() selected
command 3 as pending for logging, but is then followed by many ftp_request()
events. This resulted in command 3's response being logged for every
following ftp_request() over and over again.

Avoid both scenarios by tracking the command sequence as an absolute counter.
2023-10-24 19:10:07 +02:00
Arne Welzel
631b30f5bb btest/Files/mmdb: golang-ci suggested fixes
Thanks Benjamin for the hint.
2023-10-24 15:08:58 +02:00
Arne Welzel
44b67894ac Merge remote-tracking branch 'origin/topic/awelzel/mmdb-fix-and-tests'
* origin/topic/awelzel/mmdb-fix-and-tests:
  base/frameworks/spicy: Do not load base/misc/version
  btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests
  btest/files: Add mmdb testing databases and generator code
  zeek.bif: Switch mmdb stale check to network_time
  Fix mmdb pointer destruction
2023-10-24 14:13:37 +02:00
Arne Welzel
54a08a74da base/frameworks/spicy: Do not load base/misc/version
Unsure what it's used for today and also results in the situation that on
some platforms we generate a reporter.log in bare mode, while on others
where spicy is disabled, we do not.

If we want base/frameworks/version loaded by default, should put it into
init-bare.zeek and possibly remove the loading of the reporter framework
from it - Reporter::error() would still work and be visible on stderr,
just not create a reporter.log.
2023-10-24 13:15:21 +02:00
Arne Welzel
baf30288ca btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests 2023-10-24 13:15:18 +02:00
Arne Welzel
05922132b3 btest/files: Add mmdb testing databases and generator code 2023-10-24 11:11:02 +02:00