diff --git a/.github/workflows/features-drift.yml b/.github/workflows/features-drift.yml index f4cf3f7..59931b7 100644 --- a/.github/workflows/features-drift.yml +++ b/.github/workflows/features-drift.yml @@ -19,3 +19,6 @@ jobs: - name: Check .revengai/features.json is up to date run: python scripts/emit_features.py --check + + - name: Check ida-plugin.json dependencies match uv.lock + run: python scripts/emit_plugin_deps.py --check diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 744a1fc..b1a11c4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -90,6 +90,15 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + + # hcli installs from the tag's source archive, so the version in + # there has to match the tag. The bump lives on the tagged commit + # only, main is left alone. + VERSION="${{ steps.version.outputs.version }}" + sed -i -E "s/(\"version\": *\")[^\"]+/\1${VERSION}/" ida-plugin.json + sed -i -E "s/^(__PLUGIN_VERSION__ = \")[^\"]+/\1${VERSION}/" reai_toolkit_entry.py + git diff --quiet || git commit -am "chore: release ${{ steps.version.outputs.tag }}" + git tag "${{ steps.version.outputs.tag }}" git push origin "${{ steps.version.outputs.tag }}" diff --git a/README.md b/README.md index 82233d1..54b3054 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,20 @@ The package `PyQt5` must be installed. ### Setup +#### With HCLI (recommended) + +If you have [HCLI](https://hcli.docs.hex-rays.com/) installed, this is all you need: + +```bash +hcli plugin install revengai +``` + +It drops the plugin into your IDA user plugin directory and installs the Python +dependencies into the interpreter IDA uses. `hcli plugin upgrade revengai` picks +up new releases, `hcli plugin uninstall revengai` removes it. + +#### Manually + 1. **Download** the plugin code for your platform and Python version from the [Releases](https://github.com/revengai/plugin-ida/releases/latest) page. 2. **Extract** the archive contents into your IDA user plugin directory. diff --git a/ida-plugin.json b/ida-plugin.json index 7f44b34..64833c9 100644 --- a/ida-plugin.json +++ b/ida-plugin.json @@ -1,12 +1,45 @@ { + "$schema": "https://hcli.docs.hex-rays.com/schemas/ida-plugin.json", "IDAMetadataDescriptorVersion": 1, "plugin": { - "name": "RevEng.AI", + "name": "revengai", + "version": "3.27.1", "entryPoint": "reai_toolkit_entry.py", - "categories": ["decompilation", "integration-with-third-parties-interoperability", "malware-analysis", "other"], - "logoPath": "reai_toolkit/app/components/resources/reveng_ai_logo.jpg", - "idaVersions": ">=9.0", "description": "The RevEng.AI plugin integrates AI-powered code analysis and decompilation features into IDA Pro, enhancing reverse engineering workflows with advanced machine learning capabilities.", - "version": "3.0.0" + "license": "GPL-3.0", + "urls": { + "repository": "https://github.com/RevEngAI/plugin-ida", + "homepage": "https://reveng.ai" + }, + "authors": [ + { + "name": "RevEng.AI", + "email": "contact@reveng.ai" + } + ], + "categories": [ + "decompilation", + "integration-with-third-parties-interoperability", + "malware-analysis", + "other" + ], + "keywords": [ + "reveng.ai", + "ai", + "function-matching", + "binary-similarity", + "auto-unstrip", + "ai-decompiler" + ], + "logoPath": "reai_toolkit/app/components/resources/reveng_ai_logo.jpg", + "idaVersions": ["9.0", "9.0sp1", "9.1", "9.2", "9.3", "9.4", "9.5"], + "requiresPython": ">=3.10", + "pythonDependencies": [ + "requests==2.32.5", + "loguru==0.7.3", + "pydantic==2.12.3", + "revengai==4.75.0", + "libbs==3.8.1" + ] } } diff --git a/reai_toolkit/app/core/shared_schema.py b/reai_toolkit/app/core/shared_schema.py index 21cfc08..5e2a657 100644 --- a/reai_toolkit/app/core/shared_schema.py +++ b/reai_toolkit/app/core/shared_schema.py @@ -1,9 +1,7 @@ from enum import Enum from typing import Generic, List, Optional, TypeVar -from pydantic import BaseModel - -from reai_toolkit.vendor.pydantic import Field +from pydantic import BaseModel, Field T = TypeVar("T") diff --git a/reai_toolkit_entry.py b/reai_toolkit_entry.py index 4b98efa..158280d 100644 --- a/reai_toolkit_entry.py +++ b/reai_toolkit_entry.py @@ -44,7 +44,7 @@ def _add_vendor_paths(): # flake8: noqa: E402 # TODO: Obtain this from package metadata or ship pyproject.toml with plugin. -__PLUGIN_VERSION__ = "3.4.0" +__PLUGIN_VERSION__ = "3.27.1" __IDA_VERSION__ = idaapi.get_kernel_version() diff --git a/scripts/emit_plugin_deps.py b/scripts/emit_plugin_deps.py new file mode 100644 index 0000000..5542c9c --- /dev/null +++ b/scripts/emit_plugin_deps.py @@ -0,0 +1,69 @@ +import argparse +import re +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +MANIFEST_PATH = ROOT / "ida-plugin.json" +BLOCK = re.compile(r'("pythonDependencies": \[)(.*?)(\n *\])', re.S) + + +def normalise(name): + return re.sub(r"[-_.]+", "-", name).lower() + + +def direct(): + # no tomllib on 3.10, the block is simple enough to pull out by hand + text = (ROOT / "pyproject.toml").read_text() + block = re.search(r"^dependencies = \[(.*?)^\]", text, re.M | re.S).group(1) + return [re.match(r"[A-Za-z0-9._-]+", d).group(0) for d in re.findall(r'"([^"]+)"', block)] + + +def locked(): + text = (ROOT / "uv.lock").read_text() + versions = {} + for name, version in re.findall(r'^\[\[package\]\]\nname = "([^"]+)"\nversion = "([^"]+)"', text, re.M): + versions.setdefault(normalise(name), set()).add(version) + return versions + + +def build_dependencies(): + versions = locked() + pins = [] + for name in direct(): + found = versions.get(normalise(name), set()) + if len(found) != 1: + raise SystemExit(f"expected one locked version of {name}, found {sorted(found)}") + pins.append(f"{name}=={found.pop()}") + return pins + + +def serialize(current): + body = "".join(f'\n "{pin}",' for pin in build_dependencies()).rstrip(",") + return BLOCK.sub(lambda m: m.group(1) + body + m.group(3), current, count=1) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--check", action="store_true") + args = parser.parse_args() + + current = MANIFEST_PATH.read_text() + content = serialize(current) + if args.check: + if current != content: + print( + "ida-plugin.json pythonDependencies are out of date; run: python scripts/emit_plugin_deps.py", + file=sys.stderr, + ) + return 1 + print("ida-plugin.json pythonDependencies are up to date.") + return 0 + + MANIFEST_PATH.write_text(content) + print(f"wrote {MANIFEST_PATH}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/unit/core/test_plugin_manifest.py b/tests/unit/core/test_plugin_manifest.py new file mode 100644 index 0000000..c74cc34 --- /dev/null +++ b/tests/unit/core/test_plugin_manifest.py @@ -0,0 +1,34 @@ +import json +import os +import re +import subprocess +import sys + +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) + + +def _manifest(): + with open(os.path.join(ROOT, "ida-plugin.json")) as fh: + return json.load(fh)["plugin"] + + +def test_python_dependencies_match_uv_lock(): + result = subprocess.run([sys.executable, os.path.join(ROOT, "scripts", "emit_plugin_deps.py"), "--check"]) + + assert result.returncode == 0 + + +def test_entry_point_exists(): + assert os.path.isfile(os.path.join(ROOT, _manifest()["entryPoint"])) + + +def test_logo_exists(): + assert os.path.isfile(os.path.join(ROOT, _manifest()["logoPath"])) + + +def test_version_matches_entry_point(): + plugin = _manifest() + with open(os.path.join(ROOT, plugin["entryPoint"])) as fh: + match = re.search(r'^__PLUGIN_VERSION__ = "([^"]+)"', fh.read(), re.M) + + assert match and match.group(1) == plugin["version"]