Commit graph

18601 commits

Author SHA1 Message Date
Arne Welzel
dc487f04e4 NEWS: Entry for delayed log writes 2023-11-29 12:36:27 +01:00
Arne Welzel
bed4565682 Bump doc submodule to branch 2023-11-29 11:53:35 +01:00
Arne Welzel
e3796894c6 logging: Do not keep delay state persistent
If Log::remove_stream() and Log::create_stream() is called for a stream,
do not restore the previously used max delay or max queue size.
2023-11-29 11:53:11 +01:00
Arne Welzel
fd096b1ce6 logging: delay documentation polishing
Based on PR feedback.
2023-11-29 11:53:11 +01:00
Arne Welzel
e2ce929fa4 logging: Better error messages for invalid Log::delay() calls
Add a test for Log::delay() usage within filter policy hooks, too.
2023-11-29 11:53:11 +01:00
Arne Welzel
5e046eee58 logging/Manager: Implement DelayTokenType as an actual opaque
With a bit of tweaking in the JavaScript plugin to support opaque types, this
will allow the delay functionality to work there, too.

Making the LogDelayToken an actual opaque seems reasonable, too. It's not
supposed to be user inspected.
2023-11-29 11:53:11 +01:00
Arne Welzel
2dbb467ba2 logging: Implement get_delay_queue_size()
Primarily for introspection given that re-delaying may exceed
queue sizes.
2023-11-29 11:53:11 +01:00
Arne Welzel
f0e67022fd logging: Introduce Log::delay() and Log::delay_finish()
This is a verbose, opinionated and fairly restrictive version of the log delay idea.
Main drivers are explicitly, foot-gun-avoidance and implementation simplicity.

Calling the new Log::delay() function is only allowed within the execution
of a Log::log_stream_policy() hook for the currently active log write.

Conceptually, the delay is placed between the execution of the global stream
policy hook and the individual filter policy hooks. A post delay callback
can be registered with every Log::delay() invocation. Post delay callbacks
can (1) modify a log record as they see fit, (2) veto the forwarding of the
log record to the log filters and (3) extend the delay duration by calling
Log::delay() again. The last point allows to delay a record by an indefinite
amount of time, rather than a fixed maximum amount. This should be rare and
is therefore explicit.

Log::delay() increases an internal reference count and returns an opaque
token value to be passed to Log::delay_finish() to release a delay reference.
Once all references are released, the record is forwarded to all filters
attached to a stream when the delay completes.

This functionality separates Log::log_stream_policy() and individual filter
policy hooks. One consequence is that a common use-case of filter policy hooks,
removing unproductive log records, may run after a record was delayed. Users
can lift their filtering logic to the stream level (or replicate the condition
before the delay decision). The main motivation here is that deciding on a
stream-level delay in per-filter hooks is too late. Attaching multiple filters
to a stream can additionally result in hard to understand behavior.

On the flip side, filter policy hooks are guaranteed to run after the delay
and can be used for further mangling or filtering of a delayed record.
2023-11-29 11:53:11 +01:00
Arne Welzel
dc552e647f logging/Manager: zeek::detail'ify
Introducing zeek::logging::detail requires detail:: references to be
qualified as preparation.
2023-11-29 11:53:11 +01:00
Arne Welzel
3afd6242c7 logging/Manager: Split Write()
If we delay in the stream policy hook, we'll need to resume writing
to the attached filters later on. Prepare for that by splitting out
the filter processing.
2023-11-29 11:53:11 +01:00
Arne Welzel
2d0fa13e18 Timer: Add LOG_DELAY_EXPIRE timer type 2023-11-29 11:53:11 +01:00
Arne Welzel
56b6219fb9 Ascii: Remove extra include
Should not be needed, not sure what I was thinking.
2023-11-29 11:53:11 +01:00
Arne Welzel
847c8c822d Update zeekjs submodule
Contains the following fixes:

    2da4abe Types: Add support for opaque types
    1f1093f Types: Cast internal field to v8::Value
    67e225c Plugin: Avoid creating Exprs at runtime
2023-11-29 11:52:44 +01:00
zeek-bot
e15d68a15c Update doc submodule [nomail] [skip ci] 2023-11-29 00:21:56 +00:00
Tim Wojtulewicz
6bf3a2515a Merge remote-tracking branch 'origin/topic/timw/copy-instead-of-move'
* origin/topic/timw/copy-instead-of-move:
  Add some uses of std::move in constructors and simple functions for pass-by-value arguments
  Avoid creating a few temporary values to avoid copy operations
  Change function return types to more concise types where possible
2023-11-28 13:41:03 -07:00
Tim Wojtulewicz
ef5b169acd Add some uses of std::move in constructors and simple functions for pass-by-value arguments 2023-11-28 13:40:28 -07:00
Tim Wojtulewicz
1e33467844 Avoid creating a few temporary values to avoid copy operations 2023-11-28 13:40:28 -07:00
Tim Wojtulewicz
3295c8f1c1 Change function return types to more concise types where possible
This helps avoid needing to call std::move on return values when we know the
type of value is fixed.
2023-11-28 13:40:28 -07:00
Johanna Amann
424d1c00dd Merge remote-tracking branch 'origin/topic/johanna/fix-parsing-of-some-server-keyexchange-messages'
* origin/topic/johanna/fix-parsing-of-some-server-keyexchange-messages:
  TLS: Update cipher consts and keyexchange parsing
2023-11-28 15:12:28 +00:00
Arne Welzel
aa5d7f5a73 OpaqueVal: Register TelemetryVals, too
Even if they are not serializable, OpaqueMgr::TypeID() is called
during BuildJSON() for them and that previously just aborted.

Closes #3473
2023-11-28 09:21:31 +01:00
zeek-bot
2284ad4b85 Update doc submodule [nomail] [skip ci] 2023-11-28 00:11:35 +00:00
Arne Welzel
4f6cd751d7 Merge remote-tracking branch 'origin/topic/awelzel/ocsp-revoked-reason-unknown'
* origin/topic/awelzel/ocsp-revoked-reason-unknown:
  OCSP: Open-code unknown revoke reason strings
2023-11-27 21:36:08 +01:00
Arne Welzel
02d00a1984 OCSP: Open-code unknown revoke reason strings
OpenSSL 3.2.0 knows about more reasons. Add some backwards compatibility.

Reference: 1c8a7f5091
2023-11-27 20:53:00 +01:00
Johanna Amann
fdb8e9a7ca Spicy TLS: parse OCSP replies in TLS extension
Add support for parsing stapled OCSP responses sent by the server.
2023-11-27 17:03:19 +00:00
Johanna Amann
7c0f325d1b TLS: Update cipher consts and keyexchange parsing
Update cipher consts.

Furthermore some past updates have been applied to scriptland, but it
was not considered that some of these also have to be applied to binpac
code, to be able to correcly parse the ServerKeyExchange message.

(As a side-note - this was discovered due to a test discrepancy with the
Spicy parser)
2023-11-27 16:22:24 +00:00
Johanna Amann
4ed4b1d0a9 Spicy TLS: generate same file IDs as binpac analyzer
This reduces the amount of failing tests to... still 39. A lot of them
are due to QUIC nowadays.
2023-11-27 15:14:11 +00:00
Johanna Amann
f31e39efe2 Merge remote-tracking branch 'origin/master' into topic/johanna/spicy-tls
* origin/master: (73 commits)
  Spicy: allow providing file id in zeek::file_begin
  Spicy: allow providing file id in zeek::file_begin
  Update doc submodule [nomail] [skip ci]
  Spicy: allow providing file id in zeek::file_begin
  Spicy: allow providing file id in zeek::file_begin
  Bump cmake submodule for INCLUDE_DIRS fix
  Update doc submodule [nomail] [skip ci]
  Integrate review feedback
  Add jq to final.Dockerfile
  TableVal: Replace raw subnets/pattern_matcher with unique_ptr
  TablePatternMatcher: Drop Insert()/Remove(), use Clear()
  TableType: Simplify and inline Is...Index tests
  NEWS: Add small table[pattern] section
  Expr/Val: Add support for in set[pattern]
  zeek.bif: Implement table_pattern_matcher_stats() bif for introspection
  DFA: Extract inner Stats struct from DFA_State_Cache
  Expr: Implement string in table[pattern] of X
  RE: Remove RE_DisjunctiveMatcher and re-use MatchAll()
  TablePatternMatcher: Use const StringValPtr& instead of const StringVal*
  Val: Move TablePatternMatcher into detail namespace
  ...
2023-11-27 14:55:57 +00:00
Johanna Amann
5baa2841e8 Merge remote-tracking branch 'origin/topic/johanna/spicy-allow-providing-file-ids'
* origin/topic/johanna/spicy-allow-providing-file-ids:
  Spicy: allow providing file id in zeek::file_begin
2023-11-23 17:20:30 +00:00
Johanna Amann
9a4de4e9fc Spicy: allow providing file id in zeek::file_begin
Minor update of testcase
2023-11-23 17:17:48 +00:00
Johanna Amann
883190207a Spicy: allow providing file id in zeek::file_begin
Address more review feedback; skip hashing in cases where a file id is
already provided.
2023-11-23 15:54:19 +00:00
zeek-bot
cc646f625f Update doc submodule [nomail] [skip ci] 2023-11-23 00:12:41 +00:00
Johanna Amann
45c558af1e Spicy: allow providing file id in zeek::file_begin
Address feedback of GH-3470:
 minor changes of C++ code, unify test cases
2023-11-22 16:31:40 +00:00
Johanna Amann
ae0b328826 Spicy: allow providing file id in zeek::file_begin
Allow spicy parsers to generate their own file IDs and provide them to
Zeek. This duplicates functionality that is currently possible (and
used) by some binpac-based analyzers. One example for an analyzer
creating its own file IDs is the SSL analyzer.
2023-11-22 14:51:53 +00:00
Arne Welzel
a092fe6a8a Bump cmake submodule for INCLUDE_DIRS fix 2023-11-22 11:29:00 +01:00
Arne Welzel
e0cf206732 Merge remote-tracking branch 'origin/topic/neverlord/avoid-openssl-header-deps'
* origin/topic/neverlord/avoid-openssl-header-deps:
  Integrate review feedback
  Avoid OpenSSL header dependencies

Added NEWS during merge and removed never set OPENSSL_INCLUDE_DIR reference
in main CMakeLists.txt.
2023-11-22 10:35:27 +01:00
zeek-bot
6d6a95e761 Update doc submodule [nomail] [skip ci] 2023-11-22 00:22:12 +00:00
Dominik Charousset
d0d543ec3d Integrate review feedback 2023-11-21 17:56:18 +01:00
Arne Welzel
5ef5733fcc Merge remote-tracking branch 'matti/topic/matti/docker-jq'
* matti/topic/matti/docker-jq:
  Add jq to final.Dockerfile
2023-11-21 14:32:40 +01:00
Matti Bispham
5d7cc06e3a Add jq to final.Dockerfile 2023-11-21 22:23:37 +09:00
Arne Welzel
f95ec84d77 Merge remote-tracking branch 'origin/topic/awelzel/pattern-tables-reuse-compile-set'
* origin/topic/awelzel/pattern-tables-reuse-compile-set:
  TableVal: Replace raw subnets/pattern_matcher with unique_ptr
  TablePatternMatcher: Drop Insert()/Remove(), use Clear()
  TableType: Simplify and inline Is...Index tests
  NEWS: Add small table[pattern] section
  Expr/Val: Add support for in set[pattern]
  zeek.bif: Implement table_pattern_matcher_stats() bif for introspection
  DFA: Extract inner Stats struct from DFA_State_Cache
  Expr: Implement string in table[pattern] of X
  RE: Remove RE_DisjunctiveMatcher and re-use MatchAll()
  TablePatternMatcher: Use const StringValPtr& instead of const StringVal*
  Val: Move TablePatternMatcher into detail namespace
  TablePatternMatcher: Use unique_ptr
  IndexType: Add IsPatternIndex(), like IsSubNetIndex()
  btest: Add test for pattern tables and when
  Reuse CompileSet() instead of || string formatting
  script optimization support for using strings to index table[pattern] values
  BTests for indexing "table[pattern] of T" with strings
  support for indexing "table[pattern] of T" with strings to get multi-matches
2023-11-21 12:00:51 +01:00
Arne Welzel
cf9afd7b77 TableVal: Replace raw subnets/pattern_matcher with unique_ptr 2023-11-21 11:16:17 +01:00
Arne Welzel
36c43d2aa3 TablePatternMatcher: Drop Insert()/Remove(), use Clear()
Also move Clear() when assigning into more generic Assign() function.
2023-11-21 11:16:16 +01:00
Arne Welzel
e68194f2df TableType: Simplify and inline Is...Index tests 2023-11-21 11:15:58 +01:00
Arne Welzel
96a0312ad2 NEWS: Add small table[pattern] section 2023-11-21 10:34:17 +01:00
Arne Welzel
c113b9b297 Expr/Val: Add support for in set[pattern] 2023-11-21 10:34:17 +01:00
Arne Welzel
e39f280e3d zeek.bif: Implement table_pattern_matcher_stats() bif for introspection
Provide a script accessible way to introspect the DFA stats that can be
leveraged to gather runtime statistics of the underlying DFA. This
re-uses the existing MatcherStats used by ``get_matcher_stats()``.
2023-11-21 10:34:17 +01:00
Arne Welzel
3f240e0f0a DFA: Extract inner Stats struct from DFA_State_Cache
This makes it possible to forward declare the class in Val.h which
otherwise seems difficult.
2023-11-21 10:34:17 +01:00
Arne Welzel
c72d4a4427 Expr: Implement string in table[pattern] of X
Not sure how useful this is (and the implementation isn't optimized in
any way), but seems reasonable for consistency.

Vern suggested that set[pattern] can already be achieved via
set_to_regex(), so left out any set[pattern] variants.
2023-11-21 10:34:17 +01:00
Arne Welzel
9ae99cdc44 RE: Remove RE_DisjunctiveMatcher and re-use MatchAll()
Seems we can just open code the CompileSet() usage in the TablePatternMatcher
helper without indirecting through another class. Further, add the collection
of indices into MatchAll() rather than duplicating its code in
MatchDisjunction(). Doesn't seem like MatchAll() is used widely.
2023-11-21 10:34:16 +01:00
Arne Welzel
501b582bc7 TablePatternMatcher: Use const StringValPtr& instead of const StringVal* 2023-11-21 10:34:16 +01:00