Commit graph

15378 commits

Author SHA1 Message Date
Tim Wojtulewicz
3757a350cd Updating submodule(s) [nomail] 2023-05-19 09:50:22 -07:00
Arne Welzel
d4c99e7c3f files: Warn once for missing get_file_handle()
Repeating the message for every new call to get_file_handle() is not
very useful. It's pretty much an analyzer configuration issue so logging
it once should be enough.
2023-05-19 09:37:51 -07:00
Arne Welzel
9bda48d17c MIME: Re-use cur_entity_id for EndOfFile()
If DataIn() was called and a cur_entity_id (file_id) has been produced
previously, re-use it for calls to EndOfFile(). This avoids a costly
event_mgr.Drain() when we already have that information. It should be safer,
too, as `get_file_handle()` in script may generate a different ID and
thereby de-synchronizing.
2023-05-19 09:37:35 -07:00
Arne Welzel
3cceb7d1c0 zeek-fuzzer-setup: Configure fake DNS
I'm not sure if we somehow set this for oss-fuzz through the environment,
but didn't find anything obvious.

Running oss-fuzz reproducers locally can triggers lookups to malware.hash.cymru.com
and potentially other domains due to loading local.zeek.
2023-05-19 09:37:29 -07:00
Arne Welzel
bbcdb6494e SupportAnalyzer: Stop delivering to disabled parent analyzer
When the parent of a support analyzer has been disabled, short-circuit
delivering stream or packet data to it.

The specific scenario this avoids is the Content-Line analyzer continuing
to feed data lines into an disabled SMTP analyzer in turn creating more
events.

This is primarily useful for our fuzzing setup where data chunks up to 1MB
are generated and fed into the analyzer pipeline. In the real-world, chunk
sizes are usually bounded to packet size. Certain TCP reassembly constellations
may trigger these scenarios, however.

Closes #168
2023-05-19 09:37:23 -07:00
Tim Wojtulewicz
fc78b14cd7 Add length checking to ToRawPktHdrVal for truncated packets 2023-05-19 09:37:18 -07:00
Arne Welzel
64f84aba34 ftp: No unbounded directory command re-use
OSS-Fuzz generated traffic containing a CWD command with a single very large
path argument (427kb) starting with ".___/` \x00\x00...", This is followed
by a large number of ftp replies with code 250. The directory logic in
ftp_reply() would match every incoming reply with the one pending CWD command,
triggering path buildup ending with something 120MB in size.

Protect from re-using a directory command by setting a flag in the
CmdArg record when it was consumed for the path traversal logic.

This doesn't prevent unbounded path build-up generally, but does prevent the
amplification of a single large command with very many small ftp_replies.
Re-using a pending path command seems like a bug as well.
2023-05-19 09:37:12 -07:00
Tim Wojtulewicz
d4eb71ab8f Merge remote-tracking branch 'origin/topic/robin/spicy-search-path-fix'
* origin/topic/robin/spicy-search-path-fix:
  Fix CMake ordering issue leaving configuration paths unset.
2023-05-18 08:54:56 -07:00
Robin Sommer
933bd017f1
Fix CMake ordering issue leaving configuration paths unset. 2023-05-18 10:38:29 +02:00
zeek-bot
0c995c5f70 Update doc submodule [nomail] [skip ci] 2023-05-18 00:43:02 +00:00
Arne Welzel
b8a088d6f0 Merge remote-tracking branch 'origin/topic/awelzel/install-spicyz-config-h'
* origin/topic/awelzel/install-spicyz-config-h:
  Add license header to zeek-config*.h and zeek-version.h
  Rename util-config.h to zeek-config-paths.h and install it
  Ensure spicyz/config.h is installed
2023-05-17 16:11:15 +02:00
Arne Welzel
60be98e09b Add license header to zeek-config*.h and zeek-version.h 2023-05-17 15:02:15 +02:00
Arne Welzel
bc8b5f5830 Rename util-config.h to zeek-config-paths.h and install it
The util-config.h has never been installed previously. Skimming the history,
it was only meant for inclusion from util.cc, hence the name. Now that it's
included from some other headers, rename it to align with what it
contains and install it, too.
2023-05-17 15:01:57 +02:00
Arne Welzel
7bcf7af535 Ensure spicyz/config.h is installed 2023-05-17 13:26:12 +02:00
Robin Sommer
f14bfa63cf
Merge remote-tracking branch 'origin/topic/robin/spicy-path-fixes'
* origin/topic/robin/spicy-path-fixes:
  Introduce environment variables to override more paths configured into `spicyz`.
  Fix an ordering issue in Spicy support's CMake config.
2023-05-17 12:50:26 +02:00
Robin Sommer
e27da9d608
Introduce environment variables to override more paths configured into
`spicyz`.

These serve as fallback option if something isn't quite where
expected at runtime.
2023-05-17 12:09:13 +02:00
Arne Welzel
c2a07476cc Merge remote-tracking branch 'jgras/topic/jgras/cluster-active-node-count-fix'
* jgras/topic/jgras/cluster-active-node-count-fix:
  Fix get_active_node_count for node types not present.

Changed over to explicit existence check instead to avoid the set()
creation upon missed lookups.
2023-05-17 10:37:00 +02:00
Robin Sommer
fdf809ab2f
Fix an ordering issue in Spicy support's CMake config.
This led to variables left unset inside the subdirectory.
2023-05-17 10:19:12 +02:00
Arne Welzel
b20397d075 Update doc submodule [nomail] [skip ci] 2023-05-17 09:46:46 +02:00
Arne Welzel
2bd1ae9c92 Merge remote-tracking branch 'origin/topic/awelzel/zeekygen-param-doc-field'
* origin/topic/awelzel/zeekygen-param-doc-field:
  Bump doc submodule
  zeekygen: Render function parameters as :param x: instead of 
2023-05-17 09:03:27 +02:00
Arne Welzel
09876cfc84 Bump doc submodule
This bumps to a version that understands and renders :param x:
in a nicer way than what we have now (IMO).
2023-05-16 21:02:52 +02:00
Arne Welzel
2007eeae1b zeekygen: Render function parameters as :param x: instead of
We're currently rendering parameter descriptions from .bif file into
the .rst as follows:

    :cid: The connection identifier.

    :aid: The analyzer ID.

Switch this to :param cid: instead so that we can have Sphinx deal with
this as param docfield and group all parameters into a single section.

Currently, having the bare :cid: style causes sphinx to treat it as an
unknown field type, capitalize it and render it.
2023-05-16 20:21:12 +02:00
Jan Grashoefer
e4f654c14c Fix get_active_node_count for node types not present. 2023-05-16 17:47:50 +02:00
Robin Sommer
f6b28a6784
Merge remote-tracking branch 'origin/topic/robin/move-up-spicy'
* origin/topic/robin/move-up-spicy:
  Move Spicy submodule a layer up.
2023-05-16 12:45:15 +02:00
Robin Sommer
10477b38aa
Move Spicy submodule a layer up.
This moves `auxil/spicy/spicy` to `auxil/spicy`. It relocates the
pieces previously inside that intermediary directory. The main change
is that now tweak the compilation flags for Spicy through target
options.

This is on top of `topic/robin/spicy-plugin`.
2023-05-16 12:09:12 +02:00
Robin Sommer
85f8da6766
Merge remote-tracking branch 'origin/topic/robin/spicy-plugin'
* origin/topic/robin/spicy-plugin:
  Update doc submodule.
  Remove unused file.
  Move Spicy version information out of `zeek-config.h`.
  Revert unnecessary change to plugin class.
  Tweak format of `zkg` information in build info.
  Remove left-over file.
  Move `spicy/misc` scripts to policy and clarify purpose.
  Do not load Spicy scripts if Spicy is not available.
  Update comment.
  Use ccache on CI when compiling Spicy analyzers.
  Add `zkg_provides` to `--build-info`.
  Fix tuple type conversion.
  Fix generation of file IDs.
  Integrate the Spicy plugin into Zeek proper.
  Modernize plugin test.
2023-05-16 11:41:15 +02:00
Robin Sommer
714466f9cc
Update doc submodule. 2023-05-16 10:21:22 +02:00
Robin Sommer
f00eb35cf1
Remove unused file. 2023-05-16 10:21:22 +02:00
Robin Sommer
c335245586
Move Spicy version information out of zeek-config.h.
Turns out Spicy doesn't have nicely-named constant for version
information, but we can instead use spicyz's auto-generated `config.h`
for now.
2023-05-16 10:21:22 +02:00
Robin Sommer
90fd5c062a
Revert unnecessary change to plugin class. 2023-05-16 10:21:21 +02:00
Robin Sommer
40b1d8f913
Tweak format of zkg information in build info. 2023-05-16 10:21:21 +02:00
Robin Sommer
7945043192
Remove left-over file. 2023-05-16 10:21:21 +02:00
Robin Sommer
ecf00295c2
Move spicy/misc scripts to policy and clarify purpose. 2023-05-16 10:21:21 +02:00
Robin Sommer
a62e153dd3
Do not load Spicy scripts if Spicy is not available. 2023-05-16 10:21:21 +02:00
Robin Sommer
57eb7b4d2a
Update comment. 2023-05-16 10:21:21 +02:00
Robin Sommer
d874b2fae8
Use ccache on CI when compiling Spicy analyzers. 2023-05-16 10:21:20 +02:00
Robin Sommer
cc15948239
Add zkg_provides to --build-info.
This makes dependencies explicit that Zeek provides built-in for
`zkg`. It's in support of
https://github.com/zeek/package-manager/pull/157.

For now, `zkg_provides` contains the same data as `included_plugins`
plus an entry for `spicy-plugin`.
2023-05-16 10:21:20 +02:00
Robin Sommer
09a9a3e8f8
Fix tuple type conversion.
With an anonymous Spicy-side tuple type, we'd be missing an ID to
create a Zeek-side record, leading to undefined behavior. To still
support this case, we now make up an ID. In addition, we also could
end up not correctly tracking type ID during conversion; using a stack
now to handle recursion correctly.

We actually already have a test exercising the tuple code path, but it
took ASAN to spot the issue. Not sure how to test this beyond that.

Note: Need to backport this to the external plugin.
2023-05-16 10:21:20 +02:00
Robin Sommer
e6af74c8aa
Fix generation of file IDs.
They weren't stable, and potentially repetitive.

Note: We should backport this to the external plugin.
2023-05-16 10:21:20 +02:00
Robin Sommer
0040111955
Integrate the Spicy plugin into Zeek proper.
This reflects the `spicy-plugin` code as of `d8c296b81cc2a11`.

In addition to moving the code into Zeek's source tree, this comes
with a couple small functional changes:

- `spicyz` no longer tries to infer if it's running from the build
  directory. Instead `ZEEK_SPICY_LIBRARY` can be set to a custom
  location. `zeek-set-path.sh` does that now.

- ZEEK_CONFIG can be set to change what `spicyz -z` print out. This is
  primarily for backwards compatibility.

Some further notes on specifics:

- We raise the minimum Spicy version to 1.8 (i.e., current `main`
  branch).

- Renamed the `compiler/` subdirectory to `spicyz` to avoid
  include-path conflicts with the Spicy headers.

- In `cmake/`, the corresponding PR brings a new/extended version of
  `FindZeek`, which Spicy analyzer packages need. We also now install
  some of the files that the Spicy plugin used to bring for testing,
  so that existing packages keep working.

- For now, this all remains backwards compatible with the current
  `zkg` analyzer templates so that they work with both external and
  integrated Spicy support. Later, once we don't need to support any
  external Spicy plugin versions anymore, we can clean up the
  templates as well.

- All the plugin's tests have moved into the standard test suite. They
  are skipped if configure with `--disable-spicy`.

This holds off on adapting the new code further to Zeek's coding
conventions, so that it remains easier to maintain it in parallel to
the (now legacy) external plugin. We'll make a pass over the
formatting for (presumable) Zeek 6.1.
2023-05-16 10:17:45 +02:00
Robin Sommer
d8f7329227
Modernize plugin test.
Not using the `zeek/` include style could lead to path problems.
2023-05-15 16:08:47 +02:00
zeek-bot
fe8c2c69b5 Update doc submodule [nomail] [skip ci] 2023-05-13 00:41:08 +00:00
Arne Welzel
cfd239ad2c Merge remote-tracking branch 'origin/topic/awelzel/zeek-seed-env-2'
* origin/topic/awelzel/zeek-seed-env-2:
  Introduce ZEEK_SEED_VALUES environment variable
2023-05-12 23:45:47 +02:00
Tim Wojtulewicz
012e33426a Merge remote-tracking branch 'origin/topic/vern/event-tracing-update.May23B'
* origin/topic/vern/event-tracing-update.May23B:
  enhancements for event-tracing:   - reporting of potentially sensitive constants   - tracking of unsupported types enabling hand-editing to fix them   - fixed generation of "unspecified" aggregates   - fixed generation of IPv6 constants   - fixed generation when running without a packet source
2023-05-12 13:42:15 -07:00
Vern Paxson
1419803dbd enhancements for event-tracing:
- reporting of potentially sensitive constants
  - tracking of unsupported types enabling hand-editing to fix them
  - fixed generation of "unspecified" aggregates
  - fixed generation of IPv6 constants
  - fixed generation when running without a packet source
2023-05-12 13:17:18 -07:00
Tim Wojtulewicz
db00835797 Merge remote-tracking branch 'origin/topic/timw/update-broker'
* origin/topic/timw/update-broker:
  Update broker submodule [nomail]
2023-05-12 13:00:14 -07:00
Tim Wojtulewicz
eb5de051e3 Update broker submodule [nomail] 2023-05-12 12:44:31 -07:00
Tim Wojtulewicz
eba7f2c01e Update broker submodule [nomail] 2023-05-12 11:32:59 -07:00
Arne Welzel
b2d934226f Introduce ZEEK_SEED_VALUES environment variable
For "individually different but deterministic" runs specifying Zeek's
seed as an environment variable eases setups as one can avoid creating
extra seed files for each of the individual processes.

It is an error to specify the new ZEEK_SEED_VALUES variable together
with the existing ZEEK_SEED_FILE and -G. ZEEK_SEED takes precedence over
deterministic mode (-D) like ZEEK_SEED_FILE does today already.
2023-05-12 19:50:37 +02:00
Tim Wojtulewicz
b98ae9bdb2 Merge remote-tracking branch 'amazingpp/topic/fupeng/bad-pat-mem-leak'
* amazingpp/topic/fupeng/bad-pat-mem-leak:
  Fix memory leak caused by pattern compilation failure
2023-05-12 10:02:00 -07:00