Commit graph

6667 commits

Author SHA1 Message Date
Jon Siwek
ee4c259cd4 Merge branch 'master' into topic/vern/script-xform 2021-01-13 12:18:44 -08:00
Jon Siwek
c166288248 Add NEWS entries for lambda/capture-list functionality 2021-01-11 16:29:39 -08:00
Jon Siwek
0a7e5e67a2 Tweak vector append/move logic of Frame::SerializeCopyFrame()
No functional difference, just simplification.
2021-01-11 16:09:48 -08:00
Jon Siwek
b08112b2e7 Switch FuncType capture-list storage to optional<vector<Capture>>
May help clarify overall mem-mgmt/ownership semantics.
2021-01-11 15:57:58 -08:00
Jon Siwek
ab15a98b28 Fix memory leaks in lambda capture/frame management 2021-01-11 15:07:01 -08:00
Christian Kreibich
aa9242913f More precise type information in a config framework error message
When an option's value is a reader-incompatible table or set, Zeek now
renders the type as expressed in the script layer (e.g. "set[addr,addr]")
as opposed to the internal type tag (which'd here be "table", including
for sets).
2021-01-11 13:48:40 -08:00
Christian Kreibich
421639e7a7 Explicitly don't support sets with multiple index types in input/config frameworks
The input framework's Manager::IsCompatibleType() already rejected
sets with multiple index types that aren't all the same (i.e. that are
not pure). Pure ones (e.g. "set[addr,addr]") slipped through and could
cause Zeek to segfault elsewhere in the config framework due to type
comparison subtleties. Note that the ASCII reader can't read such sets
anyway, so this method now rejects sets with any kind of index-type
tuple.

In the config framework, the script-level change handler has a risky
conversion from any to set[bool], which can trigger segfaults when the
underlying set's index is a type tuple. We now prevent this code path
by ensuring it only applies to sets with a single index type.
2021-01-11 13:35:46 -08:00
Jon Siwek
614fade0a4 Merge branch 'master' into topic/vern/lambda-copy-semantics 2021-01-11 11:48:45 -08:00
Jon Siwek
321a027d07 Remove unusable/broken RocksDB code and options
The Broker RockSDB data store backend was previously unusable
and broken, so all code and options related to it are now removed.
2021-01-11 11:12:59 -08:00
Vern Paxson
03085d45e5 simplified some vestigial complexity I noticed when flipping through diffs 2021-01-10 17:36:03 -08:00
Jon Siwek
8c64ba6907 GH-1296: fix type-checks related to list-type equality
List-types as used in composite table/set indices, for example,
previously had incorrect same_type() comparisons due to flattening
of the list-type into a single type without checking whether the
number and kind of types all match.

This patch simply removes the flatten_type() call from same_type() since
it was already contradicting/preventing a subsequent full-comparison
between elements of two TYPE_LISTs.

There was also a superfluous special-case of the `in` operator's
type-checking for testing whether a record is in a table/set.  It's
superfluous because the general case will already do the type-checking
from MatchesIndex() after first wrapping the record operand in a
ListExpr.  The previous logic was incorrectly relying on the
flatten_type() for testing equality of a record-type against a
list-type, whereas the general case correctly normalizes to testing
equality of two list-types.

The special-cased type-checking logic for assigning a record value to a
table index during its initialization similarly needed minor
re-organization in order to maintain the same error messages as before.
2021-01-10 17:32:50 -08:00
Vern Paxson
e2edb622ac logic for driving the script optimization process 2021-01-10 14:18:11 -08:00
Vern Paxson
e42b1fa05d low-level tidying 2021-01-10 14:15:11 -08:00
Vern Paxson
607e9950bf implementation for Reduce class - code now links 2021-01-10 14:14:09 -08:00
Vern Paxson
7a9694a2a4 reduction of Stmt subclasses - compiles but does not yet link 2021-01-10 14:13:16 -08:00
Vern Paxson
10e80dfcd3 reductions of expressions in ASTs - code compiles but doesn't yet link 2021-01-10 14:04:01 -08:00
Vern Paxson
6aa84087b0 initial implementation of class for temporary variables; this will grow in complexity as we add additional optimization stages 2021-01-10 13:41:39 -08:00
Vern Paxson
8d77194719 make script function profiles immutable 2021-01-10 13:36:28 -08:00
Vern Paxson
77e9610086 options relating to script transformation: activation, dumping, selecting only a single function (for debugging) 2021-01-10 13:29:05 -08:00
Vern Paxson
8f001062bf support for rewriting script function bodies 2021-01-10 13:25:01 -08:00
Vern Paxson
63502e655f convenience function for accessing object descriptions 2021-01-10 13:22:23 -08:00
Vern Paxson
c30f787949 removed unused EventBodyList subclass 2021-01-10 13:19:59 -08:00
Vern Paxson
eb1848c547 cleaner approach for localizing errors associated with duplicated ASTs: virtualize GetLocationInfo 2021-01-07 15:14:22 -08:00
Jon Siwek
c0a5328f8e Add commentary to Frame::GetElement(int) about lack of offset adjustment 2021-01-06 22:21:09 -08:00
Jon Siwek
10ae10d4e4 Remove unused local in Inliner::Analyzer() 2021-01-06 22:13:31 -08:00
Jon Siwek
64631a2d9f Merge branch 'master' into topic/vern/script-inlining 2021-01-06 22:08:29 -08:00
Vern Paxson
80f7d36582 support for transmitting of capture-semantics closures via Broker, while keeping deprecated functionality 2021-01-04 14:29:07 -08:00
Vern Paxson
e531b2a7ca minor simplifications in using type names, and unordered sets rather than vectors 2021-01-04 14:25:50 -08:00
Vern Paxson
8f4b616d65 changes to Frames to support access to captured-by-copy-semantics variables 2021-01-04 14:17:56 -08:00
Vern Paxson
627fb8616e changes to ScriptFunc's to track captures, and LambdaExpr's to check/manage them 2021-01-04 14:07:41 -08:00
Vern Paxson
955384291d parsing of new []-style captures, and creation of associated data structures 2021-01-04 13:58:20 -08:00
Vern Paxson
f673f85acc nit: fixed some 0/1 values that should instead be false/true 2021-01-04 13:49:50 -08:00
Vern Paxson
98529ae4ec no semantic changes: factored some of the complexity of begin_func() into a pair of static functions for clarity 2021-01-04 13:40:37 -08:00
Vern Paxson
9cb506ad97 simple error propagation fix: don't complain about "unused" values that themselves are due to errors 2021-01-04 13:39:22 -08:00
Vern Paxson
c8be7ec795 no semantic changes: corrected & reflowed some comments, plus a whitespace tweak 2021-01-04 13:38:36 -08:00
Jon Siwek
604fbea00d Merge remote-tracking branch 'origin/topic/johanna/1323'
* origin/topic/johanna/1323:
  TLS 1.3 changes: Address review feedback
  Add one more TLS 1.3 testcase and update NEWS
  Fix TLS 1.3 session resumption detection.
  Introduce ssl_probable_encrypted_handshake_message event
  SSL Analyzer: ignore CCS for TLS 1.3
  TLS analyzer: change logic to track TLS 1.3 connection establishment
2020-12-22 11:00:59 -08:00
Johanna Amann
886d7178ef TLS 1.3 changes: Address review feedback
Only minor changes, new consts, and documentation updates.

Part of GH-1335. Addresses GH-1323.
2020-12-18 10:51:36 +00:00
Arne Welzel
ef7206bb99 logging/ascii: Atomically create .shadow files using rename()
A logger process being terminated/killed while in the process of creating
a new .shadow file may leave an empty (invalid) one around. This in turn
causes the logger to error and exit during startup.

    $ $ ls -lha .shadow.*
    -rw-r--r-- 1 root root 0 Dec 16 18:48 .shadow.dns.log
    -rw-r--r-- 1 root root 0 Dec 16 18:48 .shadow.packet_filter.log

    $ zeek LogAscii::enable_leftover_log_rotation=T Log::default_rotation_interval=30sec -i wlp0s20f3
    error in <params>, line 1: failed to process leftover log 'dns.log': Found leftover log, 'dns.log', but the associated shadow  file, '.shadow.dns.log', required to process it is invalid
    error in <params>, line 1: failed to process leftover log 'packet_filter.log': Found leftover log, 'packet_filter.log', but the associated shadow  file, '.shadow.packet_filter.log', required to process it is invalid
    $ ...

Prevent creating invalid .shadow files by atomically creating them.
2020-12-16 19:03:00 +01:00
Johanna Amann
3c95c9a956 Fix TLS 1.3 session resumption detection.
Now we detect TLS 1.3 session resumption by looking if both sides have
the PSK extension set, which is much more exact than the previous
approach.
2020-12-15 16:34:47 +00:00
Jon Siwek
206c674cc9 Merge EDNS ECS option parsing security/bug fixes 2020-12-15 08:03:40 -08:00
Johanna Amann
84315b54c3 Introduce ssl_probable_encrypted_handshake_message event
This event is raised for messages that (probably) are TLS 1.3 handshake
messages, including finished. This allows scripts to examine handshake
messages without having to handle all encrypted messages.
2020-12-15 15:52:24 +00:00
Johanna Amann
232777ca9b SSL Analyzer: ignore CCS for TLS 1.3
In TLS 1.3, the ChangeCipherSpec message is meaningless; it only is
included to convince middleboxes that the devices actually are speaking
TLS 1.2. Nowadays some TLS 1.3 implementations also just don't send the
packet.

In a push to unify our handling of TLS 1.3 connections - ignore CCS and
always go with application data packet counting to determine if
connections are or are not encrypted.
2020-12-15 15:22:31 +00:00
Jon Siwek
faf6d4ec1a Rename a 'do_net_run' variable to 'do_run_loop'
For clarity, since the net_run() function was renamed to run_loop().
2020-12-14 13:07:47 -08:00
Jon Siwek
44903da8fd GH-1329: call Zeek's cleanup function from standalone fuzzer driver
Otherwise, the global Broker manager object containing CAF/threading
logic is never destructed and can result in a heap-use-after-free if it
tries to access other global objects after they're cleaned up from
__cxa_finalize().
2020-12-14 12:58:06 -08:00
Johanna Amann
bea3075c1f TLS analyzer: change logic to track TLS 1.3 connection establishment
This commit changes the logic that is used to tracks connection
establishment - and moves it from scriptland into the core.

TLS 1.3 connection establishment is much more finnicky for us than the
establishment of earlier versions - since we cannot rely on the CCS
message anymore (which is meaningless and not sent in a lot of cases).

With this commit, the ssl_encrypted_data message gets raised for
encrypted TLS 1.3 handshake messages - which is much more correct than
the behavior before that just interpreted them as plaintext messages.

I will refine this a bit more - at the moment the connection established
event happens a bit too early - earlier than TLS 1.3 connections
actually can be estasblished.

Part of GH-1323
2020-12-14 19:51:05 +00:00
Jon Siwek
7b2ee2514e Tweak FuncInfo memory management
Idea being for everything to be automatically released when process
exits just so there's less potential noise from leak profilers.
2020-12-13 17:06:57 -08:00
Jon Siwek
c7bec09e14 Switch InlineExpr from using IDPList* to vector<IDPtr> 2020-12-13 15:04:53 -08:00
Jon Siwek
a0552f9771 Insert contents of #included script-opt files directly
Otherwise there is a functional problem caused by using #include to
insert the disconnected source code: language server/analysis tools,
like clangd, may get confused by those files and report everything
in them as an error.
2020-12-13 14:43:00 -08:00
Jon Siwek
fa418cb179 Simplify some IntrusivePtr operations in Expr::Duplicate/Inline 2020-12-13 14:20:10 -08:00
Jon Siwek
70ff4ef678 Remove Func::AsScriptFunc() methods
Not used frequently enough, so possibly better to minimize leakage of
details from non-detail API.
2020-12-13 14:03:39 -08:00