Commit graph

16629 commits

Author SHA1 Message Date
Robin Sommer
a89694b32d
Zeekygen: Merge in Spicy analyzer documentation.
This now merges information on analyzers from both plugins and Spicy.

Closes #3306.
2023-09-21 10:54:03 +02:00
Robin Sommer
8a3d645caf
Zeekygen: Refine location tracking for Spicy events.
When Spicy defines an event through EVT, it would end up with
more-or-less random, stale Zeek-side location information. Now making
sure it's unset, plus then using any script-side prototype we may
encounter later to update it.

Also fixing a couple location comparisons that I believe were broken
because we do sometimes copy location objects and hence can't compare
by pointer.
2023-09-21 10:54:03 +02:00
Robin Sommer
d45d197c21
Zeekygen: Refactor code documenting analyzers.
No functional change, but we refactor the logic to

1. Untie the function signature from the fact that the information
   currently comes only out of plugins.
2. Avoid some redundancies

In the next commit, we'll use this to add information from Spicy EVT
files into the output.
2023-09-21 10:54:02 +02:00
Robin Sommer
330440bb70
Add %doc-* tags to Syslog and Finger analyzers.
Same ID/text as the legacy analyzers are using.
2023-09-21 10:54:02 +02:00
Robin Sommer
6f882af7cc
Spicy: Support additional documentation tags inside EVT files.
So far we had trouble documenting Spicy analyzers through Zeekygen
because they would show up as components belonging to the
`Zeek::Spicy` plugin; whereas traditional analyzers would be their own
plugins and hence documented individually on their own. This commit
teaches Zeekygen to track Spicy analyzers separately inside their own
`Info` instances. This information isn't further used in this commit
yet, but will be merged with the plugin output in a subsequent change
to get the expected joint output.

To pass additional information to Zeekygen, EVT files now also support
two new tags for Zeekygen purposes:

- `%doc-id = ID;` defines the global ID under which everything inside
  the EVT file will be documented by Zeekygen, conceptually comparable
  to plugin names (e.g., `Zeek::Syslog`).

- `%doc-description = "text" provides additional text to go into the
  documentation (comparable to plugin descriptions).

This information is carried through into the HLTO runtime
initialization code, from where it's registered with Zeekygen.

This commit also removes a couple of previous hacks of how Spicy
integrated with Zeekygen which (1) ended up generating broken doc output
for Spicy components, and (2) don't seem to be necessary anymore
anyways.
2023-09-21 10:54:02 +02:00
Robin Sommer
7544aedb6a
Fix lack of namespace qualification inside an include file. 2023-09-21 10:54:02 +02:00
Robin Sommer
94de54ee74
Exclude script from documentation that interferes with other locations. 2023-09-21 10:54:02 +02:00
Robin Sommer
a9de8eec21
Merge remote-tracking branch 'origin/topic/robin/gh-3298-bitfields'
* origin/topic/robin/gh-3298-bitfields:
  Spicy: Fix support for exporting bitfields.
  Bump Spicy.
2023-09-21 09:56:51 +02:00
Robin Sommer
f31aa0580a
Spicy: Fix support for exporting bitfields.
Anonymous bitfields now have their fields lifted into the surrounding
record.

Closes #3298.
2023-09-21 09:55:12 +02:00
Robin Sommer
7233498cdb
Bump Spicy. 2023-09-21 09:55:12 +02:00
Benjamin Bannier
0b940d8b3c Merge branch 'topic/bbannier/spicyz-export-with-debug-output' 2023-09-20 13:05:04 +02:00
Benjamin Bannier
df62ae1f7d Updating submodule(s) [nomail] 2023-09-20 12:47:43 +02:00
Arne Welzel
4a7f03ee0c Merge remote-tracking branch 'origin/topic/awelzel/ci-benchmark-more-parameters'
* origin/topic/awelzel/ci-benchmark-more-parameters:
  ci/benchmark: Send more Cirrus, GitHub and Zeek version information
2023-09-19 19:56:54 +02:00
Arne Welzel
7b28152a92 ci/benchmark: Send more Cirrus, GitHub and Zeek version information
I wonder if we hit a query string limitation and should instead switch
to post body here. It's the `curl -G -X POST` part making this a POST
with a long query string.
2023-09-19 19:10:09 +02:00
Tim Wojtulewicz
e6ffa41aad Merge remote-tracking branch 'origin/topic/timw/telemetry-includes'
* origin/topic/timw/telemetry-includes:
  Remove some unnecessary includes of telemetry headers
2023-09-18 10:46:44 -07:00
Benjamin Bannier
3e91fd3115 Correctly compute name for spicyz export with debug log.
In 36a6770e98 we changed the way Spicy
fields exported as
record fields are represented. This broke the `zeek` debug log which
hardcoded a different representation.

This patch brings the generation of the debug log in line with the
actual AST structure. We also enable debug logging in one test to
validate that it works, at least for the case we hit here.
2023-09-18 16:05:42 +02:00
Tim Wojtulewicz
10c4f99d50 Remove some unnecessary includes of telemetry headers 2023-09-15 13:08:06 -07:00
Arne Welzel
2c4f64bc15 Merge remote-tracking branch 'origin/topic/awelzel/zeekjs-0-9-5'
* origin/topic/awelzel/zeekjs-0-9-5:
  Update zeekjs submodule
2023-09-15 12:11:32 +02:00
Arne Welzel
4f9b974e04 Merge remote-tracking branch 'origin/topic/awelzel/cmake-spicy-python3-hint'
* origin/topic/awelzel/cmake-spicy-python3-hint:
  CMakeLists: Set Python3_EXECUTABLE hint for spicy
2023-09-15 11:58:23 +02:00
Arne Welzel
3b859f3def Merge remote-tracking branch 'origin/topic/christian/gh-3263-table-constructor-index'
* origin/topic/christian/gh-3263-table-constructor-index:
  Avoid assertion/tag error on invalid table constructor index expression
2023-09-15 11:57:22 +02:00
Arne Welzel
30dc6af831 Merge remote-tracking branch 'origin/topic/bbannier/issue-3279'
* origin/topic/bbannier/issue-3279:
  Fix handling of module scope when checking exported Spicy types for collisions
2023-09-15 11:57:04 +02:00
Arne Welzel
bdb085af5f CMakeLists: Set Python3_EXECUTABLE hint for spicy 2023-09-15 11:39:21 +02:00
Arne Welzel
e424b383cd Update zeekjs submodule
Primarily for the following fixes:

	4dfc0dd Nodejs: Do not use UV_RUN_DEFAULT during InitPostScript()
	ade764e Nodejs: Unset kNoInitializeCppgc for Node 20.6 or higher
	a38df85 Fix type check of parameters array with zeek.event
	deddadd Fix type check of parameters array with zeek.invoke
2023-09-15 11:33:37 +02:00
Johanna Amann
e18edfa452 Add extract_limit_includes_missing option for file extraction
Setting this option to false does not count missing bytes in files towards the
extraction limits, and allows to extract data up to the desired limit,
even when partial files are written.

When missing bytes are encountered, files are now written as sparse
files.

Using this option requires the underlying storage and utilities to support
sparse files.
2023-09-14 12:11:42 -07:00
Johanna Amann
9928f7efb7 File extraction: use fseek
In the past, we allocated a buffer with zeroes and wrote that with
fwrite. Now, instead we just fseek to the correct offset.

This changes the way in which the file extract limit is counted a bit;
skipped bytes do no longer count against the file size limit.

(cherry picked from commit 5071592e9b7105090a1d9de19689c499070749d4)
2023-09-14 12:11:37 -07:00
Tim Wojtulewicz
5934e143aa Revert "Add extract_limit_includes_missing option for file extraction"
This reverts commit f4d0fdcd5c.
2023-09-14 12:10:40 -07:00
Christian Kreibich
87874a62d1 Avoid assertion/tag error on invalid table constructor index expression
If an index expression in a table constructor isn't a list, don't abort with an
assertion failure (on debug builds) or a bad tag check. Instead, mark the
constructor expression erroneous and return gracefully. The following...

  global a_table: table[subnet] of string = {
        1.2.3.4/24 = "unspecified",    # should have been [1.2.3.4/24] = "unspecified",
  };

...now yields:

  $ zeek ./test.zeek
  error in ././test.zeek, line 2: table constructor index is not a list (1.2.3.0/24 = unspecified)
  error in ././test.zeek, line 2: type clash in assignment (a_table = table(1.2.3.0/24 = unspecified))
2023-09-13 23:10:44 -07:00
Benjamin Bannier
4f0f22ec78 Fix handling of module scope when checking exported Spicy types for collisions
When checking exported Spicy types for collisions with existing Zeek
types we previously would also check whether they collide with names in
global scope, i.e., we didn't provide a `no_global` arg to
`detail::lookup_ID` which defaulted to false (since we also provided a
module name I'd argue that the behavior of that function is confusing
and probably error-prone -- like seen here).

This meant that e.g., a Spicy enum `foo::Direction` (automatically in
implicit Spicy module scope) would be detected to collide with the
existing Zeek `Direction` enum.

With this patch we use the `lookup_ID` API correctly and do not check
against potential collisions with globals anymore since it is not
needed.

Closes #3279.
2023-09-13 16:33:07 +02:00
zeek-bot
17347df036 Update doc submodule [nomail] [skip ci] 2023-09-13 00:46:38 +00:00
Tim Wojtulewicz
8c559915f7 Merge remote-tracking branch 'origin/topic/timw/fix-master-tests'
* origin/topic/timw/fix-master-tests:
  Update dump-events test baseline after latest master changes
2023-09-12 17:00:39 -07:00
Tim Wojtulewicz
dc23d7d3f3 Update dump-events test baseline after latest master changes 2023-09-12 15:34:38 -07:00
Johanna Amann
f4d0fdcd5c Add extract_limit_includes_missing option for file extraction
Setting this option to false does not count missing bytes in files towards the
extraction limits, and allows to extract data up to the desired limit,
even when partial files are written.

When missing bytes are encountered, files are now written as sparse
files.

Using this option requires the underlying storage and utilities to support
sparse files.

(cherry picked from commit afa6f3a0d3b8db1ec5b5e82d26225504c2891089)
2023-09-12 12:00:36 -07:00
Arne Welzel
b2c40a22cb ftp: Do not log non-pending commands
OSS Fuzz generated a CWD request and reply followed by very many EPRT
requests. This caused Zeek to re-log the CWD request and invoke `build_url_ftp()`
over and over again resulting in long processing times.

Avoid this scenario by not logging commands that aren't pending anymore.

(cherry picked from commit b05dd31667ff634ec7d017f09d122f05878fdf65)
2023-09-12 12:00:36 -07:00
Arne Welzel
f6e7ea43c3 http/smtp: Fix wrong character class usage
A call to `extract_filename_from_content_disposition()` is only
efficient if the string is guaranteed to contain the pattern that
is removed by `sub()`. Due to missing brackets around the `[:blank:]`
character class, an overly long string (756kb) ending in
"Type:dtanameaa=" matched the wrong pattern causing `sub()` to
exhibit quadratic runtime. Besides that, we may have potentially
extracted wrong information from a crafted header value.

(cherry picked from commit 6d385b1ca724a10444865e4ad38a58b31a2e2288)
2023-09-12 12:00:36 -07:00
Tim Wojtulewicz
9af7d830e7 VLAN: Fix length checking for non-Ethernet type 2 frames
(cherry picked from commit c579eb7b7cf3ca1d9008e74d7934155866c7e4f7)
2023-09-12 12:00:36 -07:00
Tim Wojtulewicz
f5a3da5945 Make sure that all sessions/connections are done before deleting plugins
(cherry picked from commit e29b499a211137cf3cf0c24a4ff82db1b806f132)
2023-09-12 12:00:36 -07:00
Arne Welzel
cca5a8ca5d Merge remote-tracking branch 'origin/topic/awelzel/deferred-default-non-const-v4'
* origin/topic/awelzel/deferred-default-non-const-v4:
  CreationInitsOptimizer: Use PreTypedef() instead of PreType()
  Fix deferred record initialization
  testing/btest: Un-deferred record initalization tests
2023-09-12 20:52:17 +02:00
Arne Welzel
6c76df4e10 CreationInitsOptimizer: Use PreTypedef() instead of PreType()
PreTypedef() does not require the PreID() trampoline and ensures
it's only called for IDs that are types. Also allows dropping
the const_cast<> due to id->GetType() returning a const TypePtr which
is different from a `const Type*`...
2023-09-12 20:23:46 +02:00
Arne Welzel
384e7e6b25 Fix deferred record initialization
Put RecordFieldInit instances into creation_inits during parsing and
determine their deferrability in an InitPostScript step. Any
RecordFieldInits can be deferred are moved into deferred_inits.

Closes #3260
2023-09-12 12:21:31 +02:00
Arne Welzel
7d6c8d7224 testing/btest: Un-deferred record initalization tests
These baselines should align with what Zeek 5.2 or before did.
2023-09-12 12:12:46 +02:00
zeek-bot
e7a747d3b2 Update doc submodule [nomail] [skip ci] 2023-09-12 00:31:02 +00:00
Tim Wojtulewicz
b783441428 Merge branch 'topic/timw/file-analyzer-dict-hash'
* topic/timw/file-analyzer-dict-hash:
  Move allocation of analyzer_hash to file_mgr
2023-09-11 10:16:05 -07:00
Tim Wojtulewicz
743d7e96f5 Move allocation of analyzer_hash to file_mgr 2023-09-11 10:15:38 -07:00
zeek-bot
607d72f7b9 Update doc submodule [nomail] [skip ci] 2023-09-09 00:38:25 +00: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
02184625b0 Merge remote-tracking branch 'origin/topic/awelzel/3267-avoid-unnecessary-inits'
* origin/topic/awelzel/3267-avoid-unnecessary-inits:
  ID/Stmt: Introduce INIT_SKIP and use in ForStmt
  CompositeHash: Skip record initialization when recovering vals
2023-09-08 13:48:47 +02:00
Arne Welzel
cea7c0ab46 ID/Stmt: Introduce INIT_SKIP and use in ForStmt
Currently, loop vars are added to a function scope's inits and
initialized upon entering a function with default values. This
applies to vector, record and table types.

This is unnecessary for variables used in for loops as they are
guaranteed to be initialized while iterating.
2023-09-08 13:05:44 +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
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
2fd83acc49 Merge remote-tracking branch 'origin/topic/awelzel/3275-fix-with-python'
* origin/topic/awelzel/3275-fix-with-python:
  ci: update-alternative to have python3 be python3.9
  Add OpenSUSE Leap 15.5 to ci
  configure/CMakelists: Use Python_EXECUTABLE as hint for interpreter
2023-09-07 14:28:16 +02:00