From 09ce4ab8e337560e5430a5d6fac7563d91e91691 Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Sun, 22 Mar 2026 14:33:28 +0200 Subject: [PATCH 1/6] Fix Dockerfile after centos7 eol --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57fd1b9..635896d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,8 @@ ENV PY="/opt/python/cp38-cp38/bin/python" RUN mkdir -p marine/.ws/data && \ rsync -L --exclude idl2wrs --exclude 'lib*.so*' --exclude 'plugins*' --exclude 'marine_*' --exclude tshark --exclude '*.html' --exclude 'lib*.a' /build/run/* marine/.ws/data/ && \ mkdir marine/.ws/libs && \ - rsync -L /build/run/libmarine.so /build/run/lib*so.0 marine/.ws/libs/ && \ + rsync -L /build/run/libmarine.so /build/run/lib*so.* marine/.ws/libs/ && \ + $PY -m pip install --no-cache-dir setuptools wheel && \ $PY setup.py bdist_wheel --dist-dir /tmp WORKDIR /dist @@ -33,7 +34,10 @@ FROM centos/python-38-centos7 USER root -RUN yum install -y libpcap && \ +RUN sed -i 's/mirror\.centos\.org/vault.centos.org/g' /etc/yum.repos.d/CentOS-*.repo && \ + sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/CentOS-*.repo && \ + sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/CentOS-*.repo && \ + yum install -y libpcap && \ yum clean all && \ rm -rf /var/yum/cache From 6864d3f229f0ef11a7b1b3e33daca103dca5db47 Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Sun, 22 Mar 2026 14:38:20 +0200 Subject: [PATCH 2/6] Update used github actions and modernize syntax --- .github/workflows/test.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f37b650..85b805e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,16 +8,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 - name: Extract branch name shell: bash - run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/heads/} | tr / -)" + run: echo "tag=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_OUTPUT id: extract_branch - name: "Pull core image" shell: bash - run: echo -n "##[set-output name=tag;]" && docker pull tomlegkov/marine-core:${{ steps.extract_branch.outputs.tag }} > /dev/null && echo "${{ steps.extract_branch.outputs.tag }}" || echo marine + run: | + if docker pull tomlegkov/marine-core:${{ steps.extract_branch.outputs.tag }} > /dev/null 2>&1; then + echo "tag=${{ steps.extract_branch.outputs.tag }}" >> $GITHUB_OUTPUT + else + echo "tag=marine" >> $GITHUB_OUTPUT + fi id: detect_tag - name: "Build marine-python docker image" @@ -26,7 +31,7 @@ jobs: - name: "Extract wheel from docker image" run: docker run -i --rm -v $(pwd)/dist:/io marine-python sh -c "cp /dist/marine*.whl /io/" - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v6 with: path: dist/*.whl From 6d272b92ff604eb60a9271358930fb9d0143aca8 Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Sun, 22 Mar 2026 14:42:53 +0200 Subject: [PATCH 3/6] Reformat accordnig to newest black version --- marine/marine.py | 8 +++++--- tests/marine/benchmark/main.py | 1 + tests/marine/test_marine.py | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/marine/marine.py b/marine/marine.py index a945cca..7929086 100644 --- a/marine/marine.py +++ b/marine/marine.py @@ -241,9 +241,11 @@ def filter_and_parse( bpf, display_filter, tuple(encoded_fields) if fields is not None else None, - tuple(field_template_indices) - if field_template_indices is not None - else None, + ( + tuple(field_template_indices) + if field_template_indices is not None + else None + ), encapsulation_type, ) if filter_key in self._filters_cache: diff --git a/tests/marine/benchmark/main.py b/tests/marine/benchmark/main.py index c9f2ca2..febc0bd 100644 --- a/tests/marine/benchmark/main.py +++ b/tests/marine/benchmark/main.py @@ -26,6 +26,7 @@ TODO: simulate PL in conversations TODO: add support for real TCP conversations with ack and seq management """ + import argparse import os import time diff --git a/tests/marine/test_marine.py b/tests/marine/test_marine.py index a81d47e..0e21bd3 100644 --- a/tests/marine/test_marine.py +++ b/tests/marine/test_marine.py @@ -1,6 +1,7 @@ """ Note: in order to run the tests, you must put libmarine.so next to the marine_fixtures.py file """ + import pytest from typing import List, Union, Optional, Dict from marine.marine import Marine, MarineFieldsValidationResult From 439fb45bae0d9d938d12e868c90ac8ec51ffa03a Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Sun, 22 Mar 2026 20:15:50 +0200 Subject: [PATCH 4/6] Expose get_wireshark_version --- marine/marine.py | 5 +++++ marine/simple_marine.py | 7 +++++++ tests/marine/test_marine.py | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/marine/marine.py b/marine/marine.py index 7929086..2f62409 100644 --- a/marine/marine.py +++ b/marine/marine.py @@ -147,6 +147,7 @@ def __init__(self, epan_auto_reset_count: Optional[int] = None): self._marine.marine_free.argtypes = [MARINE_RESULT_POINTER] self._marine.marine_dissect_all_packet_fields.restype = MARINE_PACKET_POINTER self._marine.marine_packet_free.argtypes = [MARINE_PACKET_POINTER] + self._marine.get_wireshark_version.restype = c_char_p return_code = self._marine.init_marine() if return_code < 0: @@ -471,3 +472,7 @@ def _detect_encap(self, fields: Optional[List[str]]) -> int: def report_fields(self) -> None: self._marine.marine_report_fields() + + def get_wireshark_version(self) -> str: + version = self._marine.get_wireshark_version() + return version.decode("utf-8") diff --git a/marine/simple_marine.py b/marine/simple_marine.py index 2a4b4b9..8d11cc3 100644 --- a/marine/simple_marine.py +++ b/marine/simple_marine.py @@ -141,3 +141,10 @@ def report_fields() -> None: Dumps to stdout all of marine, similiarly to `tshark -G` """ return get_marine().report_fields() + + +def get_wireshark_version() -> str: + """ + Gets the version of wireshark used by marine. + """ + return get_marine().get_wireshark_version() diff --git a/tests/marine/test_marine.py b/tests/marine/test_marine.py index 0e21bd3..03809b4 100644 --- a/tests/marine/test_marine.py +++ b/tests/marine/test_marine.py @@ -1096,3 +1096,8 @@ def test_value_error_for_unknown_pref_name(marine_instance): def test_type_error_for_invalid_pref_type(marine_instance): with pytest.raises(TypeError): marine_instance.prefs.set_str("amqp", "tls.port", "1234") + + +def test_get_wireshark_version(marine_instance: Marine): + version = marine_instance.get_wireshark_version() + assert isinstance(version, str) From 733371ff4e5f46cbc2077a73d41a71f14f516ae0 Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Sun, 22 Mar 2026 20:38:40 +0200 Subject: [PATCH 5/6] Add GitHub release publishing on version tags Version is injected from the git tag into the wheel via MARINE_VERSION build arg. The release job runs after tests pass and publishes the wheel as a GitHub release asset. --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++-- Dockerfile | 4 +++- marine/__init__.py | 1 + marine/_version.py | 1 + setup.py | 4 +++- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 marine/_version.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85b805e..f1675cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,11 @@ name: Test -on: push +on: + push: + branches: + - '**' + tags: + - 'v*' jobs: test: @@ -25,15 +30,39 @@ jobs: fi id: detect_tag + - name: Extract version from tag + if: startsWith(github.ref, 'refs/tags/v') + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + id: extract_version + - name: "Build marine-python docker image" - run: docker build --build-arg MARINE_CORE_TAG=${{ steps.detect_tag.outputs.tag }} --pull -t marine-python . + run: docker build --build-arg MARINE_CORE_TAG=${{ steps.detect_tag.outputs.tag }} --build-arg MARINE_VERSION=${{ steps.extract_version.outputs.version || '0.0.0' }} --pull -t marine-python . - name: "Extract wheel from docker image" run: docker run -i --rm -v $(pwd)/dist:/io marine-python sh -c "cp /dist/marine*.whl /io/" - uses: actions/upload-artifact@v6 with: + name: wheel path: dist/*.whl - name: "Run marine-python tests" run: docker run -i --rm marine-python + + release: + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/download-artifact@v6 + with: + name: wheel + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: '*.whl' + generate_release_notes: true diff --git a/Dockerfile b/Dockerfile index 635896d..f37c452 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,11 @@ COPY README.md ./ COPY LICENSE ./ COPY marine ./marine +ARG MARINE_VERSION=0.0.0 ENV PY="/opt/python/cp38-cp38/bin/python" -RUN mkdir -p marine/.ws/data && \ +RUN echo "__version__ = \"${MARINE_VERSION}\"" > marine/_version.py && \ + mkdir -p marine/.ws/data && \ rsync -L --exclude idl2wrs --exclude 'lib*.so*' --exclude 'plugins*' --exclude 'marine_*' --exclude tshark --exclude '*.html' --exclude 'lib*.a' /build/run/* marine/.ws/data/ && \ mkdir marine/.ws/libs && \ rsync -L /build/run/libmarine.so /build/run/lib*so.* marine/.ws/libs/ && \ diff --git a/marine/__init__.py b/marine/__init__.py index 869d1ff..aa5f2a1 100644 --- a/marine/__init__.py +++ b/marine/__init__.py @@ -13,3 +13,4 @@ from .exceptions import * from .marine import Marine from . import encap_consts +from ._version import __version__ diff --git a/marine/_version.py b/marine/_version.py new file mode 100644 index 0000000..6c8e6b9 --- /dev/null +++ b/marine/_version.py @@ -0,0 +1 @@ +__version__ = "0.0.0" diff --git a/setup.py b/setup.py index 8f776aa..93ed8ae 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ from setuptools import setup +from marine._version import __version__ + setup( name="marine", - version="3.1.2", + version=__version__, description="Python client for Marine", packages=["marine"], include_package_data=True, From 13177bb9b9c579cb07c6e9795910694d71559049 Mon Sep 17 00:00:00 2001 From: Yehonatan Zecharia Date: Mon, 23 Mar 2026 17:34:01 +0200 Subject: [PATCH 6/6] Properly store marine libs inside the marine dir --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f37c452..242a281 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN /scripts/expose_auditwheel.sh && \ $PY /scripts/modify_auditwheel_policy.py && \ /scripts/patch_auditwheel_recursive_dependency_bug.sh -RUN auditwheel repair --plat manylinux2014_x86_64 -w /dist /tmp/marine*.whl +RUN auditwheel repair --lib-sdir /.ws/libs/ --plat manylinux2014_x86_64 -w /dist /tmp/marine*.whl