feat(acquire): resumable batch extraction queue and binary inventory
Inventory classifies the DLL repository by SHA; the batch queue runs each engine build in a fresh PyGhidra process with a timeout, fingerprints the extractor environment and keeps per-attempt state and logs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
bddb5949a6
commit
b0013c5114
@@ -0,0 +1,42 @@
|
||||
import json
|
||||
import sys
|
||||
import types
|
||||
|
||||
from ams.acquire import ghidra
|
||||
|
||||
|
||||
def test_pyghidra_unicode_source_uses_safe_domain_name(tmp_path, monkeypatch):
|
||||
"""Ghidra rejects Unicode domain names; the DLL path and identity must survive."""
|
||||
source = tmp_path / 'Piotruś Pan i Wehikuł__PIKLIB61.DLL'
|
||||
source.write_bytes(b'dll')
|
||||
output = tmp_path / 'out.json'
|
||||
calls = []
|
||||
class Launcher:
|
||||
vm_args = []
|
||||
def __init__(self, **kwargs):
|
||||
self.vm_args = []
|
||||
@staticmethod
|
||||
def has_launched():
|
||||
return False
|
||||
def start(self):
|
||||
calls.append(self.vm_args)
|
||||
def run_script(dll, script, **kwargs):
|
||||
assert dll == str(source)
|
||||
assert kwargs['program_name'].isascii()
|
||||
assert ' ' not in kwargs['program_name']
|
||||
output.write_text(json.dumps({'binary': {'name': kwargs['program_name'], 'sha256': 'a'*64}}))
|
||||
monkeypatch.setitem(sys.modules, 'pyghidra', types.SimpleNamespace(run_script=run_script))
|
||||
monkeypatch.setitem(sys.modules, 'pyghidra.launcher', types.SimpleNamespace(
|
||||
PyGhidraLauncher=Launcher, HeadlessPyGhidraLauncher=Launcher))
|
||||
ghidra.run_extractor_pyghidra(str(source), str(output))
|
||||
assert calls
|
||||
assert json.loads(output.read_text())['binary']['name'] == source.name
|
||||
|
||||
|
||||
def test_find_headless_accepts_rea_variable(tmp_path, monkeypatch):
|
||||
launcher = tmp_path / 'support' / 'analyzeHeadless'
|
||||
launcher.parent.mkdir()
|
||||
launcher.touch()
|
||||
monkeypatch.delenv('GHIDRA_HEADLESS', raising=False)
|
||||
monkeypatch.setenv('GHIDRA_INSTALL_DIR', str(tmp_path))
|
||||
assert ghidra.find_headless() == str(launcher)
|
||||
Reference in New Issue
Block a user