Commit graph

503 commits

Author SHA1 Message Date
Vern Paxson
71a1aa0afd fix for needing to always flush optimization information for identifiers 2024-01-15 15:03:56 +01:00
Arne Welzel
f3cbfa9c25 parse: Support @if conditionals in record definitions
Closes #3531
2024-01-08 15:21:48 +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
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
074f51fc96 btest: Add test for pattern tables and when 2023-11-21 10:34:16 +01:00
Vern Paxson
fd1094a184 BTests for indexing "table[pattern] of T" with strings 2023-11-21 10:34:15 +01:00
Vern Paxson
280acc51bf BTest updates for latest ZAM maintenance 2023-11-10 09:57:35 +01:00
Arne Welzel
8109bbc52f Var/Func: Render function parameters using comma, not semicolon
A bit larger follow-up to what Tim pointed out: Function prototype descriptions
previously used semicolons to separate parameters.

Switch to use commas when a RecordType is used as function parameter.
Use existing "func_args" naming for consistency.
2023-10-04 17:42:30 +02:00
Arne Welzel
8ede22f6ec Var: Fix null-pointer deref on redefinition of lambdas
Closes #3314
2023-10-04 15:18:24 +02:00
Vern Paxson
3addda28d3 removed order-of-evaluation ambiguity from new BTest 2023-09-27 11:36:22 -07:00
Arne Welzel
f4322f9584 Merge remote-tracking branch 'origin/topic/vern/script-opt-maint.Sep23'
* origin/topic/vern/script-opt-maint.Sep23:
  fix for ZAM statement-level profiling (broken by GH-3199)
  ZAM fixes for compatibility with GH-3249 changes
  -O gen-C++ fixes for compatibility with GH-3249 changes minor -O gen-C++ BTest updates
  minor BTest reordering to diminish differences with script optimization
2023-09-08 16:47:29 +02:00
Arne Welzel
aaa81cae5d CompositeHash: Skip record initialization when recovering vals
Initializing fields of recovered records caused running &default expression
of fields just so that they are re-assigned in the next step with the
recovered fields. The second test case still shows that the loop var
is initialized as well even though that's not needed.

Add tests for iterating over records with &default attributes for both,
tables and vectors.

Fixes #3267
2023-09-08 13:02:34 +02:00
Vern Paxson
85cd1d69a4 minor BTest reordering to diminish differences with script optimization 2023-09-01 12:17:06 -07:00
Vern Paxson
8e5dac3900 BTests for any/vector-of-any fixes 2023-08-24 15:49:13 -07:00
Tim Wojtulewicz
e8ef169b27 Merge remote-tracking branch 'origin/topic/timw/3059-set-vector-conversion'
* origin/topic/timw/3059-set-vector-conversion:
  Fix conversion with record types
  Add conversion between set and vector using 'as' keyword
  Add std::move for a couple of variables passed by value
2023-08-11 10:35:06 -07:00
Tim Wojtulewicz
fe9926e538 Fix conversion with record types 2023-08-10 13:42:23 -07:00
Tim Wojtulewicz
af9e852c28 Add conversion between set and vector using 'as' keyword 2023-08-09 14:41:54 -07:00
Arne Welzel
431767d04b Add &default_insert attribute for tables
This is based on the discussion in zeek/zeek#2668. Using &default with tables
can be confusing as the default value is not inserted. The following example
prints an empty table at the end even new Service records was instantiated.

    type Service: record {
        occurrences: count &default=0;
        last_seen: time &default=network_time();
    };

    global services: table[string] of Service &default=Service();

    event zeek_init()
        {
        services["http"]$occurrences += 1;
        services["http"]$last_seen = network_time();

        print services;
        }

Changing above &default to &default_insert will insert the newly created
default value upon a missed lookup and act less surprising.

Other examples that caused confusion previously revolved around table of sets
 or table of vectors and `add` or `+=` not working as expected.

    tbl_of_vector["http"] += 1
    add tbl_of_set["http"][1];
2023-08-04 12:30:36 +02:00
Arne Welzel
ab388844bf UsageAnalyzer: Collect identifiers found in attributes as seeds
This marks every identifier used within an attribute as seeds. The scenario
this avoids is functions referenced through attributes on unused tables or
record types (&default, &expire_func, ...) being dinged as unused as
that's rather confusing.

Also adds test for the above and a light smoke test into language/ as it
doesn't appear we had coverage here.

Closes #3122
2023-08-01 15:46:10 +02:00
Arne Welzel
12a5616f4d Support :: prefix to reference global namespace, deprecate GLOBAL::
Closes #2709
2023-07-11 12:51:21 +02:00
Vern Paxson
a1d25670fc Fix for nested "when" statements leading to confusion over scoping 2023-07-05 17:10:38 -07:00
Vern Paxson
a4cf10e34d tweaks to BTests for ZAM feature completeness; new ZAM-only btest 2023-06-30 09:36:14 +02:00
Vern Paxson
5165a04ae0 ZAM ignores new "assert" statement 2023-06-14 17:41:41 -07:00
Vern Paxson
40d7e6949a BTest to check for invalid negative vector indices 2023-06-14 17:35:08 -07:00
Tim Wojtulewicz
d5b19c61ff Change table initialization deprecation to error 2023-06-14 10:07:23 -07:00
Tim Wojtulewicz
0110c15ee2 Make break/next/continue outside loops an error (6.1 deprecation) 2023-06-14 10:07:22 -07:00
Arne Welzel
0b0f6e509f Stmt: Rework assertion hooks break semantics
Using break in either of the hooks allows to suppress the default reporter
error message rather than suppressing solely based on the existence of an
assertion_failure() handler.
2023-06-13 16:18:01 +02:00
Arne Welzel
25ea678626 Stmt: Introduce assert statement and related hooks
including two hooks called assertion_failure() and assertion_result() for
customization and tracking of assertion results.
2023-06-12 18:16:02 +02:00
Tim Wojtulewicz
5a3abbe364 Revert "Merge remote-tracking branch 'origin/topic/vern/at-if-analyze'"
This reverts commit 4e797ddbbc, reversing
changes made to 3ac28ba5a2.
2023-05-31 09:20:33 +02:00
Tim Wojtulewicz
4e797ddbbc Merge remote-tracking branch 'origin/topic/vern/at-if-analyze'
* origin/topic/vern/at-if-analyze:
  updates reflecting review comments
  change base scripts to use run-time if's or @if ... &analyze
  a number of BTests updated with @if ... &analyze
  update for scripting coverage BTest demonstrating utility of @if ... &analyze
  BTests for new @if ... &analyze functionality
  "if ( ... ) &analyze" language feature
  classes for tracking "@if (...) &analyze" notion of code being/not being "activated"
  RemoveGlobal() method for Scope class + simplifying interfaces
2023-05-26 14:56:01 -07:00
Vern Paxson
e441ba394a updates reflecting review comments 2023-05-25 18:00:13 -07:00
Tim Wojtulewicz
351e68b66a GH-3060: Support negative index lookups for vectors 2023-05-23 13:48:58 -07:00
Vern Paxson
be87f9f6ec BTests for new @if ... &analyze functionality 2023-05-19 13:02:37 -07:00
Jan Grashoefer
ae152f1777 Annotate scheduled events with intended timestamp. 2023-05-11 12:51:06 +02:00
Jan Grashoefer
fa84d2896a Add timestamp to events. 2023-05-11 12:51:06 +02:00
Tim Wojtulewicz
e07f3f305d Remove parser error message for bro_init, et al 2023-05-02 12:06:41 -07:00
Tim Wojtulewicz
fcf7af259c GH-2920: Don't warn on uninitialized container options 2023-04-13 09:05:17 -07:00
Arne Welzel
d9611132e8 scan.l: Support @pragma, specifically push/pop ignore-deprecations
This allows to ignore-deprecations as follows:

    @pragma push ignore-deprecations
    print r$deprecated;
    @pragma pop

A bit of infrastructure is put in place for the push and pop, but
nothing overly generalized for future pragmas.
2023-04-05 10:24:30 +02:00
Arne Welzel
92f09f0db7 Merge remote-tracking branch 'origin/topic/vern/when-cleanup'
* origin/topic/vern/when-cleanup:
  test suite update for minor change in "when" error messages
  removed skeletal (non-functioning) "when" support from ZAM
  simplify WhenInfo and Trigger classes given removal of old capture semantics
  introduced notion of light-weight Frame clones
  changed function_ingredients struct to FunctionIngredients class with accessors

Renamed Frame::LightClone() to Frame::CloneForTrigger() during merge.
2023-04-04 10:02:01 +02:00
Arne Welzel
1858c6b0c2 Merge remote-tracking branch 'origin/topic/vern/CPP-Apr23-maint'
* origin/topic/vern/CPP-Apr23-maint:
  addressed static analysis concern about possible null pointer
  tweaks for "-O C++" of BTest's with conditional code

Backed out changes from at-if-lambda during merge and instead skip
test when running with ZEEK_USE_CPP.
2023-04-03 16:42:18 +02:00
Vern Paxson
910b50ef0d test suite update for minor change in "when" error messages 2023-04-02 11:38:30 -07:00
Vern Paxson
2f9272f2d5 tweaks for "-O C++" of BTest's with conditional code 2023-04-01 20:26:55 -07:00
Arne Welzel
bb80d80218 Stmt: Error on deprecated when/local usage
This has been around since Zeek v4.1, so it was warned about in Zeek 5.0
LTS and we could've removed it with 5.1.

Also removed merge_top_scope() from the zeek::detail namespace, it's
unused now.

Updated the when-aggregates test somehow. I'm not quite sure what had
been tested there :-/
2023-03-20 21:35:53 +01:00
Arne Welzel
5ef62b2de8 Expr: Remove vector scalar operations
These seem to have been deprecated since 2018, so do it now.
Unfortunately the message didn't contain a version when it'll
be removed, but it's been long enough.
2023-03-20 21:35:48 +01:00
Arne Welzel
12d5dca70f parse.y: Make out-of-scope use errors
This was marked to be done in Zeek 5.1, so do it now. The message
didn't include a version, unfortunately, but minimally there was
a comment when it should happen.
2023-03-20 21:35:48 +01:00
Arne Welzel
56c76e5949 ScriptValidation: Make break/next a warning until Zeek 6.1
The ja3 package uses next instead of return and triggers the new
errors with Zeek 5.2. That seems somewhat bad.

In case we want to do a 5.2.1 that makes this a warning, this
would be change to do so.
2023-03-02 18:46:10 +01:00
Arne Welzel
2f4f01d3f5 parse.y: Improve error reporting of type redef
It's happening regularly to me that I forget the type specifier when redef'ing
records or enums and usually it takes me a while to figure out what's going
on as the errors are not descriptive. Improve the error reporting and just
bail as there's no sensible way to continue.

Closes #2777
2023-02-21 11:58:33 +01:00
Arne Welzel
0fd92555d9 Merge remote-tracking branch 'origin/topic/awelzel/propagate-on-change-through-copy'
* origin/topic/awelzel/propagate-on-change-through-copy:
  TableVal: Propagate &on_change attribute through copy()
  testing/btest: Add test showing &expire_func/&create_expire is copied
2023-02-17 17:38:37 +01:00
Arne Welzel
9f16520aa9 Merge remote-tracking branch 'origin/topic/awelzel/2793-propagate-order-through-copy'
* origin/topic/awelzel/2793-propagate-order-through-copy:
  TableVal: Propagate &ordered through copy()
2023-02-17 17:36:19 +01:00