Commit graph

6667 commits

Author SHA1 Message Date
Jon Siwek
4824da0325 Remove superflous std::move's from Inliner return values 2020-12-13 13:44:00 -08:00
Jon Siwek
09d12c3716 Remove SetupResult::parse_only field
For parity with other setup() behavior to simply call exit() directly.
2020-12-13 13:33:50 -08:00
Jon Siwek
2219a03344 Rename Frame::IncreaseOffset() to Frame::AdjustOffset()
For clarity, since it's used for both increasing and decreasing.
2020-12-13 13:27:37 -08:00
Jon Siwek
30df2c58c0 Merge branch 'master' into topic/vern/script-inlining 2020-12-13 10:42:26 -08:00
Jon Siwek
481d989495 Superficial changes to script-opt related code
* Rename overly generic ACCESSORS macro with ZEEK_ prefix
* A few places where whitespace was noticeably wrong/distracting
* Minor/obvious reference/move semantics improvements suggested by linter
* Remove unused detail::Scope::Remove(), no need for deprecation
2020-12-13 10:33:28 -08:00
Jon Siwek
8f98b068c8 GH-1328: Improve behavior of Dictionary iterator invalidation
Previously, an assertion was triggered in debug builds upon any attempt
to insert or remove a Dictionary entry while any iteration of that
Dictionary is underway and also even in cases where Dictionary membership
was not actually modified (and thus invalidates a loop).

Now, it emits run-time warnings regardless of build-type and only when
insert/remove operations truly change the Dictionary membership.  In the
context of a Zeek script causing an invalidation, the warning message
also now helps pinpoint the exact expression that causes it.
2020-12-11 18:52:31 -08:00
Jon Siwek
bb11ce47a0 Merge remote-tracking branch 'origin/topic/neverlord/caf-migration'
Merge adjustments:
- Fix the `--with-caf=` option from emitting messages about a variable
  having an unset value.
- Fix the `zeek-config --caf_root` option

* origin/topic/neverlord/caf-migration:
  Update submodule(s)
  Fix message ordering of Broker messages
  Fix UB in shutdown of Broker manager
  Preserve string output of Broker errors
  Migrate to CAF 0.18
2020-12-10 14:14:38 -08:00
Johanna Amann
533c4c7d29 Update submodule
[nomail]
2020-12-09 21:40:36 +00:00
Jon Siwek
2ae452d8aa Merge remote-tracking branch 'origin/topic/jsiwek/gh-1321-fix-connection-status-update-event'
* origin/topic/jsiwek/gh-1321-fix-connection-status-update-event:
  GH-1321: Prevent compounding of `connection_status_update` event timers
2020-12-09 10:59:14 -08:00
Jon Siwek
a35cd2a726 GH-1321: Prevent compounding of connection_status_update event timers
Particularly for ICMP connections, a new timer got added every time a
`connection` record was updated even if there was still a pending timer
for that connection.
2020-12-08 11:20:02 -08:00
Jon Siwek
a4986a17cb Update Debug.cc to use setsignal() wrapper
So as to prefer sigaction() over either sigset() or signal(), which are
less favorable due to underspecification issues and some treating them
as obsolete/deprecated.
2020-12-07 18:03:24 -08:00
Jon Siwek
07c4662dc4 Fix narrowing conversion compiler error in SMB error-response logic 2020-12-07 16:56:07 -08:00
Jon Siwek
0b8535b879 Merge remote-tracking branch 'origin/topic/vlad/gh-1286'
Merge adjustments:
- Rewrote the check for error response as a switch statement to
  fix compiler warning about signed/unsigned comparison and also
  to just simplify/clarify the logic.
- Changed the btest to use `zeek -b`.

* origin/topic/vlad/gh-1286:
  Add tests for new SMB3 multichannel support
  Fix SMB2 response status parsing. Fixes #1286
2020-12-07 16:08:04 -08:00
Jon Siwek
abb4f0be03 Fix EDNS ECS option parsing bugs
* The parsing of IPv6 addresses tried to fill a stack-buffer with as
  much data as supplied in the Option even if it was in excess of the
  desired prefix or maximum IPv6 address size.  This could result in an
  overflow of that stack-buffer.

* The parsing of IPv4 addresses would overwrite the storage used for
  that address as many times as there were bytes in the Option in excess
  of the desired prefix length or maximum IPv4 address size.  This could
  cause the resulting IPv4 address to be derived from the incorrect
  data.

* Upon encountering unexpected/excessive option-length or source-prefix
  parameters, the data pointer used for parsing was also not always
  advanced to the start of the next alleged option's data.  Assuming all
  other parsing code correctly guards against invalid input, there's no
  further harm from that other than the subsequent parsing being more
  likely to encounter unexpected values and emitting more Weirds.

Credit to OSS-Fuzz for discovery
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28336
(Link to details becomes public 30 days after patch release)
2020-12-07 13:35:17 -08:00
Dominik Charousset
25fef3da1b Fix message ordering of Broker messages
Using two separate Broker subscribers for status events and regular
messages introduces a race on the two objects. Even if Broker sends all
messages in a particular (deterministic) order, Zeek may still process
them in a different order as a result. Since several tests rely on a
strict ordering of Broker events, these tests could fail sporadically.

Using only a single subscriber for all Broker messages makes sure that
Zeek observes all messages in the same order as Broker emits them.
2020-12-07 21:40:46 +01:00
Dominik Charousset
9da68ddc3d Fix UB in shutdown of Broker manager 2020-12-07 20:37:08 +01:00
Dominik Charousset
38aba87e41 Preserve string output of Broker errors 2020-12-07 16:43:42 +01:00
Dominik Charousset
cf2b5f7e05 Migrate to CAF 0.18 2020-12-07 14:56:19 +01:00
Jon Siwek
1f352a1e4d Fix misassociation of Zeekygen-style comments within function scopes
All Zeekygen-style comments relate to entities at global scope, so those
found within functions are now ignored instead of misassociated.
2020-12-04 19:29:11 -08:00
Jon Siwek
ff7d9e3d72 Merge branch 'master' into topic/vern/script-inlining 2020-12-04 16:18:14 -08:00
Robin Sommer
e147692a43 Fix a couple of life-time issues when plugin loading fails.
Reported by Coverity.

Follow-up to #1179.
2020-12-03 07:55:51 +00:00
Jon Siwek
71f9340e75 Merge branch 'add-X-to-double' of https://github.com/ynadji/zeek
- Minor whitespace/grammar/doc tweaks during merge

* 'add-X-to-double' of https://github.com/ynadji/zeek:
  Add `count_to_double` and `int_to_double` bif functions
2020-12-02 12:54:08 -08:00
Jon Siwek
3605e04d83 Update minimum required CMake to 3.5
Also now uses CMake's ENABLE_EXPORTS target property for the zeek
executable to ensure symbols are visible to plugins.  Prior to CMake
3.4, the policy was to export symbols by default for certain platforms,
but later versions need either the explicit target property or policy.
2020-12-01 22:13:52 -08:00
Yacin Nadji
607af85ac1 Add count_to_double and int_to_double bif functions 2020-12-01 16:35:49 -05:00
Tim Wojtulewicz
e27008ef26 GH-1184: Add 'source' field to weird log denoting where the weird was reported 2020-12-01 09:34:37 -07:00
Robin Sommer
eccbbb4476 Merge remote-tracking branch 'origin/topic/robin/gh-1179-plugin-loading'
* origin/topic/robin/gh-1179-plugin-loading:
  Retry loading plugins on failure to resolve to dependencies.
  Fix use of deprecated functionality in test.
  When attempting to activate a plugin, load dynamic libraries first.
  Add test creating multiple plugins with load dependencies.
2020-12-01 14:51:49 +00:00
Tim Wojtulewicz
616d29c08d Merge remote-tracking branch 'origin/topic/bbannier/debug_logger_lookup'
* origin/topic/bbannier/debug_logger_lookup:
  Find correct zeek namespace in debug logger macros.
2020-11-30 14:07:56 -07:00
Jon Siwek
33a55a04c3 Update documentation for Python >= 3.5 requirement 2020-11-25 14:57:09 -08:00
Robin Sommer
fe45f5335a Retry loading plugins on failure to resolve to dependencies.
Closes #1179.
2020-11-25 15:07:32 +00:00
Vlad Grigorescu
1220d3695d Fix SMB2 response status parsing. Fixes #1286 2020-11-24 15:45:12 -06:00
Robin Sommer
df40e82fd6 When attempting to activate a plugin, load dynamic libraries first.
Just moving code. This is so that we can abort if dlopen() fails without
having changed any other state yet.
2020-11-24 16:59:27 +00:00
Jon Siwek
f70a7cb4d3 Merge remote-tracking branch 'origin/topic/timw/internal-type-symbols'
* origin/topic/timw/internal-type-symbols:
  Move implementation of internal_{type,var,etc} methods back into global namespace.
2020-11-23 21:50:47 -08:00
Benjamin Bannier
b42396340e Find correct zeek namespace in debug logger macros.
These macros forward to functionality in `zeek::detail::debug_logger`
and are not intended for customization. This patch fixes the macros to
always use `::zeek::detail::debug_logger` as without the leading `::`
lookup could happen in any potentially local namespace `zeek` which does
not need to provide this symbol.

This closes zeek/spicy#597.
2020-11-23 10:58:23 +01:00
Vern Paxson
147eee5b17 merge glitch 2020-11-19 17:15:30 -08:00
Vern Paxson
22a913d8f5 Merge branch 'topic/vern/script-inlining' of github.com:zeek/zeek into topic/vern/script-inlining 2020-11-19 17:14:12 -08:00
Vern Paxson
c42586af2c inlining of Zeek script functions 2020-11-19 16:16:59 -08:00
Vern Paxson
30b29ef7ba inlining of Zeek script functions 2020-11-19 16:05:42 -08:00
Jon Siwek
824ff81bf6 Merge remote-tracking branch 'origin/topic/johanna/1033'
- Fixed signed/unsigned comparison compiler warning
- Did other minor changes to address efficiency nitpicks

* origin/topic/johanna/1033:
  BrokerStore <-> Zeek Tables: support complex indices
2020-11-17 13:34:26 -08:00
Tim Wojtulewicz
c8cf1988e5 Move implementation of internal_{type,var,etc} methods back into global namespace.
This fixes an unknown symbol error if using those methods. They're defined as extern
in the global namespace in Var.h, but Var.cc had their implementations defined in
the zeek::detail namespace.
2020-11-17 15:17:23 +00:00
Johanna Amann
44ae8f9e8f BrokerStore <-> Zeek Tables: support complex indices
This change adds support for complex indexes for sets and tables. With
this change, sets with indexes like:

set[string, count, count]

will function. Before this change, Zeek raised an error message in these
cases.

Addresses GH-1033
2020-11-17 14:48:10 +00:00
Jon Siwek
6503068922 Fix memory leak in deprecated Analyzer::ConnectionEvent() 2020-11-16 16:38:59 -08:00
Jon Siwek
02c0b33b54 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1264-ssh-host-key-fingerprints' into master
* origin/topic/jsiwek/gh-1264-ssh-host-key-fingerprints:
  Simply ssh/main.zeek by using "ssh_server_host_key" for fingerprinting
  Deprecate "ssh1_server_host_key" parameters *e* and *p*
  GH-1264: Implement "ssh_server_host_key" event
2020-11-16 11:22:37 -08:00
Johanna Amann
50a49eabb5 Merge branch 'topic/vbrevet/ssh_version' of https://github.com/vbrevet/zeek
* 'topic/vbrevet/ssh_version' of https://github.com/vbrevet/zeek:
  [SSH] Handle SSH version 1.99 SSH can set in its identification a version 1.99 (SSH-1.99-xxx). That means the client/server is compatible with SSHv1 and SSHv2. So the version choice depends of the both side.
2020-11-16 11:05:30 +00:00
Jon Siwek
331b94db39 Simply ssh/main.zeek by using "ssh_server_host_key" for fingerprinting 2020-11-14 08:40:27 -08:00
Brevet Vivien
3769ed6c66 [SSH] Handle SSH version 1.99
SSH can set in its identification a version 1.99 (SSH-1.99-xxx).
That means the client/server is compatible with SSHv1 and SSHv2.
So the version choice depends of the both side.

1.99 : 1.99 => 2.0
1.99 : 1.x  => 1.x
1.99 : 2.0  => 2.O

(see "Compatibility With Old SSH Versions" in RFC 4253)
2020-11-14 15:33:34 +01:00
Jon Siwek
45449dad72 Deprecate "ssh1_server_host_key" parameters *e* and *p*
They are named such that *e* is actually the modulus, not the exponent.
The replacement parameters are named *exponent* and *modulus* for
clarity.
2020-11-13 22:58:56 -08:00
Jon Siwek
bd40a97a78 GH-1264: Implement "ssh_server_host_key" event
This event provides host key fingerprints for both SSH1 and SSH2.
2020-11-13 22:58:56 -08:00
Jon Siwek
fc114069b0 Merge remote-tracking branch 'origin/topic/jsiwek/unknown-protocol-options'
* origin/topic/jsiwek/unknown-protocol-options:
  Move UnknownProtocol options to init-bare.zeek
  Coverity 1436183: Initialize packet_analysis::Manager fields
2020-11-12 14:35:01 -08:00
Jon Siwek
4618df762d Merge remote-tracking branch 'origin/topic/jsiwek/gh-1273-size-expr-any'
* origin/topic/jsiwek/gh-1273-size-expr-any:
  GH-1273: Change SizeExpr to yield "any" type when operating on "any"
2020-11-12 14:30:52 -08:00
Jon Siwek
aab99b743d Merge remote-tracking branch 'origin/topic/jsiwek/type-alias-introspection'
* origin/topic/jsiwek/type-alias-introspection:
  Add enum_names() BIF to return names of an enum type's values
  Add type_aliases() BIF for introspecting type-names of types/values
  Change Type::type_aliases map to store IntrusivePtr
  Fix lookup_ID() BIF to return enum values
2020-11-12 14:30:32 -08:00