From: russ Date: Fri, 30 Oct 2015 15:21:19 +0000 (-0400) Subject: cmake support for hyperscan X-Git-Tag: 3.0.0-233~756^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=441b76f1e09ec6a82782ae9bd32f2d73b969d78f;p=thirdparty%2Fsnort3.git cmake support for hyperscan --- diff --git a/cmake/FindHS.cmake b/cmake/FindHS.cmake new file mode 100644 index 000000000..e0e21f534 --- /dev/null +++ b/cmake/FindHS.cmake @@ -0,0 +1,11 @@ + +find_path (HS_INCLUDE_DIR NAMES hs/hs_compile.h) + +find_library(HS_LIBRARIES NAMES hs) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(HS REQUIRED_VARS HS_INCLUDE_DIR HS_LIBRARIES) + +mark_as_advanced(HS_INCLUDE_DIR HS_LIBRARIES) + + diff --git a/cmake/configure_options.cmake b/cmake/configure_options.cmake index 88ef1c3d2..43953efd8 100644 --- a/cmake/configure_options.cmake +++ b/cmake/configure_options.cmake @@ -39,7 +39,6 @@ set_if_true (BUILD_UNIT_TESTS UNIT_TEST) set_if_true (BUILD_PIGLET PIGLET) set_if_true (ENABLE_PROFILE PROFILE) set_if_true (ENABLE_SHELL BUILD_SHELL) - set_if_true (BUILD_PIGLET PIGLET) set_if_true (STATIC_PIGLETS STATIC_PIGLETS) diff --git a/cmake/include_libraries.cmake b/cmake/include_libraries.cmake index e9ad1b0a1..a6ffe7883 100644 --- a/cmake/include_libraries.cmake +++ b/cmake/include_libraries.cmake @@ -9,9 +9,10 @@ find_package(PCRE REQUIRED) find_package(ZLIB REQUIRED) # optional libraries -find_package(LibHS QUIET) find_package(LibLZMA QUIET) find_package(OpenSSL QUIET) find_package(Asciidoc QUIET) find_package(DBLATEX QUIET) find_package(Ruby QUIET 1.8.7) +find_package(HS QUIET) + diff --git a/cmake/sanity_checks.cmake b/cmake/sanity_checks.cmake index c11f7cee2..342437591 100644 --- a/cmake/sanity_checks.cmake +++ b/cmake/sanity_checks.cmake @@ -189,8 +189,8 @@ if (DEFINED OPENSSL_CRYPTO_LIBRARIES) check_library_exists (${OPENSSL_CRYPTO_LIBRARIES} MD5_Init "" HAVE_OPENSSL_MD5) endif() -if (DEFINED LIBHS_LIBRARIES) - check_library_exists (${LIBHS_LIBRARIES} hs_scan "" HAVE_HYPERSCAN) +if (DEFINED HS_LIBRARIES) + check_library_exists (${HS_LIBRARIES} hs_scan "" HAVE_HYPERSCAN) endif() if (DEFINED LIBLZMA_LIBRARIES) diff --git a/config.cmake.h.in b/config.cmake.h.in index 83bdf298d..d8abe906f 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -309,6 +309,9 @@ #cmakedefine HAVE_OPENSSL_MD5 1 +/* hyperscan available */ +#cmakedefine HAVE_HYPERSCAN 1 + /* lzma available */ #cmakedefine HAVE_LZMA 1 diff --git a/doc/bugs.txt b/doc/bugs.txt index 3220e9a63..2cafc9301 100644 --- a/doc/bugs.txt +++ b/doc/bugs.txt @@ -19,6 +19,9 @@ * Enabling debug messages may erroneously affect the number of packets processed from pcaps +* It is not possible to build unit tests w/o static plugins. + + ==== Config * Parsing issue with IP lists. can't parse rules with $EXTERNAL_NET diff --git a/doc/start.txt b/doc/start.txt index 28f1b2aeb..af5038c52 100644 --- a/doc/start.txt +++ b/doc/start.txt @@ -19,7 +19,7 @@ Required: * pcre from http://www.pcre.org for regular expression pattern matching -* zlib from http://www.zlib.net for decompression +* zlib >= 1.2.8 from http://www.zlib.net for decompression * pkgconfig from http://www.freedesktop.org to build the example plugins diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d2f4c136..bdcc96357 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,27 +1,29 @@ # keeping track of external libraries seperately for use in pkg-config. set(EXTERNAL_LIBRARIES - ${LUAJIT_LIBRARIES} - ${PCRE_LIBRARIES} - ${PCAP_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${LIBLZMA_LIBRARIES} - ${ZLIB_LIBRARIES} -# ${OPENSSL_CRYPTO_LIBRARY} -- part of OPENSSL_LIBRARIES ${DAQ_LIBRARIES} ${DNET_LIBRARIES} ${CLANG_CXX_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} # GCC says we must link to the threads library ${CMAKE_DL_LIBS} + ${CMAKE_THREAD_LIBS_INIT} # GCC says we must link to the threads library + ${HS_LIBRARIES} + ${LIBLZMA_LIBRARIES} + ${LUAJIT_LIBRARIES} + ${OPENSSL_LIBRARIES} +# ${OPENSSL_CRYPTO_LIBRARY} -- part of OPENSSL_LIBRARIES + ${PCAP_LIBRARIES} + ${PCRE_LIBRARIES} + ${ZLIB_LIBRARIES} CACHE INTERNAL "external libraries" FORCE ) set(EXTERNAL_INCLUDES ${DAQ_INCLUDE_DIR} - ${PCAP_INCLUDE_DIR} - ${PCRE_INCLUDE_DIR} ${DNET_INCLUDE_DIR} + ${HS_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} + ${PCAP_INCLUDE_DIR} + ${PCRE_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} CACHE INTERNAL "external INCLUDES" FORCE ) diff --git a/src/ips_options/CMakeLists.txt b/src/ips_options/CMakeLists.txt index a7a88dcda..4d25d2be7 100644 --- a/src/ips_options/CMakeLists.txt +++ b/src/ips_options/CMakeLists.txt @@ -72,7 +72,7 @@ set (IPS_SOURCES if ( HAVE_HYPERSCAN ) set(OPTION_LIST ips_regex.cc ips_regex.h) -endif +endif () if (STATIC_IPS_OPTIONS) diff --git a/src/ips_options/Makefile.am b/src/ips_options/Makefile.am index 8067c449f..9a0d73269 100644 --- a/src/ips_options/Makefile.am +++ b/src/ips_options/Makefile.am @@ -200,13 +200,6 @@ libips_raw_data_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO libips_raw_data_la_LDFLAGS = -export-dynamic -shared libips_raw_data_la_SOURCES = ips_raw_data.cc -if HAVE_HYPERSCAN -optlib_LTLIBRARIES += libips_regex.la -libips_regex_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO -libips_regex_la_LDFLAGS = -export-dynamic -shared -libips_regex_la_SOURCES = ips_regex.cc -endif - optlib_LTLIBRARIES += libips_rem.la libips_rem_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_SO libips_rem_la_LDFLAGS = -export-dynamic -shared diff --git a/src/ips_options/test/CMakeLists.txt b/src/ips_options/test/CMakeLists.txt new file mode 100644 index 000000000..c910d2f50 --- /dev/null +++ b/src/ips_options/test/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_cpputest(ips_regex_test ips_options + ips_options + framework + sfip + catch_tests + hs +) + diff --git a/src/ips_options/test/ips_regex_test.cc b/src/ips_options/test/ips_regex_test.cc index 9a9f9616e..bf9a97fb9 100644 --- a/src/ips_options/test/ips_regex_test.cc +++ b/src/ips_options/test/ips_regex_test.cc @@ -240,6 +240,7 @@ TEST_GROUP(ips_regex_option) IpsApi* api = (IpsApi*)ips_regex; api->dtor(opt); regex_cleanup(snort_conf); + api->pterm(snort_conf); } }; @@ -276,6 +277,7 @@ TEST(ips_regex_option, match_absolute) Cursor c(&pkt); CHECK(opt->eval(c, &pkt) == DETECTION_OPTION_MATCH); CHECK(!strcmp((char*)c.start(), " stew *")); + CHECK(opt->retry()); } TEST(ips_regex_option, no_match_delta) @@ -322,6 +324,7 @@ TEST(ips_regex_option_relative, no_match) CHECK(opt->is_relative()); CHECK(opt->eval(c, &pkt) == DETECTION_OPTION_NO_MATCH); + CHECK(!opt->retry()); } //-------------------------------------------------------------------------