From 4f4147fc33acb6300eabca6eafbc2c2326f40b79 Mon Sep 17 00:00:00 2001 From: zhengfeihe Date: Sun, 7 Jul 2024 18:32:56 +0900 Subject: [PATCH 01/28] replace netifaces by psutil --- ci/run_tests/requirements.txt | 2 +- ci/run_tests/run_tests.py | 14 ++++++++++++-- ci/run_tests/run_tests_windows.py | 13 +++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ci/run_tests/requirements.txt b/ci/run_tests/requirements.txt index b00a84e7c..0704b2dbf 100644 --- a/ci/run_tests/requirements.txt +++ b/ci/run_tests/requirements.txt @@ -1 +1 @@ -netifaces==0.11.0 +psutil==5.9.8 diff --git a/ci/run_tests/run_tests.py b/ci/run_tests/run_tests.py index 43a938e8e..8a93ebeb3 100644 --- a/ci/run_tests/run_tests.py +++ b/ci/run_tests/run_tests.py @@ -1,10 +1,19 @@ import os import subprocess import argparse -import netifaces as ni +import psutil +import socket PCAP_FILE_PATH = os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap") +def get_ip_address(interface): + addresses = psutil.net_if_addrs().get(interface) + if not addresses: + return None + for address in addresses: + if address.family == socket.AF_INET: + return address.address + return None def main(): parser = argparse.ArgumentParser() @@ -32,7 +41,8 @@ def main(): ) args = parser.parse_args() - ip_address = ni.ifaddresses(args.interface)[ni.AF_INET][0]["addr"] + ip_address = get_ip_address(args.interface) + print("IP address is: %s" % ip_address) try: diff --git a/ci/run_tests/run_tests_windows.py b/ci/run_tests/run_tests_windows.py index bba46d8ba..6d1bae37c 100644 --- a/ci/run_tests/run_tests_windows.py +++ b/ci/run_tests/run_tests_windows.py @@ -1,13 +1,22 @@ import os import argparse import subprocess -import netifaces as ni +import psutil +import socket TCPREPLAY_PATH = "tcpreplay-4.4.1-win" PCAP_FILE_PATH = os.path.abspath( os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap") ) +def get_ip_address(interface): + addresses = psutil.net_if_addrs().get(interface) + if not addresses: + return None + for address in addresses: + if address.family == socket.AF_INET: + return address.address + return None def find_interface(): completed_process = subprocess.run( @@ -27,7 +36,7 @@ def find_interface(): interface = columns[1] try: ni_interface = interface.lstrip("\\Device\\NPF_") - ip_address = ni.ifaddresses(ni_interface)[ni.AF_INET][0]["addr"] + ip_address = get_ip_address(ni_interface) if ip_address.startswith("169.254"): continue completed_process = subprocess.run( From e39de2bd6b1d7753e8f8127284b153a12aef80a8 Mon Sep 17 00:00:00 2001 From: "Liu, An-Chi" Date: Sun, 7 Jul 2024 13:26:36 +0300 Subject: [PATCH 02/28] Update ci/run_tests/requirements.txt --- ci/run_tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run_tests/requirements.txt b/ci/run_tests/requirements.txt index 0704b2dbf..84f3d20c0 100644 --- a/ci/run_tests/requirements.txt +++ b/ci/run_tests/requirements.txt @@ -1 +1 @@ -psutil==5.9.8 +psutil==6.0.0 From 5f80c3644bd2211909a721745fc1ef4c28c7b653 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 20:56:18 +0900 Subject: [PATCH 03/28] temporarily disable other tests --- .github/workflows/auto_update.yml | 75 --- .github/workflows/build_and_test.yml | 636 ------------------------- .github/workflows/check_dependabot.yml | 18 - .github/workflows/cifuzz.yml | 38 -- .github/workflows/codeql.yml | 47 -- .github/workflows/doxygen.yml | 49 -- .github/workflows/package.yml | 336 ------------- .github/workflows/scorecards.yml | 71 --- 8 files changed, 1270 deletions(-) delete mode 100644 .github/workflows/auto_update.yml delete mode 100644 .github/workflows/check_dependabot.yml delete mode 100644 .github/workflows/cifuzz.yml delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/doxygen.yml delete mode 100644 .github/workflows/package.yml delete mode 100644 .github/workflows/scorecards.yml diff --git a/.github/workflows/auto_update.yml b/.github/workflows/auto_update.yml deleted file mode 100644 index 7afef0803..000000000 --- a/.github/workflows/auto_update.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Auto Update - -on: - schedule: - - cron: '0 0 1 * *' # Runs at 00:00, on day 1 of the month - -permissions: - contents: read - -jobs: - precommit-update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - with: - ref: dev - - name: Setup Python - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: "3.8.x" - - name: Run update - run: | - pip install pre-commit - pre-commit autoupdate - - name: Create Pull Request - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 - with: - token: ${{ secrets.PAT }} - author: GitHub - add-paths: .pre-commit-config.yaml - commit-message: Auto pre-commit update - body: | - Update pre-commit hooks to latest - - Auto generated - branch: auto-update/precommit_update - delete-branch: true - title: Auto precommit update - labels: automated-pr - assignees: seladb - - oui-update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - with: - ref: dev - - name: Setup Python - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: "3.9.x" - - name: Run update - run: | - python3 3rdParty/OUIDataset/create_oui_data.py - mv -f PCPP_OUIDataset.json 3rdParty/OUIDataset/PCPP_OUIDataset.json - - name: Create Pull Request - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 - with: - token: ${{ secrets.PAT }} - author: GitHub - add-paths: 3rdParty/OUIDataset/PCPP_OUIDataset.json - commit-message: Auto OUI Database Update - body: | - Update OUI database to latest - - Auto generated - branch: auto-update/oui_update - delete-branch: true - title: Auto OUI Database Update - labels: automated-pr - assignees: seladb diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c34555cd9..c5fb45791 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -15,37 +15,6 @@ permissions: contents: read jobs: - pre-commit: - runs-on: ubuntu-latest - container: seladb/alpine317 - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - # Checkout is performed out of the container and doesn't match our user - - name: Fix checkout ownership - run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" - - - name: Install dependencies - run: | - apk update && apk add cppcheck python3-dev - python3 -m pip install cmake-format clang-format==18.1.6 - - # TODO: investigate how to run pre-commit with `venv` - - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 - - - name: CMake format - run: | - ./ci/cmake-format-all.sh - git diff --exit-code - - - name: Configure PcapPlusPlus for Static analysis - run: CXX=clang++ CC=clang cmake -DLIGHT_PCAPNG_ZSTD=ON -DPCAPPP_ENABLE_CLANG_TIDY=ON -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus and check any diff - run: | - cmake --build "$BUILD_DIR" -j - git diff --exit-code linux: runs-on: ubuntu-latest @@ -161,609 +130,4 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - dpdk: - runs-on: ubuntu-latest - container: seladb/${{ matrix.image }} - strategy: - matrix: - include: - - image: ubuntu2204-dpdk2211 - - image: ubuntu2004-dpdk2111 - additional-flags: -DPCAPPP_USE_DPDK_KNI=ON - - image: ubuntu2004-dpdk2011 - additional-flags: -DPCAPPP_USE_DPDK_KNI=ON - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Configure PcapPlusPlus - run: cmake -DPCAPPP_USE_DPDK=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Check AVX - run: grep avx /proc/cpuinfo - - - name: Test Packet++ - run: | - cd Tests/Packet++Test - if [ -n "$(grep avx512 /proc/cpuinfo)" ]; then Bin/Packet++Test; else echo AVX-512 SUPPORT NOT FOUND, CANNOT RUN Packet++Test; fi - - - name: Test Pcap++ - run: | - cd Tests/Pcap++Test - if [ -n "$(grep avx512 /proc/cpuinfo)" ]; then Bin/Pcap++Test -n; else echo AVX-512 SUPPORT NOT FOUND, CANNOT RUN Pcap++Test; fi - - - name: Check installation - run: | - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR - - - name: Build Tutorials - run: | - cmake -DPCAPPP_BUILD_TUTORIALS=ON -S Examples -B build_examples - cmake --build build_examples -j - - - name: Test Tutorials - run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - - pfring: - runs-on: ubuntu-latest - container: seladb/ubuntu2004-pfring - strategy: - matrix: - include: - - configure: cmake -DPCAPPP_USE_PF_RING=ON -DPF_RING_ROOT="/PF_RING" -S . -B "$BUILD_DIR" - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Configure PcapPlusPlus - run: ${{ matrix.configure }} - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Test Packet++ - run: | - cd Tests/Packet++Test - Bin/Packet++Test - - - name: Test Pcap++ - run: | - cd Tests/Pcap++Test - Bin/Pcap++Test -n - - - name: Check installation - run: | - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR - - - name: Build Tutorials - run: | - cmake -DPCAPPP_BUILD_TUTORIALS=ON -DPF_RING_ROOT="/PF_RING" -S Examples -B build_examples - cmake --build build_examples -j - - - name: Test Tutorials - run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - - macos-x86: - runs-on: ${{ matrix.os-version }} - strategy: - matrix: - include: - - os-version: macos-12 - arch: x86_64 - config-zstd: OFF - - os-version: macos-12 - arch: arm64 - config-zstd: OFF - - os-version: macos-13 - arch: x86_64 - config-zstd: OFF - - os-version: macos-13 - arch: x86_64 - config-zstd: ON - - os-version: macos-13 - arch: arm64 - config-zstd: OFF - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - python-version: "3.12" - - - name: Configure PcapPlusPlus - # Ensure user have access to network devices instead of giving super-user right - run: | - sudo chmod a+rw /dev/bpf* - cmake -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Check architecture - run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch ${{ matrix.arch }} - - - name: Install Tcpreplay - run: brew install tcpreplay - - - name: Test PcapPlusPlus - # We can't run cross compiled binaries - if: ${{ matrix.arch == 'x86_64' }} - run: | - python -m venv ./venv - source ./venv/bin/activate - python -m pip install pip - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface en0 - - - name: Test Examples - if: ${{ matrix.arch == 'x86_64' }} - run: | - cd Tests/ExamplesTest - python -m pip install -r requirements.txt - python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin - - - name: Check installation - run: | - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR - - - name: Build Tutorials - run: | - mkdir -p build_examples - cmake -DPCAPPP_BUILD_TUTORIALS=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -S Examples -B build_examples - cmake --build build_examples -j - - - name: Test Tutorials - if: ${{ matrix.arch == 'x86_64' }} - run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - - - name: Create Cobertura Report - run: | - python3 -m pip install gcovr - gcovr -v -r . $GCOVR_FLAGS -o coverage.xml - - - name: Upload Coverage Results - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 - with: - files: ./coverage.xml - flags: ${{ matrix.os-version }},unittest - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - macos-m1: - runs-on: ${{ matrix.os-version }} - strategy: - matrix: - os-version: [macos-14] - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - python-version: "3.12" - - - name: Configure PcapPlusPlus - # Ensure user have access to network devices instead of giving super-user right - # Seems macos-14 has more strict file permission - run: | - sudo chmod a+rw /dev/bpf* - sudo chmod a+rw /usr/local - cmake -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Check architecture - run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch arm64 - - - name: Install Tcpreplay - run: brew install tcpreplay - - - name: Test PcapPlusPlus - run: | - python -m venv ./venv - source ./venv/bin/activate - python -m pip install pip - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface en0 - - - name: Test Examples - run: | - cd Tests/ExamplesTest - python -m pip install -r requirements.txt - python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin - - - name: Check installation - run: | - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install "$BUILD_DIR" - - - name: Build Tutorials - run: | - mkdir -p build_examples - cmake -DPCAPPP_BUILD_TUTORIALS=ON -S Examples -B build_examples - cmake --build build_examples -j - - - name: Test Tutorials - run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - - - name: Create Cobertura Report - run: | - python3 -m pip install gcovr - gcovr -v -r . $GCOVR_FLAGS -o coverage.xml - - - name: Upload Coverage Results - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 - with: - files: ./coverage.xml - flags: ${{ matrix.os-version }},unittest - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - mingw-w64: - runs-on: windows-latest - strategy: - matrix: - include: - - env: i686 - sys: mingw32 - - env: x86_64 - sys: mingw64 - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Setup MSYS2 - uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0 - with: - msystem: ${{matrix.sys}} - install: >- - git - mingw-w64-${{matrix.env}}-cmake - mingw-w64-${{matrix.env}}-gcc - mingw-w64-${{matrix.env}}-make - - - name: Setup Python - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: "3.8.x" - - - name: Install NPcap - env: - NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} - NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} - run: | - ci\install_npcap.bat - echo "PCAP_SDK_DIR=/C/Npcap-sdk" >> $env:GITHUB_ENV - - - name: Configure PcapPlusPlus - shell: msys2 {0} - run: | - cmake -G "MinGW Makefiles" -DPCAP_ROOT=/C/Npcap-sdk -DLIGHT_PCAPNG_ZSTD=OFF -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - shell: msys2 {0} - # More than 2 jobs would make the build crash with OOM - # cc1plus.exe: out of memory allocating 65536 bytes - run: cmake --build "$BUILD_DIR" -j 2 - - - name: Install tcpreplay - run: ci\install_tcpreplay.bat - - - name: Test PcapPlusPlus - run: | - python -m pip install -r ci\run_tests\requirements.txt - python ci\run_tests\run_tests_windows.py - - - name: Test Examples - run: | - cd Tests\ExamplesTest - python -m pip install -r requirements.txt - python -m pytest --root-path=../../Dist/examples_bin - - - name: Install Coverage Requirements - run: python3 -m pip install gcovr - - - name: Process Coverage Files - shell: msys2 {0} - run: find . -name "*.gcno" -exec gcov -b -l -p -c {} + - - - name: Create Coberture Report - run: gcovr -v -g -k -r . $env:GCOVR_FLAGS.split() -o coverage.xml - - - name: Upload Coverage Results - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 - with: - files: ./coverage.xml - flags: ${{ matrix.sys }},unittest - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - visual-studio: - strategy: - matrix: - include: - - os: "windows-2019" - platform: "Visual Studio 16 2019" - arch: "x64" - pcap_lib: "npcap" - - os: windows-2019 - platform: "Visual Studio 16 2019" - arch: Win32 - pcap_lib: "winpcap" - - os: windows-2022 - platform: "Visual Studio 17 2022" - arch: "x64" - pcap_lib: "winpcap" - - os: windows-2022 - platform: "Visual Studio 17 2022" - arch: "x64" - pcap_lib: "npcap" - - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: "3.8.x" - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0 - - name: Setup OpenCppCoverage and add to PATH - run: | - choco install OpenCppCoverage -y - echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH - - - name: Install WinPcap - run: | - ci\install_winpcap.bat - echo "PCAP_SDK_DIR=C:\WpdPack" >> $env:GITHUB_ENV - if: matrix.pcap_lib == 'winpcap' - - - name: Install NPcap - env: - NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} - NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} - run: | - ci\install_npcap.bat - echo "PCAP_SDK_DIR=C:\Npcap-sdk" >> $env:GITHUB_ENV - if: matrix.pcap_lib == 'npcap' - - - name: Set Zstd - run: | - ci\install_zstd.bat - echo "ZSTD_HOME_PARAM=-z C:\zstd" >> $env:GITHUB_ENV - if: matrix.use_zstd == true - - - name: Configure PcapPlusPlus - run: cmake -A ${{ matrix.arch }} -G "${{ matrix.platform }}" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -S . -B "$env:BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build $env:BUILD_DIR -j - - - name: Install tcpreplay - run: ci\install_tcpreplay.bat - - - name: Test PcapPlusPlus - run: | - python -m pip install -r ci\run_tests\requirements.txt - python ci\run_tests\run_tests_windows.py --coverage - - - name: Test Examples - run: | - move ".\Dist\examples_bin\Debug\*" ".\Dist\examples_bin\" - cd Tests\ExamplesTest - python -m pip install -r requirements.txt - python -m pytest --root-path=../../Dist/examples_bin - - - name: Upload Coverage Results - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 - with: - files: ./Tests/Pcap++Test/Pcap++Coverage.xml,./Tests/Packet++Test/Packet++Coverage.xml - flags: ${{ matrix.os }},unittest,${{ matrix.pcap_lib }} - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - freebsd: - runs-on: ubuntu-latest - strategy: - matrix: - version: ["14.0", "13.2"] - steps: - - uses: actions/checkout@v4 - - name: Test in FreeBSD - id: test - uses: vmactions/freebsd-vm@v1 - with: - release: ${{ matrix.version }} - usesh: true - prepare: | - pkg install -y python3 bash cmake git gmake gsed libpcap tcpreplay - - run: | - echo "Building PcapPlusPlus" - chmod a+rw /dev/bpf* - cmake -S . -B Dist - cmake --build Dist -j$(sysctl -n hw.ncpu) - - echo "Setting up the network interface for the tests" - # Get the first interface name that is not 'lo' - interface_name=$(ifconfig -l | tr ' ' '\n' | grep -v '^lo' | head -n 1) - ifconfig "$interface_name" promisc - - echo "Testing PcapPlusPlus" - python3 -m ensurepip - python3 -m pip install -r ci/run_tests/requirements.txt - python3 ci/run_tests/run_tests.py --interface "$interface_name" - - echo "Testing PcapPlusPlus examples" - cd Tests/ExamplesTest - python3 -m pip install -r requirements.txt - python3 -m pytest --interface "$interface_name" --root-path=../../Dist/examples_bin - - android: - strategy: - matrix: - include: - - run-on-os: ubuntu-20.04 - target: armeabi-v7a - api-version: 30 - - run-on-os: ubuntu-20.04 - target: x86 - api-version: 30 - - run-on-os: macos-12 - target: arm64-v8a - cmake_configure: "-DCMAKE_OSX_ARCHITECTURES=arm64" - api-version: 30 - - run-on-os: macos-12 - target: x86_64 - cmake_configure: "-DCMAKE_OSX_ARCHITECTURES=x86_64" - api-version: 30 - - runs-on: ${{ matrix.run-on-os }} - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Checkout lipbcap for Android - uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 # main - with: - repository: seladb/libpcap-android - path: ./libpcap-android - - - name: Configure PcapPlusPlus - run: | - LIBPCAP_PATH=$(pwd)/libpcap-android - cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_PLATFORM="${{ matrix.api-version}}" -DANDROID_ABI="${{ matrix.target }}" -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/include/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/${{ matrix.target }}/${{ matrix.api-version}}/libpcap.a" -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Checkout ToyVpn-PcapPlusPlus - uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master - with: - repository: seladb/ToyVpn-PcapPlusPlus - path: ./ToyVpn-PcapPlusPlus - submodules: true - - - name: Install locally PcapPlusPlus - # CMake install library in $prefix/lib ToyVpn want $prefix/$target/$api-version - run: | - TOYVPN_PCAPPLUSPLUS="./ToyVpn-PcapPlusPlus/app/libs/pcapplusplus" - PCAPPLUSPLUS_LIBS_PATH="$TOYVPN_PCAPPLUSPLUS/${{ matrix.target }}/${{ matrix.api-version }}" - PCAPPLUSPLUS_INCLUDE_PATH="$TOYVPN_PCAPPLUSPLUS/include" - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR --prefix ${TOYVPN_PCAPPLUSPLUS} - mkdir -p ${PCAPPLUSPLUS_LIBS_PATH} ${PCAPPLUSPLUS_INCLUDE_PATH} - mv ${TOYVPN_PCAPPLUSPLUS}/lib/*.a ${PCAPPLUSPLUS_LIBS_PATH}/ - mv ${TOYVPN_PCAPPLUSPLUS}/include/pcapplusplus/*.h ${PCAPPLUSPLUS_INCLUDE_PATH}/ - - - name: Build ToyVpn-PcapPlusPlus - working-directory: ./ToyVpn-PcapPlusPlus - run: | - sed -i.bak "s|abiFilters.*$|abiFilters '${{ matrix.target }}'|g" app/build.gradle - chmod +x gradlew - ./gradlew assembleDebug - - xdp: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Install dependencies - run: | - sudo apt update && sudo apt -y install libpcap-dev libbpf-dev tcpreplay - - - name: Configure PcapPlusPlus - run: cmake -DPCAPPP_USE_XDP=ON -DPCAPPP_BUILD_COVERAGE=ON -S . -B $BUILD_DIR - - - name: Build PcapPlusPlus - run: cmake --build $BUILD_DIR -j - - - name: Test PcapPlusPlus - run: | - python -m venv ./venv - source ./venv/bin/activate - python -m pip install pip - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" - - - name: Create Cobertura Report - run: | - python -m pip install gcovr - gcovr -v -r . $GCOVR_FLAGS -o coverage.xml - - - name: Upload Coverage Results - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 - with: - files: ./coverage.xml - flags: xdp,unittest - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - test_regressions: - name: Run ${{ matrix.engine }}-${{ matrix.sanitizer }} fuzzer for regressions - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - sanitizer: [address, undefined, memory] - engine: [libfuzzer] - container: - image: gcr.io/oss-fuzz-base/base-builder - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Install prerequisites - run: | - apt-get update && apt-get install -y cmake autoconf flex bison - cd .. - cp -r PcapPlusPlus/ $SRC/PcapPlusPlus - git clone --depth=1 https://github.com/the-tcpdump-group/libpcap.git $SRC/libpcap - cd $SRC/PcapPlusPlus/ - - name: Compile fuzzer - run: | - export FUZZING_LANGUAGE=c - export ARCHITECTURE=x86_64 - export FUZZING_ENGINE=${{ matrix.engine }} - export SANITIZER=${{ matrix.sanitizer }} - $SRC/PcapPlusPlus/Tests/Fuzzers/ossfuzz.sh - - name: Check for regressions - run: | - export BINARY="$OUT/FuzzTarget" - export SAMPLES="Tests/Fuzzers/RegressionTests/regression_samples" - Tests/Fuzzers/RegressionTests/run_tests.sh diff --git a/.github/workflows/check_dependabot.yml b/.github/workflows/check_dependabot.yml deleted file mode 100644 index 5b46b6c38..000000000 --- a/.github/workflows/check_dependabot.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Validate dependabot - -on: - pull_request: - paths: - - '.github/dependabot.yml' - - '.github/workflows/check_dependabot.yml' - -permissions: - contents: read - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - uses: marocchino/validate-dependabot@d8ae5c0d03dd75fbd0ad5f8ab4ba8101ebbd4b37 # v3.0.0 - id: validate diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml deleted file mode 100644 index 84805e64a..000000000 --- a/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Fuzz CI -on: - pull_request: - branches: ["dev"] - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight - -permissions: - contents: read - -jobs: - Fuzzing: - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - sanitizer: [address, undefined, memory] - steps: - - name: Build Fuzzers - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@c2c0632831767ff05c568e7b552cef2801d739ff # master - with: - oss-fuzz-project-name: 'pcapplusplus' - dry-run: false - sanitizer: ${{ matrix.sanitizer }} - - name: Run Fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@c2c0632831767ff05c568e7b552cef2801d739ff # master - with: - oss-fuzz-project-name: 'pcapplusplus' - fuzz-seconds: 600 - dry-run: false - sanitizer: ${{ matrix.sanitizer }} - - name: Upload Crash - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - if: failure() && steps.build.outcome == 'success' - with: - name: artifacts - path: ./out/artifacts diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 07fec5a18..000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "dev" ] - workflow_dispatch: - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight - -permissions: - contents: read - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - container: seladb/ubuntu2204 - permissions: - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - - steps: - - name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - run: | - cmake -S . -B build - cmake --build build -j - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml deleted file mode 100644 index eb081d0bb..000000000 --- a/.github/workflows/doxygen.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build doxygen -on: - push: - branches: ["master", "dev"] - pull_request: - branches: ["dev"] - -permissions: - contents: read - -jobs: - doxygen: - runs-on: ubuntu-latest - container: seladb/ubuntu2204:latest - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Checkout docs repo - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - with: - repository: PcapPlusPlus/pcapplusplus.github.io - path: pcapplusplus.github.io - - - name: Run doxygen - run: | - cd pcapplusplus.github.io/static/api-docs/next/doxygen - doxygen Doxyfile-ci - - - name: Prepare documentation - if: github.ref == 'refs/heads/master' - run: | - cd pcapplusplus.github.io/static/api-docs/ - find next/ -maxdepth 1 -type f -exec rm {} \; - rm -rf next/search/ - mv next/html/* next/ - - - name: Upload documentation - if: github.ref == 'refs/heads/master' - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: pcapplusplus.github.io - destination-github-username: "PcapPlusPlus" - destination-repository-name: "pcapplusplus.github.io" - user-email: noreply@github.com - commit-message: Update API documentation for commit ORIGIN_COMMIT - target-branch: master diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml deleted file mode 100644 index 6b0c79539..000000000 --- a/.github/workflows/package.yml +++ /dev/null @@ -1,336 +0,0 @@ -name: Package and release - -on: - push: - tags: - - '*' - pull_request: - paths: - # Also run this workflow when this package.yml is update by a PR - - '.github/workflows/package.yml' - schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight - -env: - BUILD_DIR: Dist - -permissions: - contents: read - -jobs: - linux: - runs-on: ubuntu-latest - permissions: - contents: write - container: seladb/${{ matrix.image }} - strategy: - matrix: - include: - - image: ubuntu2404 - config-zstd: OFF - - image: ubuntu2204 - config-zstd: OFF - - image: ubuntu2204-icpx - config-zstd: OFF - additional-flags: -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx - - image: ubuntu2004 - config-zstd: OFF - - image: rhel94 - config-zstd: OFF - - image: fedora39 - config-zstd: OFF - - image: alpine317 - config-zstd: OFF - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - # Checkout is performed out of the container and doesn't match our user - - name: Fix checkout ownership - run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" - - - name: Setup Intel Compiler variables - if: contains(matrix.image, 'icpx') - run: | - . /opt/intel/oneapi/setvars.sh - printenv >> $GITHUB_ENV - - - name: Debug Cmake - run: cmake --system-information - - - name: Configure PcapPlusPlus - run: cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Package - run: cmake --build "$BUILD_DIR" --target package - - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.deb,${{ env.BUILD_DIR }}/*.rpm" - - freebsd: - runs-on: ubuntu-latest - permissions: - contents: write - strategy: - matrix: - include: - - freebsd-version: "13.2" - - freebsd-version: "14.0" - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Test in FreeBSD - uses: vmactions/freebsd-vm@f8be330398166d1eb0601f01353839d4052367b2 # v1.0.7 - with: - release: ${{ matrix.freebsd-version }} - envs: 'BUILD_DIR' - usesh: true - prepare: | - pkg install -y bash cmake git-tiny gmake gsed libpcap py39-pip - run: | - cmake -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j 4 - cmake --build "$BUILD_DIR" --target package - - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: ${{ env.BUILD_DIR }}/*.tar.gz - - macos: - runs-on: macos-12 - permissions: - contents: write - strategy: - matrix: - xcode-version: [14.2.0, 13.4.1] - arch: [x86_64, arm64] - - steps: - - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 - with: - xcode-version: "${{ matrix.xcode-version }}" - - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Configure PcapPlusPlus - run: | - cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Package - run: cmake --build "$BUILD_DIR" --target package - - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.pkg" - - mingw-w64: - runs-on: windows-latest - permissions: - contents: write - strategy: - matrix: - include: - - env: i686 - sys: mingw32 - - env: x86_64 - sys: mingw64 - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Setup MSYS2 - uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0 - with: - msystem: ${{matrix.sys}} - update: true - install: >- - git - mingw-w64-${{matrix.env}}-cmake - mingw-w64-${{matrix.env}}-gcc - mingw-w64-${{matrix.env}}-make - - - name: Install NPcap - env: - NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} - NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} - run: | - ci\install_npcap.bat - echo "PCAP_SDK_DIR=/C/Npcap-sdk" >> $env:GITHUB_ENV - - - name: Configure PcapPlusPlus - shell: msys2 {0} - run: | - cmake -G "MinGW Makefiles" -DPCAP_ROOT=/C/Npcap-sdk -DLIGHT_PCAPNG_ZSTD=OFF -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR" - - - name: Debug Cmake - shell: msys2 {0} - run: cmake --system-information - - - name: Build PcapPlusPlus - shell: msys2 {0} - # More than 2 jobs would make the build crash with OOM - # cc1plus.exe: out of memory allocating 65536 bytes - run: cmake --build "$BUILD_DIR" -j 2 - - - name: Package - shell: msys2 {0} - run: cmake --build "$BUILD_DIR" --target package - - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: ${{ env.BUILD_DIR }}/*.zip - - visual-studio: - strategy: - matrix: - os: [ windows-2019, windows-2022 ] - arch: [ Win32, x64 ] - configuration: [ Debug, Release ] - - runs-on: ${{ matrix.os }} - permissions: - contents: write - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0 - - - name: Install WinPcap - run: | - ci\install_winpcap.bat - echo "PCAP_SDK_DIR=C:\WpdPack" >> $env:GITHUB_ENV - - - name: Configure PcapPlusPlus - run: | - $platform = if ("${{ matrix.os }}" -eq "windows-2019") { "Visual Studio 16 2019" } else { "Visual Studio 17 2022" } - cmake -A ${{ matrix.arch }} -G "$platform" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DPCAPPP_PACKAGE=ON -S . -B "$env:BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build $env:BUILD_DIR --config ${{ matrix.configuration }} -j - - - name: Package - run: cmake --build "$env:BUILD_DIR" --config ${{ matrix.configuration }} --target package - - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: ${{ env.BUILD_DIR }}/*.zip - - android-build: - strategy: - matrix: - include: - - target: "armeabi-v7a" - api-version: 30 - - target: "x86" - api-version: 30 - - target: "arm64-v8a" - api-version: 30 - - target: "x86_64" - api-version: 30 - - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: Checkout lipbcap for Android - uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 # main - with: - repository: seladb/libpcap-android - path: ./libpcap-android - - - name: Configure and Build PcapPlusPlus - run: | - LIBPCAP_PATH="$(pwd)/libpcap-android" - export LIB_DIR="${{ matrix.target }}/${{ matrix.api-version }}" - export LOCAL_BUILD_DIR="${BUILD_DIR}/${LIB_DIR}" - cmake -DPCAPPP_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_LIBDIR="${LIB_DIR}" -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_PLATFORM="${{ matrix.api-version }}" -DANDROID_ABI="${{ matrix.target }}" -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/include/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/${{ matrix.target }}/${{ matrix.api-version}}/libpcap.a" -DPCAPPP_PACKAGE=ON -S . -B "$LOCAL_BUILD_DIR" - cmake --build "$LOCAL_BUILD_DIR" -j --target package - - - name: Prepare package - run: | - export LOCAL_BUILD_DIR="${BUILD_DIR}/${{ matrix.target }}/${{ matrix.api-version }}" - export PACKAGE_FILE=$(ls ${LOCAL_BUILD_DIR} | grep pcapplusplus) - export PACKAGE_DIR=$(basename ${PACKAGE_FILE%} .tar.gz) - export COMBINED_PACKAGE_DIR=$(echo "$PACKAGE_DIR" | cut -f1,2,3 -d'-') - - tar -xvf "${LOCAL_BUILD_DIR}/${PACKAGE_FILE}" - mv "${PACKAGE_DIR}" "${COMBINED_PACKAGE_DIR}" - find . -name example-app -type d -exec rm -r {} + - find . -name cmake -type d -exec rm -r {} + - find . -name pkgconfig -type d -exec rm -r {} + - mv ${COMBINED_PACKAGE_DIR}/include/pcapplusplus/* "${COMBINED_PACKAGE_DIR}/include/" - rmdir "${COMBINED_PACKAGE_DIR}/include/pcapplusplus/" - mkdir -p "android-package" - mv "${COMBINED_PACKAGE_DIR}" "android-package" - - - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - path: android-package - name: android-package-${{ matrix.target }}-${{ matrix.api-version }} - if-no-files-found: error - - android-package: - needs: android-build - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - with: - pattern: android-package-* - merge-multiple: true - - - name: Package into archive - run: | - export PACKAGE_DIR=$(ls | grep pcapplusplus) - echo "PACKAGE_DIR=$PACKAGE_DIR" >> $GITHUB_ENV - tar cvf "${PACKAGE_DIR}.tar.gz" "${PACKAGE_DIR}" - - name: Upload binaries to release - if: github.ref_type == 'tag' - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - with: - draft: true - allowUpdates: true - updateOnlyUnreleased: true - artifacts: ${{ env.PACKAGE_DIR }}.tar.gz diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml deleted file mode 100644 index 01e6b88b6..000000000 --- a/.github/workflows/scorecards.yml +++ /dev/null @@ -1,71 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. They are provided -# by a third-party and are governed by separate terms of service, privacy -# policy, and support documentation. - -name: Scorecard supply-chain security -on: - # For Branch-Protection check. Only the default branch is supported. See - # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection - branch_protection_rule: - # To guarantee Maintained check is occasionally updated. See - # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained - schedule: - - cron: '20 7 * * 2' - push: - branches: ["master"] - -# Declare default permissions as read only. -permissions: read-all - -jobs: - analysis: - name: Scorecard analysis - runs-on: ubuntu-latest - permissions: - # Needed to upload the results to code-scanning dashboard. - security-events: write - # Needed to publish results and get a badge (see publish_results below). - id-token: write - contents: read - actions: read - - steps: - - name: "Checkout code" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - with: - persist-credentials: false - - - name: "Run analysis" - uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 - with: - results_file: results.sarif - results_format: sarif - # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: - # - you want to enable the Branch-Protection check on a *public* repository, or - # - you are installing Scorecards on a *private* repository - # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. - repo_token: ${{ secrets.PAT }} - - # Public repositories: - # - Publish results to OpenSSF REST API for easy access by consumers - # - Allows the repository to include the Scorecard badge. - # - See https://github.com/ossf/scorecard-action#publishing-results. - # For private repositories: - # - `publish_results` will always be set to `false`, regardless - # of the value entered here. - publish_results: true - - # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF - # format to the repository Actions tab. - - name: "Upload artifact" - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: SARIF file - path: results.sarif - retention-days: 5 - - # Upload the results to GitHub's code scanning dashboard. - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - with: - sarif_file: results.sarif From 8541ce1f9744a0c49a119e02fc953cc585d9d028 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 20:59:27 +0900 Subject: [PATCH 04/28] test --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c5fb45791..4fd2fd378 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -56,7 +56,7 @@ jobs: - name: Set up Python run: | if [ "${{ matrix.image }}" = "alpine317" ]; then - apk add --no-cache python3 py3-virtualenv py3-virtualenv + apk add python3 py3-virtualenv py3-virtualenv python3-dev elif [ "${{ matrix.image }}" = "rhel94" ]; then yum install -y python3 python3-virtualenv python3-devel elif [ "${{ matrix.image }}" = "fedora39" ]; then From 2241be83dc6a44d976139f23cee1260653c1917f Mon Sep 17 00:00:00 2001 From: zhengfeihe Date: Sun, 7 Jul 2024 19:15:01 +0900 Subject: [PATCH 05/28] format code --- ci/run_tests/run_tests.py | 2 ++ ci/run_tests/run_tests_windows.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/run_tests/run_tests.py b/ci/run_tests/run_tests.py index 8a93ebeb3..7435f5919 100644 --- a/ci/run_tests/run_tests.py +++ b/ci/run_tests/run_tests.py @@ -6,6 +6,7 @@ PCAP_FILE_PATH = os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap") + def get_ip_address(interface): addresses = psutil.net_if_addrs().get(interface) if not addresses: @@ -15,6 +16,7 @@ def get_ip_address(interface): return address.address return None + def main(): parser = argparse.ArgumentParser() parser.add_argument("--interface", type=str, required=True, help="interface to use") diff --git a/ci/run_tests/run_tests_windows.py b/ci/run_tests/run_tests_windows.py index 6d1bae37c..18d698061 100644 --- a/ci/run_tests/run_tests_windows.py +++ b/ci/run_tests/run_tests_windows.py @@ -9,8 +9,11 @@ os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap") ) + def get_ip_address(interface): + print(interface) addresses = psutil.net_if_addrs().get(interface) + print(addresses) if not addresses: return None for address in addresses: @@ -18,6 +21,7 @@ def get_ip_address(interface): return address.address return None + def find_interface(): completed_process = subprocess.run( ["tcpreplay.exe", "--listnics"], @@ -73,7 +77,7 @@ def main(): tcpreplay_interface, ip_address = find_interface() if not tcpreplay_interface or not ip_address: - print("Cannot find an interface to run tests on!") + print("Cannot find an interface to run tests on! Info from psutil.net_if_addrs() %s"% psutil.net_if_addrs()) exit(1) print(f"Interface is {tcpreplay_interface} and IP address is {ip_address}") From 6d31da551edcb4f128d45b9dac9ea30131cb745f Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 21:50:08 +0900 Subject: [PATCH 06/28] test --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4fd2fd378..dbcd25ec5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -56,7 +56,7 @@ jobs: - name: Set up Python run: | if [ "${{ matrix.image }}" = "alpine317" ]; then - apk add python3 py3-virtualenv py3-virtualenv python3-dev + apk add python3 py3-virtualenv py3-virtualenv python3-dev gcc musl-dev linux-headers elif [ "${{ matrix.image }}" = "rhel94" ]; then yum install -y python3 python3-virtualenv python3-devel elif [ "${{ matrix.image }}" = "fedora39" ]; then From a5f2dac47e5a52c016dfbf3406749515537e70f1 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Mon, 24 Jun 2024 08:50:53 +0900 Subject: [PATCH 07/28] Revert "temporarily disable other tests" This reverts commit 5f80c3644bd2211909a721745fc1ef4c28c7b653. --- .github/workflows/auto_update.yml | 75 +++ .github/workflows/build_and_test.yml | 636 +++++++++++++++++++++++++ .github/workflows/check_dependabot.yml | 18 + .github/workflows/cifuzz.yml | 38 ++ .github/workflows/codeql.yml | 47 ++ .github/workflows/doxygen.yml | 49 ++ .github/workflows/package.yml | 336 +++++++++++++ .github/workflows/scorecards.yml | 71 +++ 8 files changed, 1270 insertions(+) create mode 100644 .github/workflows/auto_update.yml create mode 100644 .github/workflows/check_dependabot.yml create mode 100644 .github/workflows/cifuzz.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/doxygen.yml create mode 100644 .github/workflows/package.yml create mode 100644 .github/workflows/scorecards.yml diff --git a/.github/workflows/auto_update.yml b/.github/workflows/auto_update.yml new file mode 100644 index 000000000..7afef0803 --- /dev/null +++ b/.github/workflows/auto_update.yml @@ -0,0 +1,75 @@ +name: Auto Update + +on: + schedule: + - cron: '0 0 1 * *' # Runs at 00:00, on day 1 of the month + +permissions: + contents: read + +jobs: + precommit-update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + ref: dev + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.8.x" + - name: Run update + run: | + pip install pre-commit + pre-commit autoupdate + - name: Create Pull Request + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 + with: + token: ${{ secrets.PAT }} + author: GitHub + add-paths: .pre-commit-config.yaml + commit-message: Auto pre-commit update + body: | + Update pre-commit hooks to latest + + Auto generated + branch: auto-update/precommit_update + delete-branch: true + title: Auto precommit update + labels: automated-pr + assignees: seladb + + oui-update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + ref: dev + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.9.x" + - name: Run update + run: | + python3 3rdParty/OUIDataset/create_oui_data.py + mv -f PCPP_OUIDataset.json 3rdParty/OUIDataset/PCPP_OUIDataset.json + - name: Create Pull Request + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 + with: + token: ${{ secrets.PAT }} + author: GitHub + add-paths: 3rdParty/OUIDataset/PCPP_OUIDataset.json + commit-message: Auto OUI Database Update + body: | + Update OUI database to latest + + Auto generated + branch: auto-update/oui_update + delete-branch: true + title: Auto OUI Database Update + labels: automated-pr + assignees: seladb diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index dbcd25ec5..4ea34ca16 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -15,6 +15,37 @@ permissions: contents: read jobs: + pre-commit: + runs-on: ubuntu-latest + container: seladb/alpine317 + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + # Checkout is performed out of the container and doesn't match our user + - name: Fix checkout ownership + run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" + + - name: Install dependencies + run: | + apk update && apk add cppcheck python3-dev + python3 -m pip install cmake-format clang-format==18.1.6 + + # TODO: investigate how to run pre-commit with `venv` + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 + + - name: CMake format + run: | + ./ci/cmake-format-all.sh + git diff --exit-code + + - name: Configure PcapPlusPlus for Static analysis + run: CXX=clang++ CC=clang cmake -DLIGHT_PCAPNG_ZSTD=ON -DPCAPPP_ENABLE_CLANG_TIDY=ON -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus and check any diff + run: | + cmake --build "$BUILD_DIR" -j + git diff --exit-code linux: runs-on: ubuntu-latest @@ -130,4 +161,609 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + dpdk: + runs-on: ubuntu-latest + container: seladb/${{ matrix.image }} + strategy: + matrix: + include: + - image: ubuntu2204-dpdk2211 + - image: ubuntu2004-dpdk2111 + additional-flags: -DPCAPPP_USE_DPDK_KNI=ON + - image: ubuntu2004-dpdk2011 + additional-flags: -DPCAPPP_USE_DPDK_KNI=ON + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Configure PcapPlusPlus + run: cmake -DPCAPPP_USE_DPDK=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Check AVX + run: grep avx /proc/cpuinfo + + - name: Test Packet++ + run: | + cd Tests/Packet++Test + if [ -n "$(grep avx512 /proc/cpuinfo)" ]; then Bin/Packet++Test; else echo AVX-512 SUPPORT NOT FOUND, CANNOT RUN Packet++Test; fi + + - name: Test Pcap++ + run: | + cd Tests/Pcap++Test + if [ -n "$(grep avx512 /proc/cpuinfo)" ]; then Bin/Pcap++Test -n; else echo AVX-512 SUPPORT NOT FOUND, CANNOT RUN Pcap++Test; fi + + - name: Check installation + run: | + cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j + cmake --install $BUILD_DIR + + - name: Build Tutorials + run: | + cmake -DPCAPPP_BUILD_TUTORIALS=ON -S Examples -B build_examples + cmake --build build_examples -j + + - name: Test Tutorials + run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld + + pfring: + runs-on: ubuntu-latest + container: seladb/ubuntu2004-pfring + strategy: + matrix: + include: + - configure: cmake -DPCAPPP_USE_PF_RING=ON -DPF_RING_ROOT="/PF_RING" -S . -B "$BUILD_DIR" + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Configure PcapPlusPlus + run: ${{ matrix.configure }} + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Test Packet++ + run: | + cd Tests/Packet++Test + Bin/Packet++Test + + - name: Test Pcap++ + run: | + cd Tests/Pcap++Test + Bin/Pcap++Test -n + + - name: Check installation + run: | + cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j + cmake --install $BUILD_DIR + + - name: Build Tutorials + run: | + cmake -DPCAPPP_BUILD_TUTORIALS=ON -DPF_RING_ROOT="/PF_RING" -S Examples -B build_examples + cmake --build build_examples -j + + - name: Test Tutorials + run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld + + macos-x86: + runs-on: ${{ matrix.os-version }} + strategy: + matrix: + include: + - os-version: macos-12 + arch: x86_64 + config-zstd: OFF + - os-version: macos-12 + arch: arm64 + config-zstd: OFF + - os-version: macos-13 + arch: x86_64 + config-zstd: OFF + - os-version: macos-13 + arch: x86_64 + config-zstd: ON + - os-version: macos-13 + arch: arm64 + config-zstd: OFF + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json + python-version: "3.12" + + - name: Configure PcapPlusPlus + # Ensure user have access to network devices instead of giving super-user right + run: | + sudo chmod a+rw /dev/bpf* + cmake -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Check architecture + run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch ${{ matrix.arch }} + + - name: Install Tcpreplay + run: brew install tcpreplay + + - name: Test PcapPlusPlus + # We can't run cross compiled binaries + if: ${{ matrix.arch == 'x86_64' }} + run: | + python -m venv ./venv + source ./venv/bin/activate + python -m pip install pip + python -m pip install -r ci/run_tests/requirements.txt + python ci/run_tests/run_tests.py --interface en0 + + - name: Test Examples + if: ${{ matrix.arch == 'x86_64' }} + run: | + cd Tests/ExamplesTest + python -m pip install -r requirements.txt + python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin + + - name: Check installation + run: | + cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j + cmake --install $BUILD_DIR + + - name: Build Tutorials + run: | + mkdir -p build_examples + cmake -DPCAPPP_BUILD_TUTORIALS=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -S Examples -B build_examples + cmake --build build_examples -j + + - name: Test Tutorials + if: ${{ matrix.arch == 'x86_64' }} + run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld + + - name: Create Cobertura Report + run: | + python3 -m pip install gcovr + gcovr -v -r . $GCOVR_FLAGS -o coverage.xml + + - name: Upload Coverage Results + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 + with: + files: ./coverage.xml + flags: ${{ matrix.os-version }},unittest + fail_ci_if_error: false + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + macos-m1: + runs-on: ${{ matrix.os-version }} + strategy: + matrix: + os-version: [macos-14] + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json + python-version: "3.12" + + - name: Configure PcapPlusPlus + # Ensure user have access to network devices instead of giving super-user right + # Seems macos-14 has more strict file permission + run: | + sudo chmod a+rw /dev/bpf* + sudo chmod a+rw /usr/local + cmake -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Check architecture + run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch arm64 + + - name: Install Tcpreplay + run: brew install tcpreplay + + - name: Test PcapPlusPlus + run: | + python -m venv ./venv + source ./venv/bin/activate + python -m pip install pip + python -m pip install -r ci/run_tests/requirements.txt + python ci/run_tests/run_tests.py --interface en0 + + - name: Test Examples + run: | + cd Tests/ExamplesTest + python -m pip install -r requirements.txt + python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin + + - name: Check installation + run: | + cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j + cmake --install "$BUILD_DIR" + + - name: Build Tutorials + run: | + mkdir -p build_examples + cmake -DPCAPPP_BUILD_TUTORIALS=ON -S Examples -B build_examples + cmake --build build_examples -j + + - name: Test Tutorials + run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld + + - name: Create Cobertura Report + run: | + python3 -m pip install gcovr + gcovr -v -r . $GCOVR_FLAGS -o coverage.xml + + - name: Upload Coverage Results + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 + with: + files: ./coverage.xml + flags: ${{ matrix.os-version }},unittest + fail_ci_if_error: false + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + mingw-w64: + runs-on: windows-latest + strategy: + matrix: + include: + - env: i686 + sys: mingw32 + - env: x86_64 + sys: mingw64 + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Setup MSYS2 + uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0 + with: + msystem: ${{matrix.sys}} + install: >- + git + mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-make + + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.8.x" + + - name: Install NPcap + env: + NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} + NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} + run: | + ci\install_npcap.bat + echo "PCAP_SDK_DIR=/C/Npcap-sdk" >> $env:GITHUB_ENV + + - name: Configure PcapPlusPlus + shell: msys2 {0} + run: | + cmake -G "MinGW Makefiles" -DPCAP_ROOT=/C/Npcap-sdk -DLIGHT_PCAPNG_ZSTD=OFF -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + shell: msys2 {0} + # More than 2 jobs would make the build crash with OOM + # cc1plus.exe: out of memory allocating 65536 bytes + run: cmake --build "$BUILD_DIR" -j 2 + + - name: Install tcpreplay + run: ci\install_tcpreplay.bat + + - name: Test PcapPlusPlus + run: | + python -m pip install -r ci\run_tests\requirements.txt + python ci\run_tests\run_tests_windows.py + + - name: Test Examples + run: | + cd Tests\ExamplesTest + python -m pip install -r requirements.txt + python -m pytest --root-path=../../Dist/examples_bin + + - name: Install Coverage Requirements + run: python3 -m pip install gcovr + + - name: Process Coverage Files + shell: msys2 {0} + run: find . -name "*.gcno" -exec gcov -b -l -p -c {} + + + - name: Create Coberture Report + run: gcovr -v -g -k -r . $env:GCOVR_FLAGS.split() -o coverage.xml + + - name: Upload Coverage Results + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 + with: + files: ./coverage.xml + flags: ${{ matrix.sys }},unittest + fail_ci_if_error: false + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + visual-studio: + strategy: + matrix: + include: + - os: "windows-2019" + platform: "Visual Studio 16 2019" + arch: "x64" + pcap_lib: "npcap" + - os: windows-2019 + platform: "Visual Studio 16 2019" + arch: Win32 + pcap_lib: "winpcap" + - os: windows-2022 + platform: "Visual Studio 17 2022" + arch: "x64" + pcap_lib: "winpcap" + - os: windows-2022 + platform: "Visual Studio 17 2022" + arch: "x64" + pcap_lib: "npcap" + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.8.x" + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0 + - name: Setup OpenCppCoverage and add to PATH + run: | + choco install OpenCppCoverage -y + echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH + + - name: Install WinPcap + run: | + ci\install_winpcap.bat + echo "PCAP_SDK_DIR=C:\WpdPack" >> $env:GITHUB_ENV + if: matrix.pcap_lib == 'winpcap' + + - name: Install NPcap + env: + NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} + NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} + run: | + ci\install_npcap.bat + echo "PCAP_SDK_DIR=C:\Npcap-sdk" >> $env:GITHUB_ENV + if: matrix.pcap_lib == 'npcap' + + - name: Set Zstd + run: | + ci\install_zstd.bat + echo "ZSTD_HOME_PARAM=-z C:\zstd" >> $env:GITHUB_ENV + if: matrix.use_zstd == true + + - name: Configure PcapPlusPlus + run: cmake -A ${{ matrix.arch }} -G "${{ matrix.platform }}" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -S . -B "$env:BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build $env:BUILD_DIR -j + + - name: Install tcpreplay + run: ci\install_tcpreplay.bat + + - name: Test PcapPlusPlus + run: | + python -m pip install -r ci\run_tests\requirements.txt + python ci\run_tests\run_tests_windows.py --coverage + + - name: Test Examples + run: | + move ".\Dist\examples_bin\Debug\*" ".\Dist\examples_bin\" + cd Tests\ExamplesTest + python -m pip install -r requirements.txt + python -m pytest --root-path=../../Dist/examples_bin + + - name: Upload Coverage Results + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 + with: + files: ./Tests/Pcap++Test/Pcap++Coverage.xml,./Tests/Packet++Test/Packet++Coverage.xml + flags: ${{ matrix.os }},unittest,${{ matrix.pcap_lib }} + fail_ci_if_error: false + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + freebsd: + runs-on: ubuntu-latest + strategy: + matrix: + version: ["14.0", "13.2"] + steps: + - uses: actions/checkout@v4 + - name: Test in FreeBSD + id: test + uses: vmactions/freebsd-vm@v1 + with: + release: ${{ matrix.version }} + usesh: true + prepare: | + pkg install -y python3 bash cmake git gmake gsed libpcap tcpreplay + + run: | + echo "Building PcapPlusPlus" + chmod a+rw /dev/bpf* + cmake -S . -B Dist + cmake --build Dist -j$(sysctl -n hw.ncpu) + + echo "Setting up the network interface for the tests" + # Get the first interface name that is not 'lo' + interface_name=$(ifconfig -l | tr ' ' '\n' | grep -v '^lo' | head -n 1) + ifconfig "$interface_name" promisc + + echo "Testing PcapPlusPlus" + python3 -m ensurepip + python3 -m pip install -r ci/run_tests/requirements.txt + python3 ci/run_tests/run_tests.py --interface "$interface_name" + + echo "Testing PcapPlusPlus examples" + cd Tests/ExamplesTest + python3 -m pip install -r requirements.txt + python3 -m pytest --interface "$interface_name" --root-path=../../Dist/examples_bin + + android: + strategy: + matrix: + include: + - run-on-os: ubuntu-20.04 + target: armeabi-v7a + api-version: 30 + - run-on-os: ubuntu-20.04 + target: x86 + api-version: 30 + - run-on-os: macos-12 + target: arm64-v8a + cmake_configure: "-DCMAKE_OSX_ARCHITECTURES=arm64" + api-version: 30 + - run-on-os: macos-12 + target: x86_64 + cmake_configure: "-DCMAKE_OSX_ARCHITECTURES=x86_64" + api-version: 30 + + runs-on: ${{ matrix.run-on-os }} + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Checkout lipbcap for Android + uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 # main + with: + repository: seladb/libpcap-android + path: ./libpcap-android + + - name: Configure PcapPlusPlus + run: | + LIBPCAP_PATH=$(pwd)/libpcap-android + cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_PLATFORM="${{ matrix.api-version}}" -DANDROID_ABI="${{ matrix.target }}" -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/include/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/${{ matrix.target }}/${{ matrix.api-version}}/libpcap.a" -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Checkout ToyVpn-PcapPlusPlus + uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master + with: + repository: seladb/ToyVpn-PcapPlusPlus + path: ./ToyVpn-PcapPlusPlus + submodules: true + + - name: Install locally PcapPlusPlus + # CMake install library in $prefix/lib ToyVpn want $prefix/$target/$api-version + run: | + TOYVPN_PCAPPLUSPLUS="./ToyVpn-PcapPlusPlus/app/libs/pcapplusplus" + PCAPPLUSPLUS_LIBS_PATH="$TOYVPN_PCAPPLUSPLUS/${{ matrix.target }}/${{ matrix.api-version }}" + PCAPPLUSPLUS_INCLUDE_PATH="$TOYVPN_PCAPPLUSPLUS/include" + cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j + cmake --install $BUILD_DIR --prefix ${TOYVPN_PCAPPLUSPLUS} + mkdir -p ${PCAPPLUSPLUS_LIBS_PATH} ${PCAPPLUSPLUS_INCLUDE_PATH} + mv ${TOYVPN_PCAPPLUSPLUS}/lib/*.a ${PCAPPLUSPLUS_LIBS_PATH}/ + mv ${TOYVPN_PCAPPLUSPLUS}/include/pcapplusplus/*.h ${PCAPPLUSPLUS_INCLUDE_PATH}/ + + - name: Build ToyVpn-PcapPlusPlus + working-directory: ./ToyVpn-PcapPlusPlus + run: | + sed -i.bak "s|abiFilters.*$|abiFilters '${{ matrix.target }}'|g" app/build.gradle + chmod +x gradlew + ./gradlew assembleDebug + + xdp: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Install dependencies + run: | + sudo apt update && sudo apt -y install libpcap-dev libbpf-dev tcpreplay + + - name: Configure PcapPlusPlus + run: cmake -DPCAPPP_USE_XDP=ON -DPCAPPP_BUILD_COVERAGE=ON -S . -B $BUILD_DIR + + - name: Build PcapPlusPlus + run: cmake --build $BUILD_DIR -j + + - name: Test PcapPlusPlus + run: | + python -m venv ./venv + source ./venv/bin/activate + python -m pip install pip + python -m pip install -r ci/run_tests/requirements.txt + python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" + + - name: Create Cobertura Report + run: | + python -m pip install gcovr + gcovr -v -r . $GCOVR_FLAGS -o coverage.xml + + - name: Upload Coverage Results + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 + with: + files: ./coverage.xml + flags: xdp,unittest + fail_ci_if_error: false + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + test_regressions: + name: Run ${{ matrix.engine }}-${{ matrix.sanitizer }} fuzzer for regressions + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + sanitizer: [address, undefined, memory] + engine: [libfuzzer] + container: + image: gcr.io/oss-fuzz-base/base-builder + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Install prerequisites + run: | + apt-get update && apt-get install -y cmake autoconf flex bison + cd .. + cp -r PcapPlusPlus/ $SRC/PcapPlusPlus + git clone --depth=1 https://github.com/the-tcpdump-group/libpcap.git $SRC/libpcap + cd $SRC/PcapPlusPlus/ + - name: Compile fuzzer + run: | + export FUZZING_LANGUAGE=c + export ARCHITECTURE=x86_64 + export FUZZING_ENGINE=${{ matrix.engine }} + export SANITIZER=${{ matrix.sanitizer }} + $SRC/PcapPlusPlus/Tests/Fuzzers/ossfuzz.sh + - name: Check for regressions + run: | + export BINARY="$OUT/FuzzTarget" + export SAMPLES="Tests/Fuzzers/RegressionTests/regression_samples" + Tests/Fuzzers/RegressionTests/run_tests.sh diff --git a/.github/workflows/check_dependabot.yml b/.github/workflows/check_dependabot.yml new file mode 100644 index 000000000..5b46b6c38 --- /dev/null +++ b/.github/workflows/check_dependabot.yml @@ -0,0 +1,18 @@ +name: Validate dependabot + +on: + pull_request: + paths: + - '.github/dependabot.yml' + - '.github/workflows/check_dependabot.yml' + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: marocchino/validate-dependabot@d8ae5c0d03dd75fbd0ad5f8ab4ba8101ebbd4b37 # v3.0.0 + id: validate diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml new file mode 100644 index 000000000..84805e64a --- /dev/null +++ b/.github/workflows/cifuzz.yml @@ -0,0 +1,38 @@ +name: Fuzz CI +on: + pull_request: + branches: ["dev"] + schedule: + - cron: '0 0 * * 0' # Run every Sunday at midnight + +permissions: + contents: read + +jobs: + Fuzzing: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + sanitizer: [address, undefined, memory] + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@c2c0632831767ff05c568e7b552cef2801d739ff # master + with: + oss-fuzz-project-name: 'pcapplusplus' + dry-run: false + sanitizer: ${{ matrix.sanitizer }} + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@c2c0632831767ff05c568e7b552cef2801d739ff # master + with: + oss-fuzz-project-name: 'pcapplusplus' + fuzz-seconds: 600 + dry-run: false + sanitizer: ${{ matrix.sanitizer }} + - name: Upload Crash + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..07fec5a18 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,47 @@ +name: "CodeQL" + +on: + push: + branches: [ "dev" ] + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' # Run every Sunday at midnight + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + container: seladb/ubuntu2204 + permissions: + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + + steps: + - name: Checkout repository + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + - run: | + cmake -S . -B build + cmake --build build -j + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml new file mode 100644 index 000000000..eb081d0bb --- /dev/null +++ b/.github/workflows/doxygen.yml @@ -0,0 +1,49 @@ +name: Build doxygen +on: + push: + branches: ["master", "dev"] + pull_request: + branches: ["dev"] + +permissions: + contents: read + +jobs: + doxygen: + runs-on: ubuntu-latest + container: seladb/ubuntu2204:latest + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Checkout docs repo + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + repository: PcapPlusPlus/pcapplusplus.github.io + path: pcapplusplus.github.io + + - name: Run doxygen + run: | + cd pcapplusplus.github.io/static/api-docs/next/doxygen + doxygen Doxyfile-ci + + - name: Prepare documentation + if: github.ref == 'refs/heads/master' + run: | + cd pcapplusplus.github.io/static/api-docs/ + find next/ -maxdepth 1 -type f -exec rm {} \; + rm -rf next/search/ + mv next/html/* next/ + + - name: Upload documentation + if: github.ref == 'refs/heads/master' + uses: cpina/github-action-push-to-another-repository@main + env: + SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} + with: + source-directory: pcapplusplus.github.io + destination-github-username: "PcapPlusPlus" + destination-repository-name: "pcapplusplus.github.io" + user-email: noreply@github.com + commit-message: Update API documentation for commit ORIGIN_COMMIT + target-branch: master diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 000000000..6b0c79539 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,336 @@ +name: Package and release + +on: + push: + tags: + - '*' + pull_request: + paths: + # Also run this workflow when this package.yml is update by a PR + - '.github/workflows/package.yml' + schedule: + - cron: '0 0 * * 0' # Run every Sunday at midnight + +env: + BUILD_DIR: Dist + +permissions: + contents: read + +jobs: + linux: + runs-on: ubuntu-latest + permissions: + contents: write + container: seladb/${{ matrix.image }} + strategy: + matrix: + include: + - image: ubuntu2404 + config-zstd: OFF + - image: ubuntu2204 + config-zstd: OFF + - image: ubuntu2204-icpx + config-zstd: OFF + additional-flags: -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx + - image: ubuntu2004 + config-zstd: OFF + - image: rhel94 + config-zstd: OFF + - image: fedora39 + config-zstd: OFF + - image: alpine317 + config-zstd: OFF + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + # Checkout is performed out of the container and doesn't match our user + - name: Fix checkout ownership + run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" + + - name: Setup Intel Compiler variables + if: contains(matrix.image, 'icpx') + run: | + . /opt/intel/oneapi/setvars.sh + printenv >> $GITHUB_ENV + + - name: Debug Cmake + run: cmake --system-information + + - name: Configure PcapPlusPlus + run: cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Package + run: cmake --build "$BUILD_DIR" --target package + + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.deb,${{ env.BUILD_DIR }}/*.rpm" + + freebsd: + runs-on: ubuntu-latest + permissions: + contents: write + strategy: + matrix: + include: + - freebsd-version: "13.2" + - freebsd-version: "14.0" + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Test in FreeBSD + uses: vmactions/freebsd-vm@f8be330398166d1eb0601f01353839d4052367b2 # v1.0.7 + with: + release: ${{ matrix.freebsd-version }} + envs: 'BUILD_DIR' + usesh: true + prepare: | + pkg install -y bash cmake git-tiny gmake gsed libpcap py39-pip + run: | + cmake -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR" + cmake --build "$BUILD_DIR" -j 4 + cmake --build "$BUILD_DIR" --target package + + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: ${{ env.BUILD_DIR }}/*.tar.gz + + macos: + runs-on: macos-12 + permissions: + contents: write + strategy: + matrix: + xcode-version: [14.2.0, 13.4.1] + arch: [x86_64, arm64] + + steps: + - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 + with: + xcode-version: "${{ matrix.xcode-version }}" + + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Configure PcapPlusPlus + run: | + cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -S . -B "$BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build "$BUILD_DIR" -j + + - name: Package + run: cmake --build "$BUILD_DIR" --target package + + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.pkg" + + mingw-w64: + runs-on: windows-latest + permissions: + contents: write + strategy: + matrix: + include: + - env: i686 + sys: mingw32 + - env: x86_64 + sys: mingw64 + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Setup MSYS2 + uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + git + mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-make + + - name: Install NPcap + env: + NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }} + NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }} + run: | + ci\install_npcap.bat + echo "PCAP_SDK_DIR=/C/Npcap-sdk" >> $env:GITHUB_ENV + + - name: Configure PcapPlusPlus + shell: msys2 {0} + run: | + cmake -G "MinGW Makefiles" -DPCAP_ROOT=/C/Npcap-sdk -DLIGHT_PCAPNG_ZSTD=OFF -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR" + + - name: Debug Cmake + shell: msys2 {0} + run: cmake --system-information + + - name: Build PcapPlusPlus + shell: msys2 {0} + # More than 2 jobs would make the build crash with OOM + # cc1plus.exe: out of memory allocating 65536 bytes + run: cmake --build "$BUILD_DIR" -j 2 + + - name: Package + shell: msys2 {0} + run: cmake --build "$BUILD_DIR" --target package + + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: ${{ env.BUILD_DIR }}/*.zip + + visual-studio: + strategy: + matrix: + os: [ windows-2019, windows-2022 ] + arch: [ Win32, x64 ] + configuration: [ Debug, Release ] + + runs-on: ${{ matrix.os }} + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0 + + - name: Install WinPcap + run: | + ci\install_winpcap.bat + echo "PCAP_SDK_DIR=C:\WpdPack" >> $env:GITHUB_ENV + + - name: Configure PcapPlusPlus + run: | + $platform = if ("${{ matrix.os }}" -eq "windows-2019") { "Visual Studio 16 2019" } else { "Visual Studio 17 2022" } + cmake -A ${{ matrix.arch }} -G "$platform" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DPCAPPP_PACKAGE=ON -S . -B "$env:BUILD_DIR" + + - name: Build PcapPlusPlus + run: cmake --build $env:BUILD_DIR --config ${{ matrix.configuration }} -j + + - name: Package + run: cmake --build "$env:BUILD_DIR" --config ${{ matrix.configuration }} --target package + + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: ${{ env.BUILD_DIR }}/*.zip + + android-build: + strategy: + matrix: + include: + - target: "armeabi-v7a" + api-version: 30 + - target: "x86" + api-version: 30 + - target: "arm64-v8a" + api-version: 30 + - target: "x86_64" + api-version: 30 + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Checkout lipbcap for Android + uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 # main + with: + repository: seladb/libpcap-android + path: ./libpcap-android + + - name: Configure and Build PcapPlusPlus + run: | + LIBPCAP_PATH="$(pwd)/libpcap-android" + export LIB_DIR="${{ matrix.target }}/${{ matrix.api-version }}" + export LOCAL_BUILD_DIR="${BUILD_DIR}/${LIB_DIR}" + cmake -DPCAPPP_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_LIBDIR="${LIB_DIR}" -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_PLATFORM="${{ matrix.api-version }}" -DANDROID_ABI="${{ matrix.target }}" -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/include/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/${{ matrix.target }}/${{ matrix.api-version}}/libpcap.a" -DPCAPPP_PACKAGE=ON -S . -B "$LOCAL_BUILD_DIR" + cmake --build "$LOCAL_BUILD_DIR" -j --target package + + - name: Prepare package + run: | + export LOCAL_BUILD_DIR="${BUILD_DIR}/${{ matrix.target }}/${{ matrix.api-version }}" + export PACKAGE_FILE=$(ls ${LOCAL_BUILD_DIR} | grep pcapplusplus) + export PACKAGE_DIR=$(basename ${PACKAGE_FILE%} .tar.gz) + export COMBINED_PACKAGE_DIR=$(echo "$PACKAGE_DIR" | cut -f1,2,3 -d'-') + + tar -xvf "${LOCAL_BUILD_DIR}/${PACKAGE_FILE}" + mv "${PACKAGE_DIR}" "${COMBINED_PACKAGE_DIR}" + find . -name example-app -type d -exec rm -r {} + + find . -name cmake -type d -exec rm -r {} + + find . -name pkgconfig -type d -exec rm -r {} + + mv ${COMBINED_PACKAGE_DIR}/include/pcapplusplus/* "${COMBINED_PACKAGE_DIR}/include/" + rmdir "${COMBINED_PACKAGE_DIR}/include/pcapplusplus/" + mkdir -p "android-package" + mv "${COMBINED_PACKAGE_DIR}" "android-package" + + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + path: android-package + name: android-package-${{ matrix.target }}-${{ matrix.api-version }} + if-no-files-found: error + + android-package: + needs: android-build + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + pattern: android-package-* + merge-multiple: true + + - name: Package into archive + run: | + export PACKAGE_DIR=$(ls | grep pcapplusplus) + echo "PACKAGE_DIR=$PACKAGE_DIR" >> $GITHUB_ENV + tar cvf "${PACKAGE_DIR}.tar.gz" "${PACKAGE_DIR}" + - name: Upload binaries to release + if: github.ref_type == 'tag' + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + with: + draft: true + allowUpdates: true + updateOnlyUnreleased: true + artifacts: ${{ env.PACKAGE_DIR }}.tar.gz diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 000000000..01e6b88b6 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,71 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '20 7 * * 2' + push: + branches: ["master"] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + + steps: + - name: "Checkout code" + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + repo_token: ${{ secrets.PAT }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + with: + sarif_file: results.sarif From 1ee855f9c70cffeccb7639c49de93fe638c69809 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 02:21:03 +0900 Subject: [PATCH 08/28] support ubuntu24 --- .github/workflows/build_and_test.yml | 13 ++++++++++--- .github/workflows/package.yml | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index edfbd2822..1b5ff414b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | apk update && apk add cppcheck python3-dev + python3 -m venv ./venv python3 -m pip install cmake-format clang-format==18.1.6 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 @@ -52,6 +53,9 @@ jobs: strategy: matrix: include: + - image: ubuntu2404 + python: python3 + config-zstd: OFF - image: ubuntu2204 python: python3 config-zstd: OFF @@ -279,6 +283,7 @@ jobs: if: ${{ matrix.arch == 'x86_64' }} run: | python -m pip install -U pip + python -m venv ./venv python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -286,7 +291,6 @@ jobs: if: ${{ matrix.arch == 'x86_64' }} run: | cd Tests/ExamplesTest - python -m pip install -U pip python -m pip install -r requirements.txt python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin @@ -356,13 +360,13 @@ jobs: - name: Test PcapPlusPlus run: | python -m pip install -U pip + python -m venv ./venv python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 - name: Test Examples run: | cd Tests/ExamplesTest - python -m pip install -U pip python -m pip install -r requirements.txt python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin @@ -449,6 +453,7 @@ jobs: - name: Test PcapPlusPlus run: | + python -m venv ./venv python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py @@ -548,6 +553,7 @@ jobs: - name: Test PcapPlusPlus run: | + python -m venv ./venv python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py --coverage @@ -597,12 +603,12 @@ jobs: echo "Testing PcapPlusPlus" python3 -m ensurepip + python -m venv ./venv python3 -m pip install -r ci/run_tests/requirements.txt python3 ci/run_tests/run_tests.py --interface "$interface_name" echo "Testing PcapPlusPlus examples" cd Tests/ExamplesTest - python3 -m ensurepip python3 -m pip install -r requirements.txt python3 -m pytest --interface "$interface_name" --root-path=../../Dist/examples_bin @@ -692,6 +698,7 @@ jobs: - name: Test PcapPlusPlus run: | python -m pip install -U pip + python -m venv ./venv python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 1b036b1a7..6b0c79539 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -26,6 +26,8 @@ jobs: strategy: matrix: include: + - image: ubuntu2404 + config-zstd: OFF - image: ubuntu2204 config-zstd: OFF - image: ubuntu2204-icpx From ed212f436d42db1c850db6d6f5746f7a07c14663 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 02:30:02 +0900 Subject: [PATCH 09/28] test --- .github/workflows/build_and_test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 1b5ff414b..db8163f61 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -30,6 +30,7 @@ jobs: run: | apk update && apk add cppcheck python3-dev python3 -m venv ./venv + source ./venv/bin/activate python3 -m pip install cmake-format clang-format==18.1.6 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 @@ -284,6 +285,7 @@ jobs: run: | python -m pip install -U pip python -m venv ./venv + source ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -361,6 +363,7 @@ jobs: run: | python -m pip install -U pip python -m venv ./venv + source ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -454,6 +457,7 @@ jobs: - name: Test PcapPlusPlus run: | python -m venv ./venv + source ./venv/bin/activate python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py @@ -554,6 +558,7 @@ jobs: - name: Test PcapPlusPlus run: | python -m venv ./venv + source ./venv/bin/activate python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py --coverage @@ -604,6 +609,7 @@ jobs: echo "Testing PcapPlusPlus" python3 -m ensurepip python -m venv ./venv + source ./venv/bin/activate python3 -m pip install -r ci/run_tests/requirements.txt python3 ci/run_tests/run_tests.py --interface "$interface_name" @@ -699,6 +705,7 @@ jobs: run: | python -m pip install -U pip python -m venv ./venv + source ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" From ed73da04c4a6ed60beeb1ca81b35bd7fc62417cd Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 02:52:48 +0900 Subject: [PATCH 10/28] update --- .github/workflows/build_and_test.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index db8163f61..a869774aa 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -29,10 +29,9 @@ jobs: - name: Install dependencies run: | apk update && apk add cppcheck python3-dev - python3 -m venv ./venv - source ./venv/bin/activate python3 -m pip install cmake-format clang-format==18.1.6 + # TODO: investigate how to run pre-commit with `venv` - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 - name: CMake format @@ -283,9 +282,9 @@ jobs: # We can't run cross compiled binaries if: ${{ matrix.arch == 'x86_64' }} run: | - python -m pip install -U pip python -m venv ./venv source ./venv/bin/activate + python -m pip install -U pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -361,9 +360,9 @@ jobs: - name: Test PcapPlusPlus run: | - python -m pip install -U pip python -m venv ./venv source ./venv/bin/activate + python -m pip install -U pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -456,8 +455,6 @@ jobs: - name: Test PcapPlusPlus run: | - python -m venv ./venv - source ./venv/bin/activate python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py @@ -557,8 +554,6 @@ jobs: - name: Test PcapPlusPlus run: | - python -m venv ./venv - source ./venv/bin/activate python -m pip install -r ci\run_tests\requirements.txt python ci\run_tests\run_tests_windows.py --coverage @@ -608,8 +603,6 @@ jobs: echo "Testing PcapPlusPlus" python3 -m ensurepip - python -m venv ./venv - source ./venv/bin/activate python3 -m pip install -r ci/run_tests/requirements.txt python3 ci/run_tests/run_tests.py --interface "$interface_name" @@ -703,11 +696,11 @@ jobs: - name: Test PcapPlusPlus run: | - python -m pip install -U pip python -m venv ./venv source ./venv/bin/activate - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" + python -m pip install -U pip + python -m pip install -r ci/run_tests/requirements.txt + python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" - name: Create Cobertura Report run: | From 65dc067431bbedbc89ffb61d3def78dafbba2ff6 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 03:14:07 +0900 Subject: [PATCH 11/28] update --- .github/workflows/build_and_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index a869774aa..fa69717bd 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -102,6 +102,8 @@ jobs: - name: Test PcapPlusPlus run: | + python -m venv ./venv + source ./venv/bin/activate ${{ matrix.python }} -m pip install -U pip ${{ matrix.python }} -m pip install -r ci/run_tests/requirements.txt ${{ matrix.python }} ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} From 800d1927df5b3e1d4d5ea61011652189df77f3c1 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 03:33:36 +0900 Subject: [PATCH 12/28] try --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index fa69717bd..12e10cc87 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -102,7 +102,7 @@ jobs: - name: Test PcapPlusPlus run: | - python -m venv ./venv + ${{ matrix.python }} -m venv ./venv source ./venv/bin/activate ${{ matrix.python }} -m pip install -U pip ${{ matrix.python }} -m pip install -r ci/run_tests/requirements.txt From 4600133d0af62239cef68e57a56cb2895f09021d Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 11:34:08 +0900 Subject: [PATCH 13/28] test --- .github/workflows/build_and_test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 12e10cc87..122d90673 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -104,14 +104,14 @@ jobs: run: | ${{ matrix.python }} -m venv ./venv source ./venv/bin/activate - ${{ matrix.python }} -m pip install -U pip + ${{ matrix.python }} -m pip install pip ${{ matrix.python }} -m pip install -r ci/run_tests/requirements.txt ${{ matrix.python }} ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples run: | cd Tests/ExamplesTest - ${{ matrix.python }} -m pip install -U pip + ${{ matrix.python }} -m pip install pip ${{ matrix.python }} -m pip install -r requirements.txt ${{ matrix.python }} -m pytest --interface eth0 --root-path=../../Dist/examples_bin @@ -286,7 +286,7 @@ jobs: run: | python -m venv ./venv source ./venv/bin/activate - python -m pip install -U pip + python -m pip install pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -364,7 +364,7 @@ jobs: run: | python -m venv ./venv source ./venv/bin/activate - python -m pip install -U pip + python -m pip install pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 @@ -700,7 +700,7 @@ jobs: run: | python -m venv ./venv source ./venv/bin/activate - python -m pip install -U pip + python -m pip install pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" From 8054c901f837457494a8ff8a33a11522151e1328 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 11:57:49 +0900 Subject: [PATCH 14/28] try --- .github/workflows/build_and_test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 122d90673..80aca8df2 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -84,6 +84,17 @@ jobs: - name: Checkout code uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - name: Set up Python + run: | + if [ "${{ matrix.image }}" = "alpine317" ]; then + apk add --no-cache python3 py3-virtualenv + elif [ "${{ matrix.image }}" = "rhel94" ]; then + yum install -y python3 python3-virtualenv + else + apt-get update + apt-get install -y python3 python3-venv + fi + # Checkout is performed out of the container and doesn't match our user - name: Fix checkout ownership run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" From a7603f0265a9eefb275a02d210c86571fe841e27 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 12:07:50 +0900 Subject: [PATCH 15/28] test --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 80aca8df2..9fece7b11 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -88,7 +88,7 @@ jobs: run: | if [ "${{ matrix.image }}" = "alpine317" ]; then apk add --no-cache python3 py3-virtualenv - elif [ "${{ matrix.image }}" = "rhel94" ]; then + elif [ "${{ matrix.image }}" = "rhel94" ] || [ "${{ matrix.image }}" = "fedora39" ]; then yum install -y python3 python3-virtualenv else apt-get update From ab07076ba13a03042a0d7c7febc8ac972447ef3b Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 12:38:10 +0900 Subject: [PATCH 16/28] use bash for linux --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 9fece7b11..bcc95d29b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -113,6 +113,7 @@ jobs: - name: Test PcapPlusPlus run: | + bash ${{ matrix.python }} -m venv ./venv source ./venv/bin/activate ${{ matrix.python }} -m pip install pip @@ -122,7 +123,6 @@ jobs: - name: Test Examples run: | cd Tests/ExamplesTest - ${{ matrix.python }} -m pip install pip ${{ matrix.python }} -m pip install -r requirements.txt ${{ matrix.python }} -m pytest --interface eth0 --root-path=../../Dist/examples_bin From 2868ccf512dde64f2cec7c00926e10d0271be6b3 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 12:38:41 +0900 Subject: [PATCH 17/28] test --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index bcc95d29b..eb9a33ee5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -113,7 +113,7 @@ jobs: - name: Test PcapPlusPlus run: | - bash + bash # need to run bash to activate venv ${{ matrix.python }} -m venv ./venv source ./venv/bin/activate ${{ matrix.python }} -m pip install pip From ce005bdffba7cc4a6165ec2c652cee4204677675 Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 16:45:40 +0900 Subject: [PATCH 18/28] test --- .github/workflows/build_and_test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index eb9a33ee5..1031231ed 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -112,8 +112,8 @@ jobs: run: cmake --build "$BUILD_DIR" -j - name: Test PcapPlusPlus + shell: bash run: | - bash # need to run bash to activate venv ${{ matrix.python }} -m venv ./venv source ./venv/bin/activate ${{ matrix.python }} -m pip install pip @@ -121,7 +121,9 @@ jobs: ${{ matrix.python }} ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples + shell: bash run: | + source ./venv/bin/activate cd Tests/ExamplesTest ${{ matrix.python }} -m pip install -r requirements.txt ${{ matrix.python }} -m pytest --interface eth0 --root-path=../../Dist/examples_bin @@ -141,7 +143,9 @@ jobs: run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - name: Create Cobertura Report + shell: bash run: | + source ./venv/bin/activate ${{ matrix.python }} -m pip install gcovr gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml From 7d3d143c10855e71bcebf89a66d943a75477c9fb Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 17:00:13 +0900 Subject: [PATCH 19/28] try --- .github/workflows/build_and_test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 1031231ed..62e3fd96c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -87,12 +87,14 @@ jobs: - name: Set up Python run: | if [ "${{ matrix.image }}" = "alpine317" ]; then - apk add --no-cache python3 py3-virtualenv - elif [ "${{ matrix.image }}" = "rhel94" ] || [ "${{ matrix.image }}" = "fedora39" ]; then - yum install -y python3 python3-virtualenv + apk add --no-cache python3 py3-virtualenv py3-virtualenv + elif [ "${{ matrix.image }}" = "rhel94" ]; then + yum install -y python3 python3-virtualenv python3-devel + elif [ "${{ matrix.image }}" = "fedora39" ]; then + dnf install -y python3 python3-venv python3-devel else apt-get update - apt-get install -y python3 python3-venv + apt-get install -y python3 python3-venv python3-dev fi # Checkout is performed out of the container and doesn't match our user From 4a7f69745bd40ba261f69208890eac7522e1590c Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Sun, 7 Jul 2024 17:19:06 +0900 Subject: [PATCH 20/28] try --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 62e3fd96c..c34555cd9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -91,7 +91,7 @@ jobs: elif [ "${{ matrix.image }}" = "rhel94" ]; then yum install -y python3 python3-virtualenv python3-devel elif [ "${{ matrix.image }}" = "fedora39" ]; then - dnf install -y python3 python3-venv python3-devel + dnf install -y python3 python3-virtualenv python3-devel else apt-get update apt-get install -y python3 python3-venv python3-dev From 7b18e8b3f6a9bc3237b961f861568e9a3974e628 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Thu, 18 Jul 2024 09:28:06 +0900 Subject: [PATCH 21/28] try activate venv for pre-commit --- .github/workflows/build_and_test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4ea34ca16..37aaed63b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -31,7 +31,12 @@ jobs: apk update && apk add cppcheck python3-dev python3 -m pip install cmake-format clang-format==18.1.6 - # TODO: investigate how to run pre-commit with `venv` + - name: Activate virtualenv + run: | + python3 -m venv ./venv + . .venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 - name: CMake format From 5ea9c4fd9d82ca52332beacbdcb503862f182aa2 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Fri, 19 Jul 2024 11:13:14 +0900 Subject: [PATCH 22/28] Revert "try activate venv for pre-commit" This reverts commit 7b18e8b3f6a9bc3237b961f861568e9a3974e628. --- .github/workflows/build_and_test.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 37aaed63b..4ea34ca16 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -31,12 +31,7 @@ jobs: apk update && apk add cppcheck python3-dev python3 -m pip install cmake-format clang-format==18.1.6 - - name: Activate virtualenv - run: | - python3 -m venv ./venv - . .venv/bin/activate - echo PATH=$PATH >> $GITHUB_ENV - + # TODO: investigate how to run pre-commit with `venv` - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 - name: CMake format From a853f082784f6833416241099100522cbca6a8f6 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Fri, 16 Aug 2024 15:17:00 +0900 Subject: [PATCH 23/28] python3 --- .github/workflows/build_and_test.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 32b60eca9..6323dbd9a 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -57,27 +57,20 @@ jobs: - image: ubuntu2404 config-zstd: OFF - image: ubuntu2204 - python: python3 config-zstd: OFF - image: ubuntu2204-icpx - python: python3 config-zstd: OFF additional-flags: -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx additional-gcov-flags: --gcov-executable "llvm-cov gcov" - image: ubuntu2004 - python: python3 config-zstd: OFF - image: rhel94 - python: python3 config-zstd: OFF - image: ubuntu2004-zstd - python: python3 config-zstd: ON - image: fedora39 - python: python3 config-zstd: OFF - image: alpine317 - python: python3 config-zstd: OFF steps: @@ -115,19 +108,18 @@ jobs: - name: Test PcapPlusPlus shell: bash run: | - ${{ matrix.python }} -m venv ./venv + python3 -m venv ./venv source ./venv/bin/activate - ${{ matrix.python }} -m pip install pip - ${{ matrix.python }} -m pip install -r ci/run_tests/requirements.txt - ${{ matrix.python }} ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} + python3 -m pip install -r ci/run_tests/requirements.txt + python3 ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples shell: bash run: | source ./venv/bin/activate cd Tests/ExamplesTest - ${{ matrix.python }} -m pip install -r requirements.txt - ${{ matrix.python }} -m pytest --interface eth0 --root-path=../../Dist/examples_bin + python3 -m pip install -r requirements.txt + python3 -m pytest --interface eth0 --root-path=../../Dist/examples_bin - name: Check installation run: | @@ -147,7 +139,7 @@ jobs: shell: bash run: | source ./venv/bin/activate - ${{ matrix.python }} -m pip install gcovr + python3 -m pip install gcovr gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml - name: Upload Coverage Results From 5828da47d93ffde3c4ac21599286f85ddd493e76 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Fri, 16 Aug 2024 17:46:18 +0900 Subject: [PATCH 24/28] try --- .github/workflows/build_and_test.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 6323dbd9a..aace1c4ff 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -106,17 +106,15 @@ jobs: run: cmake --build "$BUILD_DIR" -j - name: Test PcapPlusPlus - shell: bash run: | python3 -m venv ./venv - source ./venv/bin/activate + . ./venv/bin/activate python3 -m pip install -r ci/run_tests/requirements.txt python3 ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples - shell: bash run: | - source ./venv/bin/activate + . ./venv/bin/activate cd Tests/ExamplesTest python3 -m pip install -r requirements.txt python3 -m pytest --interface eth0 --root-path=../../Dist/examples_bin @@ -136,9 +134,8 @@ jobs: run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - name: Create Cobertura Report - shell: bash run: | - source ./venv/bin/activate + . ./venv/bin/activate python3 -m pip install gcovr gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml From 167664d88afe19fce60a2227273411c7668b4d01 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Mon, 19 Aug 2024 09:23:07 +0900 Subject: [PATCH 25/28] add "Prepare environment for tests" step --- .github/workflows/build_and_test.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index aace1c4ff..95735aed9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -105,11 +105,14 @@ jobs: - name: Build PcapPlusPlus run: cmake --build "$BUILD_DIR" -j - - name: Test PcapPlusPlus + - name: Prepare environment for tests run: | python3 -m venv ./venv . ./venv/bin/activate python3 -m pip install -r ci/run_tests/requirements.txt + + - name: Test PcapPlusPlus + run: | python3 ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples @@ -341,13 +344,16 @@ jobs: - name: Check architecture run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch ${{ matrix.arch }} - - name: Test PcapPlusPlus - # We can't run cross compiled binaries - if: ${{ matrix.host-arch == matrix.arch }} + - name: Prepare environment for tests run: | python -m venv ./venv source ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt + + - name: Test PcapPlusPlus + # We can't run cross compiled binaries + if: ${{ matrix.host-arch == matrix.arch }} + run: | python ci/run_tests/run_tests.py --interface en0 - name: Test Examples From 4f3dc323ec50e654ea13369a0407f5ff38d7eeaa Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Mon, 19 Aug 2024 11:55:44 +0900 Subject: [PATCH 26/28] fix --- .github/workflows/build_and_test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 95735aed9..04bcb65c0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -347,7 +347,7 @@ jobs: - name: Prepare environment for tests run: | python -m venv ./venv - source ./venv/bin/activate + . ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt - name: Test PcapPlusPlus @@ -712,11 +712,14 @@ jobs: - name: Build PcapPlusPlus run: cmake --build $BUILD_DIR -j - - name: Test PcapPlusPlus + - name: Prepare environment for tests run: | python -m venv ./venv - source ./venv/bin/activate + . ./venv/bin/activate python -m pip install -r ci/run_tests/requirements.txt + + - name: Test PcapPlusPlus + run: | python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" - name: Create Cobertura Report From 2b4ac4ef20f01a0e443e055c2b2ad00dc3f181c1 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Mon, 19 Aug 2024 12:18:56 +0900 Subject: [PATCH 27/28] fix --- .github/workflows/build_and_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 04bcb65c0..3f6d053a9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -113,6 +113,7 @@ jobs: - name: Test PcapPlusPlus run: | + . ./venv/bin/activate python3 ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }} - name: Test Examples @@ -354,6 +355,7 @@ jobs: # We can't run cross compiled binaries if: ${{ matrix.host-arch == matrix.arch }} run: | + . ./venv/bin/activate python ci/run_tests/run_tests.py --interface en0 - name: Test Examples @@ -720,6 +722,7 @@ jobs: - name: Test PcapPlusPlus run: | + . ./venv/bin/activate python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" - name: Create Cobertura Report From f3ed6b257e5f3c3c254ddb332f42d2c82aee5515 Mon Sep 17 00:00:00 2001 From: "anchi.liu" Date: Mon, 19 Aug 2024 12:37:18 +0900 Subject: [PATCH 28/28] add a comment --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 3f6d053a9..e74900d50 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -53,7 +53,7 @@ jobs: container: seladb/${{ matrix.image }} strategy: matrix: - include: + include: # Check the images at https://github.com/seladb/PcapPlusPlus-DockerImages - image: ubuntu2404 config-zstd: OFF - image: ubuntu2204