From 627720c29fcc2957981039e3b6f0b03dc1341457 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 16:23:49 +0000 Subject: [PATCH 01/13] Add support for out-of-tree builds Initial work to support out-of-tree builds ``` ./autogen.sh mkdir build cd build ../configure make make check ``` IMPORTANT: `autogen.sh` doesn't call `configure` automatically anymore!! You have to do: `./autogen.sh && ./configure --$OPTIONS`. A little bit annoying but the pattern `autogen && configure && make` is very common on Linux. Known issues: * `make doc` doesn't work in out-of-tree builds, yet See: #2992 --- .github/workflows/build-rpm.yml | 2 +- .github/workflows/build.yml | 50 ++++++++- .github/workflows/build_docker.yml | 4 +- .github/workflows/build_masan.yml | 2 +- .github/workflows/build_scheduled.yml | 12 +-- .github/workflows/codeql.yml | 2 +- Makefile.am | 6 +- README.fuzzer.md | 2 +- README.md | 14 ++- autogen.sh | 6 +- configure.ac | 31 +++--- example/Makefile.in | 24 +++-- fuzz/Makefile.am | 150 +++++++++++++------------- influxdb/Makefile.in | 16 ++- rrdtool/Makefile.in | 20 ++-- src/lib/Makefile.in | 32 +++--- tests/dga/Makefile.in | 12 ++- tests/{do-dga.sh => do-dga.sh.in} | 19 ++-- tests/{do-unit.sh => do-unit.sh.in} | 6 +- tests/do.sh.in | 38 ++++--- tests/ossfuzz.sh | 2 +- tests/performance/Makefile.in | 34 +++--- tests/unit/Makefile.in | 12 ++- utils/Makefile.in | 18 ++-- utils/verify_dist_tarball.sh | 2 +- 25 files changed, 313 insertions(+), 203 deletions(-) rename tests/{do-dga.sh => do-dga.sh.in} (79%) rename tests/{do-unit.sh => do-unit.sh.in} (74%) diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml index a1afcf2e12d..0521b505015 100644 --- a/.github/workflows/build-rpm.yml +++ b/.github/workflows/build-rpm.yml @@ -22,7 +22,7 @@ jobs: echo 'CentOS Linux release 7.9.2009 (Core)' | sudo tee /etc/centos-release # symlink source directory for ndpi.spec ln -sr . $HOME/nDPI - ./autogen.sh + ./autogen.sh && ./configure cd packages/rpm ./configure diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3b578358a4..3d1608f3b3f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: sudo apt-get install autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev - name: Build nDPI library run: | - ./autogen.sh + ./autogen.sh && ./configure make -j sudo make install - name: Generate Python bindings @@ -182,7 +182,7 @@ jobs: brew install libmaxminddb - name: Configure nDPI run: | - ./autogen.sh --enable-option-checking=fatal --enable-debug-messages ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs ${{ matrix.global_context}} + ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs ${{ matrix.global_context}} - name: Build nDPI run: | make -j all @@ -226,7 +226,7 @@ jobs: if: startsWith(matrix.os, 'ubuntu') && !endsWith(matrix.os, 'arm') && !startsWith(matrix.msan, '--with-') && !startsWith(matrix.nBPF, 'nBPF') && !startsWith(matrix.global_context, '--without') # Only on a few "standard" builds run: | make distclean - ./autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --host=x86_64-w64-mingw32 + ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --host=x86_64-w64-mingw32 make -j $(nproc) all env: CC: @@ -259,7 +259,7 @@ jobs: sudo apt-get install autoconf automake debhelper libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev rrdtool librrd-dev parallel - name: Configure nDPI run: | - AR=${{ matrix.ar }} RANLIB=${{ matrix.ranlib }} ./autogen.sh --enable-option-checking=fatal --enable-debug-messages --with-sanitizer --with-lto-and-gold-linker + AR=${{ matrix.ar }} RANLIB=${{ matrix.ranlib }} ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --with-sanitizer --with-lto-and-gold-linker - name: Build nDPI run: | make -j $(nproc) all @@ -290,7 +290,7 @@ jobs: install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool make mingw-w64-x86_64-json-c mingw-w64-x86_64-crt-git mingw-w64-x86_64-pcre mingw-w64-x86_64-libpcap parallel - name: Configure nDPI on Windows msys2 run: | - msys2 -c './autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --disable-npcap' + msys2 -c './autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --disable-npcap' - name: Build nDPI on Windows msys2 run: | msys2 -c 'make -j all' @@ -302,3 +302,43 @@ jobs: msys2 -c './tests/do.sh' msys2 -c './tests/do-unit.sh' msys2 -c './tests/do-dga.sh' + + test-out-of-tree-builds: + name: Out-of-tree builds + runs-on: ubuntu-latest + env: + CC: ${{ matrix.compiler }} + CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install Ubuntu Prerequisites + run: | + sudo apt-get update + sudo apt-get install autoconf automake debhelper libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev rrdtool librrd-dev parallel + - name: Autogen nDPI + run: | + ./autogen.sh + - name: Configure and build nDPI (standard) + run: | + mkdir -p build-standard + cd standard + ./configure + make -j $(nproc) all + make -j $(nproc) -C example ndpiSimpleIntegration + make -j $(nproc) -C rrdtool + cd - + - name: Configure and build nDPI (fuzzing) + run: | + mkdir -p build-fuzzing + cd fuzzing + CC=clang CXX=clang++ ./configure --with-sanitizer --enable-fuzztargets + make -j $(nproc) all + make -j $(nproc) -C example ndpiSimpleIntegration + make -j $(nproc) -C rrdtool + cd - + - name: Print nDPI long help + run: | + cd ./build-standard/example && ./ndpiReader -H + cd ./build-fuzzing/example && ./ndpiReader -H diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 9ba9c8aff27..a0840e33a00 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -50,7 +50,7 @@ jobs: "apt-get -y update && apt-get -y install git wdiff colordiff autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev rrdtool librrd-dev && git config --global --add safe.directory $(realpath .) && - env CC=gcc ./autogen.sh --enable-option-checking=fatal --enable-debug-messages && + env CC=gcc ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages && make -j $(nproc) all && make -C example ndpiSimpleIntegration && make -C rrdtool && @@ -74,7 +74,7 @@ jobs: "apt-get -y update && apt-get -y install git wdiff colordiff autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev rrdtool librrd-dev && git config --global --add safe.directory $(realpath .) && - env CC=gcc ./autogen.sh --enable-option-checking=fatal --enable-debug-messages && + env CC=gcc ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages && make -j $(nproc) all && make -C example ndpiSimpleIntegration && make -C rrdtool && diff --git a/.github/workflows/build_masan.yml b/.github/workflows/build_masan.yml index b10a5d42d0c..d6dabf427ec 100644 --- a/.github/workflows/build_masan.yml +++ b/.github/workflows/build_masan.yml @@ -33,7 +33,7 @@ jobs: sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libjson-c-dev libpcap-dev rrdtool librrd-dev parallel libpcre3-dev libmaxminddb-dev - name: Configure nDPI run: | - ./autogen.sh --enable-option-checking=fatal --with-pcre2 --with-maxminddb --with-memory-sanitizer --disable-memory-track-origins + ./autogen.sh && ./configure --enable-option-checking=fatal --with-pcre2 --with-maxminddb --with-memory-sanitizer --disable-memory-track-origins - name: Build nDPI run: | make -j $(nproc) all diff --git a/.github/workflows/build_scheduled.yml b/.github/workflows/build_scheduled.yml index 1f73160b835..73b339409d5 100644 --- a/.github/workflows/build_scheduled.yml +++ b/.github/workflows/build_scheduled.yml @@ -23,7 +23,7 @@ jobs: sudo apt-get install libpcre3-dev libmaxminddb-dev lcov sudo apt-get install wdiff colordiff - name: Configure - run: ./autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-code-coverage --with-pcre2 --with-maxminddb --enable-tls-sigs + run: ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --enable-code-coverage --with-pcre2 --with-maxminddb --enable-tls-sigs - name: Build run: make all - name: Test @@ -55,7 +55,7 @@ jobs: sudo apt-get install autoconf automake libtool pkg-config gettext flex bison doxygen - name: Configure nDPI library run: | - ./autogen.sh --with-only-libndpi --enable-option-checking=fatal --enable-debug-build + ./autogen.sh && ./configure --with-only-libndpi --enable-option-checking=fatal --enable-debug-build - name: Generate Documentation run: | pip install --upgrade pip @@ -89,7 +89,7 @@ jobs: pprof -h - name: Configure nDPI library run: | - ./autogen.sh --enable-gprof --enable-option-checking=fatal --with-pcre2 --with-maxminddb --enable-tls-sigs + ./autogen.sh && ./configure --enable-gprof --enable-option-checking=fatal --with-pcre2 --with-maxminddb --enable-tls-sigs - name: Build nDPI library run: | make -j @@ -123,7 +123,7 @@ jobs: sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libjson-c-dev libpcap-dev rrdtool librrd-dev parallel - name: Configure nDPI run: | - ./autogen.sh --enable-option-checking=fatal --with-thread-sanitizer + ./autogen.sh && ./configure --enable-option-checking=fatal --with-thread-sanitizer - name: Build nDPI run: | make -j $(nproc) all @@ -159,7 +159,7 @@ jobs: brew install coreutils wdiff colordiff autoconf automake libtool gettext json-c rrdtool parallel libgcrypt - name: Configure nDPI run: | - ./autogen.sh --enable-option-checking=fatal --with-local-libgcrypt + ./autogen.sh && ./configure --enable-option-checking=fatal --with-local-libgcrypt - name: Build nDPI run: | make -j $(nproc) all @@ -192,7 +192,7 @@ jobs: install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool make mingw-w64-x86_64-json-c mingw-w64-x86_64-crt-git mingw-w64-x86_64-pcre mingw-w64-x86_64-libpcap mingw-w64-x86_64-libgcrypt parallel - name: Configure nDPI on Windows msys2 run: | - msys2 -c './autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --disable-npcap --with-local-libgcrypt' + msys2 -c './autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --disable-npcap --with-local-libgcrypt' - name: Build nDPI on Windows msys2 run: | msys2 -c 'make -j all' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1f6dd02cd93..26875665118 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -40,7 +40,7 @@ jobs: pprof -h - name: Configure nDPI library run: | - ./autogen.sh --enable-gprof --enable-option-checking=fatal --with-pcre2 --with-maxminddb --enable-tls-sigs --enable-debug-messages + ./autogen.sh && ./configure --enable-gprof --enable-option-checking=fatal --with-pcre2 --with-maxminddb --enable-tls-sigs --enable-debug-messages - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/Makefile.am b/Makefile.am index 2d523aedaba..41e7366b13a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,10 +53,10 @@ clean-coverage: find . -type f -name "*.gcno" -exec rm "{}" + pull: - git pull --rebase - if test -d ../nDPI-custom; then echo "Pulling ../nDPI-custom"; cd ../nDPI-custom; git pull --rebase; cd ../nDPI; fi + cd $(top_srcdir) && git pull --rebase + if test -d $(top_srcdir)/../nDPI-custom; then echo "Pulling ../nDPI-custom"; cd $(top_srcdir)/../nDPI-custom && git pull --rebase; fi changelog: - git log --since={`curl -s https://github.com/ntop/ndpi/releases | grep datetime | head -n1 | egrep -o "[0-9]+\-[0-9]+\-[0-9]+"`} --name-only --pretty=format:" - %s" | grep "^ " > CHANGELOG.latest + cd $(top_srcdir) && git log --since={`curl -s https://github.com/ntop/ndpi/releases | grep datetime | head -n1 | egrep -o "[0-9]+\-[0-9]+\-[0-9]+"`} --name-only --pretty=format:" - %s" | grep "^ " > CHANGELOG.latest .PHONY: doc doc-view coverage clean-coverage changelog diff --git a/README.fuzzer.md b/README.fuzzer.md index 31df4b8aff6..d13f2288194 100644 --- a/README.fuzzer.md +++ b/README.fuzzer.md @@ -7,7 +7,7 @@ - export CXX=/usr/bin/clang++-18 - export LD=/usr/bin/ld.lld-18 - Run autogen.sh - - ./autogen.sh --with-sanitizer --enable-fuzztargets + - ./autogen.sh && ./configure --with-sanitizer --enable-fuzztargets ## Testing nDPI with ClusterFuzz Artifacts diff --git a/README.md b/README.md index 2c58054d34f..d68390af79d 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,25 @@ A generic FAQ about nDPI is available [here](https://github.com/ntop/nDPI/blob/d In order to compile this project do -- ./autogen.sh +- ./autogen.sh && ./configure - make If you get some errors while compiling `croaring.c`, try: -- ./autogen.sh --enable-old-croaring +- ./autogen.sh && ./configure --enable-old-croaring - make To compile the library w/o any tools or tests: -- ./autogen.sh --with-only-libndpi +- ./autogen.sh && ./configure --with-only-libndpi - make +Out-of-tree builds are supported: +- ./autogen.sh +- mkdir build +- cd build +- ../configure && make + To run tests do additionally: - ./tests/do.sh # Generate and check for diff's in PCAP files @@ -85,7 +91,7 @@ The entire procedure of adding new protocols in detail: 5. Choose (do not change anything) a selection bitmask from: `src/include/ndpi_define.h` 6. Set protocol default ports in `ndpi_init_protocol_defaults` in: `src/lib/ndpi_main.c` 7. Be sure to have nBPF support, cloning `PF_RING` in the same directory where you cloned `nDPI`: `git clone https://github.com/ntop/PF_RING/ && cd PF_RING/userland/nbpf && ./configure && make`. You can ignore the `/bin/sh: 1: ../lib/pfring_config: not found` error -8. From the `nDPI` root directory, `./autogen.sh --with-pcre2` (nBPF and PCRE2 are usually optional, but they are needed to run/update *all* the unit tests) +8. From the `nDPI` root directory, `./autogen.sh && ./configure --with-pcre2` (nBPF and PCRE2 are usually optional, but they are needed to run/update *all* the unit tests) 9. `make` 10. `make check` 11. Update the documentation, adding this new protocol to `doc/protocols.rst` diff --git a/autogen.sh b/autogen.sh index 6cefb0de13e..9487e70ccd3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -42,6 +42,6 @@ fi autoreconf -ivf -echo "./configure $*" -chmod +x configure -./configure "$@" +##### +# Don't call `configure` here!!!! It breaks out-of-tree builds +##### diff --git a/configure.ac b/configure.ac index 801f3ebfd55..c6941e0f4c3 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,6 @@ AS_IF([test "${with_only_libndpi+set}" = set],[ EXTRA_TARGETS="" ]) -PWD=`pwd` - AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer])) AC_ARG_WITH(thread-sanitizer, AS_HELP_STRING([--with-thread-sanitizer], [Build with support for thread sanitizer])) @@ -26,7 +24,7 @@ AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate AC_ARG_WITH(local-libgcrypt, AS_HELP_STRING([--with-local-libgcrypt], [Build with libgcrypt (if present) instead of the enclosed gcrypt light])) AC_ARG_ENABLE(tls-sigs, AS_HELP_STRING([--enable-tls-sigs], [Enable TLS Client signature algorithm dissection. Rarely used, but requires significantly more memory.])) AC_ARG_ENABLE(npcap, AS_HELP_STRING([--disable-npcap], [msys2 only: Disable linkage against the wpcap/npcap import library in windows/WpdPack/Lib.])) -AC_ARG_WITH(nbpf-path, AS_HELP_STRING([--with-nbpf-path], [nBPF library custom path; default: ${PWD}/../PF_RING/userland/nbpf]),[NBPF_HOME=$withval],[NBPF_HOME=${PWD}/../PF_RING/userland/nbpf]) +AC_ARG_WITH(nbpf-path, AS_HELP_STRING([--with-nbpf-path], [nBPF library custom path; default: ${srcdir}/../PF_RING/userland/nbpf]),[NBPF_HOME=$withval],[NBPF_HOME="`cd ${srcdir}/../PF_RING/userland/nbpf 2>/dev/null && pwd || echo ${srcdir}/../PF_RING/userland/nbpf`"]) AC_ARG_WITH(lto-and-gold-linker, AS_HELP_STRING([--with-lto-and-gold-linker], [Build with LTO and Gold linker])) AC_ARG_ENABLE(debug-build, AS_HELP_STRING([--enable-debug-build], [Enable debug build (`-g` flag)]),[enable_debugbuild=$enableval],[enable_debugbuild=no]) AC_ARG_ENABLE(global-context-support, AS_HELP_STRING([--disable-global-context-support], [Disable support for global context. No external dependency on libpthread])) @@ -170,23 +168,23 @@ AC_DEFINE_UNQUOTED(NDPI_PATCH_LEVEL, "${NDPI_PATCH}", [nDPI patch level]) # .git as directory in a cloned repo # .git as file in submodule based integration -if test -d ".git" || test -r ".git"; then - GIT_TAG=`git log -1 --abbrev=7 --format=%h` - GIT_DATE=`git log -1 --abbrev=7 --format=%cd` +if test -d "${srcdir}/.git" || test -r "${srcdir}/.git"; then + GIT_TAG=`cd ${srcdir} && git log -1 --abbrev=7 --format=%h` + GIT_DATE=`cd ${srcdir} && git log -1 --abbrev=7 --format=%cd` # # On CentOS 6 `git rev-list HEAD --count` does not work # # - GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'` + GIT_NUM=`cd ${srcdir} && git log --pretty=oneline | wc -l | tr -d '[[:space:]]'` GIT_RELEASE="${PACKAGE_VERSION}-${GIT_NUM}-${GIT_TAG}" - A=`git log src/include/ndpi_typedefs.h|wc -l` - B=`git log src/include/ndpi_protocol_ids.h|wc -l` - C=`git log src/include/ndpi_api.h|wc -l` + A=`cd ${srcdir} && git log src/include/ndpi_typedefs.h|wc -l` + B=`cd ${srcdir} && git log src/include/ndpi_protocol_ids.h|wc -l` + C=`cd ${srcdir} && git log src/include/ndpi_api.h|wc -l` NDPI_API_VERSION=$((A+B+C)) else GIT_RELEASE="${PACKAGE_VERSION}" - GIT_DATE=`date -u -r CHANGELOG.md` + GIT_DATE=`date -u -r ${srcdir}/CHANGELOG.md` if test -z "$SOURCE_DATE_EPOCH" ; then : SOURCE_DATE_EPOCH=`date +%s` fi @@ -293,7 +291,7 @@ else fi if ! test -d $PCAP_HOME; then : - PCAP_HOME=`pwd`/../../PF_RING/userland + PCAP_HOME=${srcdir}/../../PF_RING/userland fi SHORT_MACHINE=`uname -m | cut -b1-3` if test $SHORT_MACHINE = "arm"; then @@ -318,7 +316,7 @@ else fi CUSTOM_NDPI= -if test -d ../nDPI-custom; then : +if test -d ${srcdir}/../nDPI-custom; then : CUSTOM_NDPI="-DCUSTOM_NDPI_PROTOCOLS" AC_MSG_RESULT([Compiling with custom nDPI protocols]) fi @@ -458,7 +456,10 @@ if test "${with_maxminddb+set}" = set; then : fi fi -AC_DEFINE_UNQUOTED(NDPI_BASE_DIR, "${PWD}", [nDPI base directory]) +dnl> Use absolute source directory for NDPI_BASE_DIR +NDPI_ABS_SRCDIR="`cd ${srcdir} && pwd`" +AC_DEFINE_UNQUOTED(NDPI_BASE_DIR, "${NDPI_ABS_SRCDIR}", [nDPI base directory]) +AC_SUBST(NDPI_BASE_DIR, "${NDPI_ABS_SRCDIR}") dnl> Curl dnl> AC_CHECK_LIB([curl], [curl_easy_perform]) @@ -471,6 +472,8 @@ dnl> fi AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile tests/unit/Makefile tests/performance/Makefile tests/dga/Makefile rrdtool/Makefile influxdb/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile fuzz/Makefile doc/Doxyfile.cfg utils/Makefile]) AC_CONFIG_FILES([tests/do.sh], [chmod +x tests/do.sh]) +AC_CONFIG_FILES([tests/do-dga.sh], [chmod +x tests/do-dga.sh]) +AC_CONFIG_FILES([tests/do-unit.sh], [chmod +x tests/do-unit.sh]) AC_CONFIG_HEADERS(src/include/ndpi_config.h) AC_SUBST(GIT_RELEASE) AC_SUBST(NDPI_MAJOR) diff --git a/example/Makefile.in b/example/Makefile.in index 8593abd5739..c0cda82b90b 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -1,3 +1,9 @@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + AR=@AR@ CC=@CC@ CXX=@CXX@ @@ -11,13 +17,13 @@ BUILD_MINGW=@BUILD_MINGW@ BUILD_MINGW_X64=@BUILD_MINGW_X64@ DISABLE_NPCAP=@DISABLE_NPCAP@ EXE_SUFFIX=@EXE_SUFFIX@ -SRCHOME=../src +SRCHOME=$(top_srcdir)/src ifneq ($(OS),Windows_NT) CFLAGS+=-fPIC -DPIC endif -CFLAGS+=-I$(SRCHOME)/include @NDPI_CFLAGS@ @PCAP_INC@ @GPROF_CFLAGS@ @CUSTOM_NDPI@ +CFLAGS+=-I$(SRCHOME)/include -I$(top_builddir)/src/include @NDPI_CFLAGS@ @PCAP_INC@ @GPROF_CFLAGS@ @CUSTOM_NDPI@ LDFLAGS+=@NDPI_LDFLAGS@ -LIBNDPI=$(SRCHOME)/lib/libndpi.a +LIBNDPI=$(top_builddir)/src/lib/libndpi.a LIBS=$(LIBNDPI) @PCAP_LIB@ @ADDITIONAL_LIBS@ @LIBS@ @GPROF_LIBS@ HEADERS=reader_util.h $(SRCHOME)/include/ndpi_api.h \ $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h @@ -51,7 +57,7 @@ CFLAGS+=-pthread all: ndpiReader$(EXE_SUFFIX) @DPDK_TARGET@ EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c -COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c )) +COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(notdir $(wildcard $(srcdir)/*.c))) libndpiReader.a: $(COMMON_SOURCES:%.c=%.o) $(LIBNDPI) $(AR) rsv libndpiReader.a $(COMMON_SOURCES:%.c=%.o) @@ -69,8 +75,8 @@ install: ndpiReader$(EXE_SUFFIX) mkdir -p $(DESTDIR)$(PREFIX)/bin/ mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi cp ndpiReader$(EXE_SUFFIX) $(DESTDIR)$(PREFIX)/bin/ - cp protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt - cp mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt + cp $(srcdir)/protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt + cp $(srcdir)/mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt [ -f ndpiSimpleIntegration$(EXE_SUFFIX) ] && cp ndpiSimpleIntegration$(EXE_SUFFIX) $(DESTDIR)$(PREFIX)/bin/ndpiSimpleIntegration$(EXE_SUFFIX) || true [ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true [ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true @@ -82,7 +88,7 @@ check: true # nothing to do here cppcheck: - cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include *.c + cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include $(srcdir)/*.c clean: /bin/rm -f *.o ndpiReader ndpiSimpleIntegration ndpiReader$(EXE_SUFFIX) ndpiSimpleIntegration$(EXE_SUFFIX) ndpiReader.dpdk libndpiReader.a @@ -91,8 +97,8 @@ clean: /bin/rm -rf build distdir: - cp README.DPDK '$(distdir)/' - find . -maxdepth 1 -type f -name '*.c' \ + cp $(srcdir)/README.DPDK '$(distdir)/' + find $(srcdir) -maxdepth 1 -type f -name '*.c' \ -o -name '*.h' \ -o -name '*.py' \ -o -name '*.txt' \ diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index 41295c9eeb6..c4cd73050bf 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -15,11 +15,11 @@ bin_PROGRAMS += fuzz_readerutils_workflow bin_PROGRAMS += fuzz_ndpi_reader_pl7m fuzz_ndpi_reader_pl7m_64k fuzz_ndpi_reader_pl7m_simplest fuzz_ndpi_reader_pl7m_internal fuzz_ndpi_reader_pl7m_simplest_internal fuzz_ndpi_reader_pl7m_only_subclassification fuzz_ndpi_reader_pl7m_randomize_ports #Common flags -AM_CPPFLAGS = -I ../src/lib/third_party/include/ +AM_CPPFLAGS = -I $(top_srcdir)/src/include -I $(top_srcdir)/src/lib/third_party/include/ AM_LDFLAGS = $(LIBS) AM_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) AM_CXXFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -LDADD = $(PCAP_LIB) ../src/lib/libndpi.a $(ADDITIONAL_LIBS) +LDADD = $(PCAP_LIB) $(top_builddir)/src/lib/libndpi.a $(ADDITIONAL_LIBS) if HAS_FUZZLDFLAGS CFLAGS += $(LIB_FUZZING_ENGINE) LDFLAGS += $(LIB_FUZZING_ENGINE) @@ -34,21 +34,21 @@ fuzz_process_packet_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(fuzz_process_packet_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_SOURCES = fuzz_ndpi_reader.c fuzz_common_code.c ../example/reader_util.c -fuzz_ndpi_reader_CFLAGS = -I../example/ +fuzz_ndpi_reader_CFLAGS = -I$(top_srcdir)/example/ # force usage of CXX for linker fuzz_ndpi_reader_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_alloc_fail_SOURCES = fuzz_ndpi_reader_alloc_fail.c fuzz_common_code.c ../example/reader_util.c -fuzz_ndpi_reader_alloc_fail_CFLAGS = -I../example/ -DENABLE_MEM_ALLOC_FAILURES -DCRYPT_FORCE_NO_AESNI -DENABLE_FINGERPRINT_FP +fuzz_ndpi_reader_alloc_fail_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_MEM_ALLOC_FAILURES -DCRYPT_FORCE_NO_AESNI -DENABLE_FINGERPRINT_FP # force usage of CXX for linker fuzz_ndpi_reader_alloc_fail_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_alloc_fail_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_payload_analyzer_SOURCES = fuzz_ndpi_reader_payload_analyzer.c fuzz_common_code.c ../example/reader_util.c -fuzz_ndpi_reader_payload_analyzer_CFLAGS = -I../example/ -DENABLE_MEM_ALLOC_FAILURES -DENABLE_PAYLOAD_ANALYZER +fuzz_ndpi_reader_payload_analyzer_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_MEM_ALLOC_FAILURES -DENABLE_PAYLOAD_ANALYZER # force usage of CXX for linker fuzz_ndpi_reader_payload_analyzer_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ @@ -348,56 +348,56 @@ fuzz_filecfg_category_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(fuzz_filecfg_category_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_readerutils_workflow_SOURCES = fuzz_readerutils_workflow.cpp fuzz_common_code.c ../example/reader_util.c -fuzz_readerutils_workflow_CXXFLAGS = -I../example/ +fuzz_readerutils_workflow_CXXFLAGS = -I$(top_srcdir)/example/ # force usage of CXX for linker fuzz_readerutils_workflow_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_readerutils_workflow_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_simplest_SOURCES = fuzz_ndpi_reader_pl7m_simplest.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_simplest_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_SIMPLEST_MUTATOR +fuzz_ndpi_reader_pl7m_simplest_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_SIMPLEST_MUTATOR # force usage of CXX for linker fuzz_ndpi_reader_pl7m_simplest_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_simplest_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_simplest_internal_SOURCES = fuzz_ndpi_reader_pl7m_simplest_internal.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_simplest_internal_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_SIMPLEST_MUTATOR -DPL7M_USE_INTERNAL_FUZZER_MUTATE +fuzz_ndpi_reader_pl7m_simplest_internal_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_SIMPLEST_MUTATOR -DPL7M_USE_INTERNAL_FUZZER_MUTATE # force usage of CXX for linker fuzz_ndpi_reader_pl7m_simplest_internal_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_simplest_internal_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_SOURCES = fuzz_ndpi_reader_pl7m.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DENABLE_CONFIG2 +fuzz_ndpi_reader_pl7m_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DENABLE_CONFIG2 # force usage of CXX for linker fuzz_ndpi_reader_pl7m_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_64k_SOURCES = fuzz_ndpi_reader_pl7m_64k.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_64k_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_64K_PACKETS +fuzz_ndpi_reader_pl7m_64k_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_64K_PACKETS # force usage of CXX for linker fuzz_ndpi_reader_pl7m_64k_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_64k_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_internal_SOURCES = fuzz_ndpi_reader_pl7m_internal.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_internal_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_INTERNAL_FUZZER_MUTATE +fuzz_ndpi_reader_pl7m_internal_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_USE_INTERNAL_FUZZER_MUTATE # force usage of CXX for linker fuzz_ndpi_reader_pl7m_internal_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_internal_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_only_subclassification_SOURCES = fuzz_ndpi_reader_pl7m_only_subclassification.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_only_subclassification_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DENABLE_ONLY_SUBCLASSIFICATION +fuzz_ndpi_reader_pl7m_only_subclassification_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DENABLE_ONLY_SUBCLASSIFICATION # force usage of CXX for linker fuzz_ndpi_reader_pl7m_only_subclassification_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ $(fuzz_ndpi_reader_pl7m_only_subclassification_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@ fuzz_ndpi_reader_pl7m_randomize_ports_SOURCES = fuzz_ndpi_reader_pl7m_randomize_ports.c fuzz_common_code.c ../example/reader_util.c ../src/lib/third_party/src/fuzz/pl7m.c -fuzz_ndpi_reader_pl7m_randomize_ports_CFLAGS = -I../example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_ENABLE_RANDOMIZE_PORTS +fuzz_ndpi_reader_pl7m_randomize_ports_CFLAGS = -I$(top_srcdir)/example/ -DENABLE_PCAP_L7_MUTATOR -DPL7M_ENABLE_RANDOMIZE_PORTS # force usage of CXX for linker fuzz_ndpi_reader_pl7m_randomize_ports_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \ @@ -406,7 +406,7 @@ fuzz_ndpi_reader_pl7m_randomize_ports_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_L # required for Google oss-fuzz # see https://github.com/google/oss-fuzz/tree/master/projects/ndpi -testpcaps := $(wildcard ../tests/cfgs/default/pcap/*.pcap*) +testpcaps := $(wildcard $(top_srcdir)/tests/cfgs/default/pcap/*.pcap*) testpcaps.zip: $(testpcaps) zip -j testpcaps.zip $(testpcaps) @@ -441,118 +441,118 @@ fuzz_ndpi_reader_pl7m_only_subclassification_seed_corpus.zip: testpcaps.zip fuzz_ndpi_reader_pl7m_randomize_ports_seed_corpus.zip: testpcaps.zip cp testpcaps.zip fuzz_ndpi_reader_pl7m_randomize_ports_seed_corpus.zip -files_corpus_fuzz_quic_get_crypto_data := $(wildcard corpus/fuzz_quic_get_crypto_data/*) +files_corpus_fuzz_quic_get_crypto_data := $(wildcard $(srcdir)/corpus/fuzz_quic_get_crypto_data/*) fuzz_quic_get_crypto_data_seed_corpus.zip: $(files_corpus_fuzz_quic_get_crypto_data) zip -j fuzz_quic_get_crypto_data_seed_corpus.zip $(files_corpus_fuzz_quic_get_crypto_data) -files_corpus_fuzz_serialization := $(wildcard corpus/fuzz_serialization/*) +files_corpus_fuzz_serialization := $(wildcard $(srcdir)/corpus/fuzz_serialization/*) fuzz_serialization_seed_corpus.zip: $(files_corpus_fuzz_serialization) zip -j fuzz_serialization_seed_corpus.zip $(files_corpus_fuzz_serialization) -files_corpus_fuzz_community_id := $(wildcard corpus/fuzz_community_id/*) +files_corpus_fuzz_community_id := $(wildcard $(srcdir)/corpus/fuzz_community_id/*) fuzz_community_id_seed_corpus.zip: $(files_corpus_fuzz_community_id) zip -j fuzz_community_id_seed_corpus.zip $(files_corpus_fuzz_community_id) -files_corpus_fuzz_is_stun_udp := $(wildcard corpus/fuzz_is_stun_udp/*) +files_corpus_fuzz_is_stun_udp := $(wildcard $(srcdir)/corpus/fuzz_is_stun_udp/*) fuzz_is_stun_udp_seed_corpus.zip: $(files_corpus_fuzz_is_stun_udp) zip -j fuzz_is_stun_udp_seed_corpus.zip $(files_corpus_fuzz_is_stun_udp) -files_corpus_fuzz_is_stun_tcp := $(wildcard corpus/fuzz_is_stun_tcp/*) +files_corpus_fuzz_is_stun_tcp := $(wildcard $(srcdir)/corpus/fuzz_is_stun_tcp/*) fuzz_is_stun_tcp_seed_corpus.zip: $(files_corpus_fuzz_is_stun_tcp) zip -j fuzz_is_stun_tcp_seed_corpus.zip $(files_corpus_fuzz_is_stun_tcp) -files_corpus_fuzz_alg_ses_des := $(wildcard corpus/fuzz_alg_ses_des/*) +files_corpus_fuzz_alg_ses_des := $(wildcard $(srcdir)/corpus/fuzz_alg_ses_des/*) fuzz_alg_ses_des_seed_corpus.zip: $(files_corpus_fuzz_alg_ses_des) zip -j fuzz_alg_ses_des_seed_corpus.zip $(files_corpus_fuzz_alg_ses_des) -files_corpus_fuzz_alg_bins := $(wildcard corpus/fuzz_alg_bins/*) +files_corpus_fuzz_alg_bins := $(wildcard $(srcdir)/corpus/fuzz_alg_bins/*) fuzz_alg_bins_seed_corpus.zip: $(files_corpus_fuzz_alg_bins) zip -j fuzz_alg_bins_seed_corpus.zip $(files_corpus_fuzz_alg_bins) -files_corpus_fuzz_alg_hll := $(wildcard corpus/fuzz_alg_hll/*) +files_corpus_fuzz_alg_hll := $(wildcard $(srcdir)/corpus/fuzz_alg_hll/*) fuzz_alg_hll_seed_corpus.zip: $(files_corpus_fuzz_alg_hll) zip -j fuzz_alg_hll_seed_corpus.zip $(files_corpus_fuzz_alg_hll) -files_corpus_fuzz_alg_jitter := $(wildcard corpus/fuzz_alg_jitter/*) +files_corpus_fuzz_alg_jitter := $(wildcard $(srcdir)/corpus/fuzz_alg_jitter/*) fuzz_alg_jitter_seed_corpus.zip: $(files_corpus_fuzz_alg_jitter) zip -j fuzz_alg_jitter_seed_corpus.zip $(files_corpus_fuzz_alg_jitter) -files_corpus_fuzz_alg_crc32_md5 := $(wildcard corpus/fuzz_alg_crc32_md5/*) +files_corpus_fuzz_alg_crc32_md5 := $(wildcard $(srcdir)/corpus/fuzz_alg_crc32_md5/*) fuzz_alg_crc32_md5_seed_corpus.zip: $(files_corpus_fuzz_alg_crc32_md5) zip -j fuzz_alg_crc32_md5_seed_corpus.zip $(files_corpus_fuzz_alg_crc32_md5) -files_corpus_fuzz_ds_libcache := $(wildcard corpus/fuzz_ds_libcache/*) +files_corpus_fuzz_ds_libcache := $(wildcard $(srcdir)/corpus/fuzz_ds_libcache/*) fuzz_ds_libcache_seed_corpus.zip: $(files_corpus_fuzz_ds_libcache) zip -j fuzz_ds_libcache_seed_corpus.zip $(files_corpus_fuzz_ds_libcache) -files_corpus_fuzz_ds_ptree := $(wildcard corpus/fuzz_ds_ptree/*) +files_corpus_fuzz_ds_ptree := $(wildcard $(srcdir)/corpus/fuzz_ds_ptree/*) fuzz_ds_ptree_seed_corpus.zip: $(files_corpus_fuzz_ds_ptree) zip -j fuzz_ds_ptree_seed_corpus.zip $(files_corpus_fuzz_ds_ptree) -files_corpus_fuzz_alg_bytestream := $(wildcard corpus/fuzz_alg_bytestream/*) +files_corpus_fuzz_alg_bytestream := $(wildcard $(srcdir)/corpus/fuzz_alg_bytestream/*) fuzz_alg_bytestream_seed_corpus.zip: $(files_corpus_fuzz_alg_bytestream) zip -j fuzz_alg_bytestream_seed_corpus.zip $(files_corpus_fuzz_alg_bytestream) -files_corpus_fuzz_libinjection := $(wildcard corpus/fuzz_libinjection/*) +files_corpus_fuzz_libinjection := $(wildcard $(srcdir)/corpus/fuzz_libinjection/*) fuzz_libinjection_seed_corpus.zip: $(files_corpus_fuzz_libinjection) zip -j fuzz_libinjection_seed_corpus.zip $(files_corpus_fuzz_libinjection) -files_corpus_fuzz_tls_certificate := $(wildcard corpus/fuzz_tls_certificate/*) +files_corpus_fuzz_tls_certificate := $(wildcard $(srcdir)/corpus/fuzz_tls_certificate/*) fuzz_tls_certificate_seed_corpus.zip: $(files_corpus_fuzz_tls_certificate) zip -j fuzz_tls_certificate_seed_corpus.zip $(files_corpus_fuzz_tls_certificate) -files_corpus_fuzz_filecfg_protocols := $(wildcard corpus/fuzz_filecfg_protocols/*) +files_corpus_fuzz_filecfg_protocols := $(wildcard $(srcdir)/corpus/fuzz_filecfg_protocols/*) fuzz_filecfg_protocols_seed_corpus.zip: $(files_corpus_fuzz_filecfg_protocols) zip -j fuzz_filecfg_protocols_seed_corpus.zip $(files_corpus_fuzz_filecfg_protocols) -files_corpus_fuzz_filecfg_categories := $(wildcard corpus/fuzz_filecfg_categories/*) +files_corpus_fuzz_filecfg_categories := $(wildcard $(srcdir)/corpus/fuzz_filecfg_categories/*) fuzz_filecfg_categories_seed_corpus.zip: $(files_corpus_fuzz_filecfg_categories) zip -j fuzz_filecfg_categories_seed_corpus.zip $(files_corpus_fuzz_filecfg_categories) -files_corpus_fuzz_filecfg_malicious_sha1 := $(wildcard corpus/fuzz_filecfg_malicious_sha1/*) +files_corpus_fuzz_filecfg_malicious_sha1 := $(wildcard $(srcdir)/corpus/fuzz_filecfg_malicious_sha1/*) fuzz_filecfg_malicious_sha1_seed_corpus.zip: $(files_corpus_fuzz_filecfg_malicious_sha1) zip -j fuzz_filecfg_malicious_sha1_seed_corpus.zip $(files_corpus_fuzz_filecfg_malicious_sha1) -files_corpus_fuzz_filecfg_malicious_ja4 := $(wildcard corpus/fuzz_filecfg_malicious_ja4/*) +files_corpus_fuzz_filecfg_malicious_ja4 := $(wildcard $(srcdir)/corpus/fuzz_filecfg_malicious_ja4/*) fuzz_filecfg_malicious_ja4_seed_corpus.zip: $(files_corpus_fuzz_filecfg_malicious_ja4) zip -j fuzz_filecfg_malicious_ja4_seed_corpus.zip $(files_corpus_fuzz_filecfg_malicious_ja4) -files_corpus_fuzz_filecfg_risk_domains := $(wildcard corpus/fuzz_filecfg_risk_domains/*) +files_corpus_fuzz_filecfg_risk_domains := $(wildcard $(srcdir)/corpus/fuzz_filecfg_risk_domains/*) fuzz_filecfg_risk_domains_seed_corpus.zip: $(files_corpus_fuzz_filecfg_risk_domains) zip -j fuzz_filecfg_risk_domains_seed_corpus.zip $(files_corpus_fuzz_filecfg_risk_domains) -files_corpus_fuzz_filecfg_config := $(wildcard corpus/fuzz_filecfg_config/*) +files_corpus_fuzz_filecfg_config := $(wildcard $(srcdir)/corpus/fuzz_filecfg_config/*) fuzz_filecfg_config_seed_corpus.zip: $(files_corpus_fuzz_filecfg_config) zip -j fuzz_filecfg_config_seed_corpus.zip $(files_corpus_fuzz_filecfg_config) -files_corpus_fuzz_filecfg_category := $(wildcard corpus/fuzz_filecfg_category/*) +files_corpus_fuzz_filecfg_category := $(wildcard $(srcdir)/corpus/fuzz_filecfg_category/*) fuzz_filecfg_category_seed_corpus.zip: $(files_corpus_fuzz_filecfg_category) zip -j fuzz_filecfg_category_seed_corpus.zip $(files_corpus_fuzz_filecfg_category) -files_corpus_fuzz_readerutils_workflow := $(wildcard corpus/fuzz_readerutils_workflow/*) +files_corpus_fuzz_readerutils_workflow := $(wildcard $(srcdir)/corpus/fuzz_readerutils_workflow/*) fuzz_readerutils_workflow_seed_corpus.zip: $(files_corpus_fuzz_readerutils_workflow) zip -j fuzz_readerutils_workflow_seed_corpus.zip $(files_corpus_fuzz_readerutils_workflow) -files_corpus_fuzz_ds_bitmap64_fuse := $(wildcard corpus/fuzz_ds_bitmap64_fuse/*) +files_corpus_fuzz_ds_bitmap64_fuse := $(wildcard $(srcdir)/corpus/fuzz_ds_bitmap64_fuse/*) fuzz_ds_bitmap64_fuse_seed_corpus.zip: $(files_corpus_fuzz_ds_bitmap64_fuse) zip -j fuzz_ds_bitmap64_fuse_seed_corpus.zip $(files_corpus_fuzz_ds_bitmap64_fuse) -files_corpus_fuzz_ds_domain_classify := $(wildcard corpus/fuzz_ds_domain_classify/*) +files_corpus_fuzz_ds_domain_classify := $(wildcard $(srcdir)/corpus/fuzz_ds_domain_classify/*) fuzz_ds_domain_classify_seed_corpus.zip: $(files_corpus_fuzz_ds_domain_classify) zip -j fuzz_ds_domain_classify_seed_corpus.zip $(files_corpus_fuzz_ds_domain_classify) corpus: fuzz_ndpi_reader_seed_corpus.zip fuzz_ndpi_reader_alloc_fail_seed_corpus.zip fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip fuzz_quic_get_crypto_data_seed_corpus.zip fuzz_alg_ses_des_seed_corpus.zip fuzz_alg_bins_seed_corpus.zip fuzz_alg_hll_seed_corpus.zip fuzz_alg_jitter_seed_corpus.zip fuzz_ds_libcache_seed_corpus.zip fuzz_community_id_seed_corpus.zip fuzz_serialization_seed_corpus.zip fuzz_ds_ptree_seed_corpus.zip fuzz_alg_crc32_md5_seed_corpus.zip fuzz_alg_bytestream_seed_corpus.zip fuzz_libinjection_seed_corpus.zip fuzz_tls_certificate_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip fuzz_readerutils_workflow_seed_corpus.zip fuzz_ds_bitmap64_fuse_seed_corpus.zip fuzz_ds_domain_classify_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip fuzz_is_stun_udp_seed_corpus.zip fuzz_is_stun_tcp_seed_corpus.zip fuzz_ndpi_reader_pl7m_simplest_seed_corpus.zip fuzz_ndpi_reader_pl7m_seed_corpus.zip fuzz_ndpi_reader_pl7m_64k_seed_corpus.zip fuzz_ndpi_reader_pl7m_simplest_internal_seed_corpus.zip fuzz_ndpi_reader_pl7m_internal_seed_corpus.zip fuzz_ndpi_reader_pl7m_only_subclassification_seed_corpus.zip fuzz_ndpi_reader_pl7m_randomize_ports_seed_corpus.zip fuzz_filecfg_malicious_ja4_seed_corpus.zip fuzz_filecfg_malicious_sha1_seed_corpus.zip fuzz_filecfg_categories_seed_corpus.zip - cp corpus/fuzz_*seed_corpus.zip . + cp $(srcdir)/corpus/fuzz_*seed_corpus.zip . #Create dictionaries exactly as expected by oss-fuzz. #This way, if we need to change/update/add something, #we don't need to update scripts in oss-fuzz repository dictionaries: - cp dictionary.dict fuzz_ndpi_reader.dict - cp dictionary.dict fuzz_ndpi_reader_alloc_fail.dict - cp dictionary.dict fuzz_ndpi_reader_payload_analyzer.dict - cp dictionary.dict fuzz_process_packet.dict - cp dictionary_tls_certificate.dict fuzz_tls_certificate.dict + cp $(srcdir)/dictionary.dict fuzz_ndpi_reader.dict + cp $(srcdir)/dictionary.dict fuzz_ndpi_reader_alloc_fail.dict + cp $(srcdir)/dictionary.dict fuzz_ndpi_reader_payload_analyzer.dict + cp $(srcdir)/dictionary.dict fuzz_process_packet.dict + cp $(srcdir)/dictionary_tls_certificate.dict fuzz_tls_certificate.dict clean: rm -f *.o $(bin_PROGRAMS) @@ -561,8 +561,8 @@ clean: rm -f fuzz*.dict distdir: - find . -type d | xargs -I'{}' mkdir -p '$(distdir)/{}' - find . -type f -name '*.c' \ + find $(srcdir) -type d | xargs -I'{}' mkdir -p '$(distdir)/{}' + find $(srcdir) -type f -name '*.c' \ -o -name '*.am' \ -o -name '*.h' \ -o -name '*.cpp' \ @@ -572,34 +572,34 @@ distdir: -o -name 'bd_param.txt' \ -o -name 'splt_param.txt' \ -o -name 'random_list.list' \ - -o -path './dictionary.dict' \ - -o -path './dictionary_tls_certificate.dict' \ - -o -path './corpus/fuzz_*.zip' \ - -o -path './corpus/fuzz_quic_get_crypto_data/*' \ - -o -path './corpus/fuzz_filecfg_protocols/*' \ - -o -path './corpus/fuzz_filecfg_categories/*' \ - -o -path './corpus/fuzz_filecfg_malicious_sha1/*' \ - -o -path './corpus/fuzz_filecfg_malicious_ja4/*' \ - -o -path './corpus/fuzz_filecfg_risk_domains/*' \ - -o -path './corpus/fuzz_filecfg_config/*' \ - -o -path './corpus/fuzz_filecfg_category/*' \ - -o -path './corpus/fuzz_readerutils_workflow/*' \ - -o -path './corpus/fuzz_is_stun_udp/*' \ - -o -path './corpus/fuzz_is_stun_tcp/*' \ - -o -path './corpus/fuzz_serialization/*' \ - -o -path './corpus/fuzz_community_id/*' \ - -o -path './corpus/fuzz_libinjection/*' \ - -o -path './corpus/fuzz_tls_certificate/*' \ - -o -path './corpus/fuzz_alg_ses_des/*' \ - -o -path './corpus/fuzz_alg_bins/*' \ - -o -path './corpus/fuzz_alg_hll/*' \ - -o -path './corpus/fuzz_alg_jitter/*' \ - -o -path './corpus/fuzz_alg_crc32_md5/*' \ - -o -path './corpus/fuzz_alg_bytestream/*' \ - -o -path './corpus/fuzz_ds_libcache/*' \ - -o -path './corpus/fuzz_ds_bitmap64_fuse/*' \ - -o -path './corpus/fuzz_ds_domain_classify/*' \ - -o -path './corpus/fuzz_ds_ptree/*' | xargs -I'{}' cp -r '{}' '$(distdir)/{}' + -o -path '$(srcdir)/dictionary.dict' \ + -o -path '$(srcdir)/dictionary_tls_certificate.dict' \ + -o -path '$(srcdir)/corpus/fuzz_*.zip' \ + -o -path '$(srcdir)/corpus/fuzz_quic_get_crypto_data/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_protocols/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_categories/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_malicious_sha1/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_malicious_ja4/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_risk_domains/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_config/*' \ + -o -path '$(srcdir)/corpus/fuzz_filecfg_category/*' \ + -o -path '$(srcdir)/corpus/fuzz_readerutils_workflow/*' \ + -o -path '$(srcdir)/corpus/fuzz_is_stun_udp/*' \ + -o -path '$(srcdir)/corpus/fuzz_is_stun_tcp/*' \ + -o -path '$(srcdir)/corpus/fuzz_serialization/*' \ + -o -path '$(srcdir)/corpus/fuzz_community_id/*' \ + -o -path '$(srcdir)/corpus/fuzz_libinjection/*' \ + -o -path '$(srcdir)/corpus/fuzz_tls_certificate/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_ses_des/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_bins/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_hll/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_jitter/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_crc32_md5/*' \ + -o -path '$(srcdir)/corpus/fuzz_alg_bytestream/*' \ + -o -path '$(srcdir)/corpus/fuzz_ds_libcache/*' \ + -o -path '$(srcdir)/corpus/fuzz_ds_bitmap64_fuse/*' \ + -o -path '$(srcdir)/corpus/fuzz_ds_domain_classify/*' \ + -o -path '$(srcdir)/corpus/fuzz_ds_ptree/*' | xargs -I'{}' cp -r '{}' '$(distdir)/{}' find . -type l -name '*.c' | xargs -I'{}' cp -r '{}' '$(distdir)/{}' all: corpus dictionaries diff --git a/influxdb/Makefile.in b/influxdb/Makefile.in index 26466e43e31..4da0d27579a 100644 --- a/influxdb/Makefile.in +++ b/influxdb/Makefile.in @@ -1,6 +1,12 @@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + CC=@CC@ -INC=-I ../src/include -I/usr/local/include -LIBDPI=../src/lib/libndpi.a +INC=-I $(top_srcdir)/src/include -I $(top_builddir)/src/include -I/usr/local/include +LIBDPI=$(top_builddir)/src/lib/libndpi.a CFLAGS+=@NDPI_CFLAGS@ LDFLAGS+=@NDPI_LDFLAGS@ LIB=$(LIBDPI) -lm @ADDITIONAL_LIBS@ @LIBS@ @@ -9,8 +15,8 @@ TOOLS=metric_anomaly all: $(TOOLS) -metric_anomaly: metric_anomaly.c Makefile $(LIBDPI) - $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) metric_anomaly.c -o metric_anomaly $(LIB) +metric_anomaly: $(srcdir)/metric_anomaly.c Makefile $(LIBDPI) + $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) $(srcdir)/metric_anomaly.c -o metric_anomaly $(LIB) clean: /bin/rm -f *.o $(TOOLS) *~ @@ -19,7 +25,7 @@ distclean: clean /bin/rm -f Makefile distdir: - find . -type f -name '*.c' \ + find $(srcdir) -type f -name '*.c' \ -o -name '*.txt' | xargs -I'{}' cp '{}' '$(distdir)/{}' install: diff --git a/rrdtool/Makefile.in b/rrdtool/Makefile.in index f82da441a00..9bff755cd62 100644 --- a/rrdtool/Makefile.in +++ b/rrdtool/Makefile.in @@ -1,6 +1,12 @@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + CC=@CC@ -INC=-I ../src/include -I/usr/local/include -LIBDPI=../src/lib/libndpi.a +INC=-I $(top_srcdir)/src/include -I $(top_builddir)/src/include -I/usr/local/include +LIBDPI=$(top_builddir)/src/lib/libndpi.a CFLAGS+=@NDPI_CFLAGS@ LDFLAGS+=@NDPI_LDFLAGS@ LIB=$(LIBDPI) -lm @ADDITIONAL_LIBS@ @LIBRRD@ @LIBS@ -lpthread @@ -9,11 +15,11 @@ TOOLS=rrd_anomaly rrd_similarity all: $(TOOLS) -rrd_anomaly: rrd_anomaly.c Makefile $(LIBDPI) - $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) rrd_anomaly.c -o rrd_anomaly $(LIB) +rrd_anomaly: $(srcdir)/rrd_anomaly.c Makefile $(LIBDPI) + $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) $(srcdir)/rrd_anomaly.c -o rrd_anomaly $(LIB) -rrd_similarity: rrd_similarity.c Makefile $(LIBDPI) - $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) rrd_similarity.c -o rrd_similarity $(LIB) +rrd_similarity: $(srcdir)/rrd_similarity.c Makefile $(LIBDPI) + $(CC) $(CFLAGS) $(CPPFLAGS) -g $(INC) $(LDFLAGS) $(srcdir)/rrd_similarity.c -o rrd_similarity $(LIB) clean: /bin/rm -f *.o $(TOOLS) *~ @@ -22,7 +28,7 @@ distclean: clean /bin/rm -f Makefile distdir: - find . -type f -name '*.c' \ + find $(srcdir) -type f -name '*.c' \ -o -name '*.txt' | xargs -I'{}' cp '{}' '$(distdir)/{}' install: diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index f0e72843907..12ee4a1e61a 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -5,6 +5,12 @@ # cd src/lib # make Makefile # +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@:@srcdir@/protocols:@srcdir@/third_party/src:@srcdir@/third_party/src/hll + AR = @AR@ CC = @CC@ RANLIB = @RANLIB@ @@ -23,17 +29,17 @@ endif ifneq ($(OS),Windows_NT) CFLAGS += -fPIC -DPIC endif -CFLAGS += -I. -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @NDPI_CFLAGS@ @GPROF_CFLAGS@ @CUSTOM_NDPI@ @ADDITIONAL_INCS@ +CFLAGS += -I$(srcdir) -I$(top_srcdir)/src/include -I$(top_builddir)/src/include -I$(srcdir)/third_party/include -DNDPI_LIB_COMPILATION @NDPI_CFLAGS@ @GPROF_CFLAGS@ @CUSTOM_NDPI@ @ADDITIONAL_INCS@ CFLAGS_ndpi_bitmap.c := -Wno-unused-function CFLAGS_ndpi_bitmap64_fuse.c := -Wno-unused-function -CFLAGS_third_party/src/gcrypt_light.c := -Wno-unused-function -Wno-unused-parameter -CFLAGS_third_party/src/ahocorasick.c := -Wno-unused-function -Wno-unused-parameter -CFLAGS_third_party/src/roaring.c := -Wno-unused-function -Wno-attributes +CFLAGS_gcrypt_light.c := -Wno-unused-function -Wno-unused-parameter +CFLAGS_ahocorasick.c := -Wno-unused-function -Wno-unused-parameter +CFLAGS_roaring.c := -Wno-unused-function -Wno-attributes LDFLAGS += @NDPI_LDFLAGS@ LIBS = @ADDITIONAL_LIBS@ @LIBS@ @GPROF_LIBS@ -OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) $(patsubst third_party/src/hll/%.c, third_party/src/hll/%.o, $(wildcard third_party/src/hll/*.c)) $(patsubst ./%.c, ./%.o, $(wildcard ./*.c)) -HEADERS = $(wildcard ../include/*.h) $(wildcard *.h) +OBJECTS = $(patsubst $(srcdir)/protocols/%.c, %.o, $(wildcard $(srcdir)/protocols/*.c)) $(patsubst $(srcdir)/third_party/src/%.c, %.o, $(wildcard $(srcdir)/third_party/src/*.c)) $(patsubst $(srcdir)/third_party/src/hll/%.c, %.o, $(wildcard $(srcdir)/third_party/src/hll/*.c)) $(patsubst $(srcdir)/%.c, %.o, $(wildcard $(srcdir)/*.c)) +HEADERS = $(wildcard $(top_srcdir)/src/include/*.h) $(wildcard $(top_builddir)/src/include/*.h) $(wildcard $(srcdir)/*.h) NDPI_VERSION_MAJOR = @NDPI_MAJOR@ NDPI_LIB_STATIC = libndpi.a NDPI_LIB_SHARED_BASE = libndpi.so @@ -62,7 +68,7 @@ endif all: $(NDPI_LIBS) -ndpi_main.c: ndpi_content_match.c.inc +ndpi_main.o: $(srcdir)/ndpi_content_match.c.inc $(NDPI_LIB_STATIC): $(OBJECTS) $(AR) rc $@ $(OBJECTS) @@ -74,17 +80,17 @@ $(NDPI_LIB_SHARED): $(OBJECTS) ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) %.o: %.c $(HEADERS) Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$<) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$(notdir $<)) -c $< -o $@ clean: /bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo libndpi.so* distdir: - find . -type d | xargs -I'{}' mkdir -p '$(distdir)/{}' - find ../include -type f -name '*.h' \ + find $(srcdir) -type d | xargs -I'{}' mkdir -p '$(distdir)/{}' + find $(top_srcdir)/src/include -type f -name '*.h' \ -a '!' -name 'ndpi_config.h' \ -a '!' -name 'ndpi_define.h' | xargs -I'{}' cp '{}' '$(distdir)/{}' - find . -type f -name '*.c' \ + find $(srcdir) -type f -name '*.c' \ -o -name '*.cc' \ -o -name '*.c.inc' \ -o -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}' @@ -96,7 +102,7 @@ check: true # nothing to do here cppcheck: - cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I ../include *.c protocols/*.c + cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I $(top_srcdir)/src/include $(srcdir)/*.c $(srcdir)/protocols/*.c install: $(NDPI_LIBS) mkdir -p $(DESTDIR)@libdir@ @@ -105,4 +111,4 @@ install: $(NDPI_LIBS) cp -P $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) $(DESTDIR)@libdir@/ mkdir -p $(DESTDIR)@includedir@ #Avoid installing private header - find ../include/*.h ! -name ndpi_private.h -exec cp "{}" $(DESTDIR)@includedir@/ \; + find $(top_srcdir)/src/include/*.h ! -name ndpi_private.h -exec cp "{}" $(DESTDIR)@includedir@/ \; diff --git a/tests/dga/Makefile.in b/tests/dga/Makefile.in index 39958c4f97c..3e3c993d69e 100644 --- a/tests/dga/Makefile.in +++ b/tests/dga/Makefile.in @@ -1,14 +1,20 @@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + CC=@CC@ CXX=@CXX@ EXE_SUFFIX=@EXE_SUFFIX@ -SRCHOME=../../src +SRCHOME=$(top_srcdir)/src ifneq ($(OS),Windows_NT) CFLAGS+=-fPIC -DPIC endif -CFLAGS+=-g -I$(SRCHOME)/include @NDPI_CFLAGS@ -LIBNDPI=$(SRCHOME)/lib/libndpi.a +CFLAGS+=-g -I$(SRCHOME)/include -I$(top_builddir)/src/include @NDPI_CFLAGS@ +LIBNDPI=$(top_builddir)/src/lib/libndpi.a LIBS=$(LIBNDPI) @ADDITIONAL_LIBS@ -lpthread @LIBS@ LDFLAGS+=@NDPI_LDFLAGS@ HEADERS=$(SRCHOME)/include/ndpi_api.h $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h diff --git a/tests/do-dga.sh b/tests/do-dga.sh.in similarity index 79% rename from tests/do-dga.sh rename to tests/do-dga.sh.in index ca5bcbd9b72..3f48821b2b8 100755 --- a/tests/do-dga.sh +++ b/tests/do-dga.sh.in @@ -2,6 +2,11 @@ cd "$(dirname "${0}")" || exit 1 +TOP_SRCDIR="@top_srcdir@" +TOP_BUILDDIR="@top_builddir@" +ABS_SRCDIR=@NDPI_BASE_DIR@ +ABS_BUILDDIR=$(cd ${TOP_BUILDDIR} && pwd) + # Baseline performances ------------------------------------------------------------------------------------------------ # Important notes: BASE values must be integers examples and represents percentage (e.g. 79%, 98%). BASE_ACCURACY=69 @@ -9,17 +14,17 @@ BASE_PRECISION=89 BASE_RECALL=40 # ---------------------------------------------------------------------------------------------------------------------- -DGA_EVALUATE="./dga/dga_evaluate" -DGA_DATA="dga/test_dga.csv" -NON_DGA_DATA="dga/test_non_dga.csv" +DGA_EVALUATE="${ABS_BUILDDIR}/tests/dga/dga_evaluate" +DGA_DATA="${ABS_SRCDIR}/tests/dga/test_dga.csv" +NON_DGA_DATA="${ABS_SRCDIR}/tests/dga/test_non_dga.csv" DGA_DATA_SIZE=0 NON_DGA_DATA_SIZE=0 DATA_SIZE=0 RC=0 get_evaluation_data_size() { - DGA_DATA_SIZE=$(wc -l dga/test_dga.csv | awk '{split($0,a," "); print a[1]}') - NON_DGA_DATA_SIZE=$(wc -l dga/test_non_dga.csv | awk '{split($0,a," "); print a[1]}') + DGA_DATA_SIZE=$(wc -l "${DGA_DATA}" | awk '{split($0,a," "); print a[1]}') + NON_DGA_DATA_SIZE=$(wc -l "${NON_DGA_DATA}" | awk '{split($0,a," "); print a[1]}') DATA_SIZE=$(( NON_DGA_DATA_SIZE + DGA_DATA_SIZE )) } @@ -29,9 +34,9 @@ evaluate_ndpi_dga_detection() { # Precision: TP / (TP + FP) # Recall: TP / (TP + FN) - TP=$($DGA_EVALUATE dga/test_dga.csv) + TP=$($DGA_EVALUATE "${DGA_DATA}") FN=$(( DGA_DATA_SIZE - TP )) - FP=$($DGA_EVALUATE dga/test_non_dga.csv) + FP=$($DGA_EVALUATE "${NON_DGA_DATA}") TN=$(( NON_DGA_DATA_SIZE - FP )) ACCURACY=$(echo "print(int(((${TP} + ${TN})/(${TP} + ${TN} + ${FP} + ${FN}))*100))" | python3) diff --git a/tests/do-unit.sh b/tests/do-unit.sh.in similarity index 74% rename from tests/do-unit.sh rename to tests/do-unit.sh.in index 611edf360a8..c85b1e8b3a4 100755 --- a/tests/do-unit.sh +++ b/tests/do-unit.sh.in @@ -2,7 +2,11 @@ cd "$(dirname "${0}")" || exit 1 -UNIT="./unit/unit" +TOP_BUILDDIR="@top_builddir@" +ABS_BUILDDIR=$(cd ${TOP_BUILDDIR} && pwd) +EXE_SUFFIX=@EXE_SUFFIX@ + +UNIT="${ABS_BUILDDIR}/tests/unit/unit${EXE_SUFFIX}" RC=0 diff --git a/tests/do.sh.in b/tests/do.sh.in index bfe7086d911..e25c829da50 100755 --- a/tests/do.sh.in +++ b/tests/do.sh.in @@ -56,7 +56,11 @@ NBPF_ENABLED=@NBPF_ENABLED@ NBPF_PCAPS="h323-overflow.pcap" GLOBAL_CONTEXT_ENABLED=@GLOBAL_CONTEXT_ENABLED@ GLOBAL_CONTEXT_CFGS="caches_global" -READER="${CMD_PREFIX} ../../../example/ndpiReader${EXE_SUFFIX} --cfg=filename.config,../../../example/config.txt -A -p ../../../example/protos.txt -c ../../../example/categories.txt -r ../../../example/risky_domains.txt -j ../../../example/ja4_fingerprints.csv -S ../../../example/sha1_fingerprints.csv -G ../../../lists -q -K JSON -k /dev/null -t -v 2" +TOP_BUILDDIR="@top_builddir@" +TOP_SRCDIR="@top_srcdir@" +ABS_SRCDIR=@NDPI_BASE_DIR@ +ABS_BUILDDIR=$(cd ${TOP_BUILDDIR} && pwd) +READER="${CMD_PREFIX} ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX} --cfg=filename.config,${ABS_SRCDIR}/example/config.txt -A -p ${ABS_SRCDIR}/example/protos.txt -c ${ABS_SRCDIR}/example/categories.txt -r ${ABS_SRCDIR}/example/risky_domains.txt -j ${ABS_SRCDIR}/example/ja4_fingerprints.csv -S ${ABS_SRCDIR}/example/sha1_fingerprints.csv -G ${ABS_SRCDIR}/lists -q -K JSON -k /dev/null -t -v 2" #These exports are used in parallel mode @@ -74,8 +78,8 @@ export FORCE_PARALLEL_UTESTS RC=0 -if [ ! -x "../example/ndpiReader${EXE_SUFFIX}" ]; then - echo "$0: Missing ../example/ndpiReader${EXE_SUFFIX}" +if [ ! -x "${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX}" ]; then + echo "$0: Missing ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX}" echo "$0: Run ./configure and make first" exit 1 fi @@ -104,13 +108,13 @@ else fi fuzzy_testing() { - if [ -f ../fuzz/fuzz_ndpi_reader ]; then - cp ../example/protos.txt . - cp ../example/categories.txt . - cp ../example/risky_domains.txt . - cp ../example/ja4_fingerprints.csv . - cp ../example/sha1_fingerprints.csv . - ../fuzz/fuzz_ndpi_reader -dict=../fuzz/dictionary.dict -max_total_time="${MAX_TOTAL_TIME:-592}" -print_pcs=1 -workers="${FUZZY_WORKERS:-0}" -jobs="${FUZZY_JOBS:-0}" cfgs/default/pcap/ + if [ -f ${ABS_BUILDDIR}/fuzz/fuzz_ndpi_reader ]; then + cp ${TOP_SRCDIR}/example/protos.txt . + cp ${TOP_SRCDIR}/example/categories.txt . + cp ${TOP_SRCDIR}/example/risky_domains.txt . + cp ${TOP_SRCDIR}/example/ja4_fingerprints.csv . + cp ${TOP_SRCDIR}/example/sha1_fingerprints.csv . + ${ABS_BUILDDIR}/fuzz/fuzz_ndpi_reader -dict=${TOP_SRCDIR}/fuzz/dictionary.dict -max_total_time="${MAX_TOTAL_TIME:-592}" -print_pcs=1 -workers="${FUZZY_WORKERS:-0}" -jobs="${FUZZY_JOBS:-0}" cfgs/default/pcap/ rm -f protos.txt categories.txt risky_domains.txt ja4_fingerprints.csv sha1_fingerprints.csv fi } @@ -215,10 +219,10 @@ check_results() { if [ ${GPROF_ENABLED} -eq 1 ]; then GPROF_ARGS='-nodecount 100 -nodefraction 0 -symbolize=fastlocal' - ${GPROF} -top ${GPROF_ARGS} ../../../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1 - ${GPROF} -png -output ./result/cpu_profile.png ${GPROF_ARGS} ../../../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1 - ${GPROF} -top ${GPROF_ARGS} -sample_index=alloc_space ../../../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1 - ${GPROF} -png -output ./result/heap_profile.png ${GPROF_ARGS} -sample_index=alloc_space ../../../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1 + ${GPROF} -top ${GPROF_ARGS} ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1 + ${GPROF} -png -output ./result/cpu_profile.png ${GPROF_ARGS} ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1 + ${GPROF} -top ${GPROF_ARGS} -sample_index=alloc_space ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1 + ${GPROF} -png -output ./result/heap_profile.png ${GPROF_ARGS} -sample_index=alloc_space ${ABS_BUILDDIR}/example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1 fi } @@ -226,7 +230,7 @@ if [ $FUZZY_TESTING_ENABLED -eq 1 ]; then fuzzy_testing fi -for d in $(find ./cfgs/* -type d -maxdepth 0 2>/dev/null) ; do +for d in $(find ${ABS_SRCDIR}/tests/cfgs/* -type d -maxdepth 0 2>/dev/null) ; do SKIP_CFG=0 if [ $GLOBAL_CONTEXT_ENABLED -eq 0 ]; then @@ -242,7 +246,7 @@ for d in $(find ./cfgs/* -type d -maxdepth 0 2>/dev/null) ; do continue fi - cd ./cfgs/"$(basename "$d")" || exit 1 + cd ${ABS_SRCDIR}/tests/cfgs/"$(basename "$d")" || exit 1 if [ $TEST_ONLY_RECENTLY_UPDATED_PCAPS -eq 1 ]; then # Latest 10 pcaps updatetd recently (to be more precise, pcap which triggered a change @@ -267,7 +271,7 @@ for d in $(find ./cfgs/* -type d -maxdepth 0 2>/dev/null) ; do test ${#FAILURES} -ne 0 && printf '%s: %s\n' "${0}" "${RC} pcap(s) failed" test ${#FAILURES} -ne 0 && echo "Failed: " "${FAILURES[@]}" - cd ../../ + cd ${ABS_SRCDIR}/tests done exit $RC diff --git a/tests/ossfuzz.sh b/tests/ossfuzz.sh index 1eca74e536e..6e01ebbf9b3 100644 --- a/tests/ossfuzz.sh +++ b/tests/ossfuzz.sh @@ -43,7 +43,7 @@ fi # build project cd ndpi #Workaround for introspector builds -RANLIB=llvm-ranlib LDFLAGS="-L/usr/local/lib -lpcap" ./autogen.sh --enable-fuzztargets --enable-tls-sigs +RANLIB=llvm-ranlib LDFLAGS="-L/usr/local/lib -lpcap" ./autogen.sh && ./configure --enable-fuzztargets --enable-tls-sigs make -j$(nproc) # Copy fuzzers ls fuzz/fuzz* | grep -v "\." | while read -r i; do cp "$i" "$OUT"/; done diff --git a/tests/performance/Makefile.in b/tests/performance/Makefile.in index 3041d22f5f8..ffcd5fb38f9 100644 --- a/tests/performance/Makefile.in +++ b/tests/performance/Makefile.in @@ -1,5 +1,11 @@ -INC=-I ../../src/include/ -I ../../src/lib/third_party/include/ -LIB=../../src/lib/libndpi.a @ADDITIONAL_LIBS@ @LIBS@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +INC=-I $(top_srcdir)/src/include/ -I $(top_builddir)/src/include/ -I $(top_srcdir)/src/lib/third_party/include/ +LIB=$(top_builddir)/src/lib/libndpi.a @ADDITIONAL_LIBS@ @LIBS@ TOOLS=substringsearch patriciasearch gcrypt-int gcrypt-gnu strnstr TESTS=substring_test patricia_test strnstr_test geo_test @@ -9,20 +15,20 @@ all: $(TESTS) tools: $(TOOLS) -gcrypt-int: gcrypt.c Makefile - $(CC) $(INC) @CFLAGS@ gcrypt.c -o $@ +gcrypt-int: $(srcdir)/gcrypt.c Makefile + $(CC) $(INC) @CFLAGS@ $(srcdir)/gcrypt.c -o $@ -gcrypt-gnu: gcrypt.c Makefile - $(CC) $(INC) @CFLAGS@ -DHAVE_LIBGCRYPT gcrypt.c -o $@ -lgcrypt +gcrypt-gnu: $(srcdir)/gcrypt.c Makefile + $(CC) $(INC) @CFLAGS@ -DHAVE_LIBGCRYPT $(srcdir)/gcrypt.c -o $@ -lgcrypt -substringsearch: substringsearch.c Makefile - $(CC) $(INC) @CFLAGS@ substringsearch.c -o substringsearch $(LIB) +substringsearch: $(srcdir)/substringsearch.c Makefile + $(CC) $(INC) @CFLAGS@ $(srcdir)/substringsearch.c -o substringsearch $(LIB) -strnstr: strnstr.cpp Makefile - $(CXX) $(INC) @CFLAGS@ strnstr.cpp -o strnstr +strnstr: $(srcdir)/strnstr.cpp Makefile + $(CXX) $(INC) @CFLAGS@ $(srcdir)/strnstr.cpp -o strnstr -geo: geo.c Makefile - $(CC) $(INC) @CFLAGS@ geo.c -o geo $(LIB) +geo: $(srcdir)/geo.c Makefile + $(CC) $(INC) @CFLAGS@ $(srcdir)/geo.c -o geo $(LIB) substring_test: substringsearch top-1m.csv ./substringsearch @@ -35,8 +41,8 @@ geo_test: geo # -patriciasearch: patriciasearch.c Makefile - $(CC) $(INC) @CFLAGS@ patriciasearch.c -o patriciasearch $(LIB) +patriciasearch: $(srcdir)/patriciasearch.c Makefile + $(CC) $(INC) @CFLAGS@ $(srcdir)/patriciasearch.c -o patriciasearch $(LIB) patricia_test: patriciasearch blacklist-ip.txt ./patriciasearch diff --git a/tests/unit/Makefile.in b/tests/unit/Makefile.in index 34eb5055853..660280189b5 100644 --- a/tests/unit/Makefile.in +++ b/tests/unit/Makefile.in @@ -1,15 +1,21 @@ +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + CC=@CC@ CXX=@CXX@ BUILD_MINGW=@BUILD_MINGW@ EXE_SUFFIX=@EXE_SUFFIX@ -SRCHOME=../../src +SRCHOME=$(top_srcdir)/src ifneq ($(OS),Windows_NT) CFLAGS+=-fPIC -DPIC endif -CFLAGS+=-g -I$(SRCHOME)/include @NDPI_CFLAGS@ @JSONC_CFLAGS@ @PCAP_INC@ -LIBNDPI=$(SRCHOME)/lib/libndpi.a +CFLAGS+=-g -I$(SRCHOME)/include -I$(top_builddir)/src/include @NDPI_CFLAGS@ @JSONC_CFLAGS@ @PCAP_INC@ +LIBNDPI=$(top_builddir)/src/lib/libndpi.a LIBS=$(LIBNDPI) @PCAP_LIB@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ @LIBS@ LDFLAGS+=@NDPI_LDFLAGS@ HEADERS=$(SRCHOME)/include/ndpi_api.h $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h diff --git a/utils/Makefile.in b/utils/Makefile.in index 74ae962fb52..a06644f3d82 100644 --- a/utils/Makefile.in +++ b/utils/Makefile.in @@ -1,11 +1,17 @@ -SRCHOME=../src -LIBNDPI=$(SRCHOME)/lib/libndpi.a +# Support for out-of-tree builds (VPATH) +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +INC=-I$(top_srcdir)/src/include -I$(top_builddir)/src/include +LIBNDPI=$(top_builddir)/src/lib/libndpi.a LIBS=$(LIBNDPI) @PCAP_LIB@ @ADDITIONAL_LIBS@ @LIBS@ @GPROF_LIBS@ all: hosts2domains print_rank -hosts2domains: hosts2domains.c Makefile - $(CC) -I$(SRCHOME)/include -g hosts2domains.c -o hosts2domains $(LIBS) +hosts2domains: $(srcdir)/hosts2domains.c Makefile + $(CC) $(INC) -g $(srcdir)/hosts2domains.c -o hosts2domains $(LIBS) -print_rank: print_rank.c Makefile - $(CC) -I$(SRCHOME)/include -g print_rank.c -o print_rank $(LIBS) +print_rank: $(srcdir)/print_rank.c Makefile + $(CC) $(INC) -g $(srcdir)/print_rank.c -o print_rank $(LIBS) diff --git a/utils/verify_dist_tarball.sh b/utils/verify_dist_tarball.sh index c429ae7eb8a..592152d77ae 100755 --- a/utils/verify_dist_tarball.sh +++ b/utils/verify_dist_tarball.sh @@ -12,7 +12,7 @@ git ls-tree --full-tree --name-only -r HEAD | grep -vE "${EXCLUDE_PATTERN}" | so TARBALL="${1}" if [ -z "${TARBALL}" ]; then if [ ! -r Makefile ]; then - ./autogen.sh + ./autogen.sh && ./configure fi make dist AC_VERSION="$(sed -n 's/^AC_INIT.*\([[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\).*$/\1/gp' < configure.ac)" From 6b172a7781354407e6d44dea3c1a26a9ab1eb4f6 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 18:34:27 +0200 Subject: [PATCH 02/13] Fix Github CI --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d1608f3b3f..dce4f6b61cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -307,7 +307,6 @@ jobs: name: Out-of-tree builds runs-on: ubuntu-latest env: - CC: ${{ matrix.compiler }} CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS steps: - uses: actions/checkout@v4 From 7a2954e90b78e97ab8729bcffdf3e46f991f61a4 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 19:12:33 +0200 Subject: [PATCH 03/13] Try to fix CI script --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dce4f6b61cb..b420dbf677d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -328,7 +328,7 @@ jobs: make -j $(nproc) -C example ndpiSimpleIntegration make -j $(nproc) -C rrdtool cd - - - name: Configure and build nDPI (fuzzing) + - name: Configure and build nDPI (fuzzing) run: | mkdir -p build-fuzzing cd fuzzing From 372b97b81829fade1c2b7a3c3199a824db522977 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 19:21:41 +0200 Subject: [PATCH 04/13] Fix CI --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b420dbf677d..9d3daf2e755 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -322,7 +322,7 @@ jobs: - name: Configure and build nDPI (standard) run: | mkdir -p build-standard - cd standard + cd build-standard ./configure make -j $(nproc) all make -j $(nproc) -C example ndpiSimpleIntegration @@ -331,7 +331,7 @@ jobs: - name: Configure and build nDPI (fuzzing) run: | mkdir -p build-fuzzing - cd fuzzing + cd build-fuzzing CC=clang CXX=clang++ ./configure --with-sanitizer --enable-fuzztargets make -j $(nproc) all make -j $(nproc) -C example ndpiSimpleIntegration From 65471e6ccb38c34193ef508025efc516b54d6997 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 19:33:21 +0200 Subject: [PATCH 05/13] Fix CI scripts --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d3daf2e755..1ee31e81577 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -259,7 +259,7 @@ jobs: sudo apt-get install autoconf automake debhelper libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev rrdtool librrd-dev parallel - name: Configure nDPI run: | - AR=${{ matrix.ar }} RANLIB=${{ matrix.ranlib }} ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --with-sanitizer --with-lto-and-gold-linker + ./autogen.sh && AR=${{ matrix.ar }} RANLIB=${{ matrix.ranlib }} ./configure --enable-option-checking=fatal --enable-debug-messages --with-sanitizer --with-lto-and-gold-linker - name: Build nDPI run: | make -j $(nproc) all @@ -323,7 +323,7 @@ jobs: run: | mkdir -p build-standard cd build-standard - ./configure + ../configure make -j $(nproc) all make -j $(nproc) -C example ndpiSimpleIntegration make -j $(nproc) -C rrdtool @@ -332,7 +332,7 @@ jobs: run: | mkdir -p build-fuzzing cd build-fuzzing - CC=clang CXX=clang++ ./configure --with-sanitizer --enable-fuzztargets + AR=llvm-ar RANLIB=llvm-ranlib CC=clang CXX=clang++ ../configure --with-sanitizer --enable-fuzztargets make -j $(nproc) all make -j $(nproc) -C example ndpiSimpleIntegration make -j $(nproc) -C rrdtool From e3946f13222519d8bc730a7a1383548a947a4eca Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 19:48:35 +0200 Subject: [PATCH 06/13] Fixes --- .github/workflows/build.yml | 2 +- tests/Makefile.am | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ee31e81577..b76abff0db2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -332,7 +332,7 @@ jobs: run: | mkdir -p build-fuzzing cd build-fuzzing - AR=llvm-ar RANLIB=llvm-ranlib CC=clang CXX=clang++ ../configure --with-sanitizer --enable-fuzztargets + CC=clang CXX=clang++ ../configure --with-sanitizer --enable-fuzztargets make -j $(nproc) all make -j $(nproc) -C example ndpiSimpleIntegration make -j $(nproc) -C rrdtool diff --git a/tests/Makefile.am b/tests/Makefile.am index 4d2d4039e3d..d8fb7e56cff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,8 +6,8 @@ endif EXTRA_DIST = cfgs/*/pcap cfgs/*/result cfgs/*/*.txt performance \ unit/unit.c unit/Makefile.in \ - dga/dga_evaluate.c dga/Makefile.in dga/README.md dga/test_dga.csv dga/test_non_dga.csv do-dga.sh \ - do-unit.sh do.sh.in ossfuzz.sh + dga/dga_evaluate.c dga/Makefile.in dga/README.md dga/test_dga.csv dga/test_non_dga.csv do-dga.sh.in \ + do-unit.sh.in do.sh.in ossfuzz.sh all: @echo -n "" From 788131bcac24c9cd6efaf2951fb7c2f8927e7ecf Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 20:01:32 +0200 Subject: [PATCH 07/13] Fix CI --- .github/workflows/build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b76abff0db2..349651f8aed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -339,5 +339,13 @@ jobs: cd - - name: Print nDPI long help run: | - cd ./build-standard/example && ./ndpiReader -H - cd ./build-fuzzing/example && ./ndpiReader -H + cd ./build-standard/example && ./ndpiReader -H && cd - + cd ./build-fuzzing/example && ./ndpiReader -H && cd - + - name: Tests + run: | + cd build-standard + make check # all tests + cd - + cd build-fuzzing + NDPI_FORCE_PARALLEL_UTESTS=1 ./tests/do.sh # Less tests with sanitizer to be faster + cd - From 9a6adb982b32f988eac065ea53b52c1547bc00b6 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 20:32:54 +0200 Subject: [PATCH 08/13] Fix CI --- .github/workflows/build.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 349651f8aed..25c2c11319c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -341,11 +341,15 @@ jobs: run: | cd ./build-standard/example && ./ndpiReader -H && cd - cd ./build-fuzzing/example && ./ndpiReader -H && cd - - - name: Tests + - name: Tests #We are only intersting into tests scripts being valid --> less tests than usual run: | cd build-standard - make check # all tests + NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_SKIP_PARALLEL_BAR=1 NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS=1 ./tests/do.sh + ./tests/do-unit.sh + ./tests/do-dga.sh cd - cd build-fuzzing - NDPI_FORCE_PARALLEL_UTESTS=1 ./tests/do.sh # Less tests with sanitizer to be faster + NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_SKIP_PARALLEL_BAR=1 NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS=1 ./tests/do.sh + ./tests/do-unit.sh + ./tests/do-dga.sh cd - From 21074cf2bd82643b3ad95e06e7d9121b5d7017d7 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 14 Oct 2025 20:44:35 +0200 Subject: [PATCH 09/13] Fix CI --- .github/workflows/build.yml | 2 +- tests/do.sh.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25c2c11319c..7e7eee6e48e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -349,7 +349,7 @@ jobs: ./tests/do-dga.sh cd - cd build-fuzzing - NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_SKIP_PARALLEL_BAR=1 NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS=1 ./tests/do.sh + MAX_TOTAL_TIME=10 NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_SKIP_PARALLEL_BAR=1 NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS=1 ./tests/do.sh ./tests/do-unit.sh ./tests/do-dga.sh cd - diff --git a/tests/do.sh.in b/tests/do.sh.in index e25c829da50..096d4f3ca74 100755 --- a/tests/do.sh.in +++ b/tests/do.sh.in @@ -114,7 +114,7 @@ fuzzy_testing() { cp ${TOP_SRCDIR}/example/risky_domains.txt . cp ${TOP_SRCDIR}/example/ja4_fingerprints.csv . cp ${TOP_SRCDIR}/example/sha1_fingerprints.csv . - ${ABS_BUILDDIR}/fuzz/fuzz_ndpi_reader -dict=${TOP_SRCDIR}/fuzz/dictionary.dict -max_total_time="${MAX_TOTAL_TIME:-592}" -print_pcs=1 -workers="${FUZZY_WORKERS:-0}" -jobs="${FUZZY_JOBS:-0}" cfgs/default/pcap/ + ${ABS_BUILDDIR}/fuzz/fuzz_ndpi_reader -dict=${TOP_SRCDIR}/fuzz/dictionary.dict -max_total_time="${MAX_TOTAL_TIME:-592}" -print_pcs=1 -workers="${FUZZY_WORKERS:-0}" -jobs="${FUZZY_JOBS:-0}" ${ABS_SRCDIR}/tests/cfgs/default/pcap/ rm -f protos.txt categories.txt risky_domains.txt ja4_fingerprints.csv sha1_fingerprints.csv fi } From 88f62ec409894f48bb4ee20ddc8e5f20002a367b Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 28 Oct 2025 20:06:35 +0100 Subject: [PATCH 10/13] Fix configure --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index c6941e0f4c3..bed12e6a8b6 100644 --- a/configure.ac +++ b/configure.ac @@ -470,6 +470,10 @@ dnl> ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lcurl" dnl> AC_DEFINE_UNQUOTED(HAVE_CURL, 1, [curl is present]) dnl> fi +dnl> ndpiReader has some hardcoded unit tests: we need some configuration files in the expected path +cp ${srcdir}/example/categories.txt example/ +cp -R ${srcdir}/lists lists/ + AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile tests/unit/Makefile tests/performance/Makefile tests/dga/Makefile rrdtool/Makefile influxdb/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile fuzz/Makefile doc/Doxyfile.cfg utils/Makefile]) AC_CONFIG_FILES([tests/do.sh], [chmod +x tests/do.sh]) AC_CONFIG_FILES([tests/do-dga.sh], [chmod +x tests/do-dga.sh]) From 5ea4df5a8cf1fe9c6f948632b17622a242dc90ea Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Tue, 28 Oct 2025 20:15:42 +0100 Subject: [PATCH 11/13] Fix configure --- configure.ac | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bed12e6a8b6..b02a14b5f22 100644 --- a/configure.ac +++ b/configure.ac @@ -470,9 +470,11 @@ dnl> ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lcurl" dnl> AC_DEFINE_UNQUOTED(HAVE_CURL, 1, [curl is present]) dnl> fi -dnl> ndpiReader has some hardcoded unit tests: we need some configuration files in the expected path -cp ${srcdir}/example/categories.txt example/ -cp -R ${srcdir}/lists lists/ +dnl> ndpiReader has some hard-coded unit tests: in the out-of-tree builds we need some configuration files in the expected path +if test "${srcdir}" != . ; then : + cp ${srcdir}/example/categories.txt example/ + cp -R ${srcdir}/lists lists/ +fi AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile tests/unit/Makefile tests/performance/Makefile tests/dga/Makefile rrdtool/Makefile influxdb/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile fuzz/Makefile doc/Doxyfile.cfg utils/Makefile]) AC_CONFIG_FILES([tests/do.sh], [chmod +x tests/do.sh]) From fc047c4ae33816c19fefedefdc09fec3317bec21 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Mon, 3 Nov 2025 11:09:47 +0100 Subject: [PATCH 12/13] Fix configure --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b02a14b5f22..3342cbdb0af 100644 --- a/configure.ac +++ b/configure.ac @@ -472,7 +472,7 @@ dnl> fi dnl> ndpiReader has some hard-coded unit tests: in the out-of-tree builds we need some configuration files in the expected path if test "${srcdir}" != . ; then : - cp ${srcdir}/example/categories.txt example/ + cp -p ${srcdir}/example/categories.txt example/ cp -R ${srcdir}/lists lists/ fi From 169c8cd2747a8f5662be4b54247e597f1ac10d02 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Mon, 3 Nov 2025 11:30:21 +0100 Subject: [PATCH 13/13] Fix configure --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3342cbdb0af..a5d57922c19 100644 --- a/configure.ac +++ b/configure.ac @@ -472,7 +472,8 @@ dnl> fi dnl> ndpiReader has some hard-coded unit tests: in the out-of-tree builds we need some configuration files in the expected path if test "${srcdir}" != . ; then : - cp -p ${srcdir}/example/categories.txt example/ + mkdir -p example + cp ${srcdir}/example/categories.txt example/ cp -R ${srcdir}/lists lists/ fi