Skip to content

Commit

Permalink
Add workflow step to test if plugins are loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
oshaked1 committed Jul 10, 2024
1 parent 4e67893 commit 89f0749
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-wireshark-headers-unix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ runs:
id: install_wireshark
if: ${{ steps.install_headers.outcome == 'failure' }}
run: |
ninja -C wireshark/build -j$(nproc)
ninja -C wireshark/build
sudo ninja -C wireshark/build install
shell: bash
27 changes: 27 additions & 0 deletions .github/load_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

import os
import subprocess

if os.name == 'nt':
tshark = r'build\run\RelWithDebInfo\tshark.exe'
else:
tshark = "wireshark/build/run/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)
print("Tshark errors:")
print(err.decode())
exit(1)
17 changes: 15 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Pull Request

on:
pull_request:
branches:
- main

jobs:
build:
Expand Down Expand Up @@ -84,3 +82,18 @@ jobs:
call scripts\make_cmake.bat
call scripts\make.bat
shell: cmd

- name: Load Plugins Test (Unix)
if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13')
run: |
ls -la wireshark/build/run
make install
.github/load_plugins.py
- name: Load Plugins Test (Windows)
if: matrix.os == 'windows-latest'
run: |
call scripts\make_dist.bat
set WIRESHARK_PLUGIN_DIR="${{ github.workspace }}\dist\workdir"
python .github/load_plugins.py
shell: cmd
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ jobs:
call scripts\make.bat
shell: cmd

- name: Load Plugins Test (Unix, Wireshark > 3.6.2)
if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13') && matrix.wireshark_version != 'wireshark-3.6.2'
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 Plugins Test (Ubuntu, Wireshark 3.6.2)
if: matrix.os == 'ubuntu-latest' && matrix.wireshark_version == 'wireshark-3.6.2'
run: |
sudo ninja -C wireshark/build install
sudo cp /epan/tracee-event /usr/local/lib/wireshark/plugins/3.6/epan/tracee-event.so
sudo cp /epan/tracee-network-capture /usr/local/lib/wireshark/plugins/3.6/epan/tracee-network-capture.so
sudo cp /wiretap/tracee-json /usr/local/lib/wireshark/plugins/3.6/wiretap/tracee-json.so
.github/load_plugins.py
- name: Load Plugins Test (Windows)
if: matrix.os == 'windows-latest'
run: |
pushd build
msbuild /m /p:Configuration=RelWithDebInfo install.vcxproj
popd
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: |
Expand Down
32 changes: 6 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,9 @@ install:
@mkdir -p ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan
@mkdir -p ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/wiretap

@if [ "$(OS_NAME)" = "Darwin" ]; then \
cp wireshark/build/run/tracee-event ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan/tracee-event.so; \
cp wireshark/build/run/tracee-network-capture ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan/tracee-network-capture.so; \
cp wireshark/build/run/tracee-json ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/wiretap/tracee-json.so; \
else \
cp wireshark/build/run/tracee-event.so* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan; \
cp wireshark/build/run/tracee-network-capture.so* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan; \
cp wireshark/build/run/tracee-json.so* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/wiretap; \
fi
@cp wireshark/build/run/tracee-event* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan/tracee-event.so
@cp wireshark/build/run/tracee-network-capture* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/epan/tracee-network-capture.so
@cp wireshark/build/run/tracee-json* ~/.local/lib/wireshark/plugins/$(WS_VERSION_DIR)/wiretap/tracee-json.so

# build and run
run: all install
Expand All @@ -124,23 +118,9 @@ dist: all
@mkdir dist/workdir
@cp dist/install.sh dist/workdir

@if [ -e "wireshark/build/run/tracee-event" ]; 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
@cp wireshark/build/run/tracee-event* dist/workdir/tracee-event.so
@cp wireshark/build/run/tracee-network-capture* dist/workdir/tracee-network-capture.so
@cp wireshark/build/run/tracee-json* dist/workdir/tracee-json.so

@if [ "$(OS_NAME)" = "Darwin" ]; then \
scripts/macos_rpathify.sh dist/workdir/tracee-json.so; \
Expand Down

0 comments on commit 89f0749

Please sign in to comment.