Commit graph

16933 commits

Author SHA1 Message Date
Arne Welzel
b9ca50c6bb Merge remote-tracking branch 'origin/topic/awelzel/add-postgresql-parser'
* origin/topic/awelzel/add-postgresql-parser:
  postgresql: Simplify SSL buffering and forwarding
  postgresql: Initial parser implementation
2024-09-06 17:47:52 +02:00
Arne Welzel
d0da13413b postgresql: Simplify SSL buffering and forwarding
The ssl_sink can only be connected form the backend side, so don't
overcomplicate it.
2024-09-06 16:11:19 +02:00
Arne Welzel
85ca59484b postgresql: Initial parser implementation
This adds a protocol parser for the PostgreSQL protocol and a new
postgresql.log similar to the existing mysql.log.

This should be considered preliminary and hopefully during 7.1 and 7.2
with feedback from the community, we can improve on the events and logs.
Even if most PostgreSQL communication is encrypted in the real-world, this
will minimally allow monitoring of the SSLRequest and hand off further
analysis to the SSL analyzer.

This originates from github.com/awelzel/spicy-postgresql, with lots of
polishing happening in the past two days.
2024-09-06 16:10:48 +02:00
Arne Welzel
2907d9feee Merge remote-tracking branch 'origin/topic/awelzel/add-spicy-format'
* origin/topic/awelzel/add-spicy-format:
  testing/external: Update private baselines
  analyzer/syslog: Reformat with spicy-format
  analyzer/finger: Reformat with spicy-format
  scripts/spicy: Reformat with spicy-format
  pre-commit: Add spicy-format
2024-09-05 19:19:49 +02:00
Arne Welzel
f35835c8f9 testing/external: Update private baselines 2024-09-05 19:11:05 +02:00
Arne Welzel
526c903c01 analyzer/syslog: Reformat with spicy-format 2024-09-05 19:11:05 +02:00
Arne Welzel
dae4b1fcd9 analyzer/finger: Reformat with spicy-format 2024-09-05 19:11:05 +02:00
Arne Welzel
cde5662779 scripts/spicy: Reformat with spicy-format 2024-09-05 19:11:05 +02:00
Arne Welzel
01ea74f8a8 pre-commit: Add spicy-format
This excludes the larger protocol analyzers. These should be formatted
during the 7.2 cycle, shortly before 8.0.
2024-09-05 19:11:05 +02:00
Tim Wojtulewicz
d4a646cd21 Merge remote-tracking branch 'origin/topic/timw/dns-opcode-check'
* origin/topic/timw/dns-opcode-check:
  Check for netbios to avoid reporting extra bad DNS opcodes
  Add weird for unhandled opcodes in DNS analyzer
2024-09-04 14:53:31 -07:00
Tim Wojtulewicz
6394f9893e Check for netbios to avoid reporting extra bad DNS opcodes 2024-09-04 13:07:00 -07:00
Tim Wojtulewicz
269ca3189c Add weird for unhandled opcodes in DNS analyzer 2024-09-04 13:01:24 -07:00
Tim Wojtulewicz
cd10bd3747 Merge remote-tracking branch 'origin/topic/bbannier/bump-spicy'
* origin/topic/bbannier/bump-spicy:
  Bump auxil/spicy to latest development snapshot
2024-09-03 09:04:03 -07:00
Benjamin Bannier
dffef94d4d Merge branch 'topic/bbannier/bump-clang-format' 2024-09-03 10:18:39 +02:00
Arne Welzel
cdae755a0c Bump zeek-aux for zeek/zeek-aux#57 2024-09-03 10:03:22 +02:00
Benjamin Bannier
629d273f44 Remove pre-commit exclusions for clang-format
We previously would ignore any files under `auxil/`. Since pre-commit
only formats files tracked in this repo, and `auxil/` today contains
only submodules this exclusion did not exclude anything; if however we
ever end up adding C++ files under `auxil/` we would like them to be
formatted consistently.
2024-09-02 16:49:07 +02:00
Benjamin Bannier
db42b2cfe5 Bump clang-format
This patch contains a bump of the configured clang-format version from
17.0.3 to 18.1.8 and automatically generated C++ source updates. The
main difference we are seeing from this is fixes for previously
incomplete reformats.
2024-09-02 16:46:59 +02:00
Benjamin Bannier
06d2568c58 Bump auxil/spicy to latest development snapshot 2024-09-02 16:36:27 +02:00
Arne Welzel
c27e18631c Merge branch 'fix-http-password-capture' of https://github.com/p-l-/zeek
* 'fix-http-password-capture' of https://github.com/p-l-/zeek:
  http: fix password capture when enabled
2024-08-30 18:56:48 +02:00
Arne Welzel
435770f99a Merge remote-tracking branch 'origin/topic/awelzel/no-broker-mgr-active'
* origin/topic/awelzel/no-broker-mgr-active:
  RunState: Drop broker_mgr->Active() usage
2024-08-30 15:39:06 +02:00
Arne Welzel
f6fdd16b81 Merge remote-tracking branch 'origin/topic/awelzel/less-threading-star-star'
* origin/topic/awelzel/less-threading-star-star:
  logging/WriterFrontend: No need for explicit CleanupWriteBuffer()
  logging: Switch index-assignment of raw pointers to emplace_back()
  broker/logging: Change threading::Value** usage std::vector instead
  threading/Value: Support move and copy constructors
2024-08-30 15:38:47 +02:00
Arne Welzel
a9e4a45310 RunState: Drop broker_mgr->Active() usage
...and deprecate it. The communication_enabled flag doesn't really
make a difference in how the IO loop works.
2024-08-30 15:36:56 +02:00
Arne Welzel
f0ab10a46c logging/WriterFrontend: No need for explicit CleanupWriteBuffer()
Any pending records will be cleaned in the destructor of WriterFrontend
and WriteBuffer, no need to do this explicitly.
2024-08-30 11:00:17 +02:00
Arne Welzel
a9290cc031 logging: Switch index-assignment of raw pointers to emplace_back() 2024-08-30 10:59:55 +02:00
Arne Welzel
245fd0c94f broker/logging: Change threading::Value** usage std::vector instead
This allows to leverage automatic memory management, less allocations
and using move semantics for expressing ownership.

This breaks the existing logging and broker API, but keeps the plugin
DoWrite() and HookLogWrite() methods functioning.

It further changes ValToLogVal to return a threading::Value rather than
a threading::Value*. The vector_val and set_val fields unfortunately
use the same pointer-to-array-of-pointers approach. this can'tbe changed
as it'd break backwards compatibility for plugin provided input readers
and log writers.
2024-08-30 10:58:57 +02:00
Arne Welzel
e79ce27c9f threading/Value: Support move and copy constructors 2024-08-30 10:58:23 +02:00
Pierre Lalet
88368ae856 http: fix password capture when enabled
The current implementation would only log, if the password contains a
colon, the part before the first colon (e.g., the password
`password:password` would be logged as `password`).

A test has been added to confirm the expected behaviour.
2024-08-28 21:44:39 +02:00
zeek-bot
79ebce6e3c Update doc submodule [nomail] [skip ci] 2024-08-28 00:11:20 +00:00
Johanna Amann
d89c0d1ef7 Merge remote-tracking branch 'origin/topic/johanna/fix-ssl2-client-hello-version-parsing'
* origin/topic/johanna/fix-ssl2-client-hello-version-parsing:
  Fix parsing of version field in SSLv2 client hello
2024-08-27 13:31:12 +01:00
zeek-bot
617faa1d33 Update doc submodule [nomail] [skip ci] 2024-08-24 00:20:43 +00:00
Arne Welzel
45b33bf5c1 Merge remote-tracking branch 'origin/topic/awelzel/no-child-analyzer-on-finished-connections'
* origin/topic/awelzel/no-child-analyzer-on-finished-connections:
  Analyzer: Do not add child analyzers when finished
2024-08-23 14:19:00 +02:00
Arne Welzel
be9f170561 Analyzer: Do not add child analyzers when finished
Depending on an analyzer's implementation, its Done() method may
attempt to access analyzer or connection state when executing.
When this happens in the destructor of the parent analyzer during
the process of destructing a connection, this state may have been
deleted, resulting in use-after-free crashes or worse memory
corruption.

The following cases have been observed in the wild for when this happens.

  * PIA matching during Done() for undelivered TCP data enables a Spicy
    based analyzer which in turn attempts to raise an analyzer violation
    during Done()->EndOfData().

  * Spicy analyzers attaching new analyzers during their Done() processing
    which in turn attempt to use TCP() (to call FindChild()) during Done()
    while the analyzer tree / connection is being destructed.

The second scenario was previously found to happen in the HTTP analyzer
and fixed with 6ef9423f3c.

Plug these scenarios by short-circuiting AddChildAnalyzer() if the analyzer
or connection have finished or are being finished.
2024-08-23 09:57:20 +02:00
Arne Welzel
4a4cbf2576 Merge remote-tracking branch 'origin/topic/awelzel/tcp-reassembler-undelivered-data-match-bool-bool-bool-confusion'
* origin/topic/awelzel/tcp-reassembler-undelivered-data-match-bool-bool-bool-confusion:
  TCP_Reassembler: Fix IsOrig() position in Match() call
2024-08-23 09:41:07 +02:00
Robin Sommer
a2079bcda6
Merge remote-tracking branch 'origin/topic/robin/gh-3881-spicy-ports'
* origin/topic/robin/gh-3881-spicy-ports:
  Spicy: Register well-known ports through an event handler.
  Revert "Remove deprecated port/ports fields for spicy analyzers"
2024-08-23 08:10:02 +02:00
Johanna Amann
a6edbf8bcd Fix parsing of version field in SSLv2 client hello
It turns out that, for probably a long time, we have reported an
incorrect version when parsing an SSLv2 client hello. We always reported
this as SSLv2, no matter which version the client hello actually
contained.

This bug probably went unnoticed for a long time, as SSLv2 is
essentially unused nowadays, and as this field does not show up in the
default logs.

This was found due to a baseline difference when writing the Spicy SSL
analyzer.
2024-08-22 13:14:24 +01:00
Arne Welzel
4576741fe4 TCP_Reassembler: Fix IsOrig() position in Match() call
Found during a debug session with @rsmmr. Undelivered TCP data
would only be matched for the responder and eol set to IsOrig().
2024-08-22 13:43:44 +02:00
Robin Sommer
0d3296590d
Spicy: Register well-known ports through an event handler.
This avoids the earlier problem of not tracking ports correctly in
scriptland, while still supporting `port` in EVT files and `%port` in
Spicy files.

As it turns out we are already following the same approach for file
analyzers' MIME types, so I'm applying the same pattern: it's one
event per port, without further customization points. That leaves the
patch pretty small after all while fixing the original issue.
2024-08-22 10:24:55 +02:00
zeek-bot
4b369bad2d Update doc submodule [nomail] [skip ci] 2024-08-21 00:14:27 +00:00
Johanna Amann
2f07ca9e7f Merge remote-tracking branch 'origin/topic/johanna/ssl-history-also-for-sslv2-not-only-for-things-that-use-the-more-modern-handshake'
* origin/topic/johanna/ssl-history-also-for-sslv2-not-only-for-things-that-use-the-more-modern-handshake:
  Make ssl_history work for SSLv2 handshakes/connections
2024-08-20 11:40:20 +01:00
Arne Welzel
5ac5f5f24f Merge remote-tracking branch 'origin/topic/awelzel/broker-deprecate-valp-list-interface'
* origin/topic/awelzel/broker-deprecate-valp-list-interface:
  broker: Deprecate MakeEvent(ValPList*)
  Span: Remove deduction guideline for Iter, Iter, include cleanup
2024-08-20 10:11:11 +02:00
Arne Welzel
8920637397 Merge remote-tracking branch 'origin/topic/awelzel/global-stmts-scope-fixup'
* origin/topic/awelzel/global-stmts-scope-fixup:
  ScriptOpt: Ensure global statements have non-null scope
2024-08-20 10:10:27 +02:00
Tim Wojtulewicz
b26c44ae72 Update gen-zam submodule [nomail] [skip ci] 2024-08-19 14:15:18 -07:00
Robin Sommer
547144d07e
Revert "Remove deprecated port/ports fields for spicy analyzers"
This reverts commit 15d404dd19.
2024-08-19 09:57:04 +02:00
zeek-bot
9ea316e9a4 Update doc submodule [nomail] [skip ci] 2024-08-17 00:23:21 +00:00
Tim Wojtulewicz
00c2e9afce Merge remote-tracking branch 'J-Gras/topic/jgras/remove-wrapper-analyzer'
* J-Gras/topic/jgras/remove-wrapper-analyzer:
  Remove unused wrapper packet analyzer
2024-08-16 09:06:51 -07:00
Arne Welzel
f21da04c3e Merge remote-tracking branch 'origin/topic/etyp/dns-tkey'
* origin/topic/etyp/dns-tkey:
  Add DNS TKEY event
2024-08-16 16:51:58 +02:00
Jan Grashoefer
64bc852fbe Remove unused wrapper packet analyzer
This is a leftover from the migration to the packet analysis framework.
The analyzer wrapped the original packet analysis code for comparison.
2024-08-16 16:49:12 +02:00
Evan Typanski
170276807b Add DNS TKEY event 2024-08-16 10:20:42 -04:00
Arne Welzel
9d1d4e28b3 ScriptOpt: Ensure global statements have non-null scope
The ProfileFunc() logic assumed that GetScope() returned a non-nullptr.
This holds except for the synthetic global statements function.

Fix the latter and add an assert, also add a name to the type so it's
easier to recognize in a debugger what's going on, otherwise the name
is "".

This was found by UBSAN due to it seeing the ->OrderedVars() call on a
nullptr. Elsewhere, num_params == 0 shielded from that access and so
didn't lead to crashes.
2024-08-16 13:59:24 +02:00
Arne Welzel
ec1088c3ef Merge remote-tracking branch 'origin/topic/vern/zam-regularization'
* origin/topic/vern/zam-regularization: (33 commits)
  simpler and more robust identification of function parameters for AST profiling
  fixes to limit AST traversal in the face of recursive types
  address some script optimization compiler warnings under Linux
  fix for -O C++ construction of variable names that use multiple module namespaces
  fix for script optimization of "opaque" values that are run-time constants
  fix for script optimization of nested switch statements
  script optimization fix for complex "in" expressions in conditionals
  updates to typos allow-list reflecting ZAM regularization changes
  BTest updates for ZAM regularization changes
  convert new ZAM operations to use typed operands
  complete migration of ZAM to use only public ZVal methods
  "-O validate-ZAM" option to validate generated ZAM instructions
  internal option to suppress control-flow optimization
  exposing some functionality for greater flexibility in structuring run-time execution
  rework ZAM compilation of type switches to leverage value switches
  add tracking of control flow information
  factoring of ZAM operation specifications into separate files
  updates to ZAM operations / gen-zam regularization, other than the operations themselves
  type-checking fix for vector-of-string operations
  ZVal constructor for booleans
  ...
2024-08-16 12:10:33 +02:00