Commit graph

4988 commits

Author SHA1 Message Date
Arne Welzel
cb10852f99 dhcp: Remove Broker::auto_publish()
This isn't prettier, but neither worse IMO. A test would be good.
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
189565d131 types: Fix table() resulting in table_type->IsSet() == true
typename(table()) apparently always resulted in a set[] type
being rendered. Make the yield type of an unspecified table
ANY so that type->IsSet() ends up false.

While at it, also render unspecified types as table(), set() and
vector() rather than vector of void, set[] or table[] of any which
IMO should help to figure out what's going.
2024-11-06 13:28:57 +01:00
Benjamin Bannier
f57955321e Make Spicy hook execution order deterministic in test 2024-11-06 09:42:33 +01:00
Arne Welzel
b69222d5f6 btest: Add detect-sqli test script
...I added the baselines during the merge, just not the test itself.
2024-11-04 18:42:55 +01:00
Vern Paxson
d5c820d2c5 minor ZAM BTest updates for recently added fnv1a64 BiF 2024-11-03 14:05:19 -08:00
Johanna Amann
807bb142a7 Add test for TCP over 802.3/SNAP
This admittedly is a quite esoteric combination of protocols. But - as
we do correctly support them, it seems nice to have a slightly more
complete testcase that covers this.
2024-10-31 14:37:44 +00:00
Arne Welzel
fd0181c2cb Merge branch 'modbus-fc-fixes' of https://github.com/zambo99/zeek
* 'modbus-fc-fixes' of https://github.com/zambo99/zeek:
  Fix issues with Modbus message logging
2024-10-30 14:38:53 +01:00
Arne Welzel
00a0f9c920 Merge remote-tracking branch 'origin/topic/awelzel/data-end-offset-v1'
* origin/topic/awelzel/data-end-offset-v1:
  signatures: Add data_end_offset to signature_match() and custom events
  Add pattern_end_offset to signature_state
2024-10-30 14:34:08 +01:00
Arne Welzel
04872d4e78 signatures: Add data_end_offset to signature_match() and custom events
This change tracks the current offset (number of bytes fed into matchers)
on the top-level RuleEndpointState such that we can compute the relative ending
for matched texts individually.

Additionally, it adds the data_end_offset as a new optional parameter to
signature_match().
2024-10-30 13:29:58 +01:00
Emmanuele Zambon
792aacc8e5 Fix issues with Modbus message logging
This commit fixes three issues with Zeek's Modbus message logging:

1 - Some exception responses (e.g., READ_COILS_EXCEPTION) are logged
    twice: once without and once with the exception message.
2 - Some exception responses (e.g., PROGRAM_484_EXCEPTION) are not
    logged.
3 - Some known but reserved function codes (e.g., PROGRAM_UNITY) are
    logged as unk-xxx (e.g., unk-90), while it would be possible to
    log their known name.

To address these inconsistencies, the modbus parser has been updated
to parse all exception responses (i.e., all responses where the MSB
of the function code is set) using the already defined Exception
message.
Also, the Modbus main.zeek script has been updated to consistently
demand logging exception responses to the specialized
modbus_exception event, rather than logging some exception responses
in the modbus_message event and others in the modbus_exception event.
Finally, the main.zeek script has been updated to make sure that
for every known function code, the corresponding exception code was
also present, and the enumeration of known function codes in
consts.zeek has been expanded.

Closes #3984
2024-10-30 13:12:27 +01:00
Johanna Amann
681fd37a6d Merge remote-tracking branch 'origin/topic/awelzel/skip-modbus-when-spicy-ssl-enabled'
* origin/topic/awelzel/skip-modbus-when-spicy-ssl-enabled:
  modbus: Skip non-modbus traffic testing with Spicy SSL
  testing: Add have-spicy-ssl helper and update tests
2024-10-30 11:48:15 +00:00
Johanna Amann
eb74790d90 Merge branch 'improvement/fnv1a_hashing_algorithm_improvements' of https://github.com/martinvanhensbergen/zeek
Fixes indentation.

Fixes GH-3970
2024-10-30 11:46:26 +00:00
Arne Welzel
5200b84fb3 Merge branch 'sqli-spaces-encode-to-plus' of https://github.com/cooper-grill/zeek
* 'sqli-spaces-encode-to-plus' of https://github.com/cooper-grill/zeek:
  account for spaces encoding to plus signs in sqli regex detection
2024-10-29 14:08:39 +01:00
Arne Welzel
821218e7b2 Merge remote-tracking branch 'origin/topic/vern/CPP-when-capture-naming'
* origin/topic/vern/CPP-when-capture-naming:
  fixed "-O gen-C++" naming of "when" captures to avoid ambiguities due to inlining
  Simplified & made more robust maintenance helper script for "-O gen-C++" testing
  "-a cpp" baseline updates to reflect recent BTest changes
2024-10-29 13:50:56 +01:00
Cooper Grill
ec6bf7bebc account for spaces encoding to plus signs in sqli regex detection
remove instance of plus sign to account for real plus in sql

account for spaces encoding to plus signs in sqli regex detection

add test cases for sqli space to plus

account for spaces encoding to plus signs in sqli regex detection

forgot semicolon

account for spaces encoding to plus signs in sqli regex detection
2024-10-29 07:48:36 -04:00
Arne Welzel
54bc3672d8 modbus: Skip non-modbus traffic testing with Spicy SSL
With Spicy SSL, there's no SSL conn.log produced.
2024-10-29 09:30:01 +01:00
Arne Welzel
d18045ee16 testing: Add have-spicy-ssl helper and update tests 2024-10-29 09:30:01 +01:00
Christian Kreibich
66173633f4 Merge branch 'topic/christian/telemetry-make-bifs-primary'
* topic/christian/telemetry-make-bifs-primary:
  Telemetry framework: move BIFs to the primary-bif stage
  Minor comment tweaks for init-frameworks-and-bifs.zeek
2024-10-24 07:09:16 -07:00
Arne Welzel
daa358c840 Merge remote-tracking branch 'origin/topic/awelzel/3947-telemetry-hook-scrape'
* origin/topic/awelzel/3947-telemetry-hook-scrape:
  btest/telemetry: Fix "Note compilable" typo
  misc/stats: Add zeek_net_timestamp_seconds
  telemetry/Manager: Remove variant include
  telemetry: Invoke Telemetry::sync() only at scrape/collection time
2024-10-22 19:04:51 +02:00
Arne Welzel
3d053a94f7 btest/telemetry: Fix "Note compilable" typo 2024-10-22 18:50:32 +02:00
Arne Welzel
e20aa66eae misc/stats: Add zeek_net_timestamp_seconds
Adding a metric for the network time value itself should make it
possible to observe it stopping or growing slowly as compared to
realtime when Zeek isn't able to keep up.

Also, modify the telemetry/log.zeek test to include misc/stats and
log at a higher frequency with a more interesting pcap.
2024-10-22 18:49:17 +02:00
Arne Welzel
70872673a1 telemetry: Invoke Telemetry::sync() only at scrape/collection time
This stops invoking Telemetry::sync() via a scheduled event and instead
only invokes it on-demand. This makes metric collection network time
independent and lazier, too.

With Prometheus scrape requests being processed on Zeek's main thread
now, we can safely invoke the script layer Telemetry::sync() hook.

Closes #3947
2024-10-22 18:49:11 +02:00
Martin van Hensbergen
ee84c0c59a Improvements in FNV1A hash functions
- Add FNV1a64 hash function
- make hash function type aware
- add unit tests
2024-10-22 16:07:12 +02:00
Arne Welzel
4763282f36 Merge branch 'modbus-fixes' of https://github.com/zambo99/zeek
* 'modbus-fixes' of https://github.com/zambo99/zeek:
  Prevent non-Modbus on port 502 to be reported as Modbus
2024-10-21 15:54:11 +02:00
Emmanuele Zambon
05d92dc2a5 Prevent non-Modbus on port 502 to be reported as Modbus
This commit prevents most non-Modbus TCP traffic on port 502 to be
reported as Modbus in conn.log as well as in modbus.log.
To do so, we have introduced two &enforce checks in the Modbus
protocol definition that checks that some specific fields of the
(supposedly) Modbus header are compatible with values specified in
the specs.

To ensure non-regression, with this commit we also introduce a
new btest.

Closes #3962
2024-10-21 14:40:45 +02:00
Christian Kreibich
71f7e89974 Telemetry framework: move BIFs to the primary-bif stage
This moves the Telemetry framework's BIF-defined functionalit from the
secondary-BIFs stage to the primary one. That is, this functionality is now
available from the end of init-bare.zeek, not only after the end of
init-frameworks-and-bifs.zeek.

This allows us to use script-layer telemetry in our Zeek's own code that get
pulled in during init-frameworks-and-bifs.

This change splits up the BIF features into functions, constants, and types,
because that's the granularity most workable in Func.cc and NetVar. It also now
defines the Telemetry::MetricsType enum once, not redundantly in BIFs and script
layer.

Due to subtle load ordering issues between the telemetry and cluster frameworks
this pushes the redef stage of Telemetry::metrics_port and address into
base/frameworks/telemetry/options.zeek, which is loaded sufficiently late in
init-frameworks-and-bifs.zeek to sidestep those issues. (When not doing this,
the effect is that the redef in telemetry/main.zeek doesn't yet find the
cluster-provided values, and Zeek does not end up listening on these ports.)

The need to add basic Zeek headers in script_opt/ZAM/ZBody.cc as a side-effect
of this is curious, but looks harmless.

Also includes baseline updates for the usual btests and adds a few doc strings.
2024-10-18 09:56:29 -07:00
Evan Typanski
0c79849a0f Test .evt file &priority
This was not documented nor tested, so this tests the behavior.
Documentation should be added later.
2024-10-14 08:51:58 -04:00
Vern Paxson
f90d03bc7f "-a cpp" baseline updates to reflect recent BTest changes 2024-10-11 08:12:49 -07:00
Christian Kreibich
1208555ee3 Merge remote-tracking branch 'origin/topic/vern/remove-teredo-gtpv1-script-opt-insts'
* origin/topic/vern/remove-teredo-gtpv1-script-opt-insts:
  removed specialized ZAM instructions for GTPv1 and Teredo cleanup BiFs
2024-10-09 15:36:52 -07:00
Christian Kreibich
2651de64bf Merge remote-tracking branch 'origin/topic/vern/script-opt-baselines.Oct24'
* origin/topic/vern/script-opt-baselines.Oct24:
  -a zam baseline updates reflecting recent changes to main baselines
2024-10-09 15:36:21 -07:00
Arne Welzel
ecfa03ea1d input/Raw: Rework GetLine()
This isn't a straightforward fix, unfortunately. The existing GetLine()
implementation didn't deal well with input that's incrementally produced
where individually read chunks wouldn't end with the separator.

The prior implementation increased the buffer each time it failed to find
a separator in the current buffer, but then also ended up not searching the
full new buffer size for the terminator, doing that endlessly.

This change reworks the Raw reader to rely only on bufpos for reading
and searching purposes and skip reallocation if the buffer size if it
wasn't actually exhausted.

Closes #3957
2024-10-09 14:21:07 -07:00
Vern Paxson
b4bfbcc8d2 removed specialized ZAM instructions for GTPv1 and Teredo cleanup BiFs 2024-10-05 15:39:47 -07:00
Vern Paxson
99f2bcef41 -a zam baseline updates reflecting recent changes to main baselines 2024-10-05 14:57:50 -07:00
Arne Welzel
4656faed6c POP3: Rework unbounded pending command fix
Processing out-of-order commands or finishing commands based on invalid
server responses resulted in inconsistent analyzer state, potentially
triggering null pointer references for crafted traffic.

This commit reworks cf9fe91705 such that
too many pending commands are simply discarded, rather than any attempt
being made to process them. Further, invalid server responses do not
result in command completion anymore.

Test PCAP was crafted based on traffic produced by the OSS-Fuzz reproducer.

Closes #215
2024-10-04 12:45:59 -07:00
Christian Kreibich
4ccf1dd470 Bump zeek-testing-cluster to pull in a baseline update
The recently expanded `Describe()` output (c0ffaabe) caused one test to
complain.
2024-10-04 12:44:11 -07:00
Arne Welzel
c826118385 Merge remote-tracking branch 'origin/topic/etyp/centos-missing-file-test-fail'
* origin/topic/etyp/centos-missing-file-test-fail:
  Fix flaky `missing-file-initially` test
2024-10-04 19:32:48 +02:00
Evan Typanski
5c6f172c0a Fix flaky missing-file-initially test
That test got flaky probably from #3949 on centosstream9 CI. You can
replicate that behavior by increasing the sleep time when waiting for
the file such that the test will attempt to read the missing file again.
Since the one second wait for file is glacially slow for this, speeding
it up should mean that the file gets created sooner and so the test
won't try to open the file again. But, it's always still technically
possible, since the test will wait for 10 seconds and the heartbeat
seems to be 1 second. At least if that happens, it's probably a bug or
massive slowdown of some kind.
2024-10-04 12:27:34 -04:00
Evan Typanski
e8872b4c7f Fix input error test nondeterminism
It seems like other similar tests get by because they have more "stuff"
before they call `terminate()` most likely. But, to be safe, just
removing the "received termination signal" line seems like the best
approach.
2024-10-02 13:26:41 -04:00
Evan Typanski
ecabf882ac Report suppressed warnings count
This also triggers if there is one warning, which seems a little weird,
but it seems mostly reasonable.
2024-09-30 08:20:19 -04:00
Evan Typanski
6e8d43a552 Avoid duplicating warnings when reading table
Invalid lines in a file was the one case that would not suppress future
warnings. Just make it suppress warnings too, but clear that suppression
if there is a field in between that doesn't error.

Fixes #3692
2024-09-30 08:20:19 -04:00
Vern Paxson
61258587bf BTest baseline update for more complete function/lambda names 2024-09-27 14:16:10 -07:00
Vern Paxson
a390b3665b removed unused ZAM cast-to-any operation 2024-09-27 13:24:35 -07:00
Arne Welzel
c36ae2f1a3 Merge branch 'pr/3946'
* pr/3946:
  Honor no plaintext password logging for PASS cmd

Closes #3946 - squashed commits into a single one.
2024-09-27 16:52:44 +02:00
Martin van Hensbergen
0e926afbc1 Honor no plaintext password logging for PASS cmd 2024-09-27 16:45:06 +02:00
Arne Welzel
0d925e935e logging: Dedicated log flush timer
Log flushing is currently triggered based on the threading heartbeat timer
of WriterBackends and the hard-coded WRITE_BUFFER_SIZE 1000.

This change introduces a separate timer that is managed by the logger
manager instead of piggy-backing on the heartbeat timer, as well as a
const &redef for the buffer size.

This allows to modify the log flush frequency and batch size independently
of the threading heartbeat interval. Later, this will allow to re-use the
buffering and flushing logic of writer frontends for non-Broker cluster
backends, too.

One change here is that even frontends that do not have a backend will
be flushed regularly. This is wanted for non-Broker backends and should be
very cheap. Possibly, Broker can piggy back on this timer down the road, too,
rather than using its own script-level timer (see Broker::log_flush()).
2024-09-27 15:30:35 +02:00
Tim Wojtulewicz
702fb031a4 Merge remote-tracking branch 'origin/topic/awelzel/3936-pop3-and-redis'
* origin/topic/awelzel/3936-pop3-and-redis:
  pop3: Remove unused headers
  pop3: Prevent unbounded state growth
  btest/pop3: Add somewhat more elaborate testing
2024-09-23 11:00:06 -07:00
Arne Welzel
b22ec06568 Merge remote-tracking branch 'origin/topic/etyp/enum-port-sizeof'
* origin/topic/etyp/enum-port-sizeof:
  Add enum value negative check
  Fix port/enum values `SizeOf` not being a count
2024-09-18 19:10:59 +02:00
Arne Welzel
cf9fe91705 pop3: Prevent unbounded state growth
The cmds list may grow unbounded due to the POP3 analyzer being in
multiLine mode after seeing `AUTH` in a Redis connection, but never
a `.` terminator. This can easily be provoked by the Redis ping
command.

This adds two heuristics: 1) Forcefully process the oldest commands in
the cmds list and cap it at max_pending_commands. 2) Start raising
analyzer violations if the client has been using more than
max_unknown_client_commands commands (default 10).

Closes #3936
2024-09-18 19:05:39 +02:00
Arne Welzel
b4fdce8d5b btest/pop3: Add somewhat more elaborate testing
PCAP taken from here: https://tranalyzer.com/tutorial/pop and reference
added to Traces/README.
2024-09-18 17:31:13 +02:00