06 — Tool Adapter SDK

Status: Ratified Version: 1.0.0 Applies to: All tool integrations, tools/<tool-id>/adapter.py Schema: config/plugin.schema.yaml (adapter plugins), 07 - Tool Knowledge Base Specification.md


1. Purpose

The Tool Adapter SDK defines the contracts that every integrated tool must satisfy to be executable, parseable, and reasoned about by HunterX. Adapters are the bridge between the platform and an arbitrary external tool (binary, library, remote service).

An adapter has exactly one job: execute a tool in a standard, safe, and observable way and produce canonical output. Parsing/normalization happen in separate, adapter-owned components (parser.py, normalizer.py) so that the adapter stays focused.


2. Adapter Taxonomy

Adapter Responsibility Typical tools
BaseAdapter Common contract every adapter implements — (abstract)
ScannerAdapter Active scanning / detection nmap, nuclei, sqlmap, nikto, wpscan
CrawlerAdapter Web crawling / link discovery wget, hakrawler, gobuster (dir)
EnumeratorAdapter Asset/intelligence enumeration subfinder, amass, massdns, dnsx, certsh
AnalyzerAdapter Analysis of provided input semgrep, bandit, trivy, kube-hunter
ReporterAdapter Consumes results to produce artifacts (custom format exporters)
ValidationAdapter Confirms/refutes a finding (PoC) sqlmap (verify), nuclei -validate, custom PoC

A single integration may implement multiple adapter types (e.g., nuclei as both ScannerAdapter and ValidationAdapter).


3. Common Contract (BaseAdapter)

Every adapter must implement:

Method Purpose
execute(request: ToolRequest) -> ToolResult Run the tool for the given request
parse(output: bytes) -> Iterable[ParsedItem] Convert raw output to structured items
normalize(items) -> Iterable[CanonicalEvent] Map parsed items to canonical entities
validate(items) -> ValidationReport Sanity-check normalized output
healthcheck() -> HealthReport Is the tool installed/available/authorized?
capabilities() -> set[Capability] What can this adapter do?
describe() -> AdapterInfo Metadata for registry/UI

Shared input/output types (defined in hunterx.plugins.sdk):


4. Adapter Lifecycle

discover (registry scan of tools/)
  → validate (knowledge.yaml + adapter import + healthcheck)
  → register (adapter catalog)
  → execute (per request)
       ├─ preflight (scope check, healthcheck, secret binding)
       ├─ sandbox run (process/container)
       ├─ capture output (streamed)
       ├─ parse
       ├─ normalize
       ├─ validate
       └─ emit CanonicalEvents + ToolResult
  → unload (on removal/update)

5. ScannerAdapter

Contract additions:

class ScannerAdapter(BaseAdapter):
    def scan(self, request: ScanRequest) -> ScanResult: ...   # convenience wrapper
    def discover(self, request: ScanRequest) -> Iterable[ServiceFinding]: ...

6. CrawlerAdapter

Contract additions:


7. EnumeratorAdapter

Contract additions:


8. AnalyzerAdapter

Contract additions:


9. ReporterAdapter

Contract additions:


10. ValidationAdapter

Contract additions:


11. Adapter & Tool Knowledge Integration

An adapter MUST be paired with a Tool Knowledge File (07 - Tool Knowledge Base Specification.md). The knowledge file is the contract of record for:

The adapter references knowledge via describe()['knowledge_id'] and the ToolExecutor (see 02 - Architecture.md §5.9) resolves and binds them.


12. Safety Contract (mandatory for all adapters)

  1. No direct subprocess from adapter code. All execution goes through tools/sandbox.py (the sandboxed executor).
  2. Args are structured (argv lists), never shell strings. No sh -c.
  3. Scope enforcement: adapter must check every target/port/path against the scope envelope before invocation; any deviation → VIOLATED outcome, no run.
  4. Timeouts & limits are always applied (from request, not adapter defaults).
  5. Secrets: credentials are injected by the sandbox from SecretPort by declared names; never accepted as free-form argv.
  6. Destructive actions (sqlmap --dbs on live DB, payload writes) require the mission profile’s destructive_allowed flag; otherwise blocked at the executor.
  7. Observability: every execution emits tool.started, tool.completed / tool.failed with correlation id, duration, outcome, and artifacts.
  8. Isolation: untrusted tool output is never evaluated/executed; it is parsed by declarative parsers only.

13. Error Handling Contract


14. Versioning & Compatibility


15. Packaging

Each adapter ships in tools/<tool-id>/:

adapter.py        # implements one or more contracts above
parser.py         # parser for tool output (streamed)
normalizer.py     # canonical mapping
knowledge.yaml    # Tool Knowledge File (mandatory)
workflows.yaml    # workflow position rules
mission_rules.yaml# mission applicability
ai_rules.yaml     # AI usage rules
tests/            # adapter/parser/normalizer tests
README.md         # tool documentation

Full checklist: 22 - Tool Integration Standard.md.


16. Testing an Adapter


17. References