diff options
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/build-archlinux.yml | 38 | ||||
-rw-r--r-- | .github/workflows/build-centos.yml | 59 | ||||
-rw-r--r-- | .github/workflows/build-docker.yml | 25 | ||||
-rw-r--r-- | .github/workflows/build-openwrt.yml | 57 | ||||
-rw-r--r-- | .github/workflows/build.yml | 370 | ||||
-rw-r--r-- | .github/workflows/sonarcloud.yml | 61 |
6 files changed, 610 insertions, 0 deletions
diff --git a/.github/workflows/build-archlinux.yml b/.github/workflows/build-archlinux.yml new file mode 100644 index 000000000..d2300f71d --- /dev/null +++ b/.github/workflows/build-archlinux.yml @@ -0,0 +1,38 @@ +name: ArchLinux PKGBUILD + +on: + push: + branches: + - main + - tmp + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + env: + CMAKE_C_FLAGS: -Werror + steps: + - uses: actions/checkout@v4 + with: + submodules: false + fetch-depth: 1 + - name: Prepare for ArchLinux packaging + run: | + sudo chmod -R 0777 . + mv -v packages/archlinux packages/ndpid-testing + - uses: 2m/arch-pkgbuild-builder@v1.16 + with: + debug: true + target: 'pkgbuild' + pkgname: 'packages/ndpid-testing' + - name: Upload PKG + uses: actions/upload-artifact@v4 + with: + name: nDPId-archlinux-packages + path: packages/ndpid-testing/*.pkg.tar.zst diff --git a/.github/workflows/build-centos.yml b/.github/workflows/build-centos.yml new file mode 100644 index 000000000..425595e87 --- /dev/null +++ b/.github/workflows/build-centos.yml @@ -0,0 +1,59 @@ +name: CentOs + +on: + push: + branches: + - main + - tmp + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + release: + types: [created] + +jobs: + centos8: + runs-on: ubuntu-latest + container: 'centos:8' + steps: + - uses: actions/checkout@v4 + with: + submodules: false + fetch-depth: 1 + - name: Install CentOs Prerequisites + run: | + sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + yum -y update + yum -y install curl gpg + curl 'https://packages.ntop.org/centos/ntop.repo' > /etc/yum.repos.d/ntop.repo + curl 'https://packages.ntop.org/centos/RPM-GPG-KEY-deri' | gpg --import + yum -y install yum-utils dnf-plugins-core epel-release + dnf config-manager --set-enabled powertools + yum -y update + yum -y install rpm-build gcc gcc-c++ autoconf automake make cmake flex bison gettext pkg-config libtool ndpi-dev libpcap-devel zlib-devel python3.8 git wget unzip /usr/lib64/libasan.so.5.0.0 /usr/lib64/libubsan.so.1.0.0 + repoquery -l ndpi-dev + - name: Configure nDPId + run: | + mkdir build && cd build + cmake .. -DENABLE_SYSTEMD=ON -DBUILD_EXAMPLES=ON -DENABLE_SANITIZER=ON -DNDPI_NO_PKGCONFIG=ON -DSTATIC_LIBNDPI_INSTALLDIR=/usr + - name: Build nDPId + run: | + make -C build all VERBOSE=1 + - name: CPack RPM + run: | + cd ./build && cpack -G RPM && cd .. + - name: Upload RPM + uses: actions/upload-artifact@v4 + with: + name: nDPId-centos-packages + path: build/*.rpm + - name: Upload on Failure + uses: actions/upload-artifact@v4 + if: failure() + with: + name: autoconf-config-log + path: | + build/CMakeCache.txt + libnDPI/config.log diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 000000000..bf99eccb0 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,25 @@ +name: Docker Build + +on: + push: + branches: + - 'main' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + tags: utoni/ndpid:latest diff --git a/.github/workflows/build-openwrt.yml b/.github/workflows/build-openwrt.yml new file mode 100644 index 000000000..9d329d584 --- /dev/null +++ b/.github/workflows/build-openwrt.yml @@ -0,0 +1,57 @@ +name: OpenWrt Build + +on: + schedule: + # At the end of every day + - cron: '0 0 * * *' + push: + branches: + - main + - tmp + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + release: + types: [created] + +jobs: + build: + name: ${{ matrix.arch }} ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: arm_cortex-a9_vfpv3-d16 + target: mvebu-cortexa9 + + - arch: mips_24kc + target: ath79-generic + + - arch: arm_cortex-a15_neon-vfpv4 + target: armvirt-32 + + - arch: x86_64 + target: x86-64 + + steps: + - uses: actions/checkout@v4 + with: + submodules: false + fetch-depth: 1 + + - name: Build + uses: openwrt/gh-action-sdk@v7 + env: + ARCH: ${{ matrix.arch }}-snapshot + FEED_DIR: ${{ github.workspace }}/packages/openwrt + FEEDNAME: ndpid_openwrt_packages_ci + PACKAGES: nDPId-testing + V: s + + - name: Store packages + uses: actions/upload-artifact@v4 + with: + name: nDPId-${{ matrix.arch}}-${{ matrix.target }} + path: bin/packages/${{ matrix.arch }}/ndpid_openwrt_packages_ci/*.ipk diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..61b2daba6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,370 @@ +name: Build + +on: + schedule: + # At the end of every day + - cron: '0 0 * * *' + push: + branches: + - main + - tmp + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + release: + types: [created] + +jobs: + test: + name: ${{ matrix.os }} ${{ matrix.compiler }} + runs-on: ${{ matrix.os }} + env: + CMAKE_C_COMPILER: ${{ matrix.compiler }} + CMAKE_C_FLAGS: -Werror ${{ matrix.cflags }} + CMAKE_C_EXE_LINKER_FLAGS: ${{ matrix.ldflags }} + CMAKE_MODULE_LINKER_FLAGS: ${{ matrix.ldflags }} + DYLD_LIBRARY_PATH: /usr/local/lib + strategy: + fail-fast: true + matrix: + include: + - compiler: "gcc" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=OFF -DENABLE_SANITIZER_THREAD=OFF" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=OFF" + upload: true + upload_suffix: "" + ndpi_min_version: "4.10" + - compiler: "gcc" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=ON" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "-DNDPI_WITH_MAXMINDDB=ON -DNDPI_WITH_PCRE=ON -DENABLE_MEMORY_PROFILING=ON" + sanitizer: "-DENABLE_SANITIZER=OFF -DENABLE_SANITIZER_THREAD=OFF" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=OFF" + upload: true + upload_suffix: "-host-gcrypt" + ndpi_min_version: "4.10" + - compiler: "clang" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=OFF" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=OFF -DENABLE_SANITIZER_THREAD=OFF" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=OFF" + upload: true + upload_suffix: "-no-zlib" + ndpi_min_version: "4.10" + - compiler: "gcc" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=ON" + coverage: "-DENABLE_COVERAGE=ON" + poll: "-DFORCE_POLL=ON" + upload: false + ndpi_min_version: "4.10" + - compiler: "clang" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=ON" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=OFF" + upload: false + ndpi_min_version: "4.10" + - compiler: "clang-12" + os: "ubuntu-latest" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER_THREAD=ON" + coverage: "-DENABLE_COVERAGE=OFF" + poll: + upload: false + ndpi_min_version: "4.10" + - compiler: "gcc-10" + os: "ubuntu-20.04" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=OFF" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=ON" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=ON" + upload: false + ndpi_min_version: "4.10" + - compiler: "gcc-7" + os: "ubuntu-20.04" + ndpi_build: "-DBUILD_NDPI=ON" + ndpid_examples: "-DBUILD_EXAMPLES=ON" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + sanitizer: "-DENABLE_SANITIZER=ON" + coverage: "-DENABLE_COVERAGE=OFF" + poll: "-DFORCE_POLL=OFF" + upload: false + ndpi_min_version: "4.10" + - compiler: "cc" + os: "macOS-13" + ndpi_build: "-DBUILD_NDPI=OFF" + ndpid_examples: "-DBUILD_EXAMPLES=OFF" + ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=OFF" + ndpid_zlib: "-DENABLE_ZLIB=ON" + ndpid_extras: "" + examples: "-DBUILD_EXAMPLES=OFF" + sanitizer: "-DENABLE_SANITIZER=OFF" + coverage: "-DENABLE_COVERAGE=OFF" + poll: + upload: false + ndpi_min_version: "4.10" + + steps: + - name: Print Matrix + run: | + echo '----------------------------------------' + echo '| OS.......: ${{ matrix.os }}' + echo '| CC.......: ${{ matrix.compiler }}' + echo "| CFLAGS...: $CMAKE_C_FLAGS" + echo "| LDFLAGS..: $CMAKE_C_EXE_LINKER_FLAGS" + echo '|---------------------------------------' + echo '| nDPI min.: ${{ matrix.ndpi_min_version }}' + echo '| GCRYPT...: ${{ matrix.ndpid_gcrypt }}' + echo '| ZLIB.....: ${{ matrix.ndpid_zlib }}' + echo '| Extras...: ${{ matrix.ndpid_extras }}' + echo '| ForcePoll: ${{ matrix.poll }}' + echo '|---------------------------------------' + echo '| SANITIZER: ${{ matrix.sanitizer }}' + echo '| COVERAGE.: ${{ matrix.coverage }}' + echo '|---------------------------------------' + echo '| UPLOAD...: ${{ matrix.upload }}' + echo '----------------------------------------' + - uses: actions/checkout@v4 + with: + submodules: false + fetch-depth: 1 + - name: Install MacOS Prerequisites + if: startsWith(matrix.os, 'macOS') + run: | + brew install coreutils flock automake make unzip cmake pkg-config git wget + wget 'https://www.tcpdump.org/release/libpcap-1.10.4.tar.gz' + tar -xzvf libpcap-1.10.4.tar.gz + cd libpcap-1.10.4 + ./configure && make install + cd .. + wget 'https://github.com/ntop/nDPI/archive/refs/heads/dev.zip' -O libndpi-dev.zip + unzip libndpi-dev.zip + cd nDPI-dev + ./autogen.sh --prefix=/usr/local --with-only-libndpi && make install + - name: Fix kernel mmap rnd bits on Ubuntu + if: startsWith(matrix.os, 'ubuntu') + run: | + # Workaround for compatinility between latest kernel and sanitizer + # See https://github.com/actions/runner-images/issues/9491 + sudo sysctl vm.mmap_rnd_bits=28 + - name: Install Ubuntu Prerequisites + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev zlib1g-dev libcurl4-openssl-dev libdbus-1-dev + sudo apt-get install ${{ matrix.compiler }} lcov iproute2 + - name: Install Ubuntu Prerequisites (libgcrypt) + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=ON') + run: | + sudo apt-get install libgcrypt20-dev + - name: Install Ubuntu Prerequisites (zlib) + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.ndpid_zlib, '-DENABLE_ZLIB=ON') + run: | + sudo apt-get install zlib1g-dev + - name: Install Ubuntu Prerequisites (libmaxminddb, libpcre2) + if: startsWith(matrix.ndpid_extras, '-D') + run: | + sudo apt-get install libmaxminddb-dev libpcre2-dev + - name: Checking Network Buffer Size + run: | + C_VAL=$(cat config.h | sed -n 's/^#define\s\+NETWORK_BUFFER_MAX_SIZE\s\+\([0-9]\+\).*$/\1/gp') + PY_VAL=$(cat dependencies/nDPIsrvd.py | sed -n 's/^NETWORK_BUFFER_MAX_SIZE = \([0-9]\+\).*$/\1/gp') + test ${C_VAL} = ${PY_VAL} + - name: Configure nDPId + run: | + cmake -S . -B build -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" -DCMAKE_MODULE_LINKER_FLAGS="$CMAKE_MODULE_LINKER_FLAGS" -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \ + -DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \ + ${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.sanitizer }} ${{ matrix.ndpi_build }} \ + ${{ matrix.ndpid_examples }} ${{ matrix.ndpid_zlib }} ${{ matrix.ndpid_gcrypt }} ${{ matrix.ndpid_extras }} + - name: Build nDPId + run: | + cmake --build build --verbose + - name: Build single nDPId/nDPIsrvd executables (invoke CC directly - dynamic nDPI lib) + if: startsWith(matrix.ndpi_build, '-DBUILD_NDPI=OFF') && startsWith(matrix.coverage, '-DENABLE_COVERAGE=OFF') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') + run: | + pkg-config --cflags --libs libndpi + cc -Wall -Wextra -std=gnu99 \ + ${{ matrix.poll }} -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + nDPId.c nio.c utils.c \ + $(pkg-config --cflags libndpi) -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ + -o /tmp/a.out \ + -lpcap $(pkg-config --libs libndpi) -pthread -lm + cc -Wall -Wextra -std=gnu99 \ + ${{ matrix.poll }} -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + nDPIsrvd.c nio.c utils.c \ + -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ + -o /tmp/a.out + - name: Build single nDPId/nDPIsrvd executables (invoke CC directly - static nDPI lib) + if: endsWith(matrix.compiler, 'gcc-7') == false && startsWith(matrix.ndpi_build, '-DBUILD_NDPI=ON') && startsWith(matrix.coverage, '-DENABLE_COVERAGE=OFF') && startsWith(matrix.sanitizer, '-DENABLE_SANITIZER=ON') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') && startsWith(matrix.ndpid_zlib, '-DENABLE_ZLIB=ON') + run: | + cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_ZLIB=1 -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=enum -fsanitize=leak \ + nDPId.c nio.c utils.c \ + -I./build/libnDPI/include/ndpi -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ + -o /tmp/a.out \ + -lpcap ./build/libnDPI/lib/libndpi.a -pthread -lm -lz + - name: Test EXEC + run: | + ./build/nDPId-test + ./build/nDPId -h || test $? -eq 1 + ./build/nDPIsrvd -h || test $? -eq 1 + - name: Test DIFF + if: startsWith(matrix.os, 'macOS') == false && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') + run: | + ./test/run_tests.sh ./libnDPI ./build/nDPId-test + - name: Daemon + if: startsWith(matrix.compiler, 'gcc') || endsWith(matrix.compiler, 'clang') + run: | + make -C ./build daemon VERBOSE=1 + make -C ./build daemon VERBOSE=1 + - name: Coverage + if: startsWith(matrix.coverage, '-DENABLE_COVERAGE=ON') + run: | + make -C ./build coverage + - name: Dist + if: startsWith(matrix.os, 'macOS') == false && matrix.upload == false + run: | + make -C ./build dist + - name: CPack DEB + if: startsWith(matrix.os, 'macOS') == false + run: | + cd ./build && cpack -G DEB && sudo dpkg -i nDPId-*.deb && cd .. + - name: Upload DEB + if: startsWith(matrix.os, 'macOS') == false && matrix.upload + uses: actions/upload-artifact@v4 + with: + name: nDPId-debian-packages_${{ matrix.compiler }}${{ matrix.upload_suffix }} + path: build/*.deb + - name: Test systemd + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.compiler, 'gcc') + run: | + ip -c address + sudo systemctl daemon-reload + sudo systemctl enable ndpid@lo + sudo systemctl start ndpid@lo + SYSTEMCTL_RET=3; while (( $SYSTEMCTL_RET == 3 )); do systemctl is-active ndpid@lo.service; SYSTEMCTL_RET=$?; sleep 1; done + sudo systemctl status ndpisrvd.service ndpid@lo.service || true + sudo systemctl show ndpisrvd.service ndpid@lo.service -p SubState,ActiveState || true + journalctl --no-tail --no-pager -u ndpisrvd.service -u ndpid@lo.service + - name: Build PF_RING and nDPId (invoke CC directly - dynamic nDPI lib) + if: endsWith(matrix.compiler, 'gcc-7') == false && startsWith(matrix.ndpi_build, '-DBUILD_NDPI=ON') && startsWith(matrix.coverage, '-DENABLE_COVERAGE=OFF') && startsWith(matrix.sanitizer, '-DENABLE_SANITIZER=ON') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') && startsWith(matrix.ndpid_zlib, '-DENABLE_ZLIB=ON') + run: | + git clone --depth=1 https://github.com/ntop/PF_RING.git + cd PF_RING && make all && sudo make install prefix=/usr + cd .. + cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_PFRING=1 -DENABLE_ZLIB=1 -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=enum -fsanitize=leak \ + nDPId.c npfring.c nio.c utils.c \ + -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ + -I./build/libnDPI/include/ndpi \ + -I./PF_RING/userland/lib -I./PF_RING/kernel \ + -o /tmp/a.out \ + -ldl ./PF_RING/userland/lib/libpfring.a -lpcap ./build/libnDPI/lib/libndpi.a -pthread -lm -lz + - name: Build against libnDPI-${{ matrix.ndpi_min_version }} + if: startsWith(matrix.os, 'ubuntu') + run: | + mkdir build-local-ndpi && cd build-local-ndpi + WGET_RET=0 + wget 'https://github.com/ntop/nDPI/archive/refs/tags/${{ matrix.ndpi_min_version }}.tar.gz' || { WGET_RET=$?; true; } + echo "wget returned: ${WGET_RET}" + test $WGET_RET -ne 8 && { \ + tar -xzvf ${{ matrix.ndpi_min_version }}.tar.gz; } + test $WGET_RET -ne 8 || { \ + echo "::warning file=nDPId.c::New libnDPI release required to build against release tarball, falling back to dev branch."; \ + wget 'http://github.com/ntop/nDPI/archive/refs/heads/dev.tar.gz'; \ + WGET_RET=$?; \ + tar -xzvf dev.tar.gz; \ + mv -v 'nDPI-dev' 'nDPI-${{ matrix.ndpi_min_version }}'; } + test $WGET_RET -ne 0 || { cd nDPI-${{ matrix.ndpi_min_version }}; \ + NDPI_CONFIGURE_ARGS=''; \ + test 'x${{ matrix.ndpid_gcrypt }}' != 'x-DNDPI_WITH_GCRYPT=ON' || NDPI_CONFIGURE_ARGS="$NDPI_CONFIGURE_ARGS --with-local-libgcrypt"; \ + test 'x${{ matrix.sanitizer }}' != 'x-DENABLE_SANITIZER=ON' || NDPI_CONFIGURE_ARGS="$NDPI_CONFIGURE_ARGS --with-sanitizer"; \ + echo "Configure arguments: '$NDPI_CONFIGURE_ARGS'" + ./autogen.sh --prefix=/usr --with-only-libndpi $NDPI_CONFIGURE_ARGS CC="${{ matrix.compiler }}" CXX=false \ + CFLAGS="$CMAKE_C_FLAGS" && make && sudo make install; cd ..; } + cd .. + test $WGET_RET -ne 0 || { echo "Running CMake.. (pkgconfig)"; \ + cmake -S . -B ./build-local-pkgconfig \ + -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \ + -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \ + -DBUILD_NDPI=OFF -DBUILD_EXAMPLES=ON \ + -DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \ + ${{ matrix.poll }} ${{ matrix.coverage }} \ + ${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; } + test $WGET_RET -ne 0 || { echo "Running Make.. (pkgconfig)"; \ + cmake --build ./build-local-pkgconfig --verbose; } + test $WGET_RET -ne 0 || { echo "Testing Executable.. (pkgconfig)"; \ + ./build-local-pkgconfig/nDPId-test; \ + ./build-local-pkgconfig/nDPId -h || test $? -eq 1; \ + ./build-local-pkgconfig/nDPIsrvd -h || test $? -eq 1; } + test $WGET_RET -ne 0 || { echo "Running CMake.. (static)"; \ + cmake -S . -B ./build-local-static \ + -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \ + -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \ + -DBUILD_NDPI=OFF -DBUILD_EXAMPLES=ON \ + -DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \ + -DNDPI_NO_PKGCONFIG=ON -DSTATIC_LIBNDPI_INSTALLDIR=/usr \ + ${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.ndpid_gcrypt }} \ + ${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; } + test $WGET_RET -ne 0 || { echo "Running Make.. (static)"; \ + cmake --build ./build-local-static --verbose; } + test $WGET_RET -ne 0 || { echo "Testing Executable.. (static)"; \ + ./build-local-static/nDPId-test; \ + ./build-local-static/nDPId -h || test $? -eq 1; \ + ./build-local-static/nDPIsrvd -h || test $? -eq 1; } + test $WGET_RET -ne 0 || test ! -d ./PF_RING || { echo "Running CMake.. (PF_RING)"; \ + cmake -S . -B ./build-local-pfring \ + -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \ + -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \ + -DBUILD_NDPI=OFF -DBUILD_EXAMPLES=ON -DENABLE_PFRING=ON \ + -DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \ + -DNDPI_NO_PKGCONFIG=ON -DSTATIC_LIBNDPI_INSTALLDIR=/usr \ + -DPFRING_LINK_STATIC=OFF \ + -DPFRING_INSTALLDIR=/usr -DPFRING_KERNEL_INC="$(realpath ./PF_RING/kernel)" \ + ${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.ndpid_gcrypt }} \ + ${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; } + test $WGET_RET -ne 0 || test ! -d ./PF_RING || { echo "Running Make.. (PF_RING)"; \ + cmake --build ./build-local-pfring --verbose; } + test $WGET_RET -ne 0 || test ! -d ./PF_RING || { echo "Testing Executable.. (PF_RING)"; \ + ./build-local-pfring/nDPId-test; \ + ./build-local-pfring/nDPId -h || test $? -eq 1; \ + ./build-local-pfring/nDPIsrvd -h || test $? -eq 1; } + test $WGET_RET -eq 0 -o $WGET_RET -eq 8 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 000000000..8bc58a4bd --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,61 @@ +on: + push: + branches: + - main + - tmp + pull_request: + types: [opened, synchronize, reopened] + +name: Sonarcloud Scan +jobs: + sonarcloud: + runs-on: ubuntu-latest + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 +# - uses: actions/checkout@v4 +# - name: Set up Python 3.8 for gcovr +# uses: actions/setup-python@v4 +# with: +# python-version: 3.8 +# - name: install gcovr 5.0 +# run: | +# pip install gcovr==5.0 # 5.1 is not supported + - name: Install sonar-scanner and build-wrapper + uses: SonarSource/sonarcloud-github-c-cpp@v2 + - name: Install Prerequisites + run: | + sudo apt-get update + sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev zlib1g-dev + - name: Run build-wrapper + run: | + mkdir build + cmake -S . -B build -DBUILD_NDPI=ON -DDENABLE_ZLIB=ON -DNDPI_WITH_GCRYPT=OFF + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release +# - name: Run tests +# run: | +# for file in $(ls libnDPI/tests/cfgs/*/pcap/*.pcap libnDPI/tests/cfgs/*/pcap/*.pcapng libnDPI/tests/cfgs/*/pcap/*.cap); do \ +# echo -n "${file} "; \ +# ./build/nDPId-test "${file}" >/dev/null 2>/dev/null; \ +# echo "[ok]"; \ +# done +# - name: Collect coverage into one XML report +# run: | +# gcovr --sonarqube > coverage.xml + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner \ + --define sonar.branch.name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} \ + --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \ + --define sonar.organization=lnslbrty \ + --define sonar.projectKey=lnslbrty_nDPId \ + --define sonar.exclusions=dependencies/uthash/src/** \ + --define sonar.verbose=true \ + --define sonar.python.version=3.8 \ + --define sonar.cfamily.gcov.reportsPath=coverage.xml |