Commit graph

3214 commits

Author SHA1 Message Date
Arne Welzel
480d52ca1f from_json: Support function to normalize key names
When a JSON document contains key names containing colons or other
special characters that are not valid in Zeek identifiers, from_json()
cannot be used to parse such input.

This change allows a customizable normalization function.

Closes #3142.
2023-06-29 15:57:49 +02:00
progmboy
74c553c72e fix http AUTHORIZATION base64 decode failed 2023-06-27 19:25:32 +08:00
Arne Welzel
0b317aced3 telemetry: Disable metrics centralization by default
Move the telemetry/cluster.zeek file over into policy/frameworks/telemetry/prometheus.zeek.

Mention it in local.zeek.

Relates to zeek/broker#366.
2023-06-21 20:13:55 +02:00
Tim Wojtulewicz
1be1b1e6de Update dce-rpc constants 2023-06-15 15:08:56 -07:00
Tim Wojtulewicz
0d25583049 Remove Supervisor::NodeConfig (6.1 deprecation) 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
531276cfe0 Remove LogAscii::logdir (6.1 deprecation) 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
9a79b98a1e Remove analyzer_confirmation/analyzer_violation events (6.1 deprecation) 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
a55e5e3724 Remove full scripts marked as 6.1 deprecations 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
7a867d52e2 Remove script functions marked as unused (6.1 deprecations) 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
4229af6820 Remove deprecations tagged for v6.1 2023-06-14 10:07:22 -07:00
Arne Welzel
0fe32715c0 Merge remote-tracking branch 'origin/topic/awelzel/pre-commit-typos'
* origin/topic/awelzel/pre-commit-typos:
  all: Fix typos identified by typos pre-commit hook
  NEWS typo fixes
  Start with a typos pre-commit file
2023-06-14 13:06:47 +02:00
Arne Welzel
2f1ea789d1 Merge remote-tracking branch 'origin/topic/awelzel/2285-assert-statement'
* origin/topic/awelzel/2285-assert-statement:
  NEWS: Small section about assert statement
  Stmt: Rework assertion hooks break semantics
  Stmt: Introduce assert statement and related hooks
  ZeekArgs: Helper for empty arguments
  Reporter: Allow AssertStmt to throw InterpreterException
  Lift backtrace() code into Func.{h,cc}
2023-06-14 12:51:53 +02:00
Arne Welzel
7a043e5e8f all: Fix typos identified by typos pre-commit hook 2023-06-13 17:57:32 +02:00
Arne Welzel
f53aefdd5b 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
2023-06-13 17:33:56 +02:00
Arne Welzel
0b0f6e509f Stmt: Rework assertion hooks break semantics
Using break in either of the hooks allows to suppress the default reporter
error message rather than suppressing solely based on the existence of an
assertion_failure() handler.
2023-06-13 16:18:01 +02:00
Arne Welzel
6d1991fb6a cluster/logger: Fix leftover-log-rotation in multi-logger setups
Populating log_metadata during zeek_init() is too late for the
leftover-log-rotation functionality, so do it at script parse time.

Also, prepend archiver_ to the log_metadata table and encoding function
due to being in the global namespace and to align with the
archiver_rotation_format_func. This hasn't been in a released
version yet, so fine to rename still.

Closes #3112
2023-06-13 10:47:20 +02:00
Arne Welzel
27432c457c cluster/logger: Fix global var reference 2023-06-13 10:47:20 +02:00
Tim Wojtulewicz
98e44ee14f 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() )
2023-06-12 11:04:53 -07:00
Arne Welzel
25ea678626 Stmt: Introduce assert statement and related hooks
including two hooks called assertion_failure() and assertion_result() for
customization and tracking of assertion results.
2023-06-12 18:16:02 +02:00
Arne Welzel
820c011ffc test-all-policy: Do not load nodes-experimental/manager.zeek
Turns out loading this script in non-cluster mode uses Cluster::log()
and creates cluster.log in the external baselines saying "cluster
started". Do not load it into test-all-policy.zeek and instead rely
on the new test-all-policy-cluster.test to load it transitively
when running as manager for basic checking.
2023-06-06 15:22:27 +02:00
Arne Welzel
eef7acc1e9 cluster/main: Remove extra @if ( Cluster::is_enabled() )
These have been discussed in the context of "@if &analyze" [1] and
am much in favor for not disabling/removing ~100 lines (more than
fits on a single terminal) out from the middle of a file. There's no
performance impact for having these handlers enabled unconditionally.
Also, any future work on "@if &analyze" will look at them again which
we could also skip.

This also reverts back to the behavior where the Cluster::LOG stream
is created even in non cluster setups like in previous Zeek versions.
As long as no one writes to it there's essentially no difference. If
someone does write to Cluster::LOG, I'd argue not black holing these
messages is better. Schema generators using Log::active_streams will
continue to discover Cluster::LOG even if they run in non-cluster
mode.

https://github.com/zeek/zeek/pull/3062#discussion_r1200498905
2023-06-06 15:20:10 +02:00
Arne Welzel
8f7b4902c9 socks/dpd: Add newer auth methods
The IANA has allocated a few more authentication methods, minimally
extend the signature to catch those.
2023-06-05 13:55:00 +02:00
Arne Welzel
d6ca1ec4f6 socks/dpd: Fix socks5_server side signature
The server replies with \x05 and identifier for the chosen method.
Not quite sure what the previous signature meant capture.

See also: https://datatracker.ietf.org/doc/html/rfc1928#section-3

Closes #3099.
2023-06-05 13:54:47 +02:00
Tim Wojtulewicz
1cfe0e3ee7 Merge remote-tracking branch 'origin/topic/bbannier/issue-3094'
* origin/topic/bbannier/issue-3094:
  Simplify code generated for Spicy analyzer port ranges.
2023-05-31 09:50:46 +02:00
Arne Welzel
737ac43942 catch-and-release: Mark cr_check_rule as is_used 2023-05-31 00:37:38 -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
Benjamin Bannier
dc735371be Simplify code generated for Spicy analyzer port ranges.
We previously would reprent port ranges from EVT files element-wise.
This can potentially generate a lot of code (all on a single line
though) which some versions of GCC seem to have trouble with, and which
also causes JIT overhead.

With this patch we switch to directly representing ranges. Single ports
are represented as ranges `[start, start]`.

Closes #3094.
2023-05-29 12:20:44 +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
Vern Paxson
e441ba394a updates reflecting review comments 2023-05-25 18:00:13 -07:00
Arne Welzel
f396c2b16e stats: Add zeek-net-packet-lag-seconds metric
While writing documentation about troubleshooting and looking a bit
at the older stats.log, realized we don't have the packet lag metric
exposed as metric/telemetry. Add it.

This is a Zeek instance lagging behind in network time ~6second because
it's very overloaded:

    zeek_net_packet_lag_seconds{endpoint=""} 6.169406 1684848998092
2023-05-24 09:12:01 +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
Arne Welzel
d4c99e7c3f files: Warn once for missing get_file_handle()
Repeating the message for every new call to get_file_handle() is not
very useful. It's pretty much an analyzer configuration issue so logging
it once should be enough.
2023-05-19 09:37:51 -07:00
Arne Welzel
64f84aba34 ftp: No unbounded directory command re-use
OSS-Fuzz generated traffic containing a CWD command with a single very large
path argument (427kb) starting with ".___/` \x00\x00...", This is followed
by a large number of ftp replies with code 250. The directory logic in
ftp_reply() would match every incoming reply with the one pending CWD command,
triggering path buildup ending with something 120MB in size.

Protect from re-using a directory command by setting a flag in the
CmdArg record when it was consumed for the path traversal logic.

This doesn't prevent unbounded path build-up generally, but does prevent the
amplification of a single large command with very many small ftp_replies.
Re-using a pending path command seems like a bug as well.
2023-05-19 09:37:12 -07:00
Arne Welzel
c2a07476cc Merge remote-tracking branch 'jgras/topic/jgras/cluster-active-node-count-fix'
* jgras/topic/jgras/cluster-active-node-count-fix:
  Fix get_active_node_count for node types not present.

Changed over to explicit existence check instead to avoid the set()
creation upon missed lookups.
2023-05-17 10:37:00 +02:00
Jan Grashoefer
e4f654c14c Fix get_active_node_count for node types not present. 2023-05-16 17:47:50 +02:00
Robin Sommer
ecf00295c2
Move spicy/misc scripts to policy and clarify purpose. 2023-05-16 10:21:21 +02:00
Robin Sommer
a62e153dd3
Do not load Spicy scripts if Spicy is not available. 2023-05-16 10:21:21 +02:00
Robin Sommer
0040111955
Integrate the Spicy plugin into Zeek proper.
This reflects the `spicy-plugin` code as of `d8c296b81cc2a11`.

In addition to moving the code into Zeek's source tree, this comes
with a couple small functional changes:

- `spicyz` no longer tries to infer if it's running from the build
  directory. Instead `ZEEK_SPICY_LIBRARY` can be set to a custom
  location. `zeek-set-path.sh` does that now.

- ZEEK_CONFIG can be set to change what `spicyz -z` print out. This is
  primarily for backwards compatibility.

Some further notes on specifics:

- We raise the minimum Spicy version to 1.8 (i.e., current `main`
  branch).

- Renamed the `compiler/` subdirectory to `spicyz` to avoid
  include-path conflicts with the Spicy headers.

- In `cmake/`, the corresponding PR brings a new/extended version of
  `FindZeek`, which Spicy analyzer packages need. We also now install
  some of the files that the Spicy plugin used to bring for testing,
  so that existing packages keep working.

- For now, this all remains backwards compatible with the current
  `zkg` analyzer templates so that they work with both external and
  integrated Spicy support. Later, once we don't need to support any
  external Spicy plugin versions anymore, we can clean up the
  templates as well.

- All the plugin's tests have moved into the standard test suite. They
  are skipped if configure with `--disable-spicy`.

This holds off on adapting the new code further to Zeek's coding
conventions, so that it remains easier to maintain it in parallel to
the (now legacy) external plugin. We'll make a pass over the
formatting for (presumable) Zeek 6.1.
2023-05-16 10:17:45 +02:00
Johanna Amann
3d257e52e2 Merge branch 'topic/johanna/dtls13'
* topic/johanna/dtls13:
  DTLS1.3 - address review feedback
  DTLS 1.3: Update test baseline
  DTLS 1.3: finish implementation, add connection_id extension
  Add basic DTLSv1.3 support
  SSL: Fix logging of Hello Retry Requests
2023-05-11 15:04:26 +01:00
Arne Welzel
e82a7455d7 policy/community-id: Do not use new_connection()
Issue #3028 tracks how a flipped connections reset a connection's value
including any state set during new_connection(). For the time being,
update community-id functionality back to the original connection_state_remove()
approach to avoid missing community_ids on flipped connections.
2023-05-10 17:48:33 +02:00
Johanna Amann
527c0dc09f Merge remote-tracking branch 'origin/master' into topic/johanna/dtls13
* origin/master: (35 commits)
  Update doc submodule [nomail] [skip ci]
  Updating submodule(s) [nomail]
  zeek.bif: Add log2() and ceil()
  Use the same rules as cmake submodule to reformat Zeek
  Update cmake submodule after reformat
  Fixup Val.h/Val.cc: Actually move ValFromJSON into zeek::detail
  Implement from_json bif
  Revert "Skip version.h by default for Zeek sources"
  BTest baseline updates for -O gen-C++
  updates to C++ maintenance scripts to better handle uncompilable BTests
  added ZEEK_REPORT_UNCOMPILABLE environment variable for "-O report-uncompilable"
  Skip version.h by default for Zeek sources
  core.network_time.broker: Test reliability improvement
  cluster/supervisor: Multi-logger awareness
  Bump zeek-archiver submodule
  ci: Add public-ecr-vacuum.sh
  Update doc submodule [nomail] [skip ci]
  generate-docs: Only update submodule pointer during scheduled builds
  BTest baseline updates for ZAM
  NTP: Detect out-of-order packets
  ...
2023-05-10 13:02:08 +01:00
Tim Wojtulewicz
84e3f414a7 Use the same rules as cmake submodule to reformat Zeek 2023-05-09 08:31:43 -07:00
Arne Welzel
9330a74fe1 Merge remote-tracking branch 'origin/topic/awelzel/zeek-archiver-multiple-loggers'
* origin/topic/awelzel/zeek-archiver-multiple-loggers:
  cluster/supervisor: Multi-logger awareness
  Bump zeek-archiver submodule
2023-05-09 15:20:53 +02:00
Arne Welzel
264284150b Merge remote-tracking branch 'amazing-pp/topic/fupeng/from_json_bif'
* amazing-pp/topic/fupeng/from_json_bif:
  Implement from_json bif

Minor updates during merge: Moved ValFromJSON into zeek::detail for the
time being, removed gotos, normalized some error messages to lower case,
minimal test extension and added a raw reader input framework test reading
"json lines" as a demo, adding notes about the implicit type
conversions.
2023-05-09 10:36:58 +02:00
Fupeng Zhao
584e68434d Implement from_json bif 2023-05-06 00:42:46 +00:00
Arne Welzel
c813872915 cluster/supervisor: Multi-logger awareness
When multiple loggers are configured in a Supervisor controlled cluster
configuration, encode extra information into the rotated filename to
identify which logger produced the log.

This is similar to the approach taken for ZeekControl, re-using the
log_suffix terminology, but as there's only a single zeek-archiver
process and no postprocessors and no other side-channel for additional
information, we encode extra metadata into the filename. zeek-archiver
is extended to recognize the special metadata part of the filename.

This also solves the issue that multiple loggers in a supervisor setup
overwrite each others log files within a single log-queue directory.
2023-05-05 12:27:25 +02:00
Arne Welzel
12252743b1 Merge remote-tracking branch 'origin/topic/awelzel/smb2-state-handling'
* origin/topic/awelzel/smb2-state-handling:
  NEWS: Add entry about SMB::max_pending_messages and state discarding
  scripts/smb2-main: Reset script-level state upon smb2_discarded_messages_state()
  smb2: Limit per-connection read/ioctl/tree state
2023-05-04 09:40:19 +02:00
Tim Wojtulewicz
8eed46dfa1 Merge remote-tracking branch 'origin/topic/johanna/update-ssl-databases'
* origin/topic/johanna/update-ssl-databases:
  Update Mozilla CA and Google CT lists
2023-05-03 11:13:23 -07:00
Johanna Amann
d6c4c510ea Add basic DTLSv1.3 support
DTLSv1.3 changes the DTLS record format, introducing a completely new
header - which is a first for DTLS.

We don't currently completely parse this header, as this requires a bit
more statekeeping. This will be added in a future revision. This also
also has little practical implications.
2023-05-03 16:17:31 +01:00
Johanna Amann
9742d9a76e Merge branch 'topic/johanna/no-error-message-durning-tls-or-dtls-protocol-violations'
* topic/johanna/no-error-message-durning-tls-or-dtls-protocol-violations:
  SSL: failing analyzer handling - address review feedback
  SSL: do not try to disable failed analyzer

Also folds in minor feedback from GH-3012
2023-05-03 14:20:44 +01:00