Commit graph

4461 commits

Author SHA1 Message Date
Arne Welzel
b745556d36 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-25 10:05:09 -07:00
Arne Welzel
f6615753f1 ssl: Prevent unbounded ssl_history growth
The previous fix also made it clear that the ssl_history field may grow
unbounded via the ssl_alert event. Prevent by capping using a configurable
limit (default 100) and raise a weird once reached.
2023-10-25 10:05:09 -07:00
Arne Welzel
65f8222b92 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

(cherry picked from commit 44b67894ac)
2023-10-24 13:49:25 -07:00
Arne Welzel
651b208937 Merge remote-tracking branch 'origin/topic/bbannier/issue-3279'
* origin/topic/bbannier/issue-3279:
  Fix handling of module scope when checking exported Spicy types for collisions

(cherry picked from commit 30dc6af831)
2023-10-16 13:15:40 -07:00
Tim Wojtulewicz
f0bf803dd2 Update dump_events test baseline after fseek changes 2023-09-12 09:41:10 -07:00
Johanna Amann
3c3a3c92ea Add extract_limit_includes_missing option for file extraction
Setting this option to false does not count missing bytes in files towards the
extraction limits, and allows to extract data up to the desired limit,
even when partial files are written.

When missing bytes are encountered, files are now written as sparse
files.

Using this option requires the underlying storage and utilities to support
sparse files.

(cherry picked from commit afa6f3a0d3b8db1ec5b5e82d26225504c2891089)
2023-09-12 09:41:03 -07:00
Arne Welzel
a96bcef839 ftp: Do not log non-pending commands
OSS Fuzz generated a CWD request and reply followed by very many EPRT
requests. This caused Zeek to re-log the CWD request and invoke `build_url_ftp()`
over and over again resulting in long processing times.

Avoid this scenario by not logging commands that aren't pending anymore.

(cherry picked from commit b05dd31667ff634ec7d017f09d122f05878fdf65)
2023-09-12 09:40:51 -07:00
Arne Welzel
fe9c7d4191 Merge remote-tracking branch 'origin/topic/jazoff/gh-3268t '
* origin/topic/jazoff/gh-3268:
  Fix check for emailed notices

Changes: Added a test-case printing email_delay_tokens to compare email vs
non-email notice types. Previously, both notice types would have email
delay tokens at that point in the flow.

(cherry picked from commit 7e11501d3c)
2023-09-08 11:09:56 -07:00
Arne Welzel
c413c6d71a Merge remote-tracking branch 'origin/topic/awelzel/3278-spicy-fix-port-range-off-by-one'
* origin/topic/awelzel/3278-spicy-fix-port-range-off-by-one:
  spicy: Do not register port N+1 for port N in .evt file

(cherry picked from commit 6e6a2bee8a)
2023-09-07 18:13:48 -07:00
Johanna Amann
ab2b241c3f Merge remote-tracking branch 'origin/topic/johanna/gh-3242'
* origin/topic/johanna/gh-3242:
  Community-id: load main script in notice script, fix notice script

(cherry picked from commit 70c76977cf)
2023-08-23 10:16:45 -07:00
Tim Wojtulewicz
c7cfeeb572 Update scripts.policy.misc.dump-events baseline for connection flipping PR 2023-08-16 11:05:34 -07:00
Arne Welzel
bde9c7070e Conn: In-place val flip and connection_flipped()
Avoids loosing state on a connection value when a connection is flipped.

Fixes up the NTP baseline as well where this was visible: analyzer_confirmation_info()
was raised for a connection value which was immediately forgotten due to
the subsequent connection flipping.

Closed #3028

(cherry picked from commit a2214ad611)
2023-08-16 09:57:33 -07:00
Johanna Amann
483f7a0322 Merge remote-tracking branch 'origin/topic/johanna/tcp-padding'
* origin/topic/johanna/tcp-padding:
  Do not forward padding to downstream TCP packet analyzer

(cherry picked from commit 81ce83590d)
2023-08-08 13:36:16 -07:00
Tim Wojtulewicz
a99231d956 Merge remote-tracking branch 'origin/topic/johanna/3205-do-not-parse-udp-padding'
* origin/topic/johanna/3205-do-not-parse-udp-padding:
  Do not forward more than the remaining data to downstream UDP analyzer

(cherry picked from commit 3c7a52d0a7)
2023-08-08 13:22:18 -07:00
Tim Wojtulewicz
5811e58139 Merge remote-tracking branch 'origin/topic/awelzel/3145-dcerpc-state-clean'
* origin/topic/awelzel/3145-dcerpc-state-clean:
  dce-rpc: Test cases for unbounded state growth
  dce-rpc: Handle smb2_close_request() in scripts
  smb/dce-rpc: Cleanup DCE-RPC analyzers when fid is closed and limit them
  dce-rpc: Do not repeatedly register removal hooks

(cherry picked from commit f9904511ab)
2023-08-08 12:55:21 -07:00
Robin Sommer
ddaa553418 Merge remote-tracking branch 'origin/topic/robin/gh-3157-export-switch'
* origin/topic/robin/gh-3157-export-switch:
  [Spicy] Support `switch` fields when exporting Spicy types to Zeek.

(cherry picked from commit cd2c193cb2)
2023-08-08 12:54:21 -07:00
Arne Welzel
4ae02b7973 Merge branch 'master' of https://github.com/progmboy/zeek
* 'master' of https://github.com/progmboy/zeek:
  fix http AUTHORIZATION base64 decode failed

Added a test during merge.

(cherry picked from commit b18122da08)
2023-08-08 12:51:51 -07:00
Tim Wojtulewicz
36fb655caa Merge remote-tracking branch 'origin/topic/awelzel/no-metrics-centralization'
* origin/topic/awelzel/no-metrics-centralization:
  telemetry: Disable metrics centralization by default

(cherry picked from commit 0fbfaeb996)
2023-06-21 15:42:10 -07:00
Tim Wojtulewicz
965d1de3f6 Merge remote-tracking branch 'origin/topic/awelzel/3112-log-suffix-left-over-log-rotation-fixup'
* origin/topic/awelzel/3112-log-suffix-left-over-log-rotation-fixup:
  tests: Do not use archiver_rotation_format_func as postprocessor

(cherry picked from commit 9e2e6d0174)
2023-06-15 15:56:24 -07:00
Arne Welzel
7e2d9aa7be Merge branch 'topic/awelzel/3112-log-suffix-left-over-log-rotation'
* topic/awelzel/3112-log-suffix-left-over-log-rotation:
  cluster/logger: Fix leftover-log-rotation in multi-logger setups
  cluster/logger: Fix global var reference

(cherry picked from commit f53aefdd5b)
2023-06-15 15:21:02 -07:00
Tim Wojtulewicz
d2b534e6b2 Merge remote-tracking branch 'origin/topic/awelzel/cluster-at-if-removal'
* origin/topic/awelzel/cluster-at-if-removal:
  test-all-policy: Do not load nodes-experimental/manager.zeek
  cluster/main: Remove extra @if ( Cluster::is_enabled() )

(cherry picked from commit 98e44ee14f)
2023-06-12 11:23:01 -07:00
Tim Wojtulewicz
b34e70e6cd Merge remote-tracking branch 'origin/topic/awelzel/3099-fix-and-extend-socks5-sig'
* origin/topic/awelzel/3099-fix-and-extend-socks5-sig:
  socks/dpd: Add newer auth methods
  socks/dpd: Fix socks5_server side signature

(cherry picked from commit c389d9804b)
2023-06-12 11:01:14 -07:00
Tim Wojtulewicz
7ebcbcd174 Update baseline for coverage.test-all-policy-cluster test 2023-05-31 00:40:30 -07:00
Arne Welzel
aceb023301 Add test-all-policy-cluster
After the introduction of @if ... analyze, a lot of warnings were
triggered due to nested @if and @if .. analyze usage.

Add a test for coverage of all policy scripts in cluster mode
for the usual node types so this does not happen again.
2023-05-31 00:37:30 -07:00
Tim Wojtulewicz
5a3abbe364 Revert "Merge remote-tracking branch 'origin/topic/vern/at-if-analyze'"
This reverts commit 4e797ddbbc, reversing
changes made to 3ac28ba5a2.
2023-05-31 09:20:33 +02:00
Robin Sommer
cfbb7eb8ee
Merge remote-tracking branch 'origin/topic/robin/gh-3083-export-fix'
* origin/topic/robin/gh-3083-export-fix:
  Register test analyzer only for required ports.
  Fix disappearing unit fields in Spicy type export.
2023-05-30 14:59:00 +02:00
Benjamin Bannier
0b100c1e1c Register test analyzer only for required ports.
This is a workaround for #3094.
2023-05-28 17:36:06 +02:00
Tim Wojtulewicz
4e797ddbbc Merge remote-tracking branch 'origin/topic/vern/at-if-analyze'
* origin/topic/vern/at-if-analyze:
  updates reflecting review comments
  change base scripts to use run-time if's or @if ... &analyze
  a number of BTests updated with @if ... &analyze
  update for scripting coverage BTest demonstrating utility of @if ... &analyze
  BTests for new @if ... &analyze functionality
  "if ( ... ) &analyze" language feature
  classes for tracking "@if (...) &analyze" notion of code being/not being "activated"
  RemoveGlobal() method for Scope class + simplifying interfaces
2023-05-26 14:56:01 -07:00
Robin Sommer
fd86d8530b
Fix disappearing unit fields in Spicy type export.
When a Spicy unit type was used in an EVT event definition, it could
end up being cleared out at the time the logic for `export` got to see it.

Closes #3083.

Note: This needs backporting to the legacy plugin.
2023-05-26 11:37:23 +02:00
Arne Welzel
c61f0d776f Bump cluster testsuite to latest main 2023-05-26 10:02:46 +02:00
Vern Paxson
e441ba394a updates reflecting review comments 2023-05-25 18:00:13 -07:00
Arne Welzel
3f3df93ac1 Merge remote-tracking branch 'origin/topic/timw/2914-truncated-tunnel-plus-things'
* origin/topic/timw/2914-truncated-tunnel-plus-things:
  Address wire/capture length feedback
  packet_analysis/TCP: Do not use untrusted len for DeliverPacket()
  Add regression test using pcap from GH-2683
  Add btest to test Geneve->VXLAN->Truncated inner packet
  IP: Update packet->len with accumulated fragment size
  UDP: Forward any remaining data (also empty) to session-analysis
  IPTunnel: Compute inner wire length based on cap_len differences.
  IP: fix weird name to not be ipv6 specific
  UDP: don't validate checksum if caplen < len
  PIA: Modernize how struct initialization is done
2023-05-25 20:19:20 +02:00
Tim Wojtulewicz
2bf0ebae32 Merge remote-tracking branch 'origin/topic/awelzel/auto-hilti-cxx-compiler-launcher-in-btest'
* origin/topic/awelzel/auto-hilti-cxx-compiler-launcher-in-btest:
  btest.cfg: Set HILTI_CXX_COMPILER_LAUNCHER based on build/CMakeCache.txt
2023-05-25 09:03:49 -07:00
Benjamin Bannier
8049d3a002 Speed up Spicy-related tests.
This patch changes invocations of `spicyz` and similar Spicy tools in
tests which perform compilation to use debug mode via passing `-d`. This
in turn leads to Spicy compiling generated C++ code in debug as opposed
to release mode which typically seems to require less CPU time and RAM.
For a local test running with `btest -j 16` and no caching via
`HILTI_CXX_COMPILER_LAUNCER` this sped up running of BTests under
`spicy/` by about 40s on my machine (120s vs 160s).
2023-05-25 14:59:10 +02:00
Arne Welzel
b9803e157b btest.cfg: Set HILTI_CXX_COMPILER_LAUNCHER based on build/CMakeCache.txt
If CMakeCache.txt indicates the Zeek build was done with ccache,
take the CCACHE_PROGRAM:FILEPATH= line and populate the
HILTI_CXX_COMPILER_LAUNCHER environment.

For local development with ccache, this speeds up the spicy tests
significantly after the initial run without knowing or needing know
that setting HILTI_CXX_COMPILER_LAUNCHER would've helped.
2023-05-25 13:42:12 +02:00
Arne Welzel
a41dfb28d5 Add regression test using pcap from GH-2683 2023-05-24 16:34:25 +02:00
Tim Wojtulewicz
d9718342ac Add btest to test Geneve->VXLAN->Truncated inner packet 2023-05-24 16:34:25 +02:00
Tim Wojtulewicz
18a30a7a53 IP: fix weird name to not be ipv6 specific 2023-05-24 16:29:29 +02:00
Tim Wojtulewicz
351e68b66a GH-3060: Support negative index lookups for vectors 2023-05-23 13:48:58 -07:00
Arne Welzel
e9cd849843 Fix crashing when disable_analyzer() called on root analyzers
Closes #3071.
2023-05-23 15:44:14 +02:00
Arne Welzel
09b956562e btest/input/raw: Fix reread test
This seems to have relied on the reading file twice behavior simply
testing that 16 lines are observed. Switch to using two separate
files and doing a system("mv ...") to trigger the REREAD logic, there's
not force_update() needed and it wouldn't do anything if the file
hadn't changed anyway.
2023-05-22 11:06:54 +02:00
Arne Welzel
d8b5bdf758 input/Raw: Avoid reading file twice in MODE_REREAD
Found while writing documentation and being confused why
all lines and end_of_data() arrive twice during startup.

The test is a bit fuzzy, but does fail reliably without
the changes to Raw.cc

Also fix not checking dev in the MODE_REREAD path.

Closes #3053
2023-05-22 11:06:25 +02:00
Vern Paxson
890010915a change base scripts to use run-time if's or @if ... &analyze 2023-05-19 13:26:27 -07:00
Vern Paxson
e749638380 a number of BTests updated with @if ... &analyze 2023-05-19 13:13:26 -07:00
Vern Paxson
8e375d34b7 update for scripting coverage BTest demonstrating utility of @if ... &analyze 2023-05-19 13:04:03 -07:00
Vern Paxson
be87f9f6ec BTests for new @if ... &analyze functionality 2023-05-19 13:02:37 -07:00
Arne Welzel
9bda48d17c MIME: Re-use cur_entity_id for EndOfFile()
If DataIn() was called and a cur_entity_id (file_id) has been produced
previously, re-use it for calls to EndOfFile(). This avoids a costly
event_mgr.Drain() when we already have that information. It should be safer,
too, as `get_file_handle()` in script may generate a different ID and
thereby de-synchronizing.
2023-05-19 09:37:35 -07:00
Tim Wojtulewicz
fc78b14cd7 Add length checking to ToRawPktHdrVal for truncated packets 2023-05-19 09:37:18 -07:00
Arne Welzel
2007eeae1b zeekygen: Render function parameters as :param x: instead of
We're currently rendering parameter descriptions from .bif file into
the .rst as follows:

    :cid: The connection identifier.

    :aid: The analyzer ID.

Switch this to :param cid: instead so that we can have Sphinx deal with
this as param docfield and group all parameters into a single section.

Currently, having the bare :cid: style causes sphinx to treat it as an
unknown field type, capitalize it and render it.
2023-05-16 20:21:12 +02:00
Robin Sommer
10477b38aa
Move Spicy submodule a layer up.
This moves `auxil/spicy/spicy` to `auxil/spicy`. It relocates the
pieces previously inside that intermediary directory. The main change
is that now tweak the compilation flags for Spicy through target
options.

This is on top of `topic/robin/spicy-plugin`.
2023-05-16 12:09:12 +02:00