From 8ae560e7c65f2c4739acf7583fc4b660071a08de Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 12 Jan 2024 14:04:47 -0800 Subject: [PATCH 1/4] Add feature tests for AF_PACKET, GeoIP, and JavaScript to zeek-config --- CMakeLists.txt | 2 ++ cmake_templates/zeek-config.in | 39 ++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeffce462e..cbb840f6d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1101,6 +1101,7 @@ endif () # Tell the plugin code that we're building as part of the main tree. set(ZEEK_PLUGIN_INTERNAL_BUILD true CACHE INTERNAL "" FORCE) +set(ZEEK_HAVE_AF_PACKET no) if (${CMAKE_SYSTEM_NAME} MATCHES Linux) if (NOT DISABLE_AF_PACKET) if (NOT AF_PACKET_PLUGIN_PATH) @@ -1108,6 +1109,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux) endif () list(APPEND ZEEK_INCLUDE_PLUGINS ${AF_PACKET_PLUGIN_PATH}) + set(ZEEK_HAVE_AF_PACKET yes) endif () endif () diff --git a/cmake_templates/zeek-config.in b/cmake_templates/zeek-config.in index c78ea5e855..29943e84e1 100755 --- a/cmake_templates/zeek-config.in +++ b/cmake_templates/zeek-config.in @@ -6,6 +6,9 @@ btest_tools_dir="@ZEEK_CONFIG_BTEST_TOOLS_DIR@" build_type="@CMAKE_BUILD_TYPE_LOWER@" cmake_dir="@ZEEK_CMAKE_CONFIG_DIR@" config_dir="@ZEEK_ETC_INSTALL_DIR@" +have_af_packet="@ZEEK_HAVE_AF_PACKET@" +have_geoip="@USE_GEOIP@" +have_javascript="@ZEEK_HAVE_JAVASCRIPT@" have_spicy="@USE_SPICY_ANALYZERS@" include_dir="@CMAKE_INSTALL_PREFIX@/include" lib_dir="@CMAKE_INSTALL_FULL_LIBDIR@" @@ -18,6 +21,18 @@ version="@ZEEK_VERSION_FULL@" zeek_dist="@ZEEK_DIST@" zeekpath="@DEFAULT_ZEEKPATH@" +report_feature() { + # $1: cmake feature flag value + input=$(echo "$1" | tr '[:lower:]' '[:upper:]') + if [ "$input" = "1" ] || [ "$input" = "ON" ] || [ "$input" = "YES" ] || [ "$input" = "TRUE" ] || [ "$input" = "Y" ]; then + echo "yes" + exit 0 + fi + + echo "no" + exit 1 +} + add_path() { # $1: existing path # $2: path to add @@ -67,9 +82,12 @@ Toplevel installation directories for third-party components: --binpac_root BinPAC compiler --broker_root Broker communication framework -Feature tests: +Feature tests (prints 'yes' if supported; exit code reflects result): - --have-spicy-analyzers Prints 'yes' if built-in Spicy analyzers are available; exit code reflects result + --have-af-packet Native AF_PACKET support + --have-geoip IP address geolocation & AS lookups + --have-javascript JavaScript support + --have-spicy-analyzers built-in Spicy analyzers " } @@ -109,14 +127,17 @@ while [ $# -ne 0 ]; do --config_dir) echo $config_dir ;; + --have-af-packet) + report_feature "$have_af_packet" + ;; + --have-geoip) + report_feature "$have_geoip" + ;; + --have-javascript) + report_feature "$have_javascript" + ;; --have-spicy-analyzers) - if [ "$have_spicy" = "yes" ]; then - echo "yes" - exit 0 - else - echo "no" - exit 1 - fi + report_feature "$have_spicy" ;; --include_dir) echo $include_dir From e8007f04d90b8238f38b22185b40dc925e759c77 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 12 Jan 2024 15:00:17 -0800 Subject: [PATCH 2/4] Show AF_PACKET support status in cmake output, and sort features --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbb840f6d2..53df9baaa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1435,18 +1435,19 @@ message( "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" "\nCPP: ${CMAKE_CXX_COMPILER}" "\n" - "\nzeek-client: ${INSTALL_ZEEK_CLIENT}" - "\nZeekControl: ${INSTALL_ZEEKCTL}" + "\nAF_PACKET: ${ZEEK_HAVE_AF_PACKET}" "\nAux. Tools: ${INSTALL_AUX_TOOLS}" "\nBifCL: ${_bifcl_exe_path}" "\nBinPAC: ${_binpac_exe_path}" "\nBTest: ${INSTALL_BTEST}" "\nBTest tooling: ${_install_btest_tools_msg}" "\nGen-ZAM: ${_gen_zam_exe_path}" - "\nzkg: ${INSTALL_ZKG}" + "\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}" "\nSpicy: ${_spicy}" "\nSpicy analyzers: ${USE_SPICY_ANALYZERS}" - "\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}" + "\nzeek-client: ${INSTALL_ZEEK_CLIENT}" + "\nZeekControl: ${INSTALL_ZEEKCTL}" + "\nzkg: ${INSTALL_ZKG}" "\n" "\nlibmaxminddb: ${USE_GEOIP}" "\nKerberos: ${USE_KRB5}" From b97907daed2c574ba46b34bbe17aa77f870f1125 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 12 Jan 2024 14:44:34 -0800 Subject: [PATCH 3/4] Show --disable-javascript in `configure --help` This is already supported and just missing from the help output. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 18f019b29c..7d91aedc8a 100755 --- a/configure +++ b/configure @@ -72,6 +72,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --disable-btest don't install BTest --disable-btest-pcaps don't install Zeek's BTest input pcaps --disable-cpp-tests don't build Zeek's C++ unit tests + --disable-javascript don't build Zeek's JavaScript support --disable-port-prealloc disable pre-allocating the PortVal array in ValManager --disable-python don't try to build python bindings for Broker --disable-spicy don't include Spicy From 2947bcda56edcf9e5c6a69e7a026e529191e4704 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 12 Jan 2024 14:56:11 -0800 Subject: [PATCH 4/4] Default to setting ZEEK_HAVE_JAVASCRIPT=no in CMakeLists.txt This still overrides it as appropriate when building with JS support, but shows "JavaScript: no" in the configure output also when using --disable-javascript, where it previously showed no output. --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53df9baaa9..7cdcd1d7e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1113,6 +1113,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux) endif () endif () +set(ZEEK_HAVE_JAVASCRIPT no) if (NOT DISABLE_JAVASCRIPT) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/auxil/zeekjs/cmake) find_package(Nodejs) @@ -1123,14 +1124,11 @@ if (NOT DISABLE_JAVASCRIPT) STATUS "Node.js version ${NODEJS_VERSION} is too old, need 16.13 or later. Not enabling JavaScript support." ) - set(ZEEK_HAVE_JAVASCRIPT no) else () set(ZEEKJS_PLUGIN_PATH ${CMAKE_SOURCE_DIR}/auxil/zeekjs) list(APPEND ZEEK_INCLUDE_PLUGINS ${ZEEKJS_PLUGIN_PATH}) set(ZEEK_HAVE_JAVASCRIPT yes) endif () - else () - set(ZEEK_HAVE_JAVASCRIPT no) endif () endif ()