Commit graph

11634 commits

Author SHA1 Message Date
Tim Wojtulewicz
892124378c Implement standard-library-compatible iterators for Dictionary 2021-01-14 13:49:40 -07:00
Tim Wojtulewicz
9e9998c6e5 Merge remote-tracking branch 'origin/topic/vern/bvu-remove'
* origin/topic/vern/bvu-remove:
  Use static_cast instead of dynamic_cast for Val conversions
  Remove GET_FIELD_AS macro, replace with template methods
  Add templated As() method to Val, use in various places we were using dynamic_cast
  Move ValImpl classes into detail namespace
  Some review cleanup in Val.cc
  Changes addressing pending issues per PR discussion
  Remove BroValUnion by hoisting underlying Val subclass values into subclasses
2021-01-14 13:28:06 -07:00
Tim Wojtulewicz
99e719318b Use static_cast instead of dynamic_cast for Val conversions 2021-01-14 11:58:59 -07:00
Tim Wojtulewicz
4962986df1 Remove GET_FIELD_AS macro, replace with template methods 2021-01-14 11:58:59 -07:00
Tim Wojtulewicz
a94fcad957 Add templated As() method to Val, use in various places we were using dynamic_cast 2021-01-14 11:58:59 -07:00
Tim Wojtulewicz
a7b5915b1a Move ValImpl classes into detail namespace 2021-01-14 11:58:59 -07:00
Tim Wojtulewicz
42f2691251 Some review cleanup in Val.cc 2021-01-14 11:58:59 -07:00
Vern Paxson
e652aff277 Changes addressing pending issues per PR discussion 2021-01-14 11:58:59 -07:00
Vern Paxson
7f92a573d2 Remove BroValUnion by hoisting underlying Val subclass values into subclasses 2021-01-14 11:58:59 -07:00
Tim Wojtulewicz
49ca8e2163 Merge branch 'topic/timw/fix-catalina'
* topic/timw/fix-catalina:
  Use xcode 11 on the Catalina CI image
2021-01-14 11:58:11 -07:00
Tim Wojtulewicz
27a37411c5 Use xcode 11 on the Catalina CI image 2021-01-14 10:01:31 -07:00
Jon Siwek
b4cf393475 Adjust some Reducer ref-counting and IntrusivePtr usage 2021-01-14 00:24:12 -08:00
Jon Siwek
7ce4351ed0 Fix reference counting in ListExpr inline/reduce methods 2021-01-13 23:01:44 -08:00
Jon Siwek
fffeea472a Simplify WhileStmt::CondPredStmt() 2021-01-13 22:59:15 -08:00
Jon Siwek
817315d68e Use std::move() in Case::UpdateBody() 2021-01-13 22:58:39 -08:00
Jon Siwek
177b723a60 Switch some Stmt transform/reduce logic to use IntrusivePtr 2021-01-13 22:57:48 -08:00
Jon Siwek
b799665c1a Switch some Expr transform/reduce logic to use IntrusivePtr 2021-01-13 20:27:41 -08:00
Jon Siwek
d88a899804 Adjust how some Expr::SetOpX() calls use std::move() 2021-01-13 16:40:59 -08:00
Jon Siwek
f9e0b14d38 Add missing header-includes to Reduce.h 2021-01-13 16:39:59 -08:00
Jon Siwek
2c8106295d Add std::move() for args to an assign_to_index call 2021-01-13 15:25:25 -08:00
Jon Siwek
d4ae5c5fbc Adjust memory management for &default argument expression type-check
Mainly, there was an extra Ref().  In theory, the front-insertion was
also not efficient.
2021-01-13 15:23:40 -08:00
Jon Siwek
fe8db7f150 Use string for TempVar::name
Nothing of consequence; just encapsulation of memory management
2021-01-13 13:49:32 -08:00
Jon Siwek
81fa7f7e3d Switch AnalyOpt::only_func to optional<string>
Nothing of consequence; may help express meaning and memory management.
2021-01-13 13:19:46 -08:00
Jon Siwek
48da8b7d66 Fix a signed/unsigned comparison warning 2021-01-13 12:31:19 -08:00
Jon Siwek
ee4c259cd4 Merge branch 'master' into topic/vern/script-xform 2021-01-13 12:18:44 -08:00
Jon Siwek
50b3012020 Update submodule(s) [nomail] 2021-01-12 20:48:00 -08:00
Jon Siwek
8ff1604126 Merge remote-tracking branch 'origin/topic/vern/lambda-copy-semantics'
* origin/topic/vern/lambda-copy-semantics:
  Add NEWS entries for lambda/capture-list functionality
  Tweak vector append/move logic of Frame::SerializeCopyFrame()
  Switch FuncType capture-list storage to optional<vector<Capture>>
  Fix memory leaks in lambda capture/frame management
  tests added for new capture-by-reference closure semantics & errors
  documentation updates
  test suite updates and additions for new capture semantics & suppression of error cascades
  support for transmitting of capture-semantics closures via Broker, while keeping deprecated functionality
  minor simplifications in using type names, and unordered sets rather than vectors
  changes to Frames to support access to captured-by-copy-semantics variables
  changes to ScriptFunc's to track captures, and LambdaExpr's to check/manage them
  parsing of new []-style captures, and creation of associated data structures
  nit: fixed some 0/1 values that should instead be false/true
  no semantic changes: factored some of the complexity of begin_func() into a pair of static functions for clarity
  simple error propagation fix: don't complain about "unused" values that themselves are due to errors
  no semantic changes: corrected & reflowed some comments, plus a whitespace tweak
2021-01-11 18:12:23 -08:00
zeek-bot
deae8088a6 Update doc submodule [nomail] [skip ci] 2021-01-12 00:57:00 +00: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
fcab8df8fb Btest tweak for improved type rendering in config framework errors and set types 2021-01-11 13:54:13 -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
dc38880cee canonicalization for an error message in one of the alternative test baselines 2021-01-10 14:44:46 -08:00
Vern Paxson
06f0a1b3df baseline differences for "xform" alternative: changes generally reflect exposure of transformed code, or error propagation stopping earlier due to error now occurring in an assignment (to a temporary) 2021-01-10 14:25:46 -08:00
Vern Paxson
0e4c996718 new testing alternative for script transformation (= xform) 2021-01-10 14:24:18 -08:00
Vern Paxson
117ff4eb08 bug in correctly inspecting test output file 2021-01-10 14:23:42 -08:00
Vern Paxson
bd2c94521a split bifs.string_utils into a non-error test and an only-errors test, to help control for differing error propagation 2021-01-10 14:21:51 -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