Fix CI after nBPF integration (#1746)

Add one CI job testing nBPF
This commit is contained in:
Ivan Nardi
2022-09-21 16:49:51 +02:00
committed by GitHub
parent c960bb50f0
commit 03d217eae6
4 changed files with 53 additions and 8 deletions
+32 -2
View File
@@ -169,7 +169,7 @@ jobs:
git diff-index --quiet HEAD -- || true
test:
name: ${{ matrix.os }} ${{ matrix.arch }} ${{ matrix.gcrypt }} ${{ matrix.compiler }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} ${{ matrix.msan }}
name: ${{ matrix.os }} ${{ matrix.arch }} ${{ matrix.gcrypt }} ${{ matrix.compiler }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} ${{ matrix.msan }} ${{ matrix.nBPF }}
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.compiler }}
@@ -184,6 +184,7 @@ jobs:
pcre: [""]
maxminddb: [""]
msan: [""]
nBPF: [""]
include:
- compiler: "gcc-7"
os: ubuntu-latest
@@ -192,6 +193,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "gcc-11"
os: ubuntu-latest
arch: "x86_64"
@@ -199,6 +201,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "clang-7"
os: ubuntu-latest
arch: "x86_64"
@@ -206,6 +209,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "clang-14"
os: ubuntu-22.04
arch: "x86_64"
@@ -213,6 +217,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "x86_64"
@@ -220,6 +225,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "x86_64"
@@ -227,6 +233,15 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-thread-sanitizer"
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "x86_64"
gcrypt: ""
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: "nBPF"
- compiler: "clang-14"
os: ubuntu-22.04
arch: "x86_64"
@@ -234,6 +249,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-memory-sanitizer"
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "x86_64"
@@ -241,6 +257,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "cc"
os: macOS-latest
arch: "x86_64"
@@ -248,6 +265,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "" # Disable sanitizer on macos
nBPF: ""
- compiler: "cc"
os: macos-12
arch: "x86_64"
@@ -255,6 +273,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "" # Disable sanitizer on macos
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "arm64"
@@ -262,6 +281,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "" # Disable sanitizer on arm64
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "armhf"
@@ -269,6 +289,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: "--with-sanitizer"
nBPF: ""
- compiler: "cc"
os: ubuntu-latest
arch: "s390x"
@@ -276,6 +297,7 @@ jobs:
pcre: "--with-pcre"
maxminddb: "--with-maxminddb"
msan: ""
nBPF: ""
steps:
- name: Setup multiarch/qemu-user-static
if: startsWith(matrix.os, 'ubuntu') && !startsWith(matrix.arch, 'x86_64')
@@ -304,6 +326,14 @@ jobs:
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.maxminddb, '--with-maxminddb')
run: |
sudo apt-get install libmaxminddb-dev
- name: Install Ubuntu Prerequisites (nBPF)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.nBPF, 'nBPF')
run: |
git clone https://github.com/ntop/PF_RING.git ../PF_RING
cd ../PF_RING/userland/nbpf
./configure
make
cd -
- name: Setup Ubuntu specified compiler (gcc)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'gcc')
run: |
@@ -428,7 +458,7 @@ jobs:
make dist
./utils/verify_dist_tarball.sh
- name: Build nDPI [Mingw-w64] (runs only on ubuntu jobs)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64')
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.nBPF, 'nBPF')
run: |
make distclean
./autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --host=x86_64-w64-mingw32
+8 -3
View File
@@ -13,6 +13,9 @@ 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]))
AC_ARG_WITH(memory-sanitizer, AS_HELP_STRING([--with-memory-sanitizer], [Build with support for memory sanitizer]))
@@ -22,6 +25,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])
AS_IF([test "x$enable_fuzztargets" = "xyes"], [BUILD_FUZZTARGETS=1], [BUILD_FUZZTARGETS=0])
AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
@@ -72,7 +76,6 @@ LT_INIT
LT_LIB_M
PKG_PROG_PKG_CONFIG
PWD=`pwd`
AC_PROG_CC
SYSTEM=`uname -s`
@@ -198,14 +201,15 @@ fi
MACHINE=`uname -m`
AC_MSG_CHECKING([PF_RING nBPF])
NBPF_HOME=${PWD}/../PF_RING/userland/nbpf
NBPF_ENABLED=0
AC_MSG_CHECKING([PF_RING nBPF ($NBPF_HOME)])
LIBNBPF=${NBPF_HOME}/libnbpf.a
if test -f ${LIBNBPF}; then :
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} ${LIBNBPF}"
ADDITIONAL_INCS="${ADDITIONAL_INCS} -I${NBPF_HOME}"
AC_DEFINE_UNQUOTED(HAVE_NBPF, "1", [PF_RING nBPF is present])
AC_MSG_RESULT(yes)
NBPF_ENABLED=1
else
AC_MSG_RESULT(no)
fi
@@ -388,6 +392,7 @@ AC_SUBST(GPROF_LIBS)
AC_SUBST(GPROF_ENABLED)
AC_SUBST(USE_HOST_LIBGCRYPT)
AC_SUBST(PCRE_ENABLED)
AC_SUBST(NBPF_ENABLED)
AC_SUBST(HANDLE_TLS_SIGS)
AC_SUBST(DISABLE_NPCAP)
AC_SUBST(EXE_SUFFIX)
+3 -3
View File
@@ -3627,7 +3627,7 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule,
char *filter = &attr[5];
if(ndpi_str->num_nbpf_custom_proto >= MAX_NBPF_CUSTOM_PROTO) {
NDPI_LOG_ERR(ndpi_str, "nBPF: too many protocols");
NDPI_LOG_ERR(ndpi_str, "nBPF: too many protocols\n");
return(-4); /* Too many protocols */
}
@@ -3643,14 +3643,14 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule,
if((ndpi_str->nbpf_custom_proto[ndpi_str->num_nbpf_custom_proto].tree =
nbpf_parse(filter, NULL)) == NULL) {
NDPI_LOG_ERR(ndpi_str, "nBPF invalid filter: %s", filter)
NDPI_LOG_ERR(ndpi_str, "nBPF invalid filter: %s\n", filter)
return(-5); /* Invalid filter */
} else
ndpi_str->nbpf_custom_proto[ndpi_str->num_nbpf_custom_proto].l7_protocol = subprotocol_id;
ndpi_str->num_nbpf_custom_proto++;
#else
NDPI_LOG_ERR(ndpi_str, "nDPI compiled without nBPF support: skipping rule");
NDPI_LOG_INFO(ndpi_str, "nDPI compiled without nBPF support: skipping rule\n");
return(-6);
#endif
}
+10
View File
@@ -23,6 +23,8 @@ EXE_SUFFIX=@EXE_SUFFIX@
GPROF_ENABLED=@GPROF_ENABLED@
PCRE_ENABLED=@PCRE_ENABLED@
PCRE_PCAPS="WebattackRCE.pcap"
NBPF_ENABLED=@NBPF_ENABLED@
NBPF_PCAPS="h323-overflow.pcap"
READER="${CMD_PREFIX} ../example/ndpiReader${EXE_SUFFIX} -A -p ../example/protos.txt -c ../example/categories.txt -r ../example/risky_domains.txt -j ../example/ja3_fingerprints.csv -S ../example/sha1_fingerprints.csv"
RC=0
@@ -80,6 +82,14 @@ check_results() {
fi
done
fi
if [ $NBPF_ENABLED -eq 0 ]; then
for p in $NBPF_PCAPS; do
if [ $f = $p ]; then
SKIP_PCAP=1
break
fi
done
fi
if [ $SKIP_PCAP -eq 1 ]; then
printf "%-32s\tSKIPPED\n" "$f"
continue