From 01cfbbb66e4db8c6da4af741df59d8c984ef5348 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:21:07 +0530 Subject: [PATCH 01/11] Test IDA 9.0 to 9.5 in CI and publish releases only once every asset is built CI - IDA integration runs the live headless and GUI suite on Linux for every minor version from 9.0 to 9.5 instead of 9.3 alone. The dispatch-only matrix keeps the offline IDALib check on Windows and macOS, now on 9.5. install_idalib_runtime.py installs the bundled bindings whether IDA ships them as a wheel or, as 9.0 and 9.1 do, as a source package. - The matrix jobs no longer repeat the metadata, settings, ruff and plugin lint checks that the Validate and IDA package workflows run, and install their Python packages with uv. - A Binary Ninja integration workflow runs the same suite through Binary Ninja headless and in the GUI. It needs the BN_LICENSE_B64 and BN_DOWNLOAD_URL_LINUX_X64_STABLE secrets and is skipped without them. - Ghidra integration verifies the SHA-256 of the Ghidra download, cancels superseded runs and uploads its logs next to the screenshots. - Validate runs actionlint. Workflows that run on push ignore tag pushes, so pushing a release tag starts no second CI run. Jobs have timeouts. - Integration artifacts no longer include the IDA user directories, which hold the licence registry. Releases - The IDA and Binary Ninja release workflows build the offline dependency bundles before anything is published, attach them and the plugin archive to a draft release, and then publish it. A failed bundle build used to leave a published release without its bundles, and assets cannot be added to an immutable release after publication. - verify_release_ci.py replaces the inline check of the pytest workflow. It reads the newest push or dispatch run on the release commit, so an older green run cannot hide a newer failure, and for IDA requires all six integration jobs to have succeeded rather than been skipped. Binary Ninja releases are gated on pytest and Validate only until its CI secrets exist. - The release jobs run the unit tests on the verified commit and refuse to publish if the tag moved after verification. --- .github/workflows/binja-package.yml | 6 +- .github/workflows/binja-release.yml | 67 +++-- .github/workflows/binja-tests.yml | 288 +++++++++++++++++++++ .github/workflows/ghidra-tests.yml | 77 ++++-- .github/workflows/ida-package.yml | 6 +- .github/workflows/ida-release.yml | 67 +++-- .github/workflows/ida-tests.yml | 248 +++++++----------- .github/workflows/offline-dependencies.yml | 46 +++- .github/workflows/pytest.yml | 10 + .github/workflows/ruff.yml | 19 ++ RELEASING.md | 59 +++-- docs/development.md | 50 +++- scripts/binja/run_gui_integration.py | 21 +- scripts/binja/run_headless_integration.py | 52 ++++ scripts/common/run_headless_integration.py | 12 +- scripts/common/verify_release_ci.py | 69 +++++ scripts/ida/install_idalib_runtime.py | 31 +++ tests/binja/test_integration_profile.py | 24 ++ tests/core/test_release_ci.py | 44 ++++ tests/ida/test_idalib_runtime.py | 30 +++ 20 files changed, 950 insertions(+), 276 deletions(-) create mode 100644 .github/workflows/binja-tests.yml create mode 100644 scripts/binja/run_headless_integration.py create mode 100644 scripts/common/verify_release_ci.py create mode 100644 scripts/ida/install_idalib_runtime.py create mode 100644 tests/binja/test_integration_profile.py create mode 100644 tests/core/test_release_ci.py create mode 100644 tests/ida/test_idalib_runtime.py diff --git a/.github/workflows/binja-package.yml b/.github/workflows/binja-package.yml index 83b055b..28397ef 100644 --- a/.github/workflows/binja-package.yml +++ b/.github/workflows/binja-package.yml @@ -2,6 +2,7 @@ name: Binary Ninja package on: push: + branches: ["**"] paths: - "mcrit_plugin/binja/**" - "plugin.json" @@ -48,6 +49,8 @@ on: - "pyproject.toml" - ".gitattributes" + workflow_dispatch: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -57,7 +60,8 @@ permissions: jobs: package: - name: Binary Ninja plugin package + name: Validate package + timeout-minutes: 15 runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/binja-release.yml b/.github/workflows/binja-release.yml index 286fc52..16b554e 100644 --- a/.github/workflows/binja-release.yml +++ b/.github/workflows/binja-release.yml @@ -29,6 +29,8 @@ concurrency: jobs: verify: + name: Verify release + timeout-minutes: 15 # the release is always cut from the default branch, whichever ref the workflow was started from runs-on: ubuntu-latest permissions: @@ -61,20 +63,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} SHA: ${{ steps.commit.outputs.sha }} - BRANCH: ${{ github.event.repository.default_branch }} - run: | - conclusion=$(gh api \ - "repos/${REPO}/actions/workflows/pytest.yml/runs?head_sha=${SHA}&status=completed&event=push&branch=${BRANCH}" \ - --jq '.workflow_runs[0].conclusion // ""') - if [ -z "${conclusion}" ]; then - echo "::error::No completed CI run for ${SHA}. Wait for main to go green, then re-run." - exit 1 - fi - if [ "${conclusion}" != "success" ]; then - echo "::error::CI concluded '${conclusion}' for ${SHA}. Fix main before releasing." - exit 1 - fi - echo "CI passed on ${SHA}" + run: python scripts/common/verify_release_ci.py --repo "$REPO" --sha "$SHA" --plugin binja # extensions.binary.ninja silently skips a version it has already seen, so the version must be # new: no tag may name it yet, and it must be greater than that of the current latest release. @@ -106,10 +95,25 @@ jobs: echo "previous=${previous}" >> "$GITHUB_OUTPUT" echo "Releasing ${previous:-nothing} -> ${version}" - - name: Install test tooling + build: + name: Validate + needs: verify + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ needs.verify.outputs.sha }} + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.12" + - name: Install release tooling run: | python -m pip install --upgrade pip - python -m pip install pytest requests ruff + python -m pip install pytest requests ruff PySide6 - name: Verify metadata sync run: python scripts/binja/verify_metadata_sync.py --repo . @@ -120,17 +124,28 @@ jobs: - name: Run quality checks run: python scripts/common/run_quality_checks.py --repo . - - name: Run pure Python tests + - name: Run unit tests run: python -m pytest tests release: - needs: verify + name: Publish release + timeout-minutes: 10 + needs: [verify, build, offline-dependencies] + if: ${{ !cancelled() && needs.verify.result == 'success' && needs.build.result == 'success' && (inputs.dry-run || needs.offline-dependencies.result == 'success') }} runs-on: ubuntu-latest permissions: contents: write outputs: tag: ${{ steps.publish.outputs.tag }} steps: + - name: Download dependency bundles + if: ${{ !inputs.dry-run }} + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: mcrit-plugin-dependencies-* + path: dist + merge-multiple: true + - name: Refuse to release an unverified commit env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -146,7 +161,7 @@ jobs: # The release API creates the tag on the verified commit; nothing is pushed to the branch. # --generate-notes appends its list under the notes, counted from the previous latest release. - - name: Tag and publish the release + - name: Publish release id: publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -157,7 +172,7 @@ jobs: DESCRIPTION: ${{ inputs.description }} DRY_RUN: ${{ inputs.dry-run }} run: | - flags=(--repo "${REPO}" --target "${SHA}" --title "${VERSION}" --latest --generate-notes) + flags=(--repo "${REPO}" --target "${SHA}" --title "${VERSION}" --generate-notes) if [ -n "${PREVIOUS}" ]; then flags+=(--notes-start-tag "${PREVIOUS}") fi @@ -168,18 +183,22 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" exit 0 fi - gh release create "${VERSION}" "${flags[@]}" --notes "${DESCRIPTION}" + shopt -s failglob + gh release create "${VERSION}" dist/* --draft "${flags[@]}" --notes "${DESCRIPTION}" + gh release edit "$VERSION" --repo "$REPO" --draft=false --latest echo "tag=${VERSION}" >> "$GITHUB_OUTPUT" offline-dependencies: - name: Attach offline dependency bundles - needs: release + name: Build offline dependency bundles + needs: verify if: ${{ !inputs.dry-run }} permissions: contents: write uses: ./.github/workflows/offline-dependencies.yml with: - tag: ${{ needs.release.outputs.tag }} + tag: ${{ needs.verify.outputs.version }} + ref: ${{ needs.verify.outputs.sha }} + upload-to-release: false variants: '[{"name": "binja", "packages": "-r requirements.txt"}]' # smda 4.9.0, which requirements.txt asks for, needs Python 3.11 or newer pythons: '["3.11", "3.12", "3.13"]' diff --git a/.github/workflows/binja-tests.yml b/.github/workflows/binja-tests.yml new file mode 100644 index 0000000..f310370 --- /dev/null +++ b/.github/workflows/binja-tests.yml @@ -0,0 +1,288 @@ +name: Binary Ninja CI + +on: + push: + branches: ["**"] + paths: + - "mcrit_plugin/binja/**" + - "plugin.json" + - "__init__.py" + - "requirements.txt" + - "**/ida-plugin.json" + - "scripts/binja/**" + - "tests/binja/**" + - ".github/workflows/binja-*.yml" + - "mcrit_plugin/core/**" + - "mcrit_plugin/__init__.py" + - "mcrit_plugin/ui_qt/**" + - "icons/**" + - "scripts/common/**" + - "tests/core/**" + - "tests/ui_qt/**" + - "tests/conftest.py" + - "tests/fixtures/**" + - "README.md" + - "LICENSE" + - "pyproject.toml" + - ".gitattributes" + pull_request: + paths: + - "mcrit_plugin/binja/**" + - "plugin.json" + - "__init__.py" + - "requirements.txt" + - "**/ida-plugin.json" + - "scripts/binja/**" + - "tests/binja/**" + - ".github/workflows/binja-*.yml" + - "mcrit_plugin/core/**" + - "mcrit_plugin/__init__.py" + - "mcrit_plugin/ui_qt/**" + - "icons/**" + - "scripts/common/**" + - "tests/core/**" + - "tests/ui_qt/**" + - "tests/conftest.py" + - "tests/fixtures/**" + - "README.md" + - "LICENSE" + - "pyproject.toml" + - ".gitattributes" + + workflow_dispatch: + +permissions: + contents: read + +concurrency: + # Serialize runs that share a named license; never cancel a running licensed process. + group: binaryninja-license + cancel-in-progress: false + +defaults: + run: + shell: bash + +env: + MCRIT_VERSION: "1.12.0" + MCRIT_SERVER: "http://127.0.0.1:8000" + SMDA_VERSION: "4.10.0" + +jobs: + preflight: + name: Check license availability + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + run: ${{ steps.decide.outputs.run }} + reason: ${{ steps.decide.outputs.reason }} + steps: + - name: Check configuration + id: decide + env: + FORK_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} + HAS_SECRETS: ${{ secrets.BN_LICENSE_B64 != '' && secrets.BN_DOWNLOAD_URL_LINUX_X64_STABLE != '' }} + run: | + reason="" + if [[ "$FORK_PR" == "true" ]]; then + reason="fork pull requests cannot receive Binary Ninja license secrets" + elif [[ "$HAS_SECRETS" != "true" ]]; then + reason="BN_LICENSE_B64 or BN_DOWNLOAD_URL_LINUX_X64_STABLE is not configured" + fi + if [[ -z "$reason" ]]; then + echo "run=true" >> "$GITHUB_OUTPUT" + else + echo "run=false" >> "$GITHUB_OUTPUT" + echo "reason=$reason" >> "$GITHUB_OUTPUT" + echo "::warning::Binary Ninja integration will not run: $reason" + fi + + binja: + name: Binary Ninja / Linux / headless and GUI + needs: preflight + if: needs.preflight.outputs.run == 'true' + runs-on: ubuntu-latest + timeout-minutes: 45 + services: + mongo: + image: mongo:5.0 + ports: + - 27017:27017 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.12" + + - name: Install GUI runtime dependencies + run: | + sudo apt-get update + sudo apt-get install --yes --no-install-recommends \ + xvfb libegl1 libgl1 libopengl0 libxkbcommon-x11-0 libxcb-cursor0 \ + libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 \ + libxcb-xinerama0 libxcb-xkb1 libdbus-1-3 fontconfig + + - name: Install disassembler + env: + DOWNLOAD_URL: ${{ secrets.BN_DOWNLOAD_URL_LINUX_X64_STABLE }} + BN_LICENSE_B64: ${{ secrets.BN_LICENSE_B64 }} + run: | + curl --fail --silent --show-error --location --retry 3 \ + "$DOWNLOAD_URL" --output "$RUNNER_TEMP/binaryninja.zip" + unzip -q "$RUNNER_TEMP/binaryninja.zip" -d "$RUNNER_TEMP" + test -x "$RUNNER_TEMP/binaryninja/binaryninja" + site="$(python -m site --user-site)" + mkdir -p "$site" + echo "$RUNNER_TEMP/binaryninja/python" > "$site/binaryninja.pth" + python - <<'PYTHON' + import base64 + import json + import os + from pathlib import Path + + data = base64.b64decode(os.environ["BN_LICENSE_B64"], validate=True) + entries = json.loads(data) + for entry in entries if isinstance(entries, list) else [entries]: + for value in entry.values(): + if isinstance(value, str) and value: + escaped = value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A") + print(f"::add-mask::{escaped}") + path = Path(os.environ["RUNNER_TEMP"]) / "binaryninja-license.dat" + path.touch(mode=0o600) + path.write_bytes(data) + PYTHON + + - name: Install MCRIT service + shell: bash + run: | + python -m venv "$RUNNER_TEMP/mcrit-venv" + "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install --upgrade pip + "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install "mcrit==${MCRIT_VERSION}" + + - name: Install plugin dependencies + # binaryninjaui supplies the matching Qt bindings; a pip PySide6 may have another ABI. + run: python -m pip install "smda==${SMDA_VERSION}" requests + + - name: Build deterministic MCRIT fixtures + run: | + for variant in 0 1 2; do + python scripts/common/build_test_fixture.py \ + --source tests/fixtures/mcrit_sample.c \ + --output "$RUNNER_TEMP/mcrit-variant-$variant" \ + --variant "$variant" + done + + - name: Start MCRIT server and worker + shell: bash + run: | + # setsid, not nohup alone: the runner SIGTERMs the step's process group when this step's + # shell exits, which would kill the services before the "Wait for MCRIT API" step + setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit server \ + > "$RUNNER_TEMP/mcrit-server.log" 2>&1 < /dev/null & + setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit worker \ + > "$RUNNER_TEMP/mcrit-worker.log" 2>&1 < /dev/null & + + - name: Wait for MCRIT API + shell: bash + run: | + "$RUNNER_TEMP/mcrit-venv/bin/python" - <<'PY' + import time + import requests + + deadline = time.monotonic() + 90 + last_error = None + while time.monotonic() < deadline: + try: + response = requests.get("http://127.0.0.1:8000/version", timeout=2) + if response.ok: + print(response.text) + break + except Exception as exc: + last_error = exc + time.sleep(2) + else: + raise SystemExit(f"MCRIT API did not become ready: {last_error}") + PY + + - name: Seed MCRIT reference sample + env: + PYTHONPATH: ${{ github.workspace }} + run: | + "$RUNNER_TEMP/mcrit-venv/bin/python" scripts/common/seed_mcrit.py \ + --server "$MCRIT_SERVER" \ + --sample "$RUNNER_TEMP/mcrit-variant-0" \ + --timeout 180 + echo "REFERENCE_SHA256=$(sha256sum "$RUNNER_TEMP/mcrit-variant-0" | cut -d' ' -f1)" \ + >> "$GITHUB_ENV" + + - name: Run headless integration tests + run: | + python scripts/binja/run_headless_integration.py \ + --input "$RUNNER_TEMP/mcrit-variant-1" \ + --mcrit-server "$MCRIT_SERVER" \ + --reference-sha256 "$REFERENCE_SHA256" \ + --license "$RUNNER_TEMP/binaryninja-license.dat" \ + 2>&1 | tee "$RUNNER_TEMP/binja-headless-integration.log" + + - name: Run GUI integration tests + run: | + xvfb-run -a -s "-screen 0 1600x1000x24" \ + python scripts/binja/run_gui_integration.py \ + --install-dir "$RUNNER_TEMP/binaryninja" \ + --input "$RUNNER_TEMP/mcrit-variant-2" \ + --mcrit-server "$MCRIT_SERVER" \ + --reference-sha256 "$REFERENCE_SHA256" \ + --license "$RUNNER_TEMP/binaryninja-license.dat" \ + --python-library "$(python -c 'import sysconfig; from pathlib import Path; print(Path(sysconfig.get_config_var("LIBDIR")) / sysconfig.get_config_var("INSTSONAME"))')" \ + --log "$RUNNER_TEMP/binja-gui-startup.log" \ + 2>&1 | tee "$RUNNER_TEMP/binja-gui-integration.log" + + - name: Upload integration logs + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: binja-linux-logs + retention-days: 14 + path: | + ${{ runner.temp }}/binja-headless-integration.log + ${{ runner.temp }}/binja-gui-integration.log + ${{ runner.temp }}/mcrit-server.log + ${{ runner.temp }}/mcrit-worker.log + ${{ runner.temp }}/binja-gui-startup.log + if-no-files-found: warn + + - name: Show MCRIT logs on failure + if: failure() + shell: bash + run: | + cat "$RUNNER_TEMP/mcrit-server.log" || true + cat "$RUNNER_TEMP/mcrit-worker.log" || true + + result: + name: Integration result + needs: [preflight, binja] + if: always() + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Report integration result + env: + PREFLIGHT: ${{ needs.preflight.result }} + RESULT: ${{ needs.binja.result }} + REASON: ${{ needs.preflight.outputs.reason }} + run: | + if [[ "$PREFLIGHT" != "success" || "$RESULT" == "failure" || "$RESULT" == "cancelled" ]]; then + echo "::error::Binary Ninja integration failed (preflight=$PREFLIGHT, integration=$RESULT)" + exit 1 + fi + if [[ "$RESULT" == "skipped" ]]; then + echo "::warning::Binary Ninja integration did not run: $REASON" + echo "Binary Ninja integration did not run: $REASON" >> "$GITHUB_STEP_SUMMARY" + else + echo "Binary Ninja headless and GUI integration passed." >> "$GITHUB_STEP_SUMMARY" + fi diff --git a/.github/workflows/ghidra-tests.yml b/.github/workflows/ghidra-tests.yml index f2de0af..c3b15d8 100644 --- a/.github/workflows/ghidra-tests.yml +++ b/.github/workflows/ghidra-tests.yml @@ -1,10 +1,11 @@ -name: Ghidra integration +name: Ghidra CI # Ghidra needs no licence, so its integration runs for every change that can affect the Ghidra # plugin: headless PyGhidra (export, comparison with SMDA, upload, matching, labels) and the GUI # under Xvfb (the MCRIT window, its dialogs, tabs and graph). on: push: + branches: ["**"] paths: - "mcrit_plugin/ghidra/**" - "ghidra_scripts/**" @@ -35,16 +36,25 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + env: MCRIT_VERSION: "1.12.0" MCRIT_SERVER: "http://127.0.0.1:8000" SMDA_VERSION: "4.10.0" GHIDRA_VERSION: "12.1.4" GHIDRA_ZIP: "ghidra_12.1.4_PUBLIC_20260921.zip" + GHIDRA_SHA256: "ddac49f903da9d5bac833e5cc79395098b9c33cfd3279be5f31bd00387d2d4db" jobs: ghidra: - name: PyGhidra headless and GUI / live MCRIT + name: Ghidra / Linux / headless and GUI runs-on: ubuntu-latest timeout-minutes: 45 services: @@ -75,23 +85,32 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ runner.temp }}/ghidra - key: ghidra-${{ env.GHIDRA_VERSION }} + key: ghidra-${{ runner.os }}-${{ runner.arch }}-${{ env.GHIDRA_SHA256 }} + + - name: Install GUI runtime dependencies + run: | + sudo apt-get update + sudo apt-get install --yes --no-install-recommends xvfb imagemagick - - name: Download Ghidra + - name: Install disassembler if: steps.ghidra-cache.outputs.cache-hit != 'true' shell: bash run: | mkdir -p "$RUNNER_TEMP/ghidra" curl -fsSL -o "$RUNNER_TEMP/ghidra.zip" \ "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/${GHIDRA_ZIP}" + echo "$GHIDRA_SHA256 $RUNNER_TEMP/ghidra.zip" | sha256sum --check unzip -q "$RUNNER_TEMP/ghidra.zip" -d "$RUNNER_TEMP/ghidra" - - name: Install MCRIT service, PyGhidra and plugin dependencies + - name: Install MCRIT service shell: bash run: | python -m venv "$RUNNER_TEMP/mcrit-venv" "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install --upgrade pip "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install "mcrit==${MCRIT_VERSION}" + + - name: Install plugin dependencies + run: | GHIDRA_INSTALL_DIR="$(ls -d "$RUNNER_TEMP"/ghidra/ghidra_*)" echo "GHIDRA_INSTALL_DIR=$GHIDRA_INSTALL_DIR" >> "$GITHUB_ENV" python -m pip install --upgrade pip @@ -100,11 +119,6 @@ jobs: -f "$GHIDRA_INSTALL_DIR/Ghidra/Features/PyGhidra/pypkg/dist" pyghidra python -m pip install "smda==${SMDA_VERSION}" requests - - name: Install Xvfb and ImageMagick - run: | - sudo apt-get update - sudo apt-get install --yes --no-install-recommends xvfb imagemagick - - name: Build deterministic MCRIT fixtures run: | for variant in 0 1 2; do @@ -117,24 +131,33 @@ jobs: - name: Start MCRIT server and worker shell: bash run: | + # setsid, not nohup alone: the runner SIGTERMs the step's process group when this step's + # shell exits, which would kill the services before the "Wait for MCRIT API" step setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit server \ > "$RUNNER_TEMP/mcrit-server.log" 2>&1 < /dev/null & setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit worker \ > "$RUNNER_TEMP/mcrit-worker.log" 2>&1 < /dev/null & + + - name: Wait for MCRIT API + shell: bash + run: | "$RUNNER_TEMP/mcrit-venv/bin/python" - <<'PY' import time import requests - deadline = time.monotonic() + 120 + deadline = time.monotonic() + 90 + last_error = None while time.monotonic() < deadline: try: - if requests.get("http://127.0.0.1:8000/version", timeout=2).ok: + response = requests.get("http://127.0.0.1:8000/version", timeout=2) + if response.ok: + print(response.text) break - except Exception: - pass + except Exception as exc: + last_error = exc time.sleep(2) else: - raise SystemExit("MCRIT API did not become ready") + raise SystemExit(f"MCRIT API did not become ready: {last_error}") PY - name: Seed MCRIT reference sample @@ -148,29 +171,37 @@ jobs: echo "REFERENCE_SHA256=$(sha256sum "$RUNNER_TEMP/mcrit-variant-0" | cut -d' ' -f1)" \ >> "$GITHUB_ENV" - - name: Run PyGhidra headless integration + - name: Run headless integration tests run: | python scripts/ghidra/run_pyghidra_integration.py \ --input "$RUNNER_TEMP/mcrit-variant-1" \ --mcrit-server "$MCRIT_SERVER" \ - --reference-sha256 "$REFERENCE_SHA256" + --reference-sha256 "$REFERENCE_SHA256" \ + 2>&1 | tee "$RUNNER_TEMP/ghidra-headless-integration.log" - - name: Run Ghidra GUI integration + - name: Run GUI integration tests run: | xvfb-run -a -s "-screen 0 1600x1000x24" \ python scripts/ghidra/run_gui_integration.py \ --input "$RUNNER_TEMP/mcrit-variant-2" \ --mcrit-server "$MCRIT_SERVER" \ --reference-sha256 "$REFERENCE_SHA256" \ - --screenshots "$RUNNER_TEMP/ghidra-screenshots" + --screenshots "$RUNNER_TEMP/ghidra-screenshots" \ + 2>&1 | tee "$RUNNER_TEMP/ghidra-gui-integration.log" - - name: Upload GUI screenshots + - name: Upload integration logs if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ghidra-gui-screenshots - path: ${{ runner.temp }}/ghidra-screenshots - if-no-files-found: ignore + name: ghidra-${{ env.GHIDRA_VERSION }}-linux-logs + retention-days: 14 + path: | + ${{ runner.temp }}/ghidra-headless-integration.log + ${{ runner.temp }}/ghidra-gui-integration.log + ${{ runner.temp }}/mcrit-server.log + ${{ runner.temp }}/mcrit-worker.log + ${{ runner.temp }}/ghidra-screenshots + if-no-files-found: warn - name: Show MCRIT logs on failure if: failure() diff --git a/.github/workflows/ida-package.yml b/.github/workflows/ida-package.yml index 0fb0c59..f9b422a 100644 --- a/.github/workflows/ida-package.yml +++ b/.github/workflows/ida-package.yml @@ -2,6 +2,7 @@ name: IDA package on: push: + branches: ["**"] paths: - "mcrit_plugin/ida/**" - "scripts/ida/**" @@ -46,6 +47,8 @@ on: - "pyproject.toml" - ".gitattributes" + workflow_dispatch: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -55,7 +58,8 @@ permissions: jobs: package: - name: IDA plugin package + name: Validate package + timeout-minutes: 15 runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/ida-release.yml b/.github/workflows/ida-release.yml index 42cec30..2e41e5f 100644 --- a/.github/workflows/ida-release.yml +++ b/.github/workflows/ida-release.yml @@ -9,7 +9,7 @@ permissions: contents: read concurrency: - group: release-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false defaults: @@ -21,13 +21,14 @@ env: jobs: verify: - name: Verify the tag + name: Verify release runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: read actions: read outputs: + sha: ${{ steps.guard.outputs.sha }} version: ${{ steps.guard.outputs.version }} prerelease: ${{ steps.guard.outputs.prerelease }} steps: @@ -49,14 +50,16 @@ jobs: run: | python .github/workflows/scripts/ida/release_guard.py \ --tag "${TAG}" --notes release-notes.md --github-output "${GITHUB_OUTPUT}" + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - name: Check the tag is on main + - name: Check the tag is on the default branch env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} TAG: ${{ github.ref_name }} + BRANCH: ${{ github.event.repository.default_branch }} run: | - status=$(gh api "repos/${REPO}/compare/main...${TAG}" --jq .status) + status=$(gh api "repos/${REPO}/compare/${BRANCH}...${TAG}" --jq .status) # "identical"/"behind" mean the tag is reachable from main if [ "${status}" != "identical" ] && [ "${status}" != "behind" ]; then echo "::error::${TAG} is not an ancestor of main; releases are cut from main." @@ -67,21 +70,8 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} - SHA: ${{ github.sha }} - BRANCH: main - run: | - conclusion=$(gh api \ - "repos/${REPO}/actions/workflows/pytest.yml/runs?head_sha=${SHA}&status=completed&event=push&branch=${BRANCH}" \ - --jq '.workflow_runs[0].conclusion // ""') - if [ -z "${conclusion}" ]; then - echo "::error::No completed CI run for ${SHA}. Wait for main to go green, then re-run." - exit 1 - fi - if [ "${conclusion}" != "success" ]; then - echo "::error::CI concluded '${conclusion}' for ${SHA}. Fix main before releasing." - exit 1 - fi - echo "CI passed on ${SHA}" + SHA: ${{ steps.guard.outputs.sha }} + run: python scripts/common/verify_release_ci.py --repo "$REPO" --sha "$SHA" --plugin ida - name: Keep the release notes for the later jobs uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -91,7 +81,7 @@ jobs: if-no-files-found: error build: - name: Validate and build the plugin archive + name: Validate and build plugin archive needs: verify runs-on: ubuntu-latest timeout-minutes: 15 @@ -99,6 +89,7 @@ jobs: - name: Checkout the tag uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: ${{ needs.verify.outputs.sha }} persist-credentials: false - name: Set up Python @@ -107,7 +98,7 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} - name: Install release tooling - run: python -m pip install --upgrade pip ida-hcli ruff + run: python -m pip install --upgrade pip "ida-hcli==0.28.0" ruff pytest requests PySide6 - name: Verify HCLI runtime imports run: python -c "import hcli.main" @@ -123,6 +114,9 @@ jobs: - name: Run quality checks run: python scripts/common/run_quality_checks.py --repo . + - name: Run unit tests + run: python -m pytest tests + - name: Build plugin archive env: VERSION: ${{ needs.verify.outputs.version }} @@ -142,8 +136,8 @@ jobs: if-no-files-found: error release: - name: Create the GitHub release - needs: [verify, build] + name: Publish release + needs: [verify, build, offline-dependencies] runs-on: ubuntu-latest timeout-minutes: 10 permissions: @@ -155,6 +149,13 @@ jobs: name: distribution path: dist + - name: Download dependency bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: mcrit-plugin-dependencies-* + path: dist + merge-multiple: true + - name: Fetch the release notes uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -162,32 +163,42 @@ jobs: # --generate-notes appends its list under --notes-file rather than replacing it. An IDA release is # never "latest": extensions.binary.ninja reads plugin.json from the latest release. - - name: Create the release + - name: Publish release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} TAG: ${{ github.ref_name }} PRERELEASE: ${{ needs.verify.outputs.prerelease }} + SHA: ${{ needs.verify.outputs.sha }} run: | shopt -s failglob - flags=(--latest=false) + flags=() if [ "${PRERELEASE}" = "true" ]; then flags+=(--prerelease) fi - gh release create "${TAG}" dist/* \ + # Refuse a moved tag before publishing the already verified artifacts. + tagged_sha=$(gh api "repos/${REPO}/commits/${TAG}" --jq .sha) + if [[ "$tagged_sha" != "$SHA" ]]; then + echo "::error::The release tag moved after verification." + exit 1 + fi + gh release create "${TAG}" dist/* --draft \ --repo "${REPO}" \ --title "${TAG}" \ --notes-file release-notes.md \ --generate-notes \ --verify-tag \ "${flags[@]}" + gh release edit "$TAG" --repo "$REPO" --draft=false --latest=false offline-dependencies: - name: Attach offline dependency bundles - needs: release + name: Build offline dependency bundles + needs: verify permissions: contents: write uses: ./.github/workflows/offline-dependencies.yml with: tag: ${{ github.ref_name }} + ref: ${{ needs.verify.outputs.sha }} + upload-to-release: false variants: '[{"name": "smda", "packages": "smda"}, {"name": "full", "packages": "smda ida-settings"}]' diff --git a/.github/workflows/ida-tests.yml b/.github/workflows/ida-tests.yml index 648deb8..3aec24a 100644 --- a/.github/workflows/ida-tests.yml +++ b/.github/workflows/ida-tests.yml @@ -1,4 +1,4 @@ -name: IDA integration +name: IDA CI on: push: @@ -26,8 +26,6 @@ on: - "pyproject.toml" - ".gitattributes" pull_request: - branches: - - main paths: - "mcrit_plugin/ida/**" - "scripts/ida/**" @@ -52,7 +50,7 @@ on: workflow_dispatch: inputs: run_matrix: - description: Run the broader IDA version and operating-system matrix + description: Also run offline IDALib compatibility on Windows and macOS required: false type: boolean default: false @@ -61,22 +59,29 @@ permissions: contents: read concurrency: - group: ida-integration-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +defaults: + run: + shell: bash + env: + SMDA_VERSION: "4.10.0" + HCLI_VERSION: "0.28.0" MCRIT_VERSION: "1.12.0" MCRIT_SERVER: "http://127.0.0.1:8000" jobs: preflight: - name: Licence preflight + name: Check license availability + timeout-minutes: 5 runs-on: ubuntu-latest outputs: run: ${{ steps.decide.outputs.run }} reason: ${{ steps.decide.outputs.reason }} steps: - - name: Decide whether the licensed job can run + - name: Check configuration id: decide shell: bash env: @@ -98,7 +103,11 @@ jobs: fi licensed-linux: - name: IDA Pro 9.3 / Ubuntu / live MCRIT + name: IDA ${{ matrix.version }} / Linux / headless and GUI + strategy: + fail-fast: false + matrix: + version: ["9.0", "9.1", "9.2", "9.3", "9.4", "9.5"] needs: preflight if: needs.preflight.outputs.run == 'true' runs-on: ubuntu-latest @@ -115,7 +124,7 @@ jobs: with: persist-credentials: false - - name: Set up Python 3.12 + - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12" @@ -125,7 +134,14 @@ jobs: with: enable-cache: false - - name: Install Linux IDA runtime dependencies + - name: Install HCLI + run: uv tool install "ida-hcli==${HCLI_VERSION}" + + # Metadata, settings and lint checks run in the Validate and IDA package workflows. + - name: Build plugin archive + run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip + + - name: Install GUI runtime dependencies if: runner.os == 'Linux' shell: bash run: | @@ -137,19 +153,17 @@ jobs: libxcb-icccm4 libxcb-image0 libxcb-xkb1 libxcb-xinerama0 \ libxkbcommon-x11-0 libxcb-sync1 libfreetype6 xvfb - - name: Install IDA Pro 9.3 + - name: Install disassembler id: ida shell: bash env: HCLI_API_KEY: ${{ secrets.HCLI_API_KEY }} IDA_LICENSE_ID: ${{ secrets.IDA_LICENSE_ID }} + IDA_VERSION: ${{ matrix.version }} run: | IDA_DIR="$RUNNER_TEMP/opt/ida" - uv tool install ida-hcli hcli ida install -y \ - --accept-eula \ - --set-default \ - -d release/9.3/ida-pro/ida-pro_93_x64linux.run \ + -d "ida-pro:${IDA_VERSION}:x64linux" \ -l "$IDA_LICENSE_ID" \ -i "$IDA_DIR" test -d "$IDA_DIR" @@ -172,58 +186,40 @@ jobs: echo "Propagated IDA acceptance from $SRC into test profiles" fi - - name: Keep HCLI on PATH - shell: bash - run: | - echo "$HOME/.local/bin" >> "$GITHUB_PATH" - echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - - - name: Verify service Python + - name: Install MCRIT service shell: bash run: | - python --version - python - <<'PY' - import os - import sys - - if sys.version_info[:2] != (3, 12): - raise SystemExit( - f"the MCRIT {os.environ['MCRIT_VERSION']} service venv must use Python 3.12," - f" the repository floor, got {sys.version}" - ) - PY + uv venv --python 3.12 "$RUNNER_TEMP/mcrit-venv" + uv pip install --python "$RUNNER_TEMP/mcrit-venv/bin/python" "mcrit==${MCRIT_VERSION}" - - name: Verify headless IDA executable + - name: Install IDALib test runtime shell: bash run: | - IDA_HEADLESS="" - for name in idat64 idat idat64.exe idat.exe; do - candidate="$(find "${{ steps.ida.outputs.ida-dir }}" -type f -name "$name" -print -quit)" - if [[ -n "$candidate" && -x "$candidate" ]]; then - IDA_HEADLESS="$candidate" - break - fi - done - if [[ -z "$IDA_HEADLESS" ]]; then - echo "::error::Could not locate a headless IDA executable (idat64/idat) under ${{ steps.ida.outputs.ida-dir }}" - exit 1 + # --seed: install_idalib_runtime.py installs IDA's bundled bindings with pip + uv venv --seed --python 3.12 "$RUNNER_TEMP/idalib-venv" + if [[ "$RUNNER_OS" == "Windows" ]]; then + IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/Scripts/python.exe" + else + IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/bin/python" fi - echo "Found headless IDA executable: $IDA_HEADLESS" - # must not fail: a fresh IDA may not have its license accepted yet, and some IDA - # versions/platforms return a non-zero exit from `-h` regardless - "$IDA_HEADLESS" -h > "$RUNNER_TEMP/ida-headless-help.txt" 2>&1 || true - - - name: Install validation tooling - run: python -m pip install --upgrade pip ruff + echo "IDALIB_PYTHON=$IDALIB_PYTHON" >> "$GITHUB_ENV" + "$IDALIB_PYTHON" scripts/ida/install_idalib_runtime.py \ + --ida-dir "${{ steps.ida.outputs.ida-dir }}" + uv pip install --python "$IDALIB_PYTHON" \ + "smda==${SMDA_VERSION}" "ida-settings==3.5.1" "requests" - - name: Verify metadata and package + - name: Install plugin dependencies shell: bash + env: + IDA_VERSION: ${{ matrix.version }} run: | - python scripts/ida/verify_metadata_sync.py --repo . - python scripts/common/verify_settings_sync.py --repo . - python scripts/common/run_quality_checks.py --repo . - python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - hcli plugin lint dist/mcrit-ida.zip + # The Linux installer has no bundled Python executable. + uv pip install --target "$RUNNER_TEMP/ida-py-deps" \ + "requests" "smda==${SMDA_VERSION}" "ida-settings==3.5.1" + # IDA 9.0/9.1 use Qt 5; later installers supply their own PySide6 bindings. + if [[ "$IDA_VERSION" == "9.0" || "$IDA_VERSION" == "9.1" ]]; then + uv pip install --target "$RUNNER_TEMP/ida-py-deps" "PyQt5==5.15.11" + fi - name: Build deterministic MCRIT fixtures run: | @@ -240,28 +236,6 @@ jobs: --output "${{ runner.temp }}/mcrit-gui-query.exe" \ --variant 2 - - name: Install MCRIT service - shell: bash - run: | - python -m venv "$RUNNER_TEMP/mcrit-venv" - "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install --upgrade pip - "$RUNNER_TEMP/mcrit-venv/bin/python" -m pip install "mcrit==${MCRIT_VERSION}" - - - name: Install IDALib test runtime - shell: bash - run: | - python -m venv "$RUNNER_TEMP/idalib-venv" - if [[ "$RUNNER_OS" == "Windows" ]]; then - IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/Scripts/python.exe" - else - IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/bin/python" - fi - echo "IDALIB_PYTHON=$IDALIB_PYTHON" >> "$GITHUB_ENV" - "$IDALIB_PYTHON" -m pip install --upgrade pip - "$IDALIB_PYTHON" -m pip install --upgrade \ - "${{ steps.ida.outputs.ida-dir }}/idalib/python"/idapro-*.whl \ - "smda==4.10.0" "ida-settings==3.5.1" "PySide6" "requests" - - name: Wait for MongoDB shell: bash run: | @@ -348,7 +322,7 @@ jobs: shell: bash run: echo "sha256=$(sha256sum '${{ runner.temp }}/mcrit-reference.exe' | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" - - name: Run live IDALib integration test + - name: Run headless integration tests shell: bash run: | "$IDALIB_PYTHON" scripts/ida/run_idalib_integration.py \ @@ -363,13 +337,6 @@ jobs: --timeout 180 \ --require-hcli - - name: Install plugin runtime deps for IDA's Python - shell: bash - run: | - # The Linux installer has no bundled Python executable. - python -m pip install --target "$RUNNER_TEMP/ida-py-deps" \ - "requests" "smda==4.10.0" "ida-settings==3.5.1" - - name: Seed GUI profile from licensed IDALib profile shell: bash run: | @@ -426,7 +393,7 @@ jobs: echo "Using $PYTHON_LIBRARY" "$IDAPYSWITCH" --force-path "$PYTHON_LIBRARY" - - name: Run licensed IDA GUI toolbar integration test + - name: Run GUI integration tests shell: bash env: PYTHONPATH: ${{ runner.temp }}/ida-py-deps @@ -463,37 +430,40 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ida-integration-logs + name: ida-${{ matrix.version }}-linux-logs + retention-days: 14 path: | ${{ runner.temp }}/idalib-integration.log ${{ runner.temp }}/ida-gui-integration.log ${{ runner.temp }}/ida-gui-startup.log ${{ runner.temp }}/mcrit-server.log ${{ runner.temp }}/mcrit-worker.log - ${{ runner.temp }}/ida-headless-help.txt ${{ runner.temp }}/idalib-artifacts ${{ runner.temp }}/ida-gui-artifacts - ${{ runner.temp }}/idausr-idalib - ${{ runner.temp }}/idausr-gui if-no-files-found: warn licensed-result: - name: Licensed IDA result - needs: [preflight, licensed-linux] + name: Integration result + timeout-minutes: 5 + needs: [preflight, licensed-linux, compatibility-matrix] if: always() runs-on: ubuntu-latest steps: - # Reports rather than blocks: a fork pull request cannot obtain the licence secrets, so a - # red check here would be one the contributor has no way to clear. A genuine failure of the - # licensed job is still red on that job itself; this one exists so a *skip* cannot read as - # a pass, which is how a broken step survived six weeks of fork pull requests. - - name: Report whether the licensed job actually passed + # Missing secrets are reported explicitly; real matrix failures must fail this check. + - name: Report integration result shell: bash env: RESULT: ${{ needs.licensed-linux.result }} REASON: ${{ needs.preflight.outputs.reason }} + PREFLIGHT: ${{ needs.preflight.result }} + COMPATIBILITY: ${{ needs.compatibility-matrix.result }} run: | + if [[ "$PREFLIGHT" != "success" || "$RESULT" == "failure" || "$RESULT" == "cancelled" || "$COMPATIBILITY" == "failure" || "$COMPATIBILITY" == "cancelled" ]]; then + echo "::error::IDA integration failed (preflight=$PREFLIGHT, live=$RESULT, compatibility=$COMPATIBILITY)" + exit 1 + fi if [[ "$RESULT" == "success" ]]; then + echo "All IDA 9.0–9.5 live integration tests passed." >> "$GITHUB_STEP_SUMMARY" exit 0 fi if [[ "$RESULT" == "skipped" ]]; then @@ -506,29 +476,20 @@ jobs: compatibility-matrix: name: ${{ matrix.name }} - if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_matrix }} + needs: [preflight, licensed-linux] + if: ${{ needs.preflight.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && inputs.run_matrix }} strategy: fail-fast: false matrix: include: - - name: IDA Pro 9.3 / Linux - os: ubuntu-latest - installer: release/9.3/ida-pro/ida-pro_93_x64linux.run - - name: IDA Pro 9.3 / Windows + - name: IDA 9.5 / Windows / offline headless + artifact: ida-9.5-windows-logs os: windows-latest - installer: release/9.3/ida-pro/ida-pro_93_x64win.exe - - name: IDA Pro 9.3 / macOS ARM + installer: ida-pro:9.5:x64win + - name: IDA 9.5 / macOS ARM / offline headless + artifact: ida-9.5-macos-arm-logs os: macos-latest - installer: release/9.3/ida-pro/ida-pro_93_armmac.app.zip - - name: IDA Pro 9.2 / Linux - os: ubuntu-latest - installer: release/9.2/ida-pro/ida-pro_92_x64linux.run - - name: IDA Pro 9.1 / Linux - os: ubuntu-latest - installer: release/9.1/ida-pro/ida-pro_91_x64linux.run - - name: IDA Pro 9.0 / Linux - os: ubuntu-latest - installer: release/9.0/ida-pro/ida-pro_90_x64linux.run + installer: ida-pro:9.5:armmac runs-on: ${{ matrix.os }} timeout-minutes: 60 @@ -538,7 +499,7 @@ jobs: with: persist-credentials: false - - name: Set up Python 3.12 + - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12" @@ -548,7 +509,7 @@ jobs: with: enable-cache: false - - name: Install IDA ${{ matrix.name }} + - name: Install disassembler id: ida shell: bash env: @@ -556,10 +517,8 @@ jobs: IDA_LICENSE_ID: ${{ secrets.IDA_LICENSE_ID }} run: | IDA_DIR="$RUNNER_TEMP/opt/ida" - uv tool install ida-hcli + uv tool install "ida-hcli==${HCLI_VERSION}" hcli ida install -y \ - --accept-eula \ - --set-default \ -d "${{ matrix.installer }}" \ -l "$IDA_LICENSE_ID" \ -i "$IDA_DIR" @@ -595,33 +554,8 @@ jobs: echo "$HOME/.local/bin" >> "$GITHUB_PATH" echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - - name: Verify headless IDA executable - shell: bash - run: | - IDA_HEADLESS="" - for name in idat64 idat idat64.exe idat.exe; do - candidate="$(find "${{ steps.ida.outputs.ida-dir }}" -type f -name "$name" -print -quit)" - if [[ -n "$candidate" && -x "$candidate" ]]; then - IDA_HEADLESS="$candidate" - break - fi - done - if [[ -z "$IDA_HEADLESS" ]]; then - echo "::error::Could not locate a headless IDA executable (idat64/idat) under ${{ steps.ida.outputs.ida-dir }}" - exit 1 - fi - echo "Found headless IDA executable: $IDA_HEADLESS" - "$IDA_HEADLESS" -h > "$RUNNER_TEMP/ida-headless-help.txt" 2>&1 || true - - - name: Package and lint plugin - shell: bash - run: | - python -m pip install --upgrade pip ruff - python scripts/ida/verify_metadata_sync.py --repo . - python scripts/common/verify_settings_sync.py --repo . - python scripts/common/run_quality_checks.py --repo . - python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - hcli plugin lint dist/mcrit-ida.zip + - name: Build plugin archive + run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - name: Build compatibility fixture run: | @@ -633,17 +567,18 @@ jobs: - name: Install IDALib test runtime shell: bash run: | - python -m venv "$RUNNER_TEMP/idalib-venv" + # --seed: install_idalib_runtime.py installs IDA's bundled bindings with pip + uv venv --seed --python 3.12 "$RUNNER_TEMP/idalib-venv" if [[ "$RUNNER_OS" == "Windows" ]]; then IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/Scripts/python.exe" else IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/bin/python" fi echo "IDALIB_PYTHON=$IDALIB_PYTHON" >> "$GITHUB_ENV" - "$IDALIB_PYTHON" -m pip install --upgrade pip - "$IDALIB_PYTHON" -m pip install --upgrade \ - "${{ steps.ida.outputs.ida-dir }}/idalib/python"/idapro-*.whl \ - "smda==4.10.0" "ida-settings==3.5.1" "PySide6" "requests" + "$IDALIB_PYTHON" scripts/ida/install_idalib_runtime.py \ + --ida-dir "${{ steps.ida.outputs.ida-dir }}" + uv pip install --python "$IDALIB_PYTHON" \ + "smda==${SMDA_VERSION}" "ida-settings==3.5.1" "requests" - name: Run offline IDALib lifecycle integration test shell: bash @@ -663,10 +598,9 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ida-compatibility-${{ matrix.name }} + name: ${{ matrix.artifact }} + retention-days: 14 path: | ${{ runner.temp }}/idalib-integration.log - ${{ runner.temp }}/ida-headless-help.txt ${{ runner.temp }}/idalib-artifacts - ${{ runner.temp }}/idausr-idalib if-no-files-found: warn diff --git a/.github/workflows/offline-dependencies.yml b/.github/workflows/offline-dependencies.yml index 80162d9..5623a3e 100644 --- a/.github/workflows/offline-dependencies.yml +++ b/.github/workflows/offline-dependencies.yml @@ -9,6 +9,16 @@ on: description: Release to attach the bundles to required: true type: string + ref: + description: Verified commit to build from (defaults to the release tag) + required: false + type: string + default: "" + upload-to-release: + description: Attach bundles to an existing release after building + required: false + type: boolean + default: true variants: description: 'JSON list of {"name", "packages"}; packages are passed to pip install' required: true @@ -20,6 +30,11 @@ on: default: '["3.10", "3.11", "3.12", "3.13"]' workflow_dispatch: inputs: + upload-to-release: + description: Attach bundles to an existing release after building + required: false + type: boolean + default: true tag: description: Release to attach the bundles to required: true @@ -40,9 +55,10 @@ permissions: jobs: build-dependencies: + name: Build ${{ matrix.variant.name }} / Windows / Python ${{ matrix.python-version }} runs-on: windows-latest permissions: - contents: write + contents: read timeout-minutes: 60 strategy: fail-fast: false @@ -54,7 +70,7 @@ jobs: - name: Checkout the release uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ inputs.tag }} + ref: ${{ inputs.ref || inputs.tag }} persist-credentials: false - name: Set up Python ${{ matrix.python-version }} @@ -101,11 +117,31 @@ jobs: with: name: ${{ env.BUNDLE_NAME }} path: ${{ env.BUNDLE_NAME }} - retention-days: 90 + retention-days: 14 + if-no-files-found: error - - name: Upload bundle to release + upload: + name: Attach dependency bundles + needs: build-dependencies + if: ${{ inputs.upload-to-release }} + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: write + steps: + - name: Download dependency bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: mcrit-plugin-dependencies-* + path: bundles + merge-multiple: true + + - name: Upload dependency bundles + shell: bash env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} TAG: ${{ inputs.tag }} - run: gh release upload $env:TAG $env:BUNDLE_NAME --repo $env:REPO --clobber + run: | + shopt -s failglob + gh release upload "$TAG" bundles/* --repo "$REPO" --clobber diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 4d54eac..387207c 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,17 +2,26 @@ name: pytest on: push: + branches: ["**"] pull_request: + workflow_dispatch: + permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: MCRIT_VERSION: "1.12.0" MCRIT_SERVER: "http://127.0.0.1:8000" jobs: pytest: + name: Unit tests + timeout-minutes: 15 runs-on: ubuntu-latest steps: - name: Checkout @@ -41,6 +50,7 @@ jobs: headless-integration: name: Headless backend / live MCRIT + timeout-minutes: 20 runs-on: ubuntu-latest services: mongo: diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 02ace1b..3634fd1 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -2,13 +2,22 @@ name: Validate on: push: + branches: ["**"] pull_request: + workflow_dispatch: + permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: validate: + name: Validate code and workflows + timeout-minutes: 10 runs-on: ubuntu-latest steps: - name: Checkout @@ -25,3 +34,13 @@ jobs: run: python scripts/common/verify_settings_sync.py --repo . - name: Run quality checks run: python scripts/common/run_quality_checks.py --repo . + - name: Install workflow validation tooling + shell: bash + run: | + curl --fail --silent --show-error --location \ + https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz \ + --output "$RUNNER_TEMP/actionlint.tar.gz" + echo "8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 $RUNNER_TEMP/actionlint.tar.gz" | sha256sum --check + tar -xzf "$RUNNER_TEMP/actionlint.tar.gz" -C "$RUNNER_TEMP" actionlint + - name: Validate workflows + run: '"$RUNNER_TEMP/actionlint" -color' diff --git a/RELEASING.md b/RELEASING.md index f6dde0a..a65daaa 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -7,9 +7,11 @@ This repository follows the release process shared across the MCRIT ecosystem [docker-mcrit](https://github.com/familiary/docker-mcrit)). The shape is the same everywhere; this file states the values that are specific to this repository. -This repository ships two plugins that are versioned and released independently: the IDA plugin -follows the shared process below, and the Binary Ninja plugin is released through the extension -manager's own workflow ([Binary Ninja](#binary-ninja)). +This repository ships two released plugins that are versioned and released independently: the IDA +plugin follows the shared process below, and the Binary Ninja plugin is released through the +extension manager's own workflow ([Binary Ninja](#binary-ninja)). Both workflows build every asset +first, attach them to a draft release and only then publish it, so a failed build leaves no +published release. ## IDA @@ -69,20 +71,23 @@ Pushing the tag is the release. `.github/workflows/ida-release.yml` then: 1. **Verify** — refuses to continue unless the tag matches both version strings, `CHANGELOG.md` has a `## [X.Y.Z] - ` section (which becomes the release notes), the tagged commit is on `main`, - and the `pytest` workflow passed on that commit. + and the newest unit-test, validation and IDA CI runs passed on that exact commit. All six + live integration jobs must have actually succeeded; a green skipped-license summary is insufficient. 2. **Validate and build** — runs `verify_metadata_sync.py` against the tag's version, `verify_settings_sync.py` and `run_quality_checks.py`, builds `mcrit-ida-.zip`, and lints the archive with `hcli plugin lint`. -3. **Release** — creates the GitHub release for the tag with the changelog section as its body, - GitHub's generated contributor and PR list appended under it, and the archive attached. It is +3. **Offline dependencies** — builds the Windows `smda` and `full` bundles from the verified + commit before publication. The reusable workflow's build jobs have read-only tokens. +4. **Release** — creates a draft GitHub release with the plugin ZIP and every dependency bundle, + then publishes it with the changelog section as its body and GitHub's generated contributor and + PR list appended under it. It is never marked as the latest release, because the Binary Ninja extension manager reads the latest release. HCLI indexes only the ten most recent releases of the repository, so if Binary Ninja releases ever push the newest IDA release out of that window, cut another IDA release to bring it back. -4. **Offline dependencies** — calls `offline-dependencies.yml`, which attaches the Windows - wheelhouse bundles (`smda` and `full`) to the release. It is called directly because a release - created with `GITHUB_TOKEN` does not start workflows that listen for release events. To attach - bundles to an existing release, run it by hand with that release's tag. + Assets are complete before publication, so immutable releases are supported. The release + job rechecks that the tag still names the verified commit. The asset-only dependency workflow + remains available for older mutable releases; it cannot append assets to immutable releases. Each gate fails with a message naming what to fix. Nothing has to be remembered at the console. @@ -127,9 +132,8 @@ Done once, by a repository owner; the workflow cannot create these for itself. - **Label** `no-changelog`, used by the changelog check. - Optionally, **immutable releases** (Settings → General → Releases), so a published release's - assets and tag can no longer be changed. Note that the offline-dependency workflow uploads - assets to the release after it is published, so it has to finish before a release is made - immutable. + assets and tag can no longer be changed. The release workflows upload all assets to the draft + before publishing. Standalone attachment only works for mutable releases. ### Release order across the ecosystem @@ -160,15 +164,19 @@ A release takes two steps, the same shape as an IDA release: gh workflow run binja-release.yml -f description="$(cat notes.md)" # blank generates notes ``` -`.github/workflows/binja-release.yml` checks that CI passed on `main`, that the version in -`plugin.json` is new (no tag `X.Y.Z` or `vX.Y.Z` names it yet, and it is greater than the latest -release), and runs the metadata, settings, quality and pytest checks there with a read-only token. -It then tags the same commit with the bare version through the release API and publishes it as the -latest GitHub release, with the description as notes and GitHub's generated list since the previous -latest release appended. It never pushes to `main`, so the ruleset needs no bypass. If `main` moved -between the checks and the release, the run stops. Afterwards it calls -`offline-dependencies.yml` to attach a `binja` wheelhouse bundle built from `requirements.txt` -for Python 3.11 to 3.13. To attach it to an existing release by hand, pass the same inputs: +`.github/workflows/binja-release.yml` checks that the newest `pytest` and `Validate` runs passed on +the default branch's commit, that the version in `plugin.json` is new (no tag `X.Y.Z` or `vX.Y.Z` +names it yet, and it is greater than the latest release), and runs the metadata, settings, quality +and pytest checks there with a read-only token. The licensed Binary Ninja CI does not gate the +release, because its secrets are not configured yet. The workflow then calls +`offline-dependencies.yml` to build a `binja` wheelhouse bundle from that commit's +`requirements.txt` for Python 3.11 to 3.13. Once every bundle is built, it creates a draft release +for the bare version on the verified commit, attaches the bundles, and publishes it as the latest +release, with the description as notes and GitHub's generated list since the previous latest +release appended. Publishing creates the tag. It never pushes to `main`, so the ruleset needs no +bypass. If `main` moved between the checks and the release, the run stops. `dry-run=true` runs the +checks without building bundles, tagging or publishing. To attach bundles to an existing release +that is not immutable, pass the same inputs: ```bash gh workflow run offline-dependencies.yml -f tag=X.Y.Z \ @@ -202,3 +210,10 @@ The Ghidra plugin has not been released yet. Its version is `VERSION` in checkout or source archive (see the README), so a release needs no build step. Its changes get `Ghidra:` entries in `CHANGELOG.md` like the other plugins' do. Before a first release, decide on a tag scheme (e.g. `ghidra-vX.Y.Z`) and whether a release guard like the IDA one should check it. + +## Failed publication and reruns + +A failure before publication leaves either no release or an unpublished draft. `gh release create` +refuses a tag that already has a release, so delete the failed draft before re-running. A draft +creates no tag; the Binary Ninja version tag only exists once its release is published. A +published immutable release cannot be corrected: cut a new version instead. diff --git a/docs/development.md b/docs/development.md index 3bbfc8e..1925e7b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -40,6 +40,7 @@ Everything that touches a disassembler goes through `mcrit_plugin/core/Backend.p python scripts/common/verify_settings_sync.py --repo . python scripts/common/run_quality_checks.py --repo . # ruff format + ruff check python -m pytest tests +actionlint python scripts/ida/verify_metadata_sync.py --repo . python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip @@ -51,15 +52,16 @@ python scripts/binja/verify_metadata_sync.py --repo . | Workflow | Name in Actions | Runs on | What | |---|---|---|---| | `pytest.yml` | pytest | push, PR | pytest, headless integration against MCRIT | -| `ruff.yml` | Validate | push, PR | ruff, settings sync | +| `ruff.yml` | Validate | push, PR, dispatch | ruff, settings sync, actionlint | | `changelog.yml` | Changelog | PR | changelog entry for changes shipped in either plugin | | `ida-package.yml` | IDA package | push, PR touching that plugin | metadata sync and package validation | | `binja-package.yml` | Binary Ninja package | push, PR touching that plugin | metadata sync and package validation | -| `ghidra-tests.yml` | Ghidra integration | push, PR touching that plugin, dispatch | PyGhidra headless and GUI integration against MCRIT | -| `ida-tests.yml` | IDA integration | push to main or PR touching the IDA plugin, dispatch | licensed IDA integration | +| `ghidra-tests.yml` | Ghidra CI | push, PR touching that plugin, dispatch | headless and GUI integration against MCRIT | +| `ida-tests.yml` | IDA CI | push to main or PR touching that plugin, dispatch | licensed IDA 9.0–9.5 headless and GUI integration | +| `binja-tests.yml` | Binary Ninja CI | push, PR touching that plugin, dispatch | licensed headless and GUI integration | | `ida-release.yml` | IDA release | `ida-v*` tag | release, see [RELEASING.md](../RELEASING.md) | | `binja-release.yml` | Binary Ninja release | dispatch | release, see [RELEASING.md](../RELEASING.md) | -| `offline-dependencies.yml` | Offline dependencies | called by both releases, or dispatch | Windows wheelhouse bundles | +| `offline-dependencies.yml` | Offline dependencies | called by release workflows, or dispatch | Windows wheelhouse bundles | "Touching that plugin" means a change to one of these paths: @@ -114,12 +116,15 @@ python scripts/common/run_headless_integration.py --input /tmp/mcrit-query --ref ### IDA -`.github/workflows/ida-tests.yml` runs these on pushes to `main`, on pull requests from a branch of -this repository, and on manual dispatch, using the `IDA_LICENSE_ID` and `HCLI_API_KEY` secrets. Pull -requests from a fork, and repositories without those secrets, cannot run the licensed job. It is -then skipped, and the "Licensed IDA result" check passes with a warning that names the reason, so a -skipped licensed job never reads as a tested one. Dispatch the workflow on a branch of this -repository to get the signal. Dispatch with `run_matrix` for more IDA versions and platforms. +`.github/workflows/ida-tests.yml` runs the live suite on Linux for every minor version from 9.0 +through 9.5, on pushes to `main`, on pull requests from a branch of this repository, and on manual +dispatch, using the `IDA_LICENSE_ID` and `HCLI_API_KEY` secrets. Qt 5 is installed for 9.0 and 9.1; +later versions use the installer's PySide6. Dispatch with `run_matrix` to also check offline IDALib +on IDA 9.5 for Windows and macOS ARM, without GUI coverage. Pull requests from a fork, and +repositories without those secrets, cannot run the licensed jobs. They are then skipped, and the +"Integration result" check passes with a warning that names the reason, so a skipped licensed job +never reads as a tested one; a failure in any job that did run fails it. Logs are kept for 14 +days; licence files and user profiles are not uploaded. IDALib covers packaging, conversion, upload and matching without a GUI. Use the Python version your IDA is configured for, and install `idapro` from that IDA: @@ -152,12 +157,22 @@ python scripts/ida/run_gui_integration.py \ ### Binary Ninja -Needs a licensed Binary Ninja and a Python environment matching its interpreter, with +`binja-tests.yml` uses a full Linux x64 GUI distribution and a Commercial or Ultimate license +that supports headless processing. Configure repository Actions secrets `BN_LICENSE_B64` +(base64-encoded `license.dat`) and `BN_DOWNLOAD_URL_LINUX_X64_STABLE` (the licensed Linux GUI ZIP +URL). A headless-only distribution cannot run the GUI stage. Missing secrets and fork pull +requests explicitly skip integration; package validation and unit tests still run. Credentials +are never cached or uploaded. The workflow uses GitHub-hosted runners only. The GUI explicitly loads the same Python shared +library that installed its dependencies, and imports Binary Ninja's own Qt bindings. + +For local runs, use a licensed Binary Ninja and a Python environment matching its interpreter, with `smda>=4.9.0` (it provides `smda.binja`) and `requests` installed. The runner uses a throwaway user directory with this checkout linked as a plugin, so your own profile isn't touched. The query file must have a SHA-256 the server hasn't seen yet. ```bash +python scripts/binja/run_headless_integration.py --input /tmp/mcrit-query \ + --reference-sha256 --mcrit-server http://127.0.0.1:8000/ --license /path/to/license.dat python scripts/binja/run_gui_integration.py --input /tmp/mcrit-query \ --reference-sha256 --mcrit-server http://127.0.0.1:8000/ ``` @@ -214,3 +229,16 @@ it is loaded a second time. The window's state lives on `sys`, so running the sc ## Releases See [RELEASING.md](../RELEASING.md) and [CHANGELOG.md](../CHANGELOG.md). + +## Workflow maintenance + +External actions are pinned to full commit SHAs and updated by Dependabot. Tokens default to +`contents: read`; only the jobs that publish a release or attach assets to one get write access. +CI runs on branch pushes, not tag pushes, so pushing a release tag starts no second CI run. A +release is checked against the newest CI runs on its exact commit, so after a change that the +path filters skip, dispatch the missing workflow on `main` before releasing. Never use +`pull_request_target` to run pull-request code with licence secrets. + +These choices follow GitHub's [secure use guidance](https://docs.github.com/en/actions/reference/security/secure-use), +[concurrency guidance](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency) +and [immutable release guidance](https://docs.github.com/en/code-security/concepts/supply-chain-security/immutable-releases). diff --git a/scripts/binja/run_gui_integration.py b/scripts/binja/run_gui_integration.py index ca3d305..2238401 100644 --- a/scripts/binja/run_gui_integration.py +++ b/scripts/binja/run_gui_integration.py @@ -59,7 +59,12 @@ def _sha256(path: Path) -> str: def _prepare_user_dir( - user_dir: Path, repo_root: Path, license_path: Path, server: str, site_packages: str + user_dir: Path, + repo_root: Path, + license_path: Path, + server: str, + site_packages: str, + python_library: Path | None = None, ) -> Path: plugins_dir = user_dir / "plugins" plugins_dir.mkdir(parents=True, exist_ok=True) @@ -73,6 +78,10 @@ def _prepare_user_dir( "network.enableUpdates": False, "ui.allowWelcome": False, } + if python_library is not None: + # The GUI must use the interpreter that installed native dependencies such as LIEF. + settings["python.interpreter"] = str(python_library.resolve()) + settings["python.binaryOverride"] = sys.executable (user_dir / "settings.json").write_text(json.dumps(settings, indent=2), encoding="utf-8") shutil.copy2(repo_root / "tests" / "binja" / "gui_integration.py", user_dir / "startup.py") return user_dir / "gui-integration.log" @@ -96,6 +105,7 @@ def main() -> int: parser.add_argument("--input", type=Path, required=True) parser.add_argument("--mcrit-server", default="http://127.0.0.1:8000/") parser.add_argument("--reference-sha256") + parser.add_argument("--python-library", type=Path, help="Shared Python library used by the GUI") parser.add_argument("--license", type=Path, default=_default_license()) parser.add_argument( "--site-packages", @@ -114,6 +124,8 @@ def main() -> int: raise FileNotFoundError(f"Input binary does not exist: {input_path}") if not args.license.is_file(): raise FileNotFoundError(f"Binary Ninja license not found: {args.license}") + if args.python_library is not None and not args.python_library.is_file(): + raise FileNotFoundError(f"Python shared library not found: {args.python_library}") binary = _find_binja_binary(args.install_dir) override_path = repo_root / "config_override.json" @@ -123,7 +135,12 @@ def main() -> int: process = None try: result_log = _prepare_user_dir( - user_dir, repo_root, args.license, args.mcrit_server, args.site_packages + user_dir, + repo_root, + args.license, + args.mcrit_server, + args.site_packages, + args.python_library, ) environment = os.environ.copy() environment.update( diff --git a/scripts/binja/run_headless_integration.py b/scripts/binja/run_headless_integration.py new file mode 100644 index 0000000..3ac5167 --- /dev/null +++ b/scripts/binja/run_headless_integration.py @@ -0,0 +1,52 @@ +"""Run the live MCRIT integration contract through Binary Ninja's actual backend. + +Requires a Commercial or Ultimate license with headless support. BN_LICENSE may supply +the license in memory; the user's normal profile is never used. +""" + +import argparse +import os +import sys +import tempfile +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(REPO_ROOT)) + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--input", type=Path, required=True) + parser.add_argument("--mcrit-server", default="http://127.0.0.1:8000/") + parser.add_argument("--reference-sha256") + parser.add_argument("--timeout", type=int, default=180) + parser.add_argument( + "--license", type=Path, help="Read a license without using the normal profile" + ) + args = parser.parse_args() + with tempfile.TemporaryDirectory(prefix="mcrit-binja-headless-") as user_dir: + if args.license: + os.environ["BN_LICENSE"] = args.license.read_text(encoding="utf-8") + os.environ["BN_USER_DIRECTORY"] = user_dir + os.environ["BN_DISABLE_USER_PLUGINS"] = "1" + os.environ["BN_DISABLE_REPOSITORY_PLUGINS"] = "1" + import binaryninja + + from mcrit_plugin.binja.BinjaBackend import BinjaBackend + from scripts.common.run_headless_integration import run + + with binaryninja.load(str(args.input.resolve())) as view: + if view is None: + raise RuntimeError("Binary Ninja failed to analyze the fixture") + run( + args.input.resolve(), + args.mcrit_server, + args.reference_sha256, + args.timeout, + backend=BinjaBackend(view), + ) + print("MCRIT_BN_HEADLESS_INTEGRATION_OK") + + +if __name__ == "__main__": + main() diff --git a/scripts/common/run_headless_integration.py b/scripts/common/run_headless_integration.py index 8f0ad98..756b935 100644 --- a/scripts/common/run_headless_integration.py +++ b/scripts/common/run_headless_integration.py @@ -39,7 +39,14 @@ def _matches_sample(matches, sample_id): return any(isinstance(match, dict) and match.get("sample_id") == sample_id for match in samples) -def run(input_path: Path, server: str, reference_sha256: str | None, timeout: int) -> None: +def run( + input_path: Path, + server: str, + reference_sha256: str | None, + timeout: int, + *, + backend=None, +) -> None: from mcrit_plugin.core.config import PLUGIN_ROOT, McritConfig from mcrit_plugin.core.HeadlessMcritContext import HeadlessMcritContext from mcrit_plugin.headless.HeadlessBackend import HeadlessBackend @@ -52,7 +59,8 @@ def get_setting(key): override_path = Path(PLUGIN_ROOT) / "config_override.json" if override_path.exists(): raise RuntimeError(f"{override_path} would override the test settings; move it aside") - backend = HeadlessBackend(input_path) + if backend is None: + backend = HeadlessBackend(input_path) context = HeadlessMcritContext(McritConfig("headless", get_setting), backend) interface = context.mcrit_interface client = interface.mcrit_client diff --git a/scripts/common/verify_release_ci.py b/scripts/common/verify_release_ci.py new file mode 100644 index 0000000..add6b34 --- /dev/null +++ b/scripts/common/verify_release_ci.py @@ -0,0 +1,69 @@ +"""Require successful CI on the exact release commit, including actual integration jobs.""" + +import argparse +import json +import subprocess + + +def api(path): + return json.loads(subprocess.check_output(["gh", "api", path], text=True)) + + +def latest_run(runs, sha): + eligible = [ + run + for run in runs + if run["head_sha"] == sha and run["event"] in ("push", "workflow_dispatch") + ] + if not eligible: + raise ValueError("no push or manual CI run exists for the release commit") + # Use the newest run, including pending/failed ones; never fall back to an older green run. + return max(eligible, key=lambda run: run["id"]) + + +def require_success(run, jobs, required_jobs=()): + if run["status"] != "completed" or run["conclusion"] != "success": + raise ValueError(f"newest run is {run['status']}/{run['conclusion']}") + outcomes = {job["name"]: job["conclusion"] for job in jobs} + for name in required_jobs: + if outcomes.get(name) != "success": + raise ValueError(f"required job {name!r} is {outcomes.get(name, 'missing')}") + + +def check(repo, sha, plugin): + # Binary Ninja has no licensed CI secrets yet, so its integration run cannot gate a release. + required = { + "pytest.yml": (), + "ruff.yml": (), + } + if plugin == "ida": + required["ida-tests.yml"] = [ + f"IDA {version} / Linux / headless and GUI" + for version in ("9.0", "9.1", "9.2", "9.3", "9.4", "9.5") + ] + for workflow, jobs_needed in required.items(): + response = api( + f"repos/{repo}/actions/workflows/{workflow}/runs?head_sha={sha}&per_page=100" + ) + run = latest_run(response["workflow_runs"], sha) + jobs = api(f"repos/{repo}/actions/runs/{run['id']}/jobs?filter=latest&per_page=100")["jobs"] + require_success(run, jobs, jobs_needed) + print(f"PASS {workflow} on {sha}: {run['html_url']}") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--repo", required=True) + parser.add_argument("--sha", required=True) + parser.add_argument("--plugin", required=True, choices=("ida", "binja")) + args = parser.parse_args() + try: + check(args.repo, args.sha, args.plugin) + except ValueError as error: + raise SystemExit( + f"Release CI gate failed: {error}. Run CI on this commit before releasing." + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/ida/install_idalib_runtime.py b/scripts/ida/install_idalib_runtime.py new file mode 100644 index 0000000..0510401 --- /dev/null +++ b/scripts/ida/install_idalib_runtime.py @@ -0,0 +1,31 @@ +"""Install the IDALib bindings shipped with IDA, including older source distributions.""" + +import argparse +import subprocess +import sys +from pathlib import Path + + +def find_bindings(ida_dir: Path) -> Path: + for root in (ida_dir, ida_dir / "Contents" / "MacOS"): + package = root / "idalib" / "python" + wheels = sorted(package.glob("idapro-*.whl")) + if len(wheels) == 1: + return wheels[0] + if len(wheels) > 1: + raise ValueError(f"Multiple IDALib wheels in {package}; refusing an ambiguous install") + if (package / "setup.py").is_file() or (package / "pyproject.toml").is_file(): + return package + raise FileNotFoundError(f"No bundled IDALib Python package below {ida_dir}") + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--ida-dir", required=True, type=Path) + args = parser.parse_args() + package = find_bindings(args.ida_dir.resolve()) + subprocess.run([sys.executable, "-m", "pip", "install", str(package)], check=True) + + +if __name__ == "__main__": + main() diff --git a/tests/binja/test_integration_profile.py b/tests/binja/test_integration_profile.py new file mode 100644 index 0000000..8e459f7 --- /dev/null +++ b/tests/binja/test_integration_profile.py @@ -0,0 +1,24 @@ +import importlib.util +import json +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +SCRIPT = ROOT / "scripts/binja/run_gui_integration.py" +spec = importlib.util.spec_from_file_location("run_binja_gui", SCRIPT) +runner = importlib.util.module_from_spec(spec) +spec.loader.exec_module(runner) + + +def test_isolated_gui_profile_pins_the_python_abi_without_persisting_credentials(tmp_path): + license_file = tmp_path / "input-license.dat" + license_file.write_text("private license fixture") + profile = tmp_path / "isolated" + library = tmp_path / "libpython3.12.so.1.0" + runner._prepare_user_dir(profile, ROOT, license_file, "http://localhost:8000", "/deps", library) + settings = json.loads((profile / "settings.json").read_text()) + assert settings["python.interpreter"] == str(library.resolve()) + assert settings["python.binaryOverride"] == sys.executable + assert settings["python.virtualenv"] == "/deps" + assert "private license fixture" not in (profile / "settings.json").read_text() + assert (profile / "plugins/mcrit_plugin_integration").resolve() == ROOT diff --git a/tests/core/test_release_ci.py b/tests/core/test_release_ci.py new file mode 100644 index 0000000..e9e31f9 --- /dev/null +++ b/tests/core/test_release_ci.py @@ -0,0 +1,44 @@ +import importlib.util +from pathlib import Path + +import pytest + +SCRIPT = Path(__file__).resolve().parents[2] / "scripts/common/verify_release_ci.py" +spec = importlib.util.spec_from_file_location("verify_release_ci", SCRIPT) +ci = importlib.util.module_from_spec(spec) +spec.loader.exec_module(ci) + + +def run(id=1, sha="verified", event="push", status="completed", conclusion="success"): + return {"id": id, "head_sha": sha, "event": event, "status": status, "conclusion": conclusion} + + +def test_a_newer_failed_or_pending_run_cannot_be_hidden_by_an_old_green_run(): + for newest in (run(2, conclusion="failure"), run(2, status="in_progress", conclusion=None)): + selected = ci.latest_run([run(), newest], "verified") + with pytest.raises(ValueError, match="newest run"): + ci.require_success(selected, []) + + +def test_pr_runs_or_other_commits_cannot_authorize_a_release(): + with pytest.raises(ValueError, match="no push or manual"): + ci.latest_run([run(event="pull_request"), run(2, sha="different")], "verified") + assert ci.latest_run([run(event="workflow_dispatch")], "verified")["id"] == 1 + + +@pytest.mark.parametrize("conclusion", [None, "skipped", "failure", "cancelled"]) +def test_a_green_summary_cannot_hide_a_missing_or_unexecuted_integration(conclusion): + jobs = [{"name": "Integration result", "conclusion": "success"}] + with pytest.raises(ValueError, match="missing"): + ci.require_success(run(), jobs, ["actual integration"]) + jobs.append({"name": "actual integration", "conclusion": conclusion}) + with pytest.raises(ValueError, match="required job"): + ci.require_success(run(), jobs, ["actual integration"]) + + +def test_all_required_integrations_must_succeed_but_optional_jobs_can_skip(): + jobs = [ + {"name": "live", "conclusion": "success"}, + {"name": "optional", "conclusion": "skipped"}, + ] + ci.require_success(run(), jobs, ["live"]) diff --git a/tests/ida/test_idalib_runtime.py b/tests/ida/test_idalib_runtime.py new file mode 100644 index 0000000..900bcdd --- /dev/null +++ b/tests/ida/test_idalib_runtime.py @@ -0,0 +1,30 @@ +import importlib.util +from pathlib import Path + +import pytest + +SCRIPT = Path(__file__).resolve().parents[2] / "scripts/ida/install_idalib_runtime.py" +spec = importlib.util.spec_from_file_location("install_idalib_runtime", SCRIPT) +runtime = importlib.util.module_from_spec(spec) +spec.loader.exec_module(runtime) + + +@pytest.mark.parametrize("root", ["", "Contents/MacOS"]) +@pytest.mark.parametrize("distribution", ["idapro-9.5-py3-none-any.whl", "setup.py"]) +def test_bindings_from_installer_layouts(tmp_path, root, distribution): + package = tmp_path / root / "idalib/python" + package.mkdir(parents=True) + (package / distribution).touch() + expected = package if distribution == "setup.py" else package / distribution + assert runtime.find_bindings(tmp_path) == expected + + +def test_missing_or_ambiguous_bindings_fail(tmp_path): + with pytest.raises(FileNotFoundError): + runtime.find_bindings(tmp_path) + package = tmp_path / "idalib/python" + package.mkdir(parents=True) + for version in ("9.4", "9.5"): + (package / f"idapro-{version}-py3-none-any.whl").touch() + with pytest.raises(ValueError, match="Multiple"): + runtime.find_bindings(tmp_path) From 26cef82171257f8c68b4df8e22d3a9643317e905 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:25:05 +0530 Subject: [PATCH 02/11] Point IDALib at the installation through IDADIR in the integration run idapro from IDA 9.0 and 9.1 failed to load libidalib.so when the run used an isolated IDAUSR, so the headless integration never started on those versions. --- scripts/ida/run_idalib_integration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ida/run_idalib_integration.py b/scripts/ida/run_idalib_integration.py index 9b377a3..5f559da 100644 --- a/scripts/ida/run_idalib_integration.py +++ b/scripts/ida/run_idalib_integration.py @@ -119,6 +119,8 @@ def main() -> int: environment.update( { "IDAUSR": str(idausr), + # idapro from IDA 9.0 and 9.1 cannot find libidalib under an isolated IDAUSR without it + "IDADIR": str(_find_activation_script(ida_dir).parents[2]), "MCRIT_IDA_PLUGIN_ROOT": str(plugin_root), "MCRIT_IDA_INTEGRATION_LIVE": "0" if args.offline else "1", "MCRIT_IDA_INTEGRATION_TIMEOUT": str(args.timeout), From 109dd6ab45259a7d329edc4179a2d61bcfe2720a Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:28:07 +0530 Subject: [PATCH 03/11] Name the Qt modules the IDALib integration finds imported --- tests/ida/idalib_integration.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ida/idalib_integration.py b/tests/ida/idalib_integration.py index 4e70371..e95c2b5 100644 --- a/tests/ida/idalib_integration.py +++ b/tests/ida/idalib_integration.py @@ -86,9 +86,11 @@ def _load_plugin(plugin_root): qt_modules_before = {name for name in sys.modules if name.startswith(("PySide", "PyQt"))} import ida_mcrit + qt_modules = {name for name in sys.modules if name.startswith(("PySide", "PyQt"))} _assert( - qt_modules_before == {name for name in sys.modules if name.startswith(("PySide", "PyQt"))}, - "loading the plugin entry point imported a Qt binding under IDALib", + qt_modules == qt_modules_before, + "loading the plugin entry point imported a Qt binding under IDALib: " + f"{sorted(qt_modules - qt_modules_before)}", ) plugin = ida_mcrit.PLUGIN_ENTRY() _assert(plugin.wanted_name == "MCRIT4IDA", "unexpected plugin name") From d1ede15ebf2cb9e523528149f13f77e81a6ddb21 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:31:34 +0530 Subject: [PATCH 04/11] Record where the IDALib integration's unexpected Qt import comes from --- tests/ida/idalib_integration.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/ida/idalib_integration.py b/tests/ida/idalib_integration.py index e95c2b5..f1a3942 100644 --- a/tests/ida/idalib_integration.py +++ b/tests/ida/idalib_integration.py @@ -80,17 +80,34 @@ def _matches_sample(matches, sample_id): ) +class _QtImportRecorder: + """A meta path entry that finds nothing and records where the first Qt import came from.""" + + def __init__(self): + self.stack = None + + def find_spec(self, name, path=None, target=None): + if self.stack is None and name.startswith(("PySide", "PyQt")): + self.stack = "".join(traceback.format_stack(limit=12)) + return None + + def _load_plugin(plugin_root): if str(plugin_root) not in sys.path: sys.path.insert(0, str(plugin_root)) qt_modules_before = {name for name in sys.modules if name.startswith(("PySide", "PyQt"))} - import ida_mcrit + recorder = _QtImportRecorder() + sys.meta_path.insert(0, recorder) + try: + import ida_mcrit + finally: + sys.meta_path.remove(recorder) qt_modules = {name for name in sys.modules if name.startswith(("PySide", "PyQt"))} _assert( qt_modules == qt_modules_before, "loading the plugin entry point imported a Qt binding under IDALib: " - f"{sorted(qt_modules - qt_modules_before)}", + f"{sorted(qt_modules - qt_modules_before)}, first imported from\n{recorder.stack}", ) plugin = ida_mcrit.PLUGIN_ENTRY() _assert(plugin.wanted_name == "MCRIT4IDA", "unexpected plugin name") From e1eb58da6b1aecb1c586494c11fd1523739d1c30 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:34:10 +0530 Subject: [PATCH 05/11] Do not count ida-settings' own QtCore import against the plugin entry point On IDA 9.0 the bundled PyQt5 is importable under IDALib, and ida-settings imports QtCore from it when it is loaded. The check is about what the plugin's entry point imports, so load ida-settings before taking the baseline. --- tests/ida/idalib_integration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/ida/idalib_integration.py b/tests/ida/idalib_integration.py index f1a3942..a4cf41b 100644 --- a/tests/ida/idalib_integration.py +++ b/tests/ida/idalib_integration.py @@ -95,6 +95,9 @@ def find_spec(self, name, path=None, target=None): def _load_plugin(plugin_root): if str(plugin_root) not in sys.path: sys.path.insert(0, str(plugin_root)) + # ida-settings imports QtCore itself where IDA ships an importable binding (IDA 9.0) + import ida_settings # noqa: F401 + qt_modules_before = {name for name in sys.modules if name.startswith(("PySide", "PyQt"))} recorder = _QtImportRecorder() sys.meta_path.insert(0, recorder) From 78b3d0d66a4c7d0eea2536388761a04a9ac13c91 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:37:06 +0530 Subject: [PATCH 06/11] Pass IDA 9.0 its licence key file without the setpref suffix --- .github/workflows/ida-tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ida-tests.yml b/.github/workflows/ida-tests.yml index 3aec24a..f6c4948 100644 --- a/.github/workflows/ida-tests.yml +++ b/.github/workflows/ida-tests.yml @@ -398,11 +398,17 @@ jobs: env: PYTHONPATH: ${{ runner.temp }}/ida-py-deps IDALOG: ${{ runner.temp }}/ida-gui-startup.log + IDA_VERSION: ${{ matrix.version }} run: | # keep the keyfile outside the isolated IDAUSR: that profile is uploaded as a CI artifact LICENSE_FILE=$(find "${{ steps.ida.outputs.ida-dir }}" -maxdepth 1 -type f -name '*.hexlic' -print -quit) test -n "$LICENSE_FILE" - export IDA_LICENSE="keyfile=${LICENSE_FILE}:setpref" + # IDA 9.0 rejects the ":setpref" suffix as part of the file name + if [[ "$IDA_VERSION" == "9.0" ]]; then + export IDA_LICENSE="keyfile=${LICENSE_FILE}" + else + export IDA_LICENSE="keyfile=${LICENSE_FILE}:setpref" + fi xvfb-run -a python scripts/ida/run_gui_integration.py \ --ida-dir "${{ steps.ida.outputs.ida-dir }}" \ --input "${{ runner.temp }}/mcrit-gui-query.exe" \ From d19426a4686e3ab1c1f5f7f96c1b4483c521a5d0 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:40:35 +0530 Subject: [PATCH 07/11] Let the IDA plugin change the database on IDA 9.0 ida_undo.create_undo_point takes an action name and a label from IDA 9.1 on. IDA 9.0 exposes only the form that takes a packed record, so the call raised TypeError and importing labels, like every other mutation, stopped there. The change now goes ahead on 9.0 without an undo point. --- CHANGELOG.md | 3 +++ mcrit_plugin/ida/IdaBackend.py | 6 +++++- tests/ida/test_ida_backend.py | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4022993..08ad0ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ Ninja or Ghidra applies to that plugin only. example, branch targets kept their exact bytes. The escaping now follows the report's architecture; one without an SMDA escaper keeps its raw bytes. Copy Escaped Bytes falls back to raw bytes like the rule text when escaping fails, instead of copying nothing. +- IDA 9.0: importing labels, and every other change the plugin makes to the database, failed with + a `TypeError`, because IDA 9.0 cannot set an undo point the way later versions do. The change now + goes ahead there without one. ## [2.1.1] - 2026-10-15 diff --git a/mcrit_plugin/ida/IdaBackend.py b/mcrit_plugin/ida/IdaBackend.py index 9a82983..25bc0e8 100644 --- a/mcrit_plugin/ida/IdaBackend.py +++ b/mcrit_plugin/ida/IdaBackend.py @@ -278,7 +278,11 @@ def mutation(self, title): return self._mutation_depth += 1 try: - ida_undo.create_undo_point(self.plugin_name, title) + try: + ida_undo.create_undo_point(self.plugin_name, title) + except TypeError: + # IDA 9.0's binding takes only the packed undo record, so no undo point is set there + pass yield finally: self._mutation_depth -= 1 diff --git a/tests/ida/test_ida_backend.py b/tests/ida/test_ida_backend.py index b613ed4..e716907 100644 --- a/tests/ida/test_ida_backend.py +++ b/tests/ida/test_ida_backend.py @@ -62,6 +62,17 @@ def _finish_work(instance): assert instance._deliveries.qsize() == instance._pending +def test_a_mutation_goes_ahead_where_ida_cannot_take_the_undo_point(backend): + instance, _ = backend + + # IDA 9.0's signature: one packed record, so the two-argument call raises TypeError + sys.modules["ida_undo"].create_undo_point = lambda record: True + ran = [] + with instance.mutation("Import MCRIT labels"): + ran.append(True) + assert ran == [True] + + def test_run_background_runs_work_on_a_worker_like_a_request(backend): instance, kernwin = backend on_done = MagicMock() From 3d08e3e3207aff54f97641fe41d49c09db2650df Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:43:17 +0530 Subject: [PATCH 08/11] Set IDA 9.0's undo point from the packed record Skipping the undo point let the change through but left an import of labels as separate undo steps. IDA 9.0 accepts the record the SDK's two-string helper packs: both strings, each zero-terminated. --- CHANGELOG.md | 3 +-- mcrit_plugin/ida/IdaBackend.py | 5 +++-- tests/ida/test_ida_backend.py | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08ad0ba..27d7bc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,8 +27,7 @@ Ninja or Ghidra applies to that plugin only. architecture; one without an SMDA escaper keeps its raw bytes. Copy Escaped Bytes falls back to raw bytes like the rule text when escaping fails, instead of copying nothing. - IDA 9.0: importing labels, and every other change the plugin makes to the database, failed with - a `TypeError`, because IDA 9.0 cannot set an undo point the way later versions do. The change now - goes ahead there without one. + a `TypeError`, because IDA 9.0 takes its undo points in another form than later versions do. ## [2.1.1] - 2026-10-15 diff --git a/mcrit_plugin/ida/IdaBackend.py b/mcrit_plugin/ida/IdaBackend.py index 25bc0e8..5ae73f5 100644 --- a/mcrit_plugin/ida/IdaBackend.py +++ b/mcrit_plugin/ida/IdaBackend.py @@ -281,8 +281,9 @@ def mutation(self, title): try: ida_undo.create_undo_point(self.plugin_name, title) except TypeError: - # IDA 9.0's binding takes only the packed undo record, so no undo point is set there - pass + # IDA 9.0's binding takes only the record the SDK packs from the two strings + record = b"".join(text.encode() + b"\0" for text in (self.plugin_name, title)) + ida_undo.create_undo_point(record) yield finally: self._mutation_depth -= 1 diff --git a/tests/ida/test_ida_backend.py b/tests/ida/test_ida_backend.py index e716907..3a45c67 100644 --- a/tests/ida/test_ida_backend.py +++ b/tests/ida/test_ida_backend.py @@ -62,15 +62,14 @@ def _finish_work(instance): assert instance._deliveries.qsize() == instance._pending -def test_a_mutation_goes_ahead_where_ida_cannot_take_the_undo_point(backend): +def test_a_mutation_sets_ida_90s_undo_point_from_the_packed_record(backend): instance, _ = backend - + records = [] # IDA 9.0's signature: one packed record, so the two-argument call raises TypeError - sys.modules["ida_undo"].create_undo_point = lambda record: True - ran = [] + sys.modules["ida_undo"].create_undo_point = lambda record: records.append(record) with instance.mutation("Import MCRIT labels"): - ran.append(True) - assert ran == [True] + pass + assert records == [instance.plugin_name.encode() + b"\0Import MCRIT labels\0"] def test_run_background_runs_work_on_a_worker_like_a_request(backend): From 8a1abc0aaf2b2ccbb5d8780016bf6682f724d70a Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:35:26 +0530 Subject: [PATCH 09/11] Correct the release rerun note and the pytest workflow's triggers Whether a second release can be created for a tag that only has a draft is not something the release notes should assert; the advice to delete the failed draft first holds either way. The pytest workflow can also be dispatched by hand. --- RELEASING.md | 8 ++++---- docs/development.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index a65daaa..c81c5b8 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -213,7 +213,7 @@ a tag scheme (e.g. `ghidra-vX.Y.Z`) and whether a release guard like the IDA one ## Failed publication and reruns -A failure before publication leaves either no release or an unpublished draft. `gh release create` -refuses a tag that already has a release, so delete the failed draft before re-running. A draft -creates no tag; the Binary Ninja version tag only exists once its release is published. A -published immutable release cannot be corrected: cut a new version instead. +A failure before publication leaves either no release or an unpublished draft. Delete the failed +draft before re-running, so the tag does not end up with two. A draft creates no tag; the Binary +Ninja version tag only exists once its release is published. A published immutable release cannot +be corrected: cut a new version instead. diff --git a/docs/development.md b/docs/development.md index 1925e7b..4a381b1 100644 --- a/docs/development.md +++ b/docs/development.md @@ -51,7 +51,7 @@ python scripts/binja/verify_metadata_sync.py --repo . | Workflow | Name in Actions | Runs on | What | |---|---|---|---| -| `pytest.yml` | pytest | push, PR | pytest, headless integration against MCRIT | +| `pytest.yml` | pytest | push, PR, dispatch | pytest, headless integration against MCRIT | | `ruff.yml` | Validate | push, PR, dispatch | ruff, settings sync, actionlint | | `changelog.yml` | Changelog | PR | changelog entry for changes shipped in either plugin | | `ida-package.yml` | IDA package | push, PR touching that plugin | metadata sync and package validation | From 6c4999ece17383abb9038ec9ee00d5dcdf604304 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:43:30 +0530 Subject: [PATCH 10/11] Run the Windows and macOS IDA jobs on main and on manual runs --- .github/workflows/ida-tests.yml | 155 ++++++++------------------------ docs/development.md | 4 +- 2 files changed, 37 insertions(+), 122 deletions(-) diff --git a/.github/workflows/ida-tests.yml b/.github/workflows/ida-tests.yml index f6c4948..4be9b7a 100644 --- a/.github/workflows/ida-tests.yml +++ b/.github/workflows/ida-tests.yml @@ -48,12 +48,6 @@ on: - "pyproject.toml" - ".gitattributes" workflow_dispatch: - inputs: - run_matrix: - description: Also run offline IDALib compatibility on Windows and macOS - required: false - type: boolean - default: false permissions: contents: read @@ -142,7 +136,6 @@ jobs: run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - name: Install GUI runtime dependencies - if: runner.os == 'Linux' shell: bash run: | sudo apt-get update @@ -169,7 +162,6 @@ jobs: test -d "$IDA_DIR" test -x "$IDA_DIR/ida" echo "ida-dir=$IDA_DIR" >> "$GITHUB_OUTPUT" - echo "ida-bin=$IDA_DIR/ida" >> "$GITHUB_OUTPUT" # hcli --accept-eula records EULA acceptance only in the *default* IDAUSR; the isolated # test profiles refuse batch mode without the accepted ida.reg. SRC="" @@ -197,11 +189,7 @@ jobs: run: | # --seed: install_idalib_runtime.py installs IDA's bundled bindings with pip uv venv --seed --python 3.12 "$RUNNER_TEMP/idalib-venv" - if [[ "$RUNNER_OS" == "Windows" ]]; then - IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/Scripts/python.exe" - else - IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/bin/python" - fi + IDALIB_PYTHON="$RUNNER_TEMP/idalib-venv/bin/python" echo "IDALIB_PYTHON=$IDALIB_PYTHON" >> "$GITHUB_ENV" "$IDALIB_PYTHON" scripts/ida/install_idalib_runtime.py \ --ida-dir "${{ steps.ida.outputs.ida-dir }}" @@ -236,31 +224,6 @@ jobs: --output "${{ runner.temp }}/mcrit-gui-query.exe" \ --variant 2 - - name: Wait for MongoDB - shell: bash - run: | - "$RUNNER_TEMP/mcrit-venv/bin/python" - <<'PY' - import time - import pymongo - - deadline = time.monotonic() + 60 - last_error = None - while time.monotonic() < deadline: - try: - client = pymongo.MongoClient( - "mongodb://127.0.0.1:27017/", - serverSelectionTimeoutMS=1000, - ) - client.admin.command("ping") - print("MongoDB is ready.") - break - except Exception as exc: - last_error = exc - time.sleep(1) - else: - raise SystemExit(f"MongoDB did not become ready: {last_error}") - PY - - name: Start MCRIT server and worker shell: bash run: | @@ -268,22 +231,8 @@ jobs: # shell exits, which would kill the services before the "Wait for MCRIT API" step setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit server \ > "$RUNNER_TEMP/mcrit-server.log" 2>&1 < /dev/null & - echo $! > "$RUNNER_TEMP/mcrit-server.pid" setsid nohup "$RUNNER_TEMP/mcrit-venv/bin/python" -m mcrit worker \ > "$RUNNER_TEMP/mcrit-worker.log" 2>&1 < /dev/null & - echo $! > "$RUNNER_TEMP/mcrit-worker.pid" - sleep 5 - if ! kill -0 "$(cat "$RUNNER_TEMP/mcrit-server.pid")" 2>/dev/null; then - echo "::error::MCRIT server exited during startup:" - cat "$RUNNER_TEMP/mcrit-server.log" - exit 1 - fi - if ! kill -0 "$(cat "$RUNNER_TEMP/mcrit-worker.pid")" 2>/dev/null; then - echo "::error::MCRIT worker exited during startup:" - cat "$RUNNER_TEMP/mcrit-worker.log" - exit 1 - fi - echo "MCRIT server (pid $(cat "$RUNNER_TEMP/mcrit-server.pid")) and worker (pid $(cat "$RUNNER_TEMP/mcrit-worker.pid")) started." - name: Wait for MCRIT API shell: bash @@ -422,16 +371,6 @@ jobs: --qt-platform xcb \ --require-hcli - - name: Stop MCRIT processes - if: ${{ always() }} - shell: bash - run: | - for pid_file in "$RUNNER_TEMP/mcrit-server.pid" "$RUNNER_TEMP/mcrit-worker.pid"; do - if [[ -f "$pid_file" ]]; then - kill "$(cat "$pid_file")" 2>/dev/null || true - fi - done - - name: Upload integration logs if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -451,7 +390,7 @@ jobs: licensed-result: name: Integration result timeout-minutes: 5 - needs: [preflight, licensed-linux, compatibility-matrix] + needs: [preflight, licensed-linux, other-platforms] if: always() runs-on: ubuntu-latest steps: @@ -462,10 +401,10 @@ jobs: RESULT: ${{ needs.licensed-linux.result }} REASON: ${{ needs.preflight.outputs.reason }} PREFLIGHT: ${{ needs.preflight.result }} - COMPATIBILITY: ${{ needs.compatibility-matrix.result }} + OTHER_PLATFORMS: ${{ needs.other-platforms.result }} run: | - if [[ "$PREFLIGHT" != "success" || "$RESULT" == "failure" || "$RESULT" == "cancelled" || "$COMPATIBILITY" == "failure" || "$COMPATIBILITY" == "cancelled" ]]; then - echo "::error::IDA integration failed (preflight=$PREFLIGHT, live=$RESULT, compatibility=$COMPATIBILITY)" + if [[ "$PREFLIGHT" != "success" || "$RESULT" == "failure" || "$RESULT" == "cancelled" || "$OTHER_PLATFORMS" == "failure" || "$OTHER_PLATFORMS" == "cancelled" ]]; then + echo "::error::IDA integration failed (preflight=$PREFLIGHT, linux=$RESULT, other platforms=$OTHER_PLATFORMS)" exit 1 fi if [[ "$RESULT" == "success" ]]; then @@ -480,25 +419,20 @@ jobs: echo "::warning::$message" echo "$message" >> "$GITHUB_STEP_SUMMARY" - compatibility-matrix: - name: ${{ matrix.name }} - needs: [preflight, licensed-linux] - if: ${{ needs.preflight.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && inputs.run_matrix }} + # Pull requests get the Linux matrix only; pushes to main and manual runs add these. + other-platforms: + # A skipped job shows its name unexpanded, so the name leaves the matrix to GitHub's suffix + name: IDA 9.5 / offline headless + needs: preflight + if: ${{ needs.preflight.outputs.run == 'true' && github.event_name != 'pull_request' }} strategy: fail-fast: false matrix: - include: - - name: IDA 9.5 / Windows / offline headless - artifact: ida-9.5-windows-logs - os: windows-latest - installer: ida-pro:9.5:x64win - - name: IDA 9.5 / macOS ARM / offline headless - artifact: ida-9.5-macos-arm-logs - os: macos-latest - installer: ida-pro:9.5:armmac - + os: [windows-latest, macos-latest] runs-on: ${{ matrix.os }} timeout-minutes: 60 + env: + IDA_VERSION: "9.5" steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -515,55 +449,38 @@ jobs: with: enable-cache: false + - name: Install HCLI + run: uv tool install "ida-hcli==${HCLI_VERSION}" + + - name: Build plugin archive + run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip + - name: Install disassembler id: ida - shell: bash env: HCLI_API_KEY: ${{ secrets.HCLI_API_KEY }} IDA_LICENSE_ID: ${{ secrets.IDA_LICENSE_ID }} run: | + if [[ "$RUNNER_OS" == "Windows" ]]; then + installer="x64win" + else + installer="armmac" + fi IDA_DIR="$RUNNER_TEMP/opt/ida" - uv tool install "ida-hcli==${HCLI_VERSION}" hcli ida install -y \ - -d "${{ matrix.installer }}" \ + -d "ida-pro:${IDA_VERSION}:${installer}" \ -l "$IDA_LICENSE_ID" \ -i "$IDA_DIR" test -d "$IDA_DIR" - if [[ "$RUNNER_OS" == "macOS" ]]; then - IDA_BIN="$IDA_DIR/Contents/MacOS/ida" - elif [[ "$RUNNER_OS" == "Windows" ]]; then - IDA_BIN="$(find "$IDA_DIR" -type f \( -name ida.exe -o -name ida64.exe \) -print -quit)" - else - IDA_BIN="$IDA_DIR/ida" - fi - test -n "$IDA_BIN" - test -x "$IDA_BIN" echo "ida-dir=$IDA_DIR" >> "$GITHUB_OUTPUT" - echo "ida-bin=$IDA_BIN" >> "$GITHUB_OUTPUT" - SRC="" - for cand in "$IDA_DIR/ida.reg" "$HOME/.idapro/ida.reg"; do - if [[ -f "$cand" ]]; then SRC="$cand"; break; fi - done - if [[ -z "$SRC" ]]; then - echo "::warning::No accepted ida.reg found to propagate into test profiles" - else - for prof in "$RUNNER_TEMP/idausr-idalib" "$RUNNER_TEMP/idausr-gui"; do - mkdir -p "$prof" - cp "$SRC" "$prof/ida.reg" - done - echo "Propagated IDA acceptance from $SRC into test profiles" + # macOS keeps the accepted EULA in ida.reg, which the isolated profile needs a copy of; + # Windows keeps it in the registry. + if [[ -f "$HOME/.idapro/ida.reg" ]]; then + mkdir -p "$RUNNER_TEMP/idausr-idalib" + cp "$HOME/.idapro/ida.reg" "$RUNNER_TEMP/idausr-idalib/ida.reg" fi - - name: Keep HCLI on PATH - shell: bash - run: | - echo "$HOME/.local/bin" >> "$GITHUB_PATH" - echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - - - name: Build plugin archive - run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - - - name: Build compatibility fixture + - name: Build fixture run: | python scripts/common/build_test_fixture.py \ --source tests/fixtures/mcrit_sample.c \ @@ -571,7 +488,6 @@ jobs: --variant 0 - name: Install IDALib test runtime - shell: bash run: | # --seed: install_idalib_runtime.py installs IDA's bundled bindings with pip uv venv --seed --python 3.12 "$RUNNER_TEMP/idalib-venv" @@ -586,8 +502,7 @@ jobs: uv pip install --python "$IDALIB_PYTHON" \ "smda==${SMDA_VERSION}" "ida-settings==3.5.1" "requests" - - name: Run offline IDALib lifecycle integration test - shell: bash + - name: Run offline headless integration test run: | "$IDALIB_PYTHON" scripts/ida/run_idalib_integration.py \ --ida-dir "${{ steps.ida.outputs.ida-dir }}" \ @@ -600,11 +515,11 @@ jobs: --offline \ --require-hcli - - name: Upload compatibility logs + - name: Upload integration logs if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ${{ matrix.artifact }} + name: ida-9.5-${{ matrix.os }}-logs retention-days: 14 path: | ${{ runner.temp }}/idalib-integration.log diff --git a/docs/development.md b/docs/development.md index 4a381b1..f20bfbf 100644 --- a/docs/development.md +++ b/docs/development.md @@ -119,8 +119,8 @@ python scripts/common/run_headless_integration.py --input /tmp/mcrit-query --ref `.github/workflows/ida-tests.yml` runs the live suite on Linux for every minor version from 9.0 through 9.5, on pushes to `main`, on pull requests from a branch of this repository, and on manual dispatch, using the `IDA_LICENSE_ID` and `HCLI_API_KEY` secrets. Qt 5 is installed for 9.0 and 9.1; -later versions use the installer's PySide6. Dispatch with `run_matrix` to also check offline IDALib -on IDA 9.5 for Windows and macOS ARM, without GUI coverage. Pull requests from a fork, and +later versions use the installer's PySide6. Pushes to `main` and manual runs also check IDALib on +IDA 9.5 for Windows and macOS ARM, without an MCRIT server or the GUI. Pull requests from a fork, and repositories without those secrets, cannot run the licensed jobs. They are then skipped, and the "Integration result" check passes with a warning that names the reason, so a skipped licensed job never reads as a tested one; a failure in any job that did run fails it. Logs are kept for 14 From 31c1af3f5aee0fb09f2a0a0229578c0003408645 Mon Sep 17 00:00:00 2001 From: r0ny123 <49360849+r0ny123@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:50:07 +0530 Subject: [PATCH 11/11] Write the IDA workflow's path list and shell once --- .github/workflows/ida-tests.yml | 41 ++------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ida-tests.yml b/.github/workflows/ida-tests.yml index 4be9b7a..6ba1330 100644 --- a/.github/workflows/ida-tests.yml +++ b/.github/workflows/ida-tests.yml @@ -4,7 +4,7 @@ on: push: branches: - main - paths: + paths: &paths - "mcrit_plugin/ida/**" - "scripts/ida/**" - "tests/ida/**" @@ -26,27 +26,7 @@ on: - "pyproject.toml" - ".gitattributes" pull_request: - paths: - - "mcrit_plugin/ida/**" - - "scripts/ida/**" - - "tests/ida/**" - - "CHANGELOG.md" - - "docs/config_override.json.template" - - ".github/workflows/ida-*.yml" - - ".github/workflows/scripts/ida/**" - - "mcrit_plugin/core/**" - - "mcrit_plugin/__init__.py" - - "mcrit_plugin/ui_qt/**" - - "icons/**" - - "scripts/common/**" - - "tests/core/**" - - "tests/ui_qt/**" - - "tests/conftest.py" - - "tests/fixtures/**" - - "README.md" - - "LICENSE" - - "pyproject.toml" - - ".gitattributes" + paths: *paths workflow_dispatch: permissions: @@ -77,7 +57,6 @@ jobs: steps: - name: Check configuration id: decide - shell: bash env: FORK_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} HAS_SECRETS: ${{ secrets.IDA_LICENSE_ID != '' && secrets.HCLI_API_KEY != '' }} @@ -136,7 +115,6 @@ jobs: run: python scripts/ida/package_plugin.py --repo . --output dist/mcrit-ida.zip - name: Install GUI runtime dependencies - shell: bash run: | sudo apt-get update sudo apt-get install --yes --no-install-recommends \ @@ -148,7 +126,6 @@ jobs: - name: Install disassembler id: ida - shell: bash env: HCLI_API_KEY: ${{ secrets.HCLI_API_KEY }} IDA_LICENSE_ID: ${{ secrets.IDA_LICENSE_ID }} @@ -159,7 +136,6 @@ jobs: -d "ida-pro:${IDA_VERSION}:x64linux" \ -l "$IDA_LICENSE_ID" \ -i "$IDA_DIR" - test -d "$IDA_DIR" test -x "$IDA_DIR/ida" echo "ida-dir=$IDA_DIR" >> "$GITHUB_OUTPUT" # hcli --accept-eula records EULA acceptance only in the *default* IDAUSR; the isolated @@ -179,13 +155,11 @@ jobs: fi - name: Install MCRIT service - shell: bash run: | uv venv --python 3.12 "$RUNNER_TEMP/mcrit-venv" uv pip install --python "$RUNNER_TEMP/mcrit-venv/bin/python" "mcrit==${MCRIT_VERSION}" - name: Install IDALib test runtime - shell: bash run: | # --seed: install_idalib_runtime.py installs IDA's bundled bindings with pip uv venv --seed --python 3.12 "$RUNNER_TEMP/idalib-venv" @@ -197,7 +171,6 @@ jobs: "smda==${SMDA_VERSION}" "ida-settings==3.5.1" "requests" - name: Install plugin dependencies - shell: bash env: IDA_VERSION: ${{ matrix.version }} run: | @@ -225,7 +198,6 @@ jobs: --variant 2 - name: Start MCRIT server and worker - shell: bash run: | # setsid, not nohup alone: the runner SIGTERMs the step's process group when this step's # shell exits, which would kill the services before the "Wait for MCRIT API" step @@ -235,7 +207,6 @@ jobs: > "$RUNNER_TEMP/mcrit-worker.log" 2>&1 < /dev/null & - name: Wait for MCRIT API - shell: bash run: | "$RUNNER_TEMP/mcrit-venv/bin/python" - <<'PY' import time @@ -257,7 +228,6 @@ jobs: PY - name: Seed MCRIT reference sample - shell: bash env: PYTHONPATH: ${{ github.workspace }} run: | @@ -268,11 +238,9 @@ jobs: - name: Record reference SHA-256 id: reference - shell: bash run: echo "sha256=$(sha256sum '${{ runner.temp }}/mcrit-reference.exe' | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" - name: Run headless integration tests - shell: bash run: | "$IDALIB_PYTHON" scripts/ida/run_idalib_integration.py \ --ida-dir "${{ steps.ida.outputs.ida-dir }}" \ @@ -287,7 +255,6 @@ jobs: --require-hcli - name: Seed GUI profile from licensed IDALib profile - shell: bash run: | SOURCE_REG="$RUNNER_TEMP/idausr-idalib/ida.reg" GUI_REG="$RUNNER_TEMP/idausr-gui/ida.reg" @@ -296,7 +263,6 @@ jobs: strings "$GUI_REG" | grep -q '^Licenses$' - name: Pre-accept IDAPython PyQt5 shim for GUI profile - shell: bash run: | # IDA 9.2+ shows a modal "enable the PyQt5 shim?" dialog on the first PyQt5 import; it ignores # -A / batch mode and blocks startup forever. IDAPYTHON_USE_PYQT5_SHIM=0 silences it. @@ -308,7 +274,6 @@ jobs: CFG - name: Configure IDAPython for GUI integration test - shell: bash env: IDAUSR: ${{ runner.temp }}/idausr-gui run: | @@ -343,7 +308,6 @@ jobs: "$IDAPYSWITCH" --force-path "$PYTHON_LIBRARY" - name: Run GUI integration tests - shell: bash env: PYTHONPATH: ${{ runner.temp }}/ida-py-deps IDALOG: ${{ runner.temp }}/ida-gui-startup.log @@ -396,7 +360,6 @@ jobs: steps: # Missing secrets are reported explicitly; real matrix failures must fail this check. - name: Report integration result - shell: bash env: RESULT: ${{ needs.licensed-linux.result }} REASON: ${{ needs.preflight.outputs.reason }}