Commit graph

4195 commits

Author SHA1 Message Date
Arne Welzel
8be8c22b3e smb1: Prevent accessing uninitialized referenced_tree
The added pcap was created from an OSS Fuzz test case and is borderline
valid SMB traffic, but it triggered a scripting error.

Closes #2726
2023-01-27 19:22:13 +01:00
Arne Welzel
03dc21a861 testing/mysql: Add traces recorded with a free-tier MySQL instance
Not sure this adds much more coverage then there was, but minimally
more recent software versions.

The instances/passwords were ephemeral, so hostname and password hashes
etc aren't useful to anyone.
2023-01-27 10:59:23 +01:00
Arne Welzel
672602dae7 MySQL: Fix endianness, introduce mysql_eof() event
We were parsing MySQL using bigendian even though the protocol is
specified as with "least significant byte first" [1]. This is most
problematic when parsing length encoded strings with 2 byte length
fields...

Further, I think, the EOF_Packet parsing was borked, either due to
testing the CLIENT_DEPRECATE_EOF with the wrong endianness, or due to
the workaround in Resultset processing raising mysql_ok(). Introduce a
new mysql_eof() that triggers for EOF_Packet's and remove the fake
mysql_ok() Resultset invocation to fix. Adapt the mysql script and tests
to account for the new event.

This is a quite backwards incompatible change on the event level, but
due to being quite buggy in general, doubt this matters to many.

I think there is more buried, but this fixes the violation of the simple
"SHOW ENGINE INNODB STATUS" and the existing tests continue to
succeed...

[1] https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_dt_integers.html
2023-01-27 10:59:23 +01:00
Arne Welzel
25ee288a76 Tame error reporting and abort() for undefined types
The script added as a test case reports the following messages *and*
dumps a core file. Printing the first error and a normal failure exit
seems sufficient. IMO triggering an abort() due to user scripting issues
is not something that Zeek should do

    $ zeek ./identifier-not-defined-error.zeek
    error in ./identifier-not-defined-error.zeek, line 10: identifier not defined: MyEnu
    error in ./identifier-not-defined-error.zeek, line 10 and error: &default value has inconsistent type (M::MY_ENUM_A and error)
    internal error in ./identifier-not-defined-error.zeek, line 11: type inconsistency in ZVal constructor
    Aborted (core dumped)

Change is to skip certain checks when an error type is propagated.
2023-01-26 20:05:02 +01:00
Tim Wojtulewicz
f842a86e80 Update external testing repo commit hashes for Teredo changes 2023-01-26 09:23:22 -07:00
Tim Wojtulewicz
6ebfa02199 Update scripts.base.frameworks.analyzer.logging btest to use a different trace file 2023-01-26 09:14:00 -07:00
Tim Wojtulewicz
3d5918e6b3 Update btest baselines due to reduced calls to UID::Set
UID::Set is called by AnalyzerViolation, and since Teredo isn't calling nearly
as many of those anymore the UIDs used by other calls changed as well.
2023-01-26 09:14:00 -07:00
Tim Wojtulewicz
5e68880470 GH-2669: Give script location for type clash in for-loop construction 2023-01-26 09:11:10 -07:00
Tim Wojtulewicz
e61c3a95ad GH-2684: Stop violating VXLAN for forwarding failures 2023-01-25 10:50:07 -07:00
Tim Wojtulewicz
89675fc7de Add test for new handling of unknown RDP keyboards 2023-01-23 13:01:48 -07:00
Tim Wojtulewicz
d6ce5894a7 Fix diff-remove-abspath to ignore Windows drive letters 2023-01-19 09:13:33 -07:00
Tim Wojtulewicz
7623e9f290 Use pathsep btest value in btest.cfg 2023-01-19 09:13:33 -07:00
Tim Wojtulewicz
b3498da983 Use build_dir btest value in btest.cfg 2023-01-19 09:13:33 -07:00
Arne Welzel
b4cb5e753a Merge branch 'topic/awelzel/fix-zam-memory-leak'
* topic/awelzel/fix-zam-memory-leak:
  testing/btest: Add ZAM basic test
  Fix ZAM memory leak as reported in #2634
2023-01-18 17:14:56 +01:00
Arne Welzel
eb09662d48 bifs/parse_eftp: Prevent reporter warnings/errors on invalid input
When passing invalid IPs or an out-of range port to parse_eftp()
a warning or error was generated on stderr (in addition to setting
the $valid field to F). Prevent the output by adding safe-guarding
and using IPAddr::ConvertString() instead.
2023-01-16 15:20:02 +01:00
Arne Welzel
d4a84e7442 Merge remote-tracking branch 'origin/topic/vern/dup-rec-fields2'
* origin/topic/vern/dup-rec-fields2:
  fix for crashes when record definitions repeat a field name

Removed dead if !init code during merge.
2023-01-12 09:42:50 +01:00
Vern Paxson
a172617250 fix for crashes when record definitions repeat a field name 2023-01-10 13:56:47 -08:00
Arne Welzel
2d852209b0 Merge remote-tracking branch 'origin/topic/awelzel/analyzer-log'
* origin/topic/awelzel/analyzer-log:
  btest/net-control: Use different expiration times for rules
  analyzer: Add analyzer.log for logging violations/confirmations
2023-01-10 10:22:58 +01:00
Arne Welzel
a004bdf5d9 Merge remote-tracking branch 'origin/topic/awelzel/2647-intel-seen-file-names'
* origin/topic/awelzel/2647-intel-seen-file-names:
  intel/seen/file-names: Use file_over_new_connection()
2023-01-10 10:12:04 +01:00
Arne Welzel
ebf1a199c2 Merge branch 'topic/awelzel/analyzer-requested-analyzers'
* topic/awelzel/analyzer-requested-analyzers:
  scripts/analyzer: Introduce Analyzer::requested_analyzers
2023-01-10 10:11:37 +01:00
Arne Welzel
6d19c49efe intel/seen/file-names: Use file_over_new_connection()
The seen/file-names script relies on f$info$filename to be populated.
For HTTP and other network protocols, however, this field is only
populated during file_over_new_connection() that's running after
file_new().

Use the file_new() event only for files without connections and
file_over_new_connection() implies that f$conns is populated, anyway.

Special case SMB to avoid finding files twice, because there's a
custom implementation in seen/smb-filenames.zeek.

Fixes #2647
2023-01-10 10:10:28 +01:00
Arne Welzel
56833fcfd9 btest/net-control: Use different expiration times for rules
There's some non-determinism here: Force the expiration of the
shunt_flow rules first.
2023-01-09 18:11:55 +01:00
Arne Welzel
17d0ade26a analyzer: Add analyzer.log for logging violations/confirmations
By default this only logs all the violations, regardless of the
confirmation state (for which there's still dpd.log). It includes
packet, protocol and file analyzers.

This uses options, change handlers and event groups for toggling
the functionality at runtime.

Closes #2031
2023-01-09 18:11:49 +01:00
Arne Welzel
51376191f7 testing/btest: Add ZAM basic test
While there's a btest environment for ZAM, it's currently not run by
default. Add a single zam/basic.test so that we catch memory leaks or
dead-on-arrival cases with the current CI setup.
2023-01-09 12:30:26 +01:00
Arne Welzel
21cc5f9132 EventRegistry/Func: Disable events when all bodies are disabled
This is just a small optimization on top of what is there.

Add state to Func for tracking if any enabled bodies exist which
allows us to propagate it up to the EventHandler::bool() operator.
In turn, when all bodies of an event's Func have been runtime disabled,
the event itself will not be invoked anymore.

Experiments have shown that this allows runtime toggling of new_event()
without performance impact when disabled. This could enable use-cases
where new_packet() handlers are enabled for a split second once in a
while to either dump or sample raw packet data at runtime.
2023-01-05 12:03:58 +01:00
Arne Welzel
4e75d54d49 scripts/analyzer: Introduce Analyzer::requested_analyzers
In certain deployment scenarios, all analyzers are disabled by default.
However, conditionally/optionally loaded scripts may rely on analyzers
functioning and declare a request for them.

Add a global set set to the Analyzer module where external scripts can record
their requirement/request for a certain analyzer. Analyzers found in this
set are enabled at zeek_init() time.
2022-12-13 14:28:16 +01:00
Arne Welzel
061c066a51 Merge remote-tracking branch 'origin/topic/awelzel/fix-dump-events-test'
* origin/topic/awelzel/fix-dump-events-test:
  Func: Use std::stable_sort() for sorting bodies by priority
  btest/dump-events: Do not skip everywhere and update baselines
2022-12-13 11:51:12 +01:00
Arne Welzel
f1bcb5dad9 Merge remote-tracking branch 'origin/topic/awelzel/topic/awelzel/disable-stream-event-groups-take-two'
* origin/topic/awelzel/topic/awelzel/disable-stream-event-groups-take-two:
  testing/external: Bump cluster testing commit
  logging: Add event_groups to Stream
  zeek.bif: Add has_event_group() / has_module_events()
2022-12-13 11:38:25 +01:00
Christian Kreibich
2a9c0f8d1d Bump cluster testsuite to pull in get-id-value robustness fixes 2022-12-12 19:51:26 -08:00
Arne Welzel
93f3c2b612 testing/external: Bump cluster testing commit 2022-12-09 16:59:36 +01:00
Arne Welzel
a0aa00fa81 logging: Add event_groups to Stream
This commit adds an optional event_groups field to the Logging::Stream record
to associated event groups with logging streams.

This can be used to disable all event groups of a logging stream when it is
disabled. It does require making an explicit connection between the
logging stream and the involved groups, however.
2022-12-09 16:59:36 +01:00
Arne Welzel
ba4b8faea2 zeek.bif: Add has_event_group() / has_module_events()
Introduce helpers to determine if a given attribute or module event
group exists given a string.
2022-12-09 16:59:07 +01:00
Arne Welzel
33244ae75f Merge remote-tracking branch 'origin/topic/vern/script-opt-maint.Dec22'
* origin/topic/vern/script-opt-maint.Dec22:
  maintenance updates for -O C++
  maintenance updates for -O ZAM
  update test suite to avoid GH-2385 problems, including incorrect typing
2022-12-09 16:08:26 +01:00
Arne Welzel
63aaf91bf7 btest/dump-events: Do not skip everywhere and update baselines 2022-12-09 15:34:54 +01:00
Arne Welzel
a349679a4c Merge remote-tracking branch 'origin/topic/awelzel/2629-notice-file-info'
* origin/topic/awelzel/2629-notice-file-info:
  analyzer/files: handle non-analyzer names in describe_file()
  frameworks/notice: Handle fa_file with no or more than a single connection better
2022-12-06 12:23:47 +01:00
Arne Welzel
85ce48eb1e analyzer/files: handle non-analyzer names in describe_file()
When a fa_file object is created through the use of Input::add_analysis(),
the fa_file's source is likely not valid representation of an analyzer's
tag and a Files::describe() should not error and instead return an empty
description.

Add a new Analyzer::is_tag() helper that can be used to pre-check `f$source`.
2022-12-06 11:17:30 +01:00
Arne Welzel
1e06c8bfda frameworks/notice: Handle fa_file with no or more than a single connection better
* When a file is transferred over multiple connection, have
  create_file_info() just pick the first one instead of none.

* Do not unconditionally assume cid and cuid as set on a
  Notice::FileInfo object.
2022-12-06 11:17:30 +01:00
Arne Welzel
d9b7da334d Merge branch 'topic/fox-ds/ssh-key-init-events' of github.com:fox-ds/zeek
* 'topic/fox-ds/ssh-key-init-events' of github.com:fox-ds/zeek:
  Added several events for detailed info on the SSH2 key init directions

* Straightened out the zeek:see lines in events.bif to be the same across all events.
2022-12-06 10:04:53 +01:00
Joost Jansen
bcdbca4bb9 Added several events for detailed info on the SSH2 key init directions 2022-12-05 12:35:05 +01:00
Arne Welzel
56b23fc0b4 Merge branch 'topic/nadavk/krb_pa_ts' of github.com:nadavkluger/zeek
* 'topic/nadavk/krb_pa_ts' of github.com:nadavkluger/zeek:
  Expose PA_ENC_TIMESTAMP to script land
2022-12-05 10:33:53 +01:00
Christian Kreibich
dbd5f4e1b7 Merge remote-tracking branch 'origin/topic/awelzel/2628-is-used-multiple'
* origin/topic/awelzel/2628-is-used-multiple:
  ID: Add AddAttr() helper
  Attr: Duplicated &is_used is allowed
2022-12-04 18:37:11 -08:00
Vern Paxson
52775bea89 maintenance updates for -O C++ 2022-12-04 17:59:14 -08:00
Vern Paxson
ab7cccf9b6 maintenance updates for -O ZAM 2022-12-04 17:58:33 -08:00
Vern Paxson
66c5bdbeac update test suite to avoid GH-2385 problems, including incorrect typing 2022-12-04 17:56:30 -08:00
Arne Welzel
ef920ef3f5 Attr: Duplicated &is_used is allowed
When using the same function for eval conditions in signatures, we
previously attempted to add &is_used multiple times to the function
triggering an ambiguous attribute error.

Turns out there's already a list of attributes that are accepted
to be used multiple times, so just add ATTR_IS_USED there.

Fixes #2628
2022-12-02 17:15:05 +01:00
nadavkluger
433b535e10 Expose PA_ENC_TIMESTAMP to script land 2022-12-02 15:43:19 +02:00
Arne Welzel
203a309612 parse.y: Allow trailing commas for table, set, vector and record construction
Python, Ruby, Javascript, Go, ..., allow use of trailing commas and is even
recommended in some style-guides as it keeps diffs smaller. The black formatter
for Python even goes as far to take a trailing comma as an indication to
format a list one-item on a line.

It has been a bit unusual to not be able to put trailing commas in Zeek
scripts, so this change allows for it.

It explicitly prevents trailing commas in list expressions on the left
hand side. Concretely, this disallows trailing commas in the key list
expression during table initializations.

It probably allows for commas in more places that I haven't fully grasped.
Maybe we should tighten those down again if we find them surprising.
2022-12-01 12:05:29 +01:00
Johanna Amann
d38e227a04 Merge remote-tracking branch 'origin/topic/awelzel/2583-mqtt-cluster-testing-follow-up'
* origin/topic/awelzel/2583-mqtt-cluster-testing-follow-up:
  testing/external: Bump cluster testsuite
2022-11-30 15:41:50 +00:00
Arne Welzel
6a98386820 testing/external: Bump cluster testsuite
...also add/propose aliases for sync-commits / sync-repos, because I could not
remember for the past 5 times or so in which direction they would sync and
would find myself reading the README, Makefile, or comments in the scripts.
2022-11-30 15:10:14 +01:00
Johanna Amann
f4527ee4db Merge remote-tracking branch 'origin/topic/awelzel/2514-expire-all-timers-special-case'
* origin/topic/awelzel/2514-expire-all-timers-special-case:
  TimerMgr: Add back max_timer_expires=0 special case
  Add btest for expiration of all pending timers.
2022-11-30 13:45:09 +00:00