summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2025-05-22 19:58:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2025-05-22 19:58:03 (GMT)
commit983634278e4f9ad4e31472a1dca15efeda5398eb (patch)
treee2d0e20849b0102b17cc7669d1eb8bef29ed7d7e
parentc3fb323e06bafe2fa04a00c29cf07a7bf4e44b37 (diff)
Mark Hyperscan as an optional dependency.
-rw-r--r--configure.ac29
-rw-r--r--src/Makefile.am8
-rw-r--r--src/analysis/scan/patterns/backends/Makefile.am8
-rw-r--r--src/rost.c10
4 files changed, 50 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 5ac8f62..693e9f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,6 +249,10 @@ AC_ARG_ENABLE([jsonglib-support],
AS_HELP_STRING([--disable-jsonglib-support], [disable jsonglib support [default=no]]),
[], [enable_jsonglib_support=yes])
+AC_ARG_ENABLE([hs-support],
+ AS_HELP_STRING([--disable-hs-support], [disable hs number recognition [default=no]]),
+ [], [enable_hs_support=yes])
+
AC_ARG_ENABLE([python-bindings],
AS_HELP_STRING([--disable-python-bindings], [disable Python bindings [default=no]]),
[], [enable_python_bindings=yes])
@@ -593,10 +597,24 @@ if test "$libhs_found" = "yes"; then
libhs_version=`pkg-config libhs --modversion`
else
libhs_version='-'
+ enable_hs_support=''
+fi
+
+AM_CONDITIONAL([BUILD_HS_SUPPORT], [test "x$enable_hs_support" = "xyes"])
+
+if test "x$BUILD_HS_SUPPORT_TRUE" = "x"; then
+ # Hyperscan support is available and enabled
+ CPPFLAGS="$CPPFLAGS -DINCLUDE_HS_SUPPORT"
fi
-AC_SUBST(LIBHS_CFLAGS)
-AC_SUBST(LIBHS_LIBS)
+if test "x$enable_hs_support" = "xyes"; then
+
+ AC_SUBST(LIBHS_CFLAGS)
+ AC_SUBST(LIBHS_LIBS)
+
+ true # empty if/then body not allowed
+
+fi
#--- Checks for json-glib-1.0
@@ -961,6 +979,12 @@ else
disable_magic_support="yes"
fi
+if test "x$enable_hs_support" = "xyes"; then
+ disable_hs_support="no"
+else
+ disable_hs_support="yes"
+fi
+
if test "x$enable_python_bindings" = "xyes"; then
disable_python_bindings="no"
else
@@ -973,6 +997,7 @@ echo Consider local resources..................... : $with_local_resources
echo Disable GTK support.......................... : $disable_gtk_support
echo Disable cURL support......................... : $disable_curl_support
echo Disable Magic support........................ : $disable_magic_support
+echo Disable Hyperscan support.................... : $disable_hs_support
echo Disable Python bindings...................... : $disable_python_bindings
echo Build a Python binary distribution........... : $build_python_package
diff --git a/src/Makefile.am b/src/Makefile.am
index 7332cbf..7411287 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -59,7 +59,7 @@ libchrysacore_la_LDFLAGS = \
-avoid-version -ldl -lm \
$(TOOLKIT_LIBS) $(LIBXML_LIBS) \
$(LIBSQLITE_LIBS) $(LIBARCHIVE_LIBS) \
- $(LIBSSL_LIBS) $(LIBHS_LIBS)
+ $(LIBSSL_LIBS)
if BUILD_CURL_SUPPORT
@@ -73,6 +73,12 @@ libchrysacore_la_LDFLAGS += $(LIBMAGIC_LIBS)
endif
+if BUILD_HS_SUPPORT
+
+libchrysacore_la_LDFLAGS += $(LIBHS_LIBS)
+
+endif
+
libchrysacore4_la_SOURCES =
diff --git a/src/analysis/scan/patterns/backends/Makefile.am b/src/analysis/scan/patterns/backends/Makefile.am
index 23b0163..84711a7 100644
--- a/src/analysis/scan/patterns/backends/Makefile.am
+++ b/src/analysis/scan/patterns/backends/Makefile.am
@@ -6,10 +6,16 @@ libanalysisscanpatternsbackends_la_SOURCES = \
acism-int.h \
acism.h acism.c \
bitap-int.h \
- bitap.h bitap.c \
+ bitap.h bitap.c
+
+if BUILD_HS_SUPPORT
+
+libanalysisscanpatternsbackends_la_SOURCES += \
hyperscan-int.h \
hyperscan.h hyperscan.c
+endif
+
# Cf. https://www.gnu.org/software/automake/manual/html_node/Per_002dObject-Flags.html
AM_CFLAGS = $(LIBGOBJ_CFLAGS) $(LIBHS_CFLAGS)
diff --git a/src/rost.c b/src/rost.c
index 4a052c3..b94b367 100644
--- a/src/rost.c
+++ b/src/rost.c
@@ -41,7 +41,9 @@
#include "analysis/scan/scanner.h"
#include "analysis/scan/patterns/backends/acism.h"
#include "analysis/scan/patterns/backends/bitap.h"
-#include "analysis/scan/patterns/backends/hyperscan.h"
+#ifdef INCLUDE_HS_SUPPORT
+# include "analysis/scan/patterns/backends/hyperscan.h"
+#endif
#include "core/core.h"
#include "core/global.h"
#include "core/logs.h"
@@ -93,7 +95,11 @@ static void show_rost_help(const char *name)
printf("\n");
+#ifdef INCLUDE_HS_SUPPORT
printf("\t-A --algorithm=NAME\tSelect one of the available algorithms for data: acism, bitmap, hyperscan (default: acsim).\n");
+#else
+ printf("\t-A --algorithm=NAME\tSelect one of the available algorithms for data: acism, bitmap (default: acsim).\n");
+#endif
printf("\t-C --check-only\t\tValidate the rule syntax without performing a scan (discard the file/dir argument).\n");
printf("\t-j --print-json\t\tPrint matching strings in JSON format instead of simple text.\n");
printf("\t-s --print-strings\tPrint matching strings (default text format only).\n");
@@ -303,8 +309,10 @@ int main(int argc, char **argv)
g_scan_options_set_backend_for_data(options, G_TYPE_ACISM_BACKEND);
else if (strcmp(optarg, "bitmap") == 0)
g_scan_options_set_backend_for_data(options, G_TYPE_BITAP_BACKEND);
+#ifdef INCLUDE_HS_SUPPORT
else if (strcmp(optarg, "hyperscan") == 0)
g_scan_options_set_backend_for_data(options, G_TYPE_HYPERSCAN_BACKEND);
+#endif
else
g_scan_options_set_backend_for_data(options, G_TYPE_INVALID);
break;