Commit graph

4560 commits

Author SHA1 Message Date
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
Arne Welzel
057bc673a8 Merge remote-tracking branch 'origin/topic/bbannier/issue-3276'
* origin/topic/bbannier/issue-3276:
  Propagate failure reason in `spicy::decline_input`/`zeek::reject_protocol`.
2023-09-07 16:18:20 +02:00
Arne Welzel
8cd2eceed1 spicy: Do not register port N+1 for port N in .evt file
Closes #3278
2023-09-07 12:58:34 +02:00
Benjamin Bannier
d7c3e0ac69 Propagate failure reason in spicy::decline_input/zeek::reject_protocol.
Closes #3276.
2023-09-06 10:32:11 +02:00
Arne Welzel
7e11501d3c Merge remote-tracking branch 'origin/topic/jazoff/gh-3268t '
* origin/topic/jazoff/gh-3268:
  Fix check for emailed notices

Changes: Added a test-case printing email_delay_tokens to compare email vs
non-email notice types. Previously, both notice types would have email
delay tokens at that point in the flow.
2023-09-04 14:01:23 +02:00
Vern Paxson
e78570ad89 ZAM fixes for compatibility with GH-3249 changes 2023-09-01 12:20:35 -07:00
Vern Paxson
80eed34985 -O gen-C++ fixes for compatibility with GH-3249 changes
minor -O gen-C++ BTest updates
2023-09-01 12:17:38 -07:00
Vern Paxson
85cd1d69a4 minor BTest reordering to diminish differences with script optimization 2023-09-01 12:17:06 -07:00
Arne Welzel
14a2c02f9d Merge remote-tracking branch 'origin/topic/awelzel/1705-http-pending-requests'
* origin/topic/awelzel/1705-http-pending-requests:
  http: Prevent request/response de-synchronization and unbounded state growth
2023-09-01 11:54:10 +02:00
Arne Welzel
af1714853f http: Prevent request/response de-synchronization and unbounded state growth
When http_reply events are received before http_request events, either
through faking traffic or possible re-ordering, it is possible to trigger
unbounded state growth due to later http_requests never being matched
again with responses.

Prevent this by synchronizing request/response counters when late
requests come in.

Also forcefully flush pending requests when http_replies are never
observed either due to the analyzer having been disabled or because
half-duplex traffic.

Fixes #1705
2023-08-28 15:02:58 +02:00
Arne Welzel
fc768a9e01 dhcp: Handle is_orig=T for connections from server to 255.255.255.255
This works around the new semantics of is_orig=T for "connections"
from DHCP servers to broadcast addresses. IMO, having the server address
as originator in the conn.log is still more intuitive.
2023-08-28 12:15:55 +02:00
Arne Welzel
ba04f4c31d IPBasedAnalyzer: Don't flip connections when destination is broadcast
Closes #3235
2023-08-28 12:15:55 +02:00
Vern Paxson
8e5dac3900 BTests for any/vector-of-any fixes 2023-08-24 15:49:13 -07:00
Tim Wojtulewicz
ae03d591b8 Merge remote-tracking branch 'origin/topic/vern/script-opt-maint.Aug23'
* origin/topic/vern/script-opt-maint.Aug23:
  updated notes regarding "-O gen-C++" maintenance
  "-O gen-C++" support for "assert" statements
  addressed some nits re "-O gen-C++" script optimization
  fixes for compiling lambdas to C++
  fixes to avoid ambiguities in analyzing captures for script optimization
  disambiguate lambdas by adding scoping and consideration of captures
  addressed performance and correctness issues flagged by Coverity
2023-08-24 12:17:55 -07:00
Vern Paxson
81a9745fb3 "-O gen-C++" support for "assert" statements 2023-08-24 11:46:59 -07:00
Arne Welzel
ee12a7a6e7 PPP: Add PPP analyzer to handle LINKTYPE_PPP (0x9)
Using pcaps from https://interop.seemann.io/ as samples for QUIC protocol
data didn't produce a conn.log for the contained data. `tcpdump -r`
and Wireshark do show the contained IP/UDP packets. Teach Zeek how
to handle link type DLT_PPP 0x09 using a new PPP analyzer based on the
PPPSerial analyzer code.

Usual update to files/x509 baseline after adding new analyzer due
to enum values changing.
2023-08-23 16:41:19 +02:00
Robin Sommer
e8292be0ce
Merge remote-tracking branch 'origin/topic/robin/spicy-export-extensions'
* origin/topic/robin/spicy-export-extensions:
  [Spicy] Clean up representation of EVT record fields.
  [Spicy] Extend functionality of `export` in EVT files.
  [Spicy] Refactor parsing of `export` in EVT files.
2023-08-22 15:04:05 +02:00
Robin Sommer
cdadd934ce
[Spicy] Extend functionality of export in EVT files.
We now support selecting which fields of a unit type get exported into
the automatically created Zeek record; as well as selecting which
fields get a `&log` attribute added automatically to either all fields
or to selected fields.

Syntax:

- To export only selected fields:

    export Foo::X with { field1, field3 };

- To export all but selected fields:

    export Foo::X without { field2, field3 };

- To `&log` all fields:

    export Foo::X &log;

- To `&log` only selected fields:

    export Foo::X with { field1 &log, field3 }; # exports (only) field1 and field3, and marks field1 for logging

Syntax is still subject to change.

Closes #3218.
Closes #3219.
2023-08-21 10:26:25 +02:00
Vern Paxson
3e0f814635 disambiguate lambdas by adding scoping and consideration of captures 2023-08-16 16:58:05 -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
Tim Wojtulewicz
1dc9235cee Pass parsed file record information with ReadFile/WriteFile events 2023-08-07 13:44:38 -07:00
Tim Wojtulewicz
18fd384469 Add length field from header to ModbusHeaders record type 2023-08-07 13:44:37 -07:00
Tim Wojtulewicz
406a406813 Modbus: Add support for Encapsulation Interface Transport (FC=2B) requests and responses 2023-08-07 13:44:37 -07:00
Tim Wojtulewicz
f14be0de29 Modbus: Add support for Diagnostics (FC=8) requests and responses 2023-08-07 13:44:37 -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
Johanna Amann
81ce83590d Merge remote-tracking branch 'origin/topic/johanna/tcp-padding'
* origin/topic/johanna/tcp-padding:
  Do not forward padding to downstream TCP packet analyzer
2023-08-03 07:18:49 +01:00
Johanna Amann
940e3afab4 Do not forward padding to downstream TCP packet analyzer
This is similar to GH-3206. There do not seem to be practical
consequences - but we should still fix it.

This also includes the udp-testcase that was forgotten in GH-3206.
2023-08-02 17:17:01 +01: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
Johanna Amann
a391367c36 Do not forward more than the remaining data to downstream UDP analyzer
This fixes a bug introduced in 2b9de839b0
/ GH-3080, which causes UDP padding to be sent to UDP based analyzers.

Fixes GH-3205.
2023-07-27 13:35:41 +01:00
Tim Wojtulewicz
bd75d72f3f Merge remote-tracking branch 'origin/topic/vern/zam-memory-reduction'
* origin/topic/vern/zam-memory-reduction:
  Baseline "-a zam" update
  increase BTest wait time to abide ZAM compilation times
  avoid script coverage overhead (especially memory) when using ZAM
  fixes for correctly tracking which functions have been fully inlined
  support for discarding ASTs once compiled via ZAM script optimization
  some code simplifications and streamlining
2023-07-26 14:46:23 -07:00
Vern Paxson
ed75b82b3b Baseline "-a zam" update 2023-07-26 13:32:00 -07:00
Vern Paxson
35a6efbfa7 increase BTest wait time to abide ZAM compilation times 2023-07-26 13:32:00 -07:00
Johanna Amann
33d6e1a011 Better input framework error messages for unset non-optionals
The input framework currently gives a rather opaque error message when
encountering a line in which a required value is not provided. This
change updates this behavior; the error message now provides the record
element (or the name or the index element) which was not set in the
input data, even though it is required to be set by the underlying Zeek
type.
2023-07-21 15:11:31 +01:00
Tim Wojtulewicz
0e40f7e6af More test updates for opaqueval changes 2023-07-20 14:01:33 -07:00
Tim Wojtulewicz
5b74e717bc Fix plugin.hooks test for opaque-printing change 2023-07-20 10:43:36 -07:00
Tim Wojtulewicz
1f39a33442 Merge remote-tracking branch 'origin/topic/vern/ZAM-maint.Jul23'
* origin/topic/vern/ZAM-maint.Jul23:
  ZAM btest baseline update
  more extensive ZAM inlining & compilation of lambdas
  fixes for ZAM compilation of switch statements
  fix for ZAM inlining failing to inline function call arguments
  avoid constructing TypeList's on-the-fly for ListVal's with fixed types
  ZAM optimization for ?$ operator applied to non-optional fields
  ASSERT seatbelts for low-level vector accesses
  comment typo
  low-level ZAM micro-optimizations
  fix for recent smart pointer change
2023-07-17 16:33:46 -07:00
Vern Paxson
57e5d1462e ZAM btest baseline update 2023-07-17 16:31:31 -07:00
Vern Paxson
bf6d030894 -a cpp Btest baseline updates 2023-07-13 13:11:26 -07:00
Vern Paxson
42697d72f2 minor BTest generalizations & simplifications 2023-07-13 13:10:14 -07:00
Arne Welzel
b6bff8aa37 Merge remote-tracking branch 'origin/topic/awelzel/2709-colon-colon-for-global'
* origin/topic/awelzel/2709-colon-colon-for-global:
  ci: Bust Ubuntu 22.10 image cache
  Support :: prefix to reference global namespace, deprecate GLOBAL::
2023-07-12 17:29:51 +02:00
Tim Wojtulewicz
f9904511ab Merge remote-tracking branch 'origin/topic/awelzel/3145-dcerpc-state-clean'
* origin/topic/awelzel/3145-dcerpc-state-clean:
  dce-rpc: Test cases for unbounded state growth
  dce-rpc: Handle smb2_close_request() in scripts
  smb/dce-rpc: Cleanup DCE-RPC analyzers when fid is closed and limit them
  dce-rpc: Do not repeatedly register removal hooks
2023-07-11 16:17:12 -07:00
Arne Welzel
12a5616f4d Support :: prefix to reference global namespace, deprecate GLOBAL::
Closes #2709
2023-07-11 12:51:21 +02:00
Robin Sommer
cd2c193cb2
Merge remote-tracking branch 'origin/topic/robin/gh-3157-export-switch'
* origin/topic/robin/gh-3157-export-switch:
  [Spicy] Support `switch` fields when exporting Spicy types to Zeek.
2023-07-07 11:46:29 +02:00
Arne Welzel
f00dac544e Merge remote-tracking branch 'origin/topic/vern/GH-3159.B'
* origin/topic/vern/GH-3159.B:
  Fix for nested "when" statements leading to confusion over scoping
2023-07-06 11:35:47 +02:00
Robin Sommer
65e5e739d0
[Spicy] Support switch fields when exporting Spicy types to Zeek.
Closes #3157.
2023-07-06 08:40:54 +02:00
Vern Paxson
a1d25670fc Fix for nested "when" statements leading to confusion over scoping 2023-07-05 17:10:38 -07:00
Tim Wojtulewicz
d1ed0e577b Merge remote-tracking branch 'origin/topic/awelzel/3028-connection-flipped'
* origin/topic/awelzel/3028-connection-flipped:
  Update dump-events baseline, not running with OpenSSL 3
  Conn: In-place val flip and connection_flipped()
  Conn: Remove is_version_sep()
  Remove icmp_conn leftovers
2023-07-05 13:32:34 -07:00
Arne Welzel
fe71202f25 Merge remote-tracking branch 'origin/topic/awelzel/global-ids-with-modules'
* origin/topic/awelzel/global-ids-with-modules:
  global_ids(): Include module names
2023-07-05 15:33:30 +02:00