Commit graph

308 commits

Author SHA1 Message Date
Jon Siwek
2a8de33c63 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1122'
* origin/topic/jsiwek/gh-1122:
  GH-165: Fix global initializations that indirectly use builtin types
  Improve how primary/top-level BIFs get initialized
  GH-1122: Allow initializing globals with calls to subdir BIFs
  GH-1122: Improve error for global record initialization exceptions
2020-09-04 17:24:50 -07:00
Johanna Amann
425b6104c5 Merge remote-tracking branch 'origin/topic/jsiwek/gh-955-prohibit-typecasting-switch-fallthrough'
* origin/topic/jsiwek/gh-955-prohibit-typecasting-switch-fallthrough:
  GH-955: Prohibit `fallthrough` in typecasting `switch` cases

Closes GH-955
2020-09-02 11:49:28 -07:00
Jon Siwek
5e6bb843ab Merge remote-tracking branch 'origin/topic/timw/174-duplicate-attributes'
- Replaced "tag" with "attribute" in the error message since the former
  is not exactly the same concept/meaning and also not user-facing
  terminology

* origin/topic/timw/174-duplicate-attributes:
  Allow duplicate attributes in full redefs
  Short-circuit checking of whether attr exists
  Expanded check for other tag types, fixed btest to cover more tags
  GH-174: Add warning for duplicate attributes
2020-08-31 17:39:47 -07:00
Johanna Amann
b8a47de26c Merge remote-tracking branch 'origin/topic/jsiwek/gh-926-ternary-type-checking'
* origin/topic/jsiwek/gh-926-ternary-type-checking:
  GH-926: Improve type-checking for ternary conditional operator

Fixes GH-926
2020-08-28 16:52:29 -07:00
Tim Wojtulewicz
36e3ab7177 Expanded check for other tag types, fixed btest to cover more tags 2020-08-27 15:17:38 -07:00
Jon Siwek
5ed13284c3 GH-165: Fix global initializations that indirectly use builtin types 2020-08-27 14:01:08 -07:00
Jon Siwek
1bbae2368d GH-1122: Allow initializing globals with calls to subdir BIFs 2020-08-27 12:20:37 -07:00
Jon Siwek
cf06ade325 GH-1122: Improve error for global record initialization exceptions 2020-08-26 14:24:36 -07:00
Jon Siwek
3368958ac1 GH-955: Prohibit fallthrough in typecasting switch cases 2020-08-26 12:55:10 -07:00
Tim Wojtulewicz
b687730a01 Merge remote-tracking branch 'origin/topic/jsiwek/gh-710-expire-func-type-check'
* origin/topic/jsiwek/gh-710-expire-func-type-check:
  GH-710: Check that &expire_func is a function and not hook/event
2020-08-24 14:30:58 -07:00
Tim Wojtulewicz
989531826f GH-174: Add warning for duplicate attributes 2020-08-24 19:44:51 +00:00
Jon Siwek
3bc5309e9e GH-926: Improve type-checking for ternary conditional operator 2020-08-21 18:33:14 -07:00
Jon Siwek
e1a39d27f3 GH-710: Check that &expire_func is a function and not hook/event 2020-08-21 15:42:51 -07:00
Jon Siwek
164b1f6514 GH-594: Improve table initialization type-check error messages 2020-08-19 19:59:19 -07:00
Robin Sommer
45bef16be0 Catch if &add_func/&delete_func is applied to IDs that don't have values.
We do to allow adding &add_func to a global that's not immediately
initialized, as a later redef may fix that.

Closes #467.
2020-08-18 10:34:05 +00:00
Jon Siwek
7967a5b0aa General btest cleanup
- Use `-b` most everywhere, it will save time.

- Start some intel tests upon the input file being fully read instead of
  at an arbitrary time.

- Improve termination condition for some sumstats/cluster tests.

- Filter uninteresting output from some supervisor tests.

- Test for `notice_policy.log` is no longer needed.
2020-08-11 11:26:22 -07:00
Johanna Amann
8e99d4b170 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1080-error-on-enum-redefinition-conflict'
* origin/topic/jsiwek/gh-1080-error-on-enum-redefinition-conflict:
  Fix incorrect conflict detection of namespaced-enum-names
  Improve error message for an enum name conflicting with non-enum ID
  GH-1080: Treat enum name re-use across different enum types as an error
  GH-1080: Rename conflicting NetControl::DROP enum definitions

Fixes GH-1080
2020-08-04 20:25:40 +00:00
Jon Siwek
26ad26c101 Fix incorrect conflict detection of namespaced-enum-names
E.g. defining a `Foo::RED` enum name when a `GLOBAL::RED` identifier
already exists would previously be treated as an error, even though the
names don't truly conflict.
2020-07-31 16:44:49 -07:00
Jon Siwek
69c0cf1513 Improve error message for an enum name conflicting with non-enum ID 2020-07-31 16:24:26 -07:00
Jon Siwek
4a9567e04f GH-1080: Treat enum name re-use across different enum types as an error 2020-07-31 16:23:40 -07:00
Johanna Amann
417a6eb1e9 Completely remove all traces of the COUNTER type.
Relates to GH-1095
2020-07-30 12:11:05 -07:00
Jon Siwek
eb826bd337 GH-734: Improve handling of lambdas that escape enclosing frame 2020-07-14 22:38:43 -07:00
Jon Siwek
20294d372c Fix wrong frame offsets for locals of alternate event/hook prototypes
Local frame offsets were being assigned based on number of the alternate
prototype's parameters, which may end up having less total parameters
than the canonical prototype, causing the local value to incorrectly
overwrite an event/hook argument value.
2020-07-10 10:59:12 -07:00
Jon Siwek
26b3d406b4 Emit deprecation warning for use of &deprecated function parameters
Particularly, this is meant for using &deprecated on canonical
event/hook prototype parameters to encourage users to create handlers
to another, non-deprecated prototype.  i.e. for canonical prototypes,
we may not always want to put &deprecated directly on the prototype
itself since that signals deprecation of the ID entirely.
2020-07-10 10:57:05 -07:00
Jon Siwek
6e67a40d24 Allow Zeek function equality comparisons
Equality between two functions acts like a pointer comparison.
2020-07-07 18:39:23 -07:00
Tim Wojtulewicz
e6871ed3e9 GH-1040: Add zero-indexed version of str_split 2020-07-06 17:05:40 -07:00
Johanna Amann
9c44403c62 Fix crash when trying to redef non-existing enum
Fixes GH-958
2020-05-07 14:57:03 -07:00
Jon Siwek
62ec60b96f Merge remote-tracking branch 'origin/topic/jazoff/avoid-redundant-inactivity-timers'
- Changed the logic significantly to just guarantee there's only ever a
  single inactivity timer per connection

- Updated language.expire_subnet btest which is unduly sensitive to
  timer-related changes

* origin/topic/jazoff/avoid-redundant-inactivity-timers:
  avoid scheduling redundant inactivity timers
2020-05-04 17:12:36 -07:00
Vern Paxson
b86d5b4424 bug fixes for using "when" in functions that have a local of type "any" 2020-04-25 16:56:24 -07:00
Tim Wojtulewicz
ba1c03188f Merge remote-tracking branch 'origin/topic/jsiwek/alternate-hook-event-prototypes'
* origin/topic/jsiwek/alternate-hook-event-prototypes:
  Add warning for ineffective &default arguments in handlers
  Fix frame size allocation of alternate event/hook handlers
  Emit error for alternate event/hook prototype args with attributes
  Improve alternate event/hook prototype matching
  Allow alternate event/hook prototype declarations
2020-04-13 15:00:25 -07:00
Jon Siwek
640dbea57c Add warning for ineffective &default arguments in handlers
For event/hook handlers that had a previous declaration, any &default
arguments are ineffective.  Only &default uses in the initial
prototype's arguments have an effect (that includes if the handler
is actually the site at which the declaration occurs).
2020-04-09 22:51:01 -07:00
Jon Siwek
9243341e8c Fix frame size allocation of alternate event/hook handlers
When the only existing handler doesn't use the full argument list, still
have to ensure the full frame is allocated because all arguments get set
regardless.
2020-04-09 22:05:34 -07:00
Jon Siwek
070b28ac05 Emit error for alternate event/hook prototype args with attributes
Argument attributes are only allowed in the canonical prototype.
2020-04-09 21:00:09 -07:00
Jon Siwek
9b6934eab8 Improve alternate event/hook prototype matching
This fixes it to again allow the old behavior of matching a handler
against the canonical prototype as long as all argument types, but not
necessarily names, match.
2020-04-09 20:20:38 -07:00
Jon Siwek
da56cd44d9 Fix using patterns stored as table/set indices
Pattern values used as table/set indices are stored in serialized form
using just the pattern text, but re-creating the value from that didn't
fully initialize/compile the regex matcher after (re-)creating it from
that pattern text.
2020-04-06 17:12:33 -07:00
Jon Siwek
8c0e8ecd28 Allow alternate event/hook prototype declarations
The alternates must be some subset of the canonical prototype (the one
that's first declared) and allows users to define handlers for any
such prototype.  Example:

    # Prototype declarations
    global my_event: event(s: string, c: count);
    global my_event: event(c: count);
    global my_event: event();

    # Handler definitions
    event my_event(s: string, c: count) { print s, c; }
    event my_event(c: count) { print c; }
    event my_event() { }

This allows handlers to consume a subset of the arguments or even
re-order them.  This makes it easier to either extend an existing
event/hook's arguments and/or deprecate usages of certain prototypes.
2020-04-01 17:25:28 -07:00
Johanna Amann
3ce1c9ffd6 Merge remote-tracking branch 'origin/topic/jsiwek/misc-lambda-fixes'
* origin/topic/jsiwek/misc-lambda-fixes:
  GH-725: fix logic for finding a lambda's usage of outer IDs
  Change record field anonymous functions to use lambda expressions
2020-03-31 15:46:54 -07:00
Jon Siwek
1ca11f11c7 GH-725: fix logic for finding a lambda's usage of outer IDs 2020-03-26 17:05:59 -07:00
Jon Siwek
f032885085 Change record field anonymous functions to use lambda expressions
There was an alternate syntax to assign anonymous functions to record
fields that was never migrated to use the new lambda expression
machinery (and so didn't allow referencing variables in outer scope):

    type myrec: record {
        foo: function(a: string);
    };

    local o = "o";
    local mr = myrec($foo(a: string) = { print a + o; });
2020-03-26 15:48:18 -07:00
Jon Siwek
98d94ec785 Enable leak checks for btests that produce runtime exceptions
These were previously reporting leaks due to various allocations not
getting cleaned up during the stack unwind, but at the current state of
the transition toward IntrusivePtr usage, theses tests no longer leak.
2020-03-23 21:51:12 -07:00
Jon Siwek
427150b27a Merge remote-tracking branch 'origin/topic/jsiwek/gh-857-rebuild-tables-on-record-redef'
* origin/topic/jsiwek/gh-857-rebuild-tables-on-record-redef:
  Initialize RecordVal default fields when redef'd
  GH-857: fix redefining record types used to index tables
  Change RecordVals to get resized at time of RecordType redef
2020-03-20 11:31:11 -07:00
Jon Siwek
b62727a7fa Merge branch 'intrusive_ptr' of https://github.com/MaxKellermann/zeek
* 'intrusive_ptr' of https://github.com/MaxKellermann/zeek: (32 commits)
  Scope: store IntrusivePtr in `local`
  Scope: pass IntrusivePtr to AddInit()
  DNS_Mgr: use class IntrusivePtr
  Scope: use class IntrusivePtr
  Attr: use class IntrusivePtr
  Expr: check_and_promote_expr() returns IntrusivePtr
  Frame: use class IntrusivePtr
  Val: RecordVal::LookupWithDefault() returns IntrusivePtr
  Type: RecordType::FieldDefault() returns IntrusivePtr
  Val: TableVal::Delete() returns IntrusivePtr
  Type: base_type() returns IntrusivePtr
  Type: init_type() returns IntrusivePtr
  Type: merge_types() returns IntrusivePtr
  Type: use class IntrusivePtr in VectorType
  Type: use class IntrusivePtr in EnumType
  Type: use class IntrusivePtr in FileType
  Type: use class IntrusivePtr in TypeDecl
  Type: make TypeDecl `final` and the dtor non-`virtual`
  Type: use class IntrusivePtr in TypeType
  Type: use class IntrusivePtr in FuncType
  ...
2020-03-17 22:51:46 -07:00
Jon Siwek
71b82595ba GH-857: fix redefining record types used to index tables
This change tracks all TableVals created at parse-time whose index
depends on a given RecordType.  Should that RecordType be redef'd, those
TableVals are immediately rebuilt such that they are valid to
subsequently use in either parse-time initializations or eventually in
any arbitrary run-time expression.
2020-03-12 18:25:48 -07:00
Jon Siwek
363fc49518 Fix a btest to order zeek_init() events via &priority 2020-03-05 14:19:34 -08:00
Jon Siwek
a3b1d202a5 Improve stability of a &expire_func btest
The order in which &expire_func's get called isn't well-defined, so
separate the output from either to ensure diffs against the Baseline are
always consistent.
2020-02-07 15:11:06 -08:00
Johanna Amann
49a21d73d0 Merge remote-tracking branch 'origin/topic/jsiwek/gh-780-indefinite-log-buffer'
* origin/topic/jsiwek/gh-780-indefinite-log-buffer:
  GH-780: Prevent log batches from indefinite buffering
2020-02-07 09:35:29 -08:00
Johanna Amann
b1040f88c9 &on_change wrapup: documentation, tests, whitespacing
Adds documentation, fixes a whitespace issues, fixes compiler warning on
some Linux system, extends test.
2020-02-05 14:15:14 -08:00
Jon Siwek
43e54c7930 GH-780: Prevent log batches from indefinite buffering
Logs that got sent sparsely or burstily would get buffered for long
periods of time since the logic to flush them only does so on the next
log write.  In the worst case, a subsequent log write could never happen
and cause a log entry to be indefinitely buffered.

This fix introduces a recurring event/timer to simply flush all pending
logs at frequency of Broker::log_batch_interval.
2020-02-05 13:06:52 -08:00
Johanna Amann
18ab7838a9 Table expiry now raises &on_change handlers
Expiry is remprted as ELEMENT_EXPIRED (which was newly introduced), to
allow distinction from table deletion.
2020-02-05 12:37:52 -08:00
Johanna Amann
7f9f66fce9 Prevent recursion of &on_change handlers.
This change prevents &on_change handlers for a table from running if an
&on_change handler for the same table is already running.
2020-02-05 11:45:16 -08:00