From 0a99d036d2adf82c60dcb6617c822f33d02c089c Mon Sep 17 00:00:00 2001 From: Ofek Shaked Date: Mon, 8 Jul 2024 17:33:51 +0300 Subject: [PATCH] Add workflow step to test if plugins are loaded --- .github/load_plugins.py | 25 +++++++++++++++++++++++++ .github/workflows/pr.yml | 18 ++++++++++++++++++ .github/workflows/release.yml | 18 ++++++++++++++++++ Makefile | 21 +++++---------------- 4 files changed, 66 insertions(+), 16 deletions(-) create mode 100755 .github/load_plugins.py diff --git a/.github/load_plugins.py b/.github/load_plugins.py new file mode 100755 index 0000000..1617dda --- /dev/null +++ b/.github/load_plugins.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import os +import subprocess + +if os.name == 'nt': + tshark = os.path.join(os.getenv("ProgramFiles"), "Wireshark", "tshark.exe") +else: + tshark = "tshark" + +proc = subprocess.Popen([tshark, "-G", "plugins"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +out, err = proc.communicate() +if proc.returncode != 0: + print(f'tshark exited with return code {proc.returncode}, stderr:') + print(err.decode()) + exit(1) + +out = out.decode() +if 'tracee-event' in out and 'tracee-network-capture' in out and 'tracee-json' in out: + print('Plugins loaded successfully') + exit(0) +else: + print("Plugins not loaded. tshark output:") + print(out) + exit(1) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 263dba2..8beccf9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -84,3 +84,21 @@ jobs: call scripts\make_cmake.bat call scripts\make.bat shell: cmd + + - name: Load Plugin Test (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + run: | + sudo ninja -C wireshark/build install + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-event" -execdir mv {} tracee-event.so \; + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-network-capture" -execdir mv {} tracee-network-capture.so \; + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-json" -execdir mv {} tracee-json.so \; + export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + .github/load_plugins.py + + - name: Load Plugin Test (Windows) + if: matrix.os == 'windows-latest' + run: | + cd build + msbuild install.vcxproj + python .github/load_plugins.py + shell: cmd diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d76b70c..d32574a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,6 +108,24 @@ jobs: call scripts\make.bat shell: cmd + - name: Load Plugin Test (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + run: | + sudo ninja -C wireshark/build install + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-event" -execdir mv {} tracee-event.so \; + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-network-capture" -execdir mv {} tracee-network-capture.so \; + sudo find /usr/local/lib/wireshark/plugins -type f -name "tracee-json" -execdir mv {} tracee-json.so \; + export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + .github/load_plugins.py + + - name: Load Plugin Test (Windows) + if: matrix.os == 'windows-latest' + run: | + cd build + msbuild install.vcxproj + python .github/load_plugins.py + shell: cmd + - name: Create distribution archive (Unix) if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' run: | diff --git a/Makefile b/Makefile index 4587f1d..61a5a31 100644 --- a/Makefile +++ b/Makefile @@ -134,28 +134,17 @@ dist: all @mkdir dist/workdir @cp dist/install.sh dist/workdir - @if [ -e "wireshark/build/run/tracee-event" ]; then \ + @if [ "$(OS_NAME)" = "Darwin" ]; then \ cp wireshark/build/run/tracee-event dist/workdir/tracee-event.so; \ - else \ - cp wireshark/build/run/tracee-event.so* dist/workdir; \ - fi - - @if [ -e "wireshark/build/run/tracee-network-capture" ]; then \ cp wireshark/build/run/tracee-network-capture dist/workdir/tracee-network-capture.so; \ - else \ - cp wireshark/build/run/tracee-network-capture.so* dist/workdir; \ - fi - - @if [ -e "wireshark/build/run/tracee-json" ]; then \ cp wireshark/build/run/tracee-json dist/workdir/tracee-json.so; \ - else \ - cp wireshark/build/run/tracee-json.so* dist/workdir; \ - fi - - @if [ "$(OS_NAME)" = "Darwin" ]; then \ scripts/macos_rpathify.sh dist/workdir/tracee-json.so; \ scripts/macos_rpathify.sh dist/workdir/tracee-event.so; \ scripts/macos_rpathify.sh dist/workdir/tracee-network-capture.so; \ + else \ + cp wireshark/build/run/tracee-event.so* dist/workdir; \ + cp wireshark/build/run/tracee-network-capture.so* dist/workdir; \ + cp wireshark/build/run/tracee-json.so* dist/workdir; \ fi @cp -r profiles dist/workdir