Commit graph

437 commits

Author SHA1 Message Date
Tim Wojtulewicz
57a3c733d1 Reduce some false-positive warnings from GCC to warnings with -Werror
This also works around some of the same warnings. These are known bugs
in GCC 11+ and GCC 13.x.
2025-07-10 14:07:08 -07:00
Christian Kreibich
0c64f6a7b9 Establish plugin infrastructure for ConnKey factories.
ConnKey factories are intermediaries that encapsulate the details of how to
instantiate ConnKeys, which codify the hash input for connection lookups.
2025-06-25 13:18:07 +02:00
Christian Kreibich
d19fdfd17c Add new ConnKey abstraction. 2025-06-25 13:18:07 +02:00
Tim Wojtulewicz
c07519353f Avoid linting headers in external paths 2025-06-23 08:35:24 -07:00
Tim Wojtulewicz
9928403b0b Move type definitions/aliases from util.h to a separate file 2025-06-11 11:11:54 -07:00
Tim Wojtulewicz
4e5207b7f5 Skip linting on highwayhash and src/3rdparty files 2025-04-23 12:21:21 -07:00
Tim Wojtulewicz
7111d6a143 Disable linting for files generated by bison
These files will report lots of findings in the code that we have no
control over.
2025-04-17 09:26:55 -07:00
Tim Wojtulewicz
64e2fccc2b Make sure clang-tidy and iwyu are added to all targets 2025-04-17 09:26:55 -07:00
Tim Wojtulewicz
2ea0f3e70a Lay out initial parts for the Storage framework
This includes a manager, component manager, BIF and script code, and
parts to support new storage backend plugins.
2025-03-18 09:32:34 -07:00
Tim Wojtulewicz
36c1a3ca4a Remove existing hand-written clang-tidy setup 2025-03-07 11:00:44 -07:00
Tim Wojtulewicz
c1dd1e991e Add ability to enable iwyu and clang-tidy at configure time 2025-03-07 11:00:44 -07:00
Arne Welzel
ac9594ffae cluster: Add to src/CMakeLists.txt 2024-11-22 10:43:55 +01:00
Christian Kreibich
71f7e89974 Telemetry framework: move BIFs to the primary-bif stage
This moves the Telemetry framework's BIF-defined functionalit from the
secondary-BIFs stage to the primary one. That is, this functionality is now
available from the end of init-bare.zeek, not only after the end of
init-frameworks-and-bifs.zeek.

This allows us to use script-layer telemetry in our Zeek's own code that get
pulled in during init-frameworks-and-bifs.

This change splits up the BIF features into functions, constants, and types,
because that's the granularity most workable in Func.cc and NetVar. It also now
defines the Telemetry::MetricsType enum once, not redundantly in BIFs and script
layer.

Due to subtle load ordering issues between the telemetry and cluster frameworks
this pushes the redef stage of Telemetry::metrics_port and address into
base/frameworks/telemetry/options.zeek, which is loaded sufficiently late in
init-frameworks-and-bifs.zeek to sidestep those issues. (When not doing this,
the effect is that the redef in telemetry/main.zeek doesn't yet find the
cluster-provided values, and Zeek does not end up listening on these ports.)

The need to add basic Zeek headers in script_opt/ZAM/ZBody.cc as a side-effect
of this is curious, but looks harmless.

Also includes baseline updates for the usual btests and adds a few doc strings.
2024-10-18 09:56:29 -07:00
Arne Welzel
ec1088c3ef Merge remote-tracking branch 'origin/topic/vern/zam-regularization'
* origin/topic/vern/zam-regularization: (33 commits)
  simpler and more robust identification of function parameters for AST profiling
  fixes to limit AST traversal in the face of recursive types
  address some script optimization compiler warnings under Linux
  fix for -O C++ construction of variable names that use multiple module namespaces
  fix for script optimization of "opaque" values that are run-time constants
  fix for script optimization of nested switch statements
  script optimization fix for complex "in" expressions in conditionals
  updates to typos allow-list reflecting ZAM regularization changes
  BTest updates for ZAM regularization changes
  convert new ZAM operations to use typed operands
  complete migration of ZAM to use only public ZVal methods
  "-O validate-ZAM" option to validate generated ZAM instructions
  internal option to suppress control-flow optimization
  exposing some functionality for greater flexibility in structuring run-time execution
  rework ZAM compilation of type switches to leverage value switches
  add tracking of control flow information
  factoring of ZAM operation specifications into separate files
  updates to ZAM operations / gen-zam regularization, other than the operations themselves
  type-checking fix for vector-of-string operations
  ZVal constructor for booleans
  ...
2024-08-16 12:10:33 +02:00
Vern Paxson
1457099df3 "-O validate-ZAM" option to validate generated ZAM instructions 2024-08-16 11:18:58 +02:00
Vern Paxson
e94764982d factoring of ZAM operation specifications into separate files 2024-08-16 11:18:58 +02:00
Tim Wojtulewicz
2f8733e08d Don't install empty ZAM directories 2024-08-05 16:23:03 -07:00
Arne Welzel
003d2d1468 CMakeLists: Disable -Werror for 3rdparty/sqlite3.c
We package vanilla sqlite from upstream and on Fedora 40 with sqlite 3.46
there's the following compiler warning:

    In function 'sqlite3Strlen30',
        inlined from 'sqlite3ColumnSetColl' at
        ../../src/3rdparty/sqlite3.c:122105:10:
        ../../src/3rdparty/sqlite3.c:35003:28: error: 'strlen' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
    35003 |   return 0x3fffffff & (int)strlen(z);
          |                            ^~~~~~~~~
    In function 'sqlite3ColumnSetColl':

Disabling -Werror on sqlite3.c seems sensible given we have little
control over that code.
2024-06-18 10:03:32 +02:00
Vern Paxson
1989dc5e5a enable ZAM operation specifications to reside in multiple files (not yet used) 2024-05-08 12:50:49 -07:00
Vern Paxson
8d762eea54 ZAM classes in support of finer-grained profiling 2024-03-19 10:59:49 -07:00
Tim Wojtulewicz
2aaaab4dad Make BIFs just return ValPtr directly instead of BifReturnVal 2024-01-22 10:35:34 -07:00
Christian Kreibich
a06053ce75 Move MMDB logic out of mmdb.bif and into MMDB.cc/h.
This does not change the implementation except for some light renaming where
things are now naturally scoped within MMDB.cc.
2024-01-10 20:44:35 -08:00
Christian Kreibich
8406959ae2 Move MaxMind/GeoIP BiF functionality into separate file 2024-01-10 20:28:37 -08:00
Christian Kreibich
b4725c113f Sort toplevel .bif list in CMakeLists
Not important, but here it is safe to do so and the list is getting lengthy.
2024-01-10 20:14:24 -08:00
Tim Wojtulewicz
bbcc4b00fb Set -Werror / /WX via target_compile_options to force warnings as errors 2024-01-08 13:25:05 -07:00
Vern Paxson
dd389c0380 splitting off script optimization CSE into its own source files 2023-12-12 09:45:19 +01:00
Vern Paxson
c028901146 script optimization support for tracking information associated with BiFs/functions 2023-12-04 16:53:57 -08:00
Tim Wojtulewicz
c743be0c54 Remove usage of FindRequiredPackage 2023-08-07 09:33:52 -07:00
Tim Wojtulewicz
1991b87a07 Reduce amount of files passed to clang-tidy 2023-07-07 09:17:05 -07:00
Benjamin Bannier
c718f7f632 Prefer Spicy include directories of this build over accidental ones.
Closes #3153.
2023-06-27 14:45:44 +02:00
Arne Welzel
6efc696179 formatters/JSON: Prepare to remove rapidjson from installed Zeek headers
threading/formatters/JSON.h currently includes rapidjson headers for declaring
the NullDoubleWriter. This appears mostly an internal detail, but
results in the situation that 1) we need to ship rapidjson headers with
the Zeek install tree and 2) taking care that external plugins are able
to find these headers should they include formatters/JSON.h.

There are currently no other Zeek headers that include rapidjson, so this
seems very unfortunate and self-inflicted given it's not actually required.

Attempt to hide this implementation detail with the goal to remove the
rapidjson includes with v7.1 and then also stop bundling and exposing
the include path to external plugins.

The NullDoubleWriter implementation moves into a new formatters/detail/json.h
header which is not installed.

Closes #3128
2023-06-17 13:48:25 +02:00
Tim Wojtulewicz
62382e6cb9 Force -std=c++17 mode for plugin targets, remove use of RequireCXX17.cmake 2023-06-15 09:51:32 -07:00
Tim Wojtulewicz
4229af6820 Remove deprecations tagged for v6.1 2023-06-14 10:07:22 -07:00
Tim Wojtulewicz
0203e7cd58 bison_target argument changes from HEADER to DEFINES_FILE 2023-05-31 14:28:51 +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
Arne Welzel
4ef019a637 CMakeLists: Skip zeek-version.h include for zeek_objs, too
I've continued to see somewhat slower builds after Zeek version bumps. It
appears files covered by zeek_objs didn't have -DZEEK_CONFIG_SKIP_VERSION_H
set causing ccache invalidation after a version bump.
2023-05-25 20:54:33 +02:00
Vern Paxson
052cda9df0 classes for tracking "@if (...) &analyze" notion of code being/not being "activated" 2023-05-19 12:43:12 -07: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
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
Tim Wojtulewicz
84e3f414a7 Use the same rules as cmake submodule to reformat Zeek 2023-05-09 08:31:43 -07:00
Arne Welzel
a3ef8783b1 Merge remote-tracking branch 'origin/topic/neverlord/gh-2806'
* origin/topic/neverlord/gh-2806:
  test/builtin-plugins: Add plugin using ZEEK_VERSION_NUMBER
  Revert putting plugins into a fresh scope for now
  Propagate zeek-version.h skip via CMake properties
2023-04-27 13:23:14 +02:00
Dominik Charousset
9971121509 Revert putting plugins into a fresh scope for now 2023-04-25 17:20:33 +02:00
Dominik Charousset
1715028986 Propagate zeek-version.h skip via CMake properties
Add a define for `ZEEK_CONFIG_SKIP_VERSION_H` to static plugins as well
as to dynamic plugins that we build alongside Zeek. When including
`zeek-config.h` with this macro defined, the header skips including
`zeek-version.h`.
2023-04-24 17:51:25 +02:00
Arne Welzel
2891b8af44 cmake: Fixup BRO_PLUGIN_INSTALL_PATH references
Commit 19cbb328a9 removed setting of
BRO_PLUGIN_INSTALL_PATH in favor of ZEEK_PLUGIN_DIR. Replace left-over
references the former.
2023-04-24 12:15:37 +02:00
Christian Kreibich
99de7b7526 Add community_id_v1() based on corelight/zeek-community-id
"Community ID" has become an established flow hash for connection correlation
across different monitoring and storage systems. Other NSMs have had native
and built-in support for Community ID since late 2018. And even though the
roots of "Community ID" are very close to Zeek, Zeek itself has never provided
out-of-the-box support and instead required users to install an external plugin.

While we try to make that installation as easy as possible, an external plugin
always sets the bar higher for an initial setup and can be intimidating.
It also requires a rebuild operation of the plugin during upgrades. Nothing
overly complicated, but somewhat unnecessary for such popular functionality.

This isn't a 1:1 import. The options are parameters and the "verbose"
functionality  has been removed. Further, instead of a `connection`
record, the new bif works with `conn_id`, allowing computation of the
hash with little effort on the command line:

    $ zeek -e 'print community_id_v1([$orig_h=1.2.3.4, $orig_p=1024/tcp, $resp_h=5.6.7.8, $resp_p=80/tcp])'
    1:RcCrCS5fwYUeIzgDDx64EN3+okU

Reference: https://github.com/corelight/zeek-community-id/
2023-04-21 20:44:09 +02:00
Dominik Charousset
9aeed5284d Redesign subdir-libs and plugin scaffolding 2023-04-13 22:23:46 +02:00
Arne Welzel
3284259561 Add zeek -V/--build-info
This adds a new utility called ci/collect-repo-info.py to produce a JSON
document that is then baked into the Zeek executable file. Further, when
creating a tarball via `make dist`, put a top-level repo-info.json file
in place that is picked when no .git directory exists.

Closes #1405
2023-02-13 12:23:29 +01:00
Tim Wojtulewicz
58f4ff91d8 Fixes to support the Npcap library on Windows
- Ignore conan libpcap if PCAP_ROOT_DIR is passed
- Update the cmake submodule to pick up changes for finding the right
  paths to npcap
- Add lazy-loading of npcap so the library path gets set correctly
  at startup
2023-01-11 11:42:58 -07:00
Tim Wojtulewicz
dd6e4a65ee GH-2637: Re-remove the bro symlink wrapper 2022-12-16 08:16:11 -07:00