]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4542: Enable parse warning for plugin loading
authorOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Fri, 13 Dec 2024 08:28:52 +0000 (08:28 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Fri, 13 Dec 2024 08:28:52 +0000 (08:28 +0000)
Merge in SNORT/snort3 from ~OSHUMEIK/snort3:fix_static_build to master

Squashed commit of the following:

commit cc436080f672ff6ed30899493d3fd340d1c1963f
Author: Oleksii Shumeiko <oshumeik@cisco.com>
Date:   Tue Dec 10 10:02:05 2024 +0200

    log: print all warnings before command line is parsed

commit f8d595f5517c2990037a0a59ac47fb16c564cdd2
Author: Yehor Velykozhon <yvelykoz@cisco.com>
Date:   Mon Dec 9 17:02:24 2024 +0200

    build: include/exclude snort_ml module conditionally

cmake/FindML.cmake
config.cmake.h.in
configure_cmake.sh
src/log/messages.cc
src/network_inspectors/CMakeLists.txt
src/network_inspectors/kaizen/kaizen_engine.cc
src/network_inspectors/kaizen/kaizen_inspector.cc
src/network_inspectors/network_inspectors.cc

index a2856331a9a20ce2f2f00e735940df32ed1c4405..0282bcbefdd36a823f0816885bf4ae5814453d23 100644 (file)
@@ -9,6 +9,6 @@ find_package_handle_standard_args(ML
     ML_INCLUDE_DIRS
 )
 
-if (ML_FOUND AND NOT ENABLE_KAIZEN_MOCK)
+if (ML_FOUND AND NOT USE_LIBML_MOCK)
     set(HAVE_LIBML TRUE)
 endif()
index 1da3047b9eef99f669a3f8a69a5bcdc02408bb28..d57ab59dc26be3e9dc4e70974503f5cf8ba3f9db 100644 (file)
 /* libml available */
 #cmakedefine HAVE_LIBML 1
 
+/* don't worry about libml and mock the inspector */
+#cmakedefine USE_LIBML_MOCK 1
+
 /*  Availability of specific library functions */
 
 /* Define to 1 if you have the `malloc_trim' function. */
index 8dc7023a627bcc31f7ad3cbf5af14615dc518a94..c2a3e6b0babd1df218769df8c03915b9f27c20e4 100755 (executable)
@@ -479,7 +479,7 @@ while [ $# -ne 0 ]; do
             append_cache_entry ML_LIBRARIES_DIR_HINT PATH $optarg
             ;;
         --without-libml)
-            append_cache_entry ENABLE_KAIZEN_MOCK BOOL true
+            append_cache_entry USE_LIBML_MOCK BOOL true
             ;;
         SIGNAL_SNORT_RELOAD=*)
             append_cache_entry SIGNAL_SNORT_RELOAD STRING $optarg
index dbe5083b4b4aa109d0b40fd96ab4bfd570a6c6dc..dcfcd8e7b89c154331c87fff98f1e4ae258a1094 100644 (file)
@@ -101,7 +101,7 @@ namespace snort
 {
 void ParseWarning(WarningGroup wg, const char* format, ...)
 {
-    if ( !(SnortConfig::get_conf()->warning_flags & (1 << wg)) )
+    if ( SnortConfig::get_conf() and !(SnortConfig::get_conf()->warning_flags & (1 << wg)) )
         return;
 
     char buf[STD_BUF+1];
index d6df6900f8ae1ec0251f12482f5982535a42b972..fd8694b757bc271f448892cdb5e290b3eefd8e33 100644 (file)
@@ -3,7 +3,11 @@ add_subdirectory(appid)
 add_subdirectory(arp_spoof)
 add_subdirectory(binder)
 add_subdirectory(extractor)
-add_subdirectory(kaizen)
+
+if ( HAVE_LIBML OR USE_LIBML_MOCK )
+    add_subdirectory(kaizen)
+endif()
+
 add_subdirectory(normalize)
 add_subdirectory(packet_capture)
 add_subdirectory(perf_monitor)
@@ -19,11 +23,17 @@ if(STATIC_INSPECTORS)
     )
 endif()
 
+if ( HAVE_LIBML OR USE_LIBML_MOCK )
+    set(KAIZEN_STATIC_OBJ
+        $<TARGET_OBJECTS:kaizen>
+    )
+endif()
+
 set(STATIC_NETWORK_INSPECTOR_PLUGINS
     $<TARGET_OBJECTS:appid>
     $<TARGET_OBJECTS:binder>
     $<TARGET_OBJECTS:extractor>
-    $<TARGET_OBJECTS:kaizen>
+    ${KAIZEN_STATIC_OBJ}
     $<TARGET_OBJECTS:normalize>
     $<TARGET_OBJECTS:port_scan>
     $<TARGET_OBJECTS:reputation>
index ca2e5b824e12ba2671169bc349cbfaa9f521f75d..6e60a7762dc4c7b4ef5443979da2661d3671656a 100644 (file)
@@ -198,11 +198,7 @@ static void kaizen_engine_dtor(Inspector* p)
 static const InspectApi kaizen_engine_api =
 {
     {
-#if defined(HAVE_LIBML) || defined(REG_TEST)
         PT_INSPECTOR,
-#else
-        PT_MAX,
-#endif
         sizeof(InspectApi),
         INSAPI_VERSION,
         0,
index a128374b9ee16dec91b1e28ba88a0546f44f7dad..863eb59f37d9bbd9d737e188093116cc38d0896f 100644 (file)
@@ -210,11 +210,7 @@ static void kaizen_dtor(Inspector* p)
 static const InspectApi kaizen_api =
 {
     {
-#if defined(HAVE_LIBML) || defined(REG_TEST)
         PT_INSPECTOR,
-#else
-        PT_MAX,
-#endif
         sizeof(InspectApi),
         INSAPI_VERSION,
         0,
index 4b7cd53e0176aee75c903a1dd0100993c1d94318..7abdadda522ed627e41999ac87bfda14eaba2728 100644 (file)
@@ -32,8 +32,12 @@ extern const BaseApi* nin_reputation;
 
 extern const BaseApi* nin_appid[];
 extern const BaseApi* nin_extractor[];
+
+#if defined(HAVE_LIBML) || defined(USE_LIBML_MOCK)
 extern const BaseApi* nin_kaizen_engine[];
 extern const BaseApi* nin_kaizen[];
+#endif
+
 extern const BaseApi* nin_port_scan[];
 extern const BaseApi* nin_rna[];
 
@@ -56,8 +60,12 @@ void load_network_inspectors()
     PluginManager::load_plugins(network_inspectors);
     PluginManager::load_plugins(nin_appid);
     PluginManager::load_plugins(nin_extractor);
+
+#if defined(HAVE_LIBML) || defined(USE_LIBML_MOCK)
     PluginManager::load_plugins(nin_kaizen_engine);
     PluginManager::load_plugins(nin_kaizen);
+#endif
+
     PluginManager::load_plugins(nin_port_scan);
     PluginManager::load_plugins(nin_rna);