Commit graph

19557 commits

Author SHA1 Message Date
Vern Paxson
789b06b1ea gen-zam: fix memory management for vector-of-strings operations 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
f330505e83 gen-zam: Deprecate bro_int_t and bro_uint_t 2025-08-20 08:52:25 -07:00
Johanna Amann
902577b7ce gen-zam: Fix compile error on GCC-12/Ubuntu 22.04 2025-08-20 08:52:25 -07:00
Christian Kreibich
4a7cf8c26e gen-zam: Remove unnecessary include from CMakeLists.txt 2025-08-20 08:52:25 -07:00
Christian Kreibich
b51430c04e gen-zam: Trivial source tweaks to make it build 2025-08-20 08:52:25 -07:00
Christian Kreibich
5ea34f20b8 gen-zam: Establish the usual environment for cmake-driven builds 2025-08-20 08:52:25 -07:00
Christian Kreibich
c1f240295f gen-zam: Move Gen-ZAM sources to src subdirectory 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
c618bb7a56 bifcl: Remove submodule, adapt CMake configuration for Zeek build 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
f6d9696bf1 bifcl: Require C++20 for builds 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
d8d8772342 bifcl: Add NOLINT for clang-tidy performance-enum-size to generated headers 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
c63a220579 bifcl: Add missing include of cinttypes 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
867d91b535 bifcl: Some other minor cleanup 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
23a5e46b8e bifcl: Minor cleanup of include files 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
7026938082 bifcl: Pass boolean false to BuiltinFunc constructor instead of zero
This fixes a modernize-use-bool-literals clang-tidy warning in the
generated code.
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
c30aa7a903 bifcl: Don't do 'using namespace std' in headers, plus a little cleanup 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
75a8814cee bifcl: Switch more namespacing in generated code to nested style 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
234726dac7 bifcl: Reformat CMakeLists via pre-commit 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
2f97833acd bifcl: Switch namespacing in generated code to C++-17-style nested namespaces 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
d2edc334ad bifcl: Add #pragma once to generated headers 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
dac04be859 bifcl: Make BIFs just return ValPtr directly instead of BifReturnVal 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
f2cd4ae3e6 bifcl: Reformat Bifcl in Spicy style 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
8e5b722145 bifcl: Remove usage of FindRequiredPackage 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
af0c68c183 bifcl: Add /J flag on Windows to force unsigned char 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
3004675015 bifcl: Force -std=c++17 mode for cmake targets, remove use of RequireCXX17.cmake 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
af2a1b67bc bifcl: Require CMake 3.15.0 to build, similar to the recent changes to zeek and broker 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
7275016bcb bifcl: Remove vendored CMake files from repo 2025-08-20 08:52:25 -07:00
Arne Welzel
e7cce57f2b bifcl: Render runtime type checks for var_args bifs
Currently, Zeek disables any static type checking for var_arg bifs.
However, the generated preamble for var_args bifs assume that
typed positional arguments are correctly typed and blindly calls
the type converters on them. This easily triggers abort()s at runtime
currently when a script mistakenly uses the wrong types for var_arg
bifs. For example, calling publish_rr() with a port instead of a string
causes a hard-abort with Zeek 5.0.8.

    $ zeek -e 'Cluster::publish_rr(Cluster::Pool(), 80/tcp)'
    fatal error in <no location>: Val::CONVERTER (port/string) (80/tcp)
    Aborted (core dumped)

Extend bifcl so that for var_arg functions and the types that bifcl understands,
we render a runtime type check and explicit early return to avoid the abort().
For any/other types, the implementer of the bif continuous to be responsible
for type checking.

This isn't solving the var_args situation generally, but avoids some
ad-hoc fixes trickling in current bif implementations.

Some references:

https://github.com/zeek/zeek/issues/1523
https://github.com/zeek/zeek/issues/2425
https://github.com/zeek/zeek/issues/2935
https://github.com/zeek/zeek/pull/2950
2025-08-20 08:52:25 -07:00
Arne Welzel
efb32d31fc bifcl: builtin-func.l: Allow more than just one additional component
I'm not sure why this was restricted to only two components,
the following appears functional in Zeek scripts.

    module A::B::C;

    export {
      type MyRecord: record {
        a: string;
      };
    }

Closes #25.
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
8e295df115 bifcl: Other minor cleanups 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
8662b29ac6 bifcl: Use bools for boolean comparisons 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
224a42e1f0 bifcl: Use nullptrs for pointer initializations 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
4ed4f3e1b8 bifcl: Include stdint.h early to prevent redefinition of int type macros 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
0c4676e835 bifcl: Remove argument from BIFCL_LSAN_DISABLE macro to fix warning on Windows 2025-08-20 08:52:25 -07:00
Tomer Lev
4352f0c0bb bifcl: Only adding subdir if running standalone 2025-08-20 08:52:25 -07:00
Tomer Lev
c6042154b9 bifcl: Adding support for libunistd. Also adding pragma guard for the right arch 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
3a18b2144c bifcl: Add clang-format and run it on everything 2025-08-20 08:52:25 -07:00
Elad Solomon
552be424c4 bifcl: Adapted bifcl to compile with MSVC for Windows environment. 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
f69f9e06e1 bifcl: Use full path to filename in #line directives in generated code
This fixes the DWARF information gets output by the compiler, and allows debuggers
to use the full path name to display contextual information when a session stops
inside of BIF code.
2025-08-20 08:52:25 -07:00
Benjamin Bannier
09d3268740 bifcl: Keep zeekygen comments close to their definitions
The Yacc grammar treats comments like other whitespace and when seeing
the first definition in a file would previously emit all whitespace
before emitting the `export` section containing the definition. This
lead to the first definition being separated from their zeekygen
documention (separated by `export {`).

With this patch we start the export section before emitting whitespace.
While this might now pull more "whitespace" into the exported part, it
avoids breaking the association between zeekygen comments and
definitions.

Closes #15.
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
e080c5c6b2 bifcl: Remove remaining uses of Bro naming 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
669875a9b7 bifcl: Deprecate bro_int_t and bro_uint_t 2025-08-20 08:52:25 -07:00
Vern Paxson
2f3f7e9ce2 bifcl: trimmed & regularized some minor variable naming 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
02fe78a03f bifcl: Allow analyzer to be passed as nullptr for enqueue methods
This allows the methods to be used in contexts where the analyzer ID
is not available or when the ID doesn't matter, such as in packet
analyzers.
2025-08-20 08:52:25 -07:00
Seth Hall
d0ed713108 bifcl: Updates for building Zeek as a subproject 2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
ea625959c1 bifcl: Rename Session::ConnVal() to Session::GetVal() 2025-08-20 08:52:25 -07:00
Jon Siwek
ae56d45a1f bifcl: Prevent use of LeakSanitizer on FreeBSD 2025-08-20 08:52:25 -07:00
Jon Siwek
34c4f678cf bifcl: Add missing zeek/ to generated header includes
Related to https://github.com/zeek/zeek/pull/1377
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
279d5f3fad bifcl: Remove v4.1 deprecation warnings 2025-08-20 08:52:25 -07:00
Vern Paxson
72fa791294 bifcl: support for new FileVal class 2025-08-20 08:52:24 -07:00
Jon Siwek
23a4b7e7c1 bifcl: Update minimum required CMake to 3.5 2025-08-20 08:52:24 -07:00