Commit graph

348 commits

Author SHA1 Message Date
Robin Sommer
a3e170093d
Set SPICY_BUILD_DIRECTORY in zeek-path-dev.
Having this set allows running Spicy tests from inside
`auxil/spicy/tests`.
2023-07-05 11:32:34 +02:00
Tim Wojtulewicz
d5e2531b2f Add /J flag on Windows to force unsigned char 2023-06-30 13:48:24 -07:00
Tim Wojtulewicz
25da02fe50 Move CMake template files to separate directory 2023-06-26 13:39:59 -07: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
Arne Welzel
2fddddbf51 Merge remote-tracking branch 'origin/topic/awelzel/3090-propagate-doctest-defines'
* origin/topic/awelzel/3090-propagate-doctest-defines:
  Options: Do not output full usage on --test error
  CMakeLists: Propagate DOCTEST defines to external plugins
2023-06-15 18:35:32 +02:00
Arne Welzel
07b869e645 CMakeLists: Propagate DOCTEST defines to external plugins
If Zeek has not been built with doctest enabled then it's not easy
to run a plugin's tests (and if they really wanted to they could
again undef the DOCTEST_CONFIG_DISABLE and provide their own doctest
main() implementation.

Relates to #3090
2023-06-15 13:56:32 +02:00
Arne Welzel
2c4b2306fa CMakeLists: Add rapidjson/include to zeek_dynamic_plugin_base
threading/formatters/JSON.h has a rapidjson include. Extend the
include directories of external plugins so they are setup to find
these in Zeek's install tree.

Relates to #3090
2023-06-15 12:23:20 +02:00
Benjamin Bannier
eb1c7eff6c Clarify subitem relationship in CMake configure summary. 2023-06-09 13:31:53 +02:00
Tim Wojtulewicz
ef2473564e Revert part of previous CMake debug type fix 2023-05-22 16:11:58 -07:00
Christian Kreibich
3a55cf3911 Fix CMAKE_BUILD_TYPE_LOWER definition-vs-use ordering problem
It needs to be defined by the time we create zeek-config, which happens before
its current definition. To avoid a redundant TOLOWER when we check for presence
of --enable-debug at the beginning, this also switches this to a case-unadjusted
comparison to "Debug", which we use elsewhere in the file too.
2023-05-19 17:08:10 -07:00
Robin Sommer
933bd017f1
Fix CMake ordering issue leaving configuration paths unset. 2023-05-18 10:38:29 +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
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
57eb7b4d2a
Update comment. 2023-05-16 10:21:21 +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
Arne Welzel
8c0e7cd8bc Merge remote-tracking branch 'origin/topic/neverlord/version-header'
* origin/topic/neverlord/version-header:
  testing/zeek-version-link: Assume nm is there
  Drop dependency for zeek_dynamic_plugin_base
  Fixup ifdef check in Plugin.h
  Update cmake_minimum_required() in test plugins
  testing: Add zeek-version-link tests
  Clean up ZEEK_CONFIG_SKIP_VERSION_H issues

cmake-format during merge
2023-05-10 23:33:11 +02:00
Dominik Charousset
879f605407 Drop dependency for zeek_dynamic_plugin_base 2023-05-10 16:59:07 +02:00
Tim Wojtulewicz
84e3f414a7 Use the same rules as cmake submodule to reformat Zeek 2023-05-09 08:31:43 -07:00
Dominik Charousset
986834dce7 Clean up ZEEK_CONFIG_SKIP_VERSION_H issues 2023-05-08 18:05:56 +02:00
Arne Welzel
02b7439d44 Revert "Skip version.h by default for Zeek sources"
This reverts commit 8246baf25c.

Actually fails the include_plugins CI test and I had just
opened another related issue.
2023-05-05 21:05:17 +02:00
Dominik Charousset
8246baf25c Skip version.h by default for Zeek sources 2023-05-05 17:12:10 +02:00
Dominik Charousset
94ec8167b2
Integrate review feedback
Co-authored-by: Tim Wojtulewicz <timwoj@gmail.com>
2023-05-02 21:24:53 +02:00
Dominik Charousset
c2c34148ca Fix CMake option defaults on Windows 2023-05-02 20:43:33 +02:00
Dominik Charousset
7af3611807 Move build defaults from configure to CMake
Moving the defaults for build variables from the `configure` script to
`CMakeLists.txt` gives the same default behavior on platforms where the
`configure` script is not available (Windows) and also allows a pure
CMake-based work flow (e.g., the standard `cmake -S . -B build`) without
having to manually adjust the defaults.

The `configure` script also becomes much simpler as a result.
2023-04-29 11:04:30 +02:00
Tim Wojtulewicz
08a039446f Add template file and cmake call for zeek-path setup on Windows 2023-04-25 15:15:04 -07:00
Dominik Charousset
19cbb328a9 Fix install directory for plugins 2023-04-22 16:12:22 +02:00
Dominik Charousset
12ea6ed478 Improve CMake variables, update cmake submodule 2023-04-18 21:17:33 +02:00
Dominik Charousset
1d81fb4fb0 Fix builds with plugins that use zeek-config
When building plugins externally with `zeek-config` (as opposed to using
`ZEEK_DIST`), they point into the install prefix. There, we add a new
file `ZeekPluginBootstrap.cmake` that helps `ZeekPlugin.cmake` to find
everything else it needs from there.

Our template for plugins generates a `configure` script that sets
various variables with values from `zeek-config`. We only need
`BROKER_ROOT_DIR` with the new bootstrapping logic. Everything else, we
can get from the new bootstrapping file and from the CMake package file
for Zeek.
2023-04-15 00:08:42 +02:00
Arne Welzel
832291fd92 CMakeLists: Convert string append to list append
Seems the builtin plugins started with string(APPEND ...) and that
was copied over. Make it list(APPEND ...) instead.
2023-04-14 11:26:47 +02:00
Arne Welzel
f0b9c59adb Add experimental JavaScript support when libnode is available
zeek.on('zeek_init', () => {
        console.log('Hello, Zeek!');
    });

For interaction with external systems and HTTP APIs, JavaScript and the
Node.js ecosystem beat Zeek script. Make it more easily accessible by
including ZeekJS with Zeek directly.

When a recent enough libnode version is found on the build system, ZeekJS is
added as a builtin plugin. This behavior can be disabled via
``--disable-javascript``. Linux distributions providing such a package are
Ubuntu (22.10) and Debian (testing/bookworm) as libnode-dev.
Fedora provides it as nodejs-devel.

This plugin takes over loading of .js or .cjs files. When no such files
are provided to Zeek, Node and the V8 engine are not initialized and
should not get into the way.

This should be considered experimental.
2023-04-14 11:26:41 +02:00
Dominik Charousset
9aeed5284d Redesign subdir-libs and plugin scaffolding 2023-04-13 22:23:46 +02:00
Arne Welzel
d23b1331e5 zeek-config: Move ZEEK_VERSION* out of zeek-config.h
When bumping the VERSION file, everything that includes the auto-generated
zeek/zeek-config.h needs to rebuild and ccache usage is voided due the file
changing. Split the mutable version information into a new zeek-version.h
file to avoid this.

Further, do not include zeek-version.h within Plugin.h and avoid the reference
to ZEEK_VERSION_FUNCTION unless we're building an external plugin.

Closes #2776.
2023-02-22 16:48:39 +01:00
Tim Wojtulewicz
d34e4fb29b Call python explicitly from cmake for collecting repo info on Windows 2023-02-15 10:47:43 -07: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
Robin Sommer
bc252c63dc
Add BIF have_spicy_analyzers().
We previously used the Spicy plugin's `Spicy::available` to test for
Spicy support. However, having Spicy support does not necessarily mean that we
have built Zeek with its in-tree Spicy analyzers: the Spicy plugin
could have been pulled in from external. The new BIF now reliably
tells us whether the Spicy analyzers are available; its result
corresponds to what `zeek-config --have-spicy-analyzers` returns as
well.

We also move the two current checks over to use this BIF.

(Note: I refrained from renaming the CMake-side `USE_SPICY_ANALYERS`
to `HAVE_SPICY_ANALYZERS`. We should do this eventually for
consistency, but I didn't want to make more changes than necessary
right now.)
2023-02-03 13:47:26 +01:00
Robin Sommer
04a1ead978
Provide infrastructure to migrate legacy analyzers to Spicy.
As initial examples, this branch ports the Syslog and Finger analyzers
over. We leave the old analyzers in place for now and activate them
iff we compile without any Spicy.

Needs `zeek-spicy-infra` branches in `spicy/`, `spicy-plugin/`,
`CMake/`, and `zeek/zeek-testing-private`.

Note that the analyzer events remain associated with the Spicy plugin
for now: that's where they will show up with `-NN`, and also inside
the Zeekygen documentation.

We switch CMake over to linking the runtime library into the plugin,
vs. at the top-level through object libraries.
2023-02-01 11:33:48 +01:00
Tim Wojtulewicz
1f0860b5e2 Make sure the DEBUG flag is defined when building in debug mode
MSVC uses _DEBUG, unlike all of the other compilers, so we aren't
properly enabling/disabling varying bits of code that are dependent
on DEBUG being defined.
2023-01-19 09:13:33 -07:00
Tim Wojtulewicz
e44eb3522e Fix zeek-path-dev.sh creation to better support Windows 2023-01-19 09:13:33 -07: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
Tim Wojtulewicz
a0659994f0 Merge remote-tracking branch 'origin/topic/bbannier/issue-2586'
* origin/topic/bbannier/issue-2586:
  Make dependency of `zeek` on spicy-plugin's driver object file explicit.
2022-11-17 11:34:55 -07:00
Josh Soref
4b7eb50892 Spelling NEWS & CMakeLists.txt
* analyzer
* calling
* can
* compatibility
* configurable
* conjunction
* connection
* corresponding
* currently
* evaluated
* framework
* frequently
* functionality
* handshake
* information
* more
* necessary
* occurred
* ocsp
* potentially
* preexisting
* serialized
* superseded
* synchronized
* timer
* unnecessary
* workarounds

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-16 20:21:38 -05:00
Benjamin Bannier
b94c8bc91b Make dependency of zeek on spicy-plugin's driver object file explicit.
For generators like Makefile the implicit dependency would not have been
apparent to `make` which could have lead to build failures (depending on
the way targets were scheduled). This patch makes the dependency
explicit so it can be enforced.

Closes #2586.
2022-11-16 09:23:47 +01:00
voidbar
2e3425000f Apply suggestions from code review
Co-authored-by: Tim Wojtulewicz <timwoj@gmail.com>
2022-11-09 18:56:00 +02:00
Tomer Lev
12494aac45 Fixed initial CR comments 2022-11-09 18:54:42 +02:00
Tim Wojtulewicz
d3baa0d1f7 Temporarily move cmake directive into MSVC section 2022-11-09 18:16:13 +02:00
Tim Wojtulewicz
bf06cc9c2f Turn on unit tests by default, and ifdef out a few of them 2022-11-09 18:16:13 +02:00
Tim Wojtulewicz
77c555a3a8 Fixing some issues from rebasing 2022-11-09 18:16:13 +02:00
Tomer Lev
0c61bcbfcd Fixed extern C issue with windows headers, fixed a GEN-ZAM regex issue, fixd compilation with c-ares 2022-11-09 18:16:04 +02:00
Elad Solomon
dbaf6696ef Fixed arec package linkage 2022-11-09 18:15:34 +02:00