fix(setup): name the analysis tool to add and explain missing tools (#17297)

* fix(setup): name the analysis tool to add when none is ready

When no native analysis tool is ready, setup names the one to add for this
operating system and links its guide, and automatic provider selection says so
plainly. Its recovery lists only providers this host can run, explains each,
asks the agent to get the person's agreement before setting one up, and says
what REA can still do without one.

Fixes #17292

* fix(providers): explain missing tools and ask before setting them up

Each external tool's repair for a missing installation now starts with what
the tool is and what setting it up installs, from one domain table, and tells
the agent to ask the person before installing it. The no-ready-provider
recovery skips providers this host refuses or that refused the target, Kuna
reports an unsupported host before its unset command, and IDA's repair carries
its description in remediationAction. AGENTS.md notes that agents are the
primary users, with a person behind them who may not know what is missing.

* fix(android): keep JADX release metadata loadable from source

Pre-install fixture scripts import JadxRelease.ts directly, so it stays
dependency-free. JadxConfiguration adds the tool description where it reports
a missing JAR.

* fix(pcap): keep the tool refusal reason in the repair action

pcapToolUnavailable had set remediationAction to the shared tshark setup
text alone, so the projected action dropped the refusal reason while the
message kept only the bare steps. adb and apktool still project both as
`${reason}. ${toolSetupRemediation(...)}` through providerConfigurationRefusal.

The helper now puts that same combined text in userMessage and leaves
remediationAction unset, so the projection copies it into the action. The
pcap CLI tests assert the reason, the Wireshark steps, and the tshark setup
prefix in both fields.

* fix(pcap): carry the tool-setup repair on the refusal itself

The recovery guide requires each refusal to carry its remediation; shared
projection formats those facts and must not fill them in. pcapToolUnavailable
had left remediationAction unset so the action was copied from the message.

The helper now sets remediationAction to PCAP_TOOL_REMEDIATION and keeps the
reason in userMessage. providerConfigurationRefusal, which adb and apktool
use, does the same with the configuration's own repair. CLI tests check the
reason and the repair separately.

* test(android): expect the tool repair in remediation, not the message
This commit is contained in:
morluto authored and GitHub committed 2026-12-05 20:03:04 -05:00
1 parent 2b5019ba03
commit fbd895281c
56 files changed
+609 -147

No files matched your search

+2
View File
@@ -12,6 +12,8 @@ Ghidra uses ephemeral databases without modifying executable bytes or controllin
REA is for everyone, not only developers. Text that people read while getting REA working (README quick starts, setup, update and doctor output, and update notices) must be understandable to someone who is not a developer. Name the one command to run next, and say when people can ask their agent to do it instead. Error remediation in tool results is for agents and stays precise; keep technical detail in reference docs and JSON fields.
Agents are REA's primary users, so design tools and results for agent use first. Behind each agent is a person who may be new to reverse engineering and may not know what is missing, for example that no Ghidra is set up for the `.exe` they asked about. When a result depends on something only the person can know or decide, such as which tool to install, give the agent enough to explain it in plain words and say to ask first. See [recovery design](docs/development/tool-design.md#design-recovery-around-the-failure).
Configuration changes must be additive and idempotent, with backups. Installers must not install or upgrade unrelated software, including Homebrew, Node.js, npm, Java, or Ghidra; Ghidra and IDA are bring-your-own. `rea setup` must show its planned changes and require approval before writing files or installing Hopper.
Preserve caller-selected inputs and local evidence, including output, URLs, paths, digests, and metadata. Redact transport authentication credentials and explicitly marked sensitive values; do not infer secrecy from names or text patterns. Do not persist the ambient environment merely because a child inherits it.
+7
View File
@@ -207,6 +207,13 @@ them through provider readiness, capability discovery, doctor and CLI/MCP output
An error description is not a repair instruction. Do not make each consumer
guess the fix from diagnostic text or invent another list of prerequisites.
When the repair is the person's decision, such as installing software,
accepting a license or changing something outside REA, the recovery gives the
agent what it needs to explain the choice in plain words: what the tool is,
what setting it up installs, and the step to take. It tells the agent to ask
the person before acting. The owning contract supplies that description, so it
stays accurate. When no tool can run, also say what REA can still do without it.
Make the producer state recovery and retry semantics, and make the error type
require them. Each refusal carries its remediation and whether the unchanged
request, a changed request or no retry can succeed; shared projection formats
+5 -2
View File
@@ -156,8 +156,11 @@ into the file it updates.
After setup, REA reports which agents can use it and which analysis tools are
ready, then names the next step: restart the agents it changed, open an agent
that was already connected, or run setup again to choose an agent. Failed steps
and diagnostics remain in terminal history.
that was already connected, or run setup again to choose an agent. When no tool
for compiled programs is ready, it adds one line naming the tool to add for
your operating system (Ghidra on Windows; Hopper or Ghidra elsewhere) and its
guide section; `--json` carries the same line as `nextStep.addAnalysisTool`.
Failed steps and diagnostics remain in terminal history.
Select exact clients in scripts with repeatable `--client` flags. Each explicit
client skips interactive selection. Use `--all-detected` only when you intend
+5 -1
View File
@@ -5,6 +5,7 @@ import {
cancelledBy,
carriedReason,
} from "../domain/analysisErrorCore.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { isQualifiedCallerPath } from "../filesystem/callerPath.js";
import { findWindowsExecutable } from "../process/WindowsExecutable.js";
import { ProviderStartupDeadline } from "../process/ProviderDeadline.js";
@@ -32,7 +33,10 @@ const VERSION_TIMEOUT_MS = 10_000;
const ADB_VERSION_REMEDIATION = `Set ${ADB_BINARY_ENV} to an Android SDK Platform-Tools adb binary whose \`adb version\` reports its version, or put one on PATH.`;
/** Repair when the selected adb binary does not exist. */
const ADB_MISSING_REMEDIATION = `Set ${ADB_BINARY_ENV} to an absolute path to an existing adb binary.`;
const ADB_MISSING_REMEDIATION = toolSetupRemediation(
"adb",
`Set ${ADB_BINARY_ENV} to an absolute path to an existing adb binary.`,
);
/** Repair when execution of the adb binary selected by the environment is denied. */
const ADB_NOT_EXECUTABLE_REMEDIATION = `Set ${ADB_BINARY_ENV} to an absolute path to the adb executable file, not a directory, and check execute permission on it and search permission on its parent directories.`;
const VERSION_MAX_OUTPUT_BYTES = 64 * 1024;
+3 -1
View File
@@ -840,7 +840,9 @@ it("reports a missing selected binary as a capability gap with recovery", async
if (result.ok) return;
const projected = projectAnalysisError(result.error);
expect(projected).toMatchObject({ code: "capability_unavailable" });
expect(projected.message).toContain("REA_ADB_PATH");
expect(projected.message).toBe(
"The selected adb binary was not found: /nonexistent/adb.",
);
expect(projected.remediation).toMatchObject({
action: expect.stringContaining("REA_ADB_PATH") as unknown,
});
+2 -1
View File
@@ -1,4 +1,5 @@
import type { HostPlatform } from "../platform/HostPlatform.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { appendCallerPath } from "../filesystem/callerPath.js";
import {
DEFAULT_JADX_OPERATION_TIMEOUT_MS,
@@ -123,7 +124,7 @@ const jadxFailureRemediation = (kind: JadxFailureKind): string => {
case "operation_timeout":
return JADX_OPERATION_TIMEOUT_REMEDIATION;
case "jar":
return JADX_JAR_CONFIGURATION_REMEDIATION;
return toolSetupRemediation("jadx", JADX_JAR_CONFIGURATION_REMEDIATION);
case "java_probe":
return JADX_JAVA_PROBE_REMEDIATION;
case "unsupported_host":
+4 -1
View File
@@ -153,7 +153,10 @@ export const jadxBridgeIdentity =
return bridgeIdentity;
};
/** Remediation when `REA_JADX_MCP_JAR` is missing or not an absolute path. */
/**
* Remediation when `REA_JADX_MCP_JAR` is missing or not an absolute path.
* Release scripts load this module from source, so it imports nothing.
*/
export const JADX_JAR_CONFIGURATION_REMEDIATION = `Download the jadx-headless-mcp ${JADX_RELEASE.version} release JAR from ${JADX_RELEASE.url}, verify SHA-256 ${JADX_RELEASE.sha256}, and set REA_JADX_MCP_JAR to its absolute path. REA does not download or install it.`;
/** Remediation when the selected Java runtime cannot satisfy the JADX bridge. */
+5 -1
View File
@@ -2,6 +2,7 @@ import {
processInspectionCancellationError,
processInspectionFailure,
} from "../providers/OwnedCommandCleanup.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
import { capturedApktoolFailureOutput } from "./ApktoolCommandOutput.js";
import { ok, err, type Result } from "../domain/result.js";
@@ -55,7 +56,10 @@ const apktoolVersionProbeTimeoutGuidance = (): {
const APKTOOL_VERSION_REMEDIATION = `Set ${APKTOOL_COMMAND_ENV} to an Apktool 2.7.0 or newer launcher whose --version prints its version, or put one on PATH.`;
/** Repair when the selected apktool launcher does not exist. */
const APKTOOL_MISSING_REMEDIATION = `Set ${APKTOOL_COMMAND_ENV} to an absolute apktool launcher (the upstream wrapper or a java -jar script).`;
const APKTOOL_MISSING_REMEDIATION = toolSetupRemediation(
"apktool",
`Set ${APKTOOL_COMMAND_ENV} to an absolute apktool launcher (the upstream wrapper or a java -jar script).`,
);
/** Repair when execution of the selected apktool launcher is denied. */
const APKTOOL_NOT_EXECUTABLE_REMEDIATION = `Check file type and execute permission for ${APKTOOL_COMMAND_ENV} or select an executable apktool launcher.`;
+4 -1
View File
@@ -768,7 +768,10 @@ it("reports a missing launcher as a capability gap with recovery", async () => {
expect(projected).toMatchObject({ code: "capability_unavailable" });
expect(projected.details).toMatchObject({
provider_id: "apktool",
reason: expect.stringContaining("REA_APKTOOL_COMMAND") as unknown,
reason: "The selected apktool launcher was not found: /nonexistent/apktool",
});
expect(projected.remediation).toMatchObject({
action: expect.stringContaining("REA_APKTOOL_COMMAND") as unknown,
});
});
+43 -11
View File
@@ -1,4 +1,5 @@
import { PCAP_CAPTURE_UNSUPPORTED_HOST_REASON } from "../domain/pcap/pcapAnalysis.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { WABT_RELEASE_LINE } from "../domain/wasm/wasmArtifact.js";
import { DEFAULT_CALL_RELATIONSHIP_DIRECTION } from "../contracts/enhancedInputs.js";
import {
@@ -609,17 +610,23 @@ const workflowAvailabilityFor = (
: "provider_missing",
remediation:
policy.androidAnalysisAvailability?.remediation ??
"Set REA_JADX_MCP_JAR to a caller-supplied jadx-headless-mcp JAR (rea doctor --provider jadx names its download URL and SHA-256) and provide a full JDK on Linux, macOS, or Windows x64 with its matching bundled native controls.",
UNCONFIGURED_JADX_REMEDIATION,
};
if (kind === "adb-provider")
return ownerProbeAvailability(
policy.adbAnalysisAvailability,
"Set REA_ADB_PATH to a caller-supplied adb executable or make adb available on PATH. This checks the client version only; device and serial availability depend on the request.",
toolSetupRemediation(
"adb",
"Set REA_ADB_PATH to a caller-supplied adb executable or make adb available on PATH. This checks the client version only; device and serial availability depend on the request.",
),
);
if (kind === "apktool-provider")
return ownerProbeAvailability(
policy.apktoolAnalysisAvailability,
"Set REA_APKTOOL_COMMAND to a caller-supplied Apktool executable or make Apktool 2.7.0 or newer available on PATH.",
toolSetupRemediation(
"apktool",
"Set REA_APKTOOL_COMMAND to a caller-supplied Apktool executable or make Apktool 2.7.0 or newer available on PATH.",
),
);
if (kind === "jeb-provider") {
const availability = policy.jebAnalysisAvailability;
@@ -634,7 +641,10 @@ const workflowAvailabilityFor = (
};
return ownerProbeAvailability(
availability,
"Start a JEB client serving MCP (GUI client, or headless via its programmatic launcher) and point REA_JEB_MCP_URL at it (default http://127.0.0.1:8425/mcp). REA does not install or launch JEB.",
toolSetupRemediation(
"jeb",
"Start a JEB client serving MCP (GUI client, or headless via its programmatic launcher) and point REA_JEB_MCP_URL at it (default http://127.0.0.1:8425/mcp). REA does not install or launch JEB.",
),
);
}
const browser = browserProviderAvailability(name, kind, policy);
@@ -661,16 +671,30 @@ const workflowAvailabilityFor = (
return null;
};
/**
* Repair when no Android JADX provider is configured. It names no release so
* it cannot drift from the pinned engine the Android boundary reports.
*/
export const UNCONFIGURED_JADX_REMEDIATION = toolSetupRemediation(
"jadx",
"Set REA_JADX_MCP_JAR to a caller-supplied jadx-headless-mcp JAR (rea doctor --provider jadx names its download URL and SHA-256) and provide a full JDK on Linux, macOS, or Windows x64 with its matching bundled native controls.",
);
const firmwareRemediation = (
operation: "inspect_firmware_regions" | "extract_firmware",
): string => {
const requirement =
FIRMWARE_TOOL_REQUIREMENTS[FIRMWARE_OPERATION_ENGINES[operation]];
return `On Linux, provide an absolute ${requirement.commandEnvironment} (${requirement.requirement}) path, util-linux prlimit and procps ps.${operation === "inspect_firmware_regions" ? "" : " Extraction also requires the selected format’s external extractor."}`;
return toolSetupRemediation(
FIRMWARE_OPERATION_ENGINES[operation],
`On Linux, provide an absolute ${requirement.commandEnvironment} (${requirement.requirement}) path, util-linux prlimit and procps ps.${operation === "inspect_firmware_regions" ? "" : " Extraction also requires the selected format’s external extractor."}`,
);
};
const PWNTOOLS_REMEDIATION =
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.";
const PWNTOOLS_REMEDIATION = toolSetupRemediation(
"pwntools",
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.",
);
/** Each host-restricted feature's configuration flag and setup remediation. */
const HOST_FEATURES: Readonly<
@@ -689,8 +713,10 @@ const HOST_FEATURES: Readonly<
},
javascriptRecovery: {
enabled: (policy) => policy.javascriptRecoveryEnabled,
remediation:
remediation: toolSetupRemediation(
"wakaru",
"On Linux x64, provide an absolute REA_WAKARU_COMMAND for Wakaru ^1.13.0 (verified with 1.14.0) and util-linux prlimit; see docs/guides/javascript/javascript-recovery.md#install-wakaru. No binary target is required.",
),
},
binaryLayout: {
enabled: (policy) => policy.binaryLayoutEnabled,
@@ -702,13 +728,17 @@ const HOST_FEATURES: Readonly<
},
packetCapture: {
enabled: (policy) => policy.packetCaptureEnabled,
remediation:
remediation: toolSetupRemediation(
"tshark",
"On Linux, supply TShark 4.x on PATH or through absolute REA_TSHARK_COMMAND, and util-linux prlimit (REA_TSHARK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
),
},
signalRecording: {
enabled: (policy) => policy.signalRecordingEnabled,
remediation:
remediation: toolSetupRemediation(
"sigrok",
"On Linux, supply sigrok-cli 0.7.2 via absolute REA_SIGROK_COMMAND and util-linux prlimit (REA_SIGROK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
),
},
evmInterface: {
enabled: (policy) => policy.evmInterfaceEnabled,
@@ -773,8 +803,10 @@ const webModuleImportAvailability = (
name: "native-literal-resolution",
available: false,
missing_operations: ["native-module-resolver"],
remediation:
remediation: toolSetupRemediation(
"chromium",
"Provide an absolute REA_BROWSER_EXECUTABLE supporting import.meta.resolve; no binary target is required.",
),
},
],
});
+12 -3
View File
@@ -1,4 +1,5 @@
import { DESKTOP_EXPORT_FRAMEWORK_VERSION } from "../domain/desktop/appExport.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import type { DoctorHost, DoctorSkillState } from "./Doctor.js";
import type { DoctorCheck } from "../ports/DoctorProviderInspection.js";
import type {
@@ -83,8 +84,10 @@ export const desktopBuildChecks = (
{ ...nodeCheck(context.host), name: named("node") },
result("ps", facts.ps.found, facts.ps.detail, {
classification: "missing_dependency",
remediation:
remediation: toolSetupRemediation(
"procps",
"Install procps, whose ps REA's process supervisor runs from /bin/ps or /usr/bin/ps: sudo apt install procps.",
),
}),
dockerCheck(facts.docker),
daemonCheck(facts.daemon),
@@ -128,7 +131,10 @@ const dockerCheck = (docker: DesktopBuildCommand): DoctorCheck =>
remediation:
docker.status === "invalid"
? "Set REA_DOCKER_COMMAND to the absolute path of the Docker CLI, or unset it to use docker on PATH."
: "Install Docker Engine: https://docs.docker.com/engine/install/",
: toolSetupRemediation(
"docker",
"Install Docker Engine: https://docs.docker.com/engine/install/",
),
},
);
@@ -229,7 +235,10 @@ const agentEnvCheck = (facts: DesktopBuildFacts): DoctorCheck => {
remediation:
agentEnv.status === "invalid"
? `Set REA_AGENT_ENV_COMMAND to the absolute path of agent-env, or unset it to use agent-env on PATH. To install it: ${AGENTENV_INSTALL_COMMAND}`
: `${AGENTENV_INSTALL_COMMAND}, or rea setup --desktop-build --install-agentenv.`,
: toolSetupRemediation(
"agentenv",
`${AGENTENV_INSTALL_COMMAND}, or rea setup --desktop-build --install-agentenv.`,
),
details: { expected_version: DESKTOP_EXPORT_FRAMEWORK_VERSION },
});
};
+7 -1
View File
@@ -1,4 +1,5 @@
import { mkdir } from "node:fs/promises";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { join, posix } from "node:path";
import { describe, expect, it, vi } from "vitest";
@@ -1269,7 +1270,12 @@ describe("doctor Linux and Hopper discovery", () => {
);
expect(
result.checks.find(({ name }) => name === "hopper")?.remediation,
).toBe("Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH.");
).toBe(
toolSetupRemediation(
"hopper",
"Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH.",
),
);
});
it("explains how to recover from an unsupported configured launcher", async () => {
const path = "/custom/Hopper";
+5 -1
View File
@@ -11,6 +11,7 @@ import {
import { selectedHomeDirectorySettings } from "../config/homeDirectory.js";
import { ok, err, type Result } from "../domain/result.js";
import { macosMajorVersion } from "../domain/macosVersion.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import type { HopperReleaseError } from "./HopperReleaseFeed.js";
import {
hopperSetupSupport,
@@ -368,7 +369,10 @@ const hopperRemediation = (
return "Unset or update HOPPER_LAUNCHER_PATH to an executable Hopper launcher.";
if (support?.supported === false)
return `Automated Hopper setup is unavailable on this host: ${support.remediation} Configure a supported provider such as Ghidra or IDA, or set HOPPER_LAUNCHER_PATH to an existing launcher.`;
return "Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH.";
return toolSetupRemediation(
"hopper",
"Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH.",
);
};
const optionalHopperStartupTimeoutCheck = (
+4 -1
View File
@@ -174,7 +174,10 @@ export const runSetup = async (
// cleanup can still turn a ready setup into one that needs attention.
if (cleanup === undefined)
return result.status === "ready"
? { ...result, nextStep: setupNextStep(result.clients, result.doctor) }
? {
...result,
nextStep: setupNextStep(result.clients, result.doctor, host.platform),
}
: result;
const cleanupReason = setupCleanupReason(cleanup);
const cleanupReport: AnalysisCleanupObservation = {
+25
View File
@@ -2,20 +2,32 @@ import type {
ClientConfigurationResult,
SetupDoctorSummary,
} from "./SetupTypes.js";
import { NATIVE_ANALYSIS_PROVIDER_IDS } from "../domain/providerSelection.js";
import { SUPPORTED_CLIENT_DEFINITIONS } from "./SupportedClients.js";
/**
* What the person does after a ready setup, decided once for every adapter.
* `clients` holds setup IDs; `message` is plain words an agent can relay, and
* `exampleRequest` is a first request to suggest once an agent can use REA.
* `addAnalysisTool` is present only when no native analysis tool is ready.
*/
export interface SetupNextStep {
readonly action: "restart_clients" | "open_clients" | "connect_client";
readonly clients: readonly string[];
readonly message: string;
readonly exampleRequest?: string;
readonly addAnalysisTool?: string;
}
/**
* How to add a native analysis tool, in plain words, pointing at the guide
* section for this operating system. Hopper does not run on Windows.
*/
export const addAnalysisToolMessage = (platform: NodeJS.Platform): string =>
platform === "win32"
? "To look inside programs such as .exe files, add Ghidra, a free tool that turns compiled programs into readable code: rea.tools/get-started/#ghidra. You can ask your agent to set it up."
: "To look inside compiled programs, add Hopper (its free demo mode works with REA) or Ghidra: rea.tools/get-started/#native. You can ask your agent to set it up.";
/** A first request that works for any app; brackets mark what to fill in. */
export const SETUP_EXAMPLE_REQUEST =
"Use REA to find out how [a feature] works in [an app on this computer].";
@@ -59,6 +71,19 @@ export const readySetupClients = (
export const setupNextStep = (
clients: Readonly<Record<string, ClientConfigurationResult>>,
doctor: SetupDoctorSummary,
platform: NodeJS.Platform,
): SetupNextStep => {
const step = clientNextStep(clients, doctor);
return doctor.availableProviders.some((id) =>
NATIVE_ANALYSIS_PROVIDER_IDS.has(id),
)
? step
: { ...step, addAnalysisTool: addAnalysisToolMessage(platform) };
};
const clientNextStep = (
clients: Readonly<Record<string, ClientConfigurationResult>>,
doctor: SetupDoctorSummary,
): SetupNextStep => {
const changed = changedSetupClients(clients);
if (changed.length > 0) {
@@ -689,14 +689,27 @@ describe("analysis provider registry: rejection origins", () => {
const registry = new AnalysisProviderRegistry([
candidate("alpha", { available: false, unconfigured: true }).provider,
candidate("gamma", { available: false, unconfigured: true }).provider,
candidate("delta", { available: false, unsupportedHost: true }).provider,
]);
const selection = await registry.select(DATABASE_TARGET);
if (!selection.ok) throw selection.error;
const projected = projectAnalysisError(
registry.unboundOperationError("binary_overview", selection.value),
);
expect(projected.message).toContain(
"Provider selection failed local readiness checks. No target-support refusal was reported.",
expect(projected.message).toBe(
"No analysis tool that can open this file is set up on this computer yet.",
);
// The recovery offers only providers this host can run, and asks first.
const action = projected.remediation.action ?? "";
expect(action).toContain(
"Providers that can run on this host: alpha: Repair the fixture provider. gamma: Repair the fixture provider.",
);
expect(action).not.toContain("delta");
expect(action).toContain(
"Ask the person which one, if any, they want set up. If they agree,",
);
expect(action).toContain(
"Without a provider, open_binary and inspect_artifact still identify the file",
);
expect(projected.details).toMatchObject({
rejections: [
@@ -705,6 +718,11 @@ describe("analysis provider registry: rejection origins", () => {
origin: "availability",
code: "not_configured",
},
{
provider_id: "delta",
origin: "availability",
code: "unsupported_host",
},
{
provider_id: "gamma",
origin: "availability",
@@ -774,9 +792,19 @@ describe("analysis provider registry: rejection origins", () => {
diagnostics: { target_kind: "archive" },
}),
};
const unconfiguredAndRefusing: AnalysisProviderCandidate = {
...candidate("gamma", { available: false, unconfigured: true }).provider,
inspectTargetSupport: () => ({
status: "unsupported",
code: "target_format_unsupported",
reason: "gamma refuses archives",
diagnostics: { target_kind: "archive" },
}),
};
const mixed = new AnalysisProviderRegistry([
unconfiguredButAdmitting,
refusingTarget,
unconfiguredAndRefusing,
]);
const mixedSelection = await mixed.select(ARTIFACT_TARGET);
expect(mixedSelection.ok).toBe(true);
@@ -792,10 +820,22 @@ describe("analysis provider registry: rejection origins", () => {
origin: string;
code: string;
}[];
expect(rejections).toMatchObject([
{ origin: "availability", code: "not_configured" },
{ origin: "target", code: "target_format_unsupported" },
]);
// Setting up a provider that refuses this file cannot help.
const action = projected.remediation.action ?? "";
expect(action).toContain("Providers that can run on this host: alpha:");
expect(action).not.toContain("gamma:");
expect(rejections).toEqual(
expect.arrayContaining([
expect.objectContaining({
origin: "availability",
code: "not_configured",
}),
expect.objectContaining({
origin: "target",
code: "target_format_unsupported",
}),
]),
);
}
});
});
@@ -914,6 +954,7 @@ const candidate = (
options: {
readonly available?: boolean;
readonly unconfigured?: boolean;
readonly unsupportedHost?: boolean;
readonly profile?: "resolved" | "missing" | "error";
} = {},
): CandidateFixture => {
@@ -937,9 +978,15 @@ const candidate = (
}
: {
status: "unavailable",
code: options.unconfigured ? "not_configured" : "runtime_missing",
code: options.unsupportedHost
? "unsupported_host"
: options.unconfigured
? "not_configured"
: "runtime_missing",
reason: `${id} runtime is unavailable`,
remediation: "Repair the fixture provider.",
remediation: options.unsupportedHost
? "Use another host."
: "Repair the fixture provider.",
diagnostics: { executable_path: `/opt/${id}/bin/analyze` },
},
inspectTargetSupport: (target): ProviderTargetSupport =>
@@ -22,10 +22,10 @@ import type { AnalysisError } from "../../domain/analysisErrorBase.js";
import { createAnalysisExecutionEvidence } from "../../domain/analysisObservation.js";
import type { BinaryTarget } from "../../domain/binaryTargetTypes.js";
import { ok, type Result } from "../../domain/result.js";
import { NATIVE_ANALYSIS_PROVIDER_IDS } from "../../domain/providerSelection.js";
import { admitCompletedAnalysis } from "../investigation/admitCompletedAnalysis.js";
import type { RecoveryAdmission } from "../investigation/InvestigationRetention.js";
const NATIVE_PROVIDERS = new Set(["hopper", "ghidra", "ida", "kuna"]);
const executionSelections = new WeakMap<
AnalysisExecution,
| {
@@ -48,7 +48,7 @@ export const bindFreshNativeExecution = (
const binding = route.binding;
if (
binding === null ||
!NATIVE_PROVIDERS.has(binding.identity.id) ||
!NATIVE_ANALYSIS_PROVIDER_IDS.has(binding.identity.id) ||
execution.provider.id !== binding.identity.id ||
(execution.provider.version !== null &&
binding.identity.version !== null &&
@@ -1,4 +1,5 @@
import type { ProviderProcessInspectionCleanup } from "../../process/ProviderProcess.js";
import { toolSetupRemediation } from "../../domain/toolSetupRemediation.js";
import {
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
@@ -242,7 +243,10 @@ export const projectFailure = (
? unavailable(
"executable_missing",
cause.message,
"Install x11-utils, or set REA_XPROP_COMMAND to an xprop executable.",
toolSetupRemediation(
"xprop",
"Install x11-utils, or set REA_XPROP_COMMAND to an xprop executable.",
),
)
: cause,
signal,
@@ -1,4 +1,5 @@
import { access, stat } from "node:fs/promises";
import { toolSetupRemediation } from "../../domain/toolSetupRemediation.js";
import { HOST_PLATFORM } from "../../platform/HostPlatform.js";
import { constants } from "node:fs";
import { isAbsolute } from "node:path";
@@ -10,6 +11,10 @@ import { snapshotEnvironment } from "../../process/snapshotEnvironment.js";
const OPERATION = "inspect_web_network_capture";
const MITMDUMP_REQUIREMENT =
"Native capture decoding requires an absolute REA_MITMDUMP_COMMAND path to caller-supplied mitmdump 12.3.1; HAR needs no external engine.";
const MITMDUMP_SETUP_REMEDIATION = toolSetupRemediation(
"mitmproxy",
"Set REA_MITMDUMP_COMMAND to the absolute path of mitmdump 12.3.1, or supply a HAR capture, which needs no external engine.",
);
/** Native mitmproxy decoding is offline and uses only an explicitly configured Linux tool. */
export class MitmproxyCaptureAdapter implements HistoricalCaptureFormatAdapter {
@@ -50,7 +55,10 @@ export class MitmproxyCaptureAdapter implements HistoricalCaptureFormatAdapter {
"mitmproxy",
OPERATION,
MITMDUMP_REQUIREMENT,
{ userMessage: MITMDUMP_REQUIREMENT },
{
userMessage: MITMDUMP_REQUIREMENT,
remediationAction: MITMDUMP_SETUP_REMEDIATION,
},
);
try {
await access(command, constants.R_OK | constants.X_OK);
@@ -1,4 +1,5 @@
import { QueuedProviderClose } from "../../providers/QueuedProviderClose.js";
import { toolSetupRemediation } from "../../domain/toolSetupRemediation.js";
import { snapshotEnvironment } from "../../process/snapshotEnvironment.js";
import { HOST_PLATFORM } from "../../platform/HostPlatform.js";
import {
@@ -150,6 +151,10 @@ export class NativeModuleResolver implements WebModuleResolutionPort {
{
userMessage:
"Provide an absolute REA_BROWSER_EXECUTABLE for a caller-supplied Chromium browser supporting import.meta.resolve. REA installs no browser.",
remediationAction: toolSetupRemediation(
"chromium",
"Set REA_BROWSER_EXECUTABLE to the absolute path of a Chromium-based browser that supports import.meta.resolve.",
),
...(executable === undefined
? {}
: { diagnostics: { executable } }),
+4 -1
View File
@@ -1,4 +1,5 @@
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { capturedProviderOutput } from "../process/capturedProviderOutput.js";
import {
readerIntegrityFailure,
@@ -493,8 +494,10 @@ export class TsharkCaptureProvider implements PacketCapturePort {
limits: { selected: limits, defaults, output: outputControl },
effectiveLimits,
observedOutput: capturedOutput,
configurationHelp:
configurationHelp: toolSetupRemediation(
"tshark",
"On Linux, supply TShark 4.x on PATH or through absolute REA_TSHARK_COMMAND, and util-linux prlimit through REA_TSHARK_PRLIMIT_COMMAND (default /usr/bin/prlimit).",
),
readerIntegrity: (failure) =>
readerIntegrityFailure(operation, resourcePath, failure),
});
+4
View File
@@ -319,6 +319,10 @@ const renderReadyCapabilities = (
writeLine("│ Ask your agent something like:");
writeLine(`│ "${nextStep.exampleRequest}"`);
}
if (nextStep?.addAnalysisTool !== undefined) {
writeLine("│");
writeLine(`│ ${nextStep.addAnalysisTool}`);
}
};
/** The terminal's wording of the next step; its picker needs Space. */
+10 -13
View File
@@ -10,20 +10,17 @@ it("retains provider-owned configuration diagnostics and repair in public refusa
command_source: "environment",
},
});
expect(
projectAnalysisError(
providerConfigurationRefusal(
"apktool",
"inspect_apktool_client",
failure,
),
),
).toMatchObject({
const error = providerConfigurationRefusal(
"apktool",
"inspect_apktool_client",
failure,
);
expect(error.userMessage).toBe("version unreadable.");
expect(error.remediationAction).toBe(failure.remediation);
expect(projectAnalysisError(error)).toMatchObject({
code: "capability_unavailable",
message: "version unreadable. Inspect the selected launcher.",
remediation: {
action: "version unreadable. Inspect the selected launcher.",
},
message: "version unreadable.",
remediation: { action: "Inspect the selected launcher." },
details: { diagnostics: failure.diagnostics },
});
});
+14 -6
View File
@@ -11,10 +11,18 @@ export const providerConfigurationRefusal = (
readonly diagnostics?: Readonly<Record<string, JsonValue>>;
},
): AnalysisCapabilityUnavailableError => {
const reason = `${failure.message}. ${failure.remediation}`;
return new AnalysisCapabilityUnavailableError(providerId, operation, reason, {
cause: failure,
userMessage: reason,
diagnostics: failure.diagnostics,
});
const message = /[.!?]$/u.test(failure.message)
? failure.message
: `${failure.message}.`;
return new AnalysisCapabilityUnavailableError(
providerId,
operation,
failure.message,
{
cause: failure,
userMessage: message,
remediationAction: failure.remediation,
diagnostics: failure.diagnostics,
},
);
};
+8
View File
@@ -15,6 +15,14 @@ export const analysisProviderSelectorSchema = z.union([
analysisProviderIdSchema,
]);
/** Providers that analyze native machine code, such as a Windows .exe. */
export const NATIVE_ANALYSIS_PROVIDER_IDS: ReadonlySet<string> = new Set([
"hopper",
"ghidra",
"ida",
"kuna",
]);
/** Stable reasons a deep provider cannot participate in target selection. */
export const PROVIDER_REJECTION_CODES = [
"not_configured",
+54 -4
View File
@@ -71,7 +71,9 @@ export class ProviderSelectionError extends AnalysisError {
diagnostics: structuredClone(rejection.diagnostics),
}));
this.remediationAction =
options.remediationAction ?? requestedProviderRepair(options);
options.remediationAction ??
requestedProviderRepair(options) ??
noReadyProviderRecovery(options);
this.userMessage =
options.userMessage ?? providerSelectionUserMessage(options);
}
@@ -102,6 +104,52 @@ const requestedProviderRepair = (
)?.remediation
: undefined;
/**
* With no provider requested and none ready, the next step is one of the
* providers this host can run, set up with the person's agreement. Providers
* that cannot run on this host are not offered.
*/
const noReadyProviderRecovery = (
options: ProviderSelectionErrorOptions,
): string | undefined => {
if (
options.reason !== "provider_unavailable" ||
options.requestedProviderId !== "auto"
)
return undefined;
const unavailable = (options.rejections ?? []).filter(
({ origin }) => origin === "availability",
);
if (unavailable.length === 0) return undefined;
const refusedTarget = new Set(
(options.rejections ?? [])
.filter(({ origin }) => origin === "target")
.map(({ providerId }) => providerId),
);
const settable = unavailable.filter(
({ providerId, code, remediation }) =>
code !== "unsupported_host" &&
remediation !== undefined &&
!refusedTarget.has(providerId),
);
const choices =
settable.length === 0
? "No analysis provider for this target can run on this host."
: `Providers that can run on this host: ${settable
.map(
({ providerId, remediation }) =>
`${providerId}: ${remediation ?? ""}`,
)
.join(
" ",
)} Ask the person which one, if any, they want set up. If they agree, set it up, rerun \`rea setup\` so the client registration records its location, restart the client, and retry.`;
return `${choices} ${WITHOUT_PROVIDER}`;
};
/** What static inspection still offers when no deep provider is ready. */
const WITHOUT_PROVIDER =
"Without a provider, open_binary and inspect_artifact still identify the file and inspect packaged applications (Electron, .NET, Python, Bun, Deno).";
/** True when every recorded rejection describes availability, not target support. */
const providerAvailabilityOnly = (
rejections: readonly ProviderSelectionRejection[] | undefined,
@@ -119,9 +167,11 @@ const providerSelectionUserMessage = (
case "unknown_provider":
return `The requested analysis provider is unknown. Choose one of: ${options.candidateIds.join(", ") || "no configured providers"}.`;
case "provider_unavailable":
return providerAvailabilityOnly(options.rejections)
? "Provider selection failed local readiness checks. No target-support refusal was reported. Review the local provider diagnostics or run `rea doctor`, then retry."
: "The selected analysis provider is unavailable. Review the reported local diagnostics or run `rea doctor`, then retry.";
if (!providerAvailabilityOnly(options.rejections))
return "The selected analysis provider is unavailable. Review the reported local diagnostics or run `rea doctor`, then retry.";
return options.requestedProviderId === "auto"
? "No analysis tool that can open this file is set up on this computer yet."
: "Provider selection failed local readiness checks. No target-support refusal was reported. Review the local provider diagnostics or run `rea doctor`, then retry.";
case "target_unsupported":
return "The selected analysis provider does not support this target. Choose another provider or open a supported extracted binary.";
case "invalid_options":
+62
View File
@@ -0,0 +1,62 @@
/**
* Plain descriptions of the external tools REA can use but does not install.
* Setting one up is the person's decision, so a repair for a missing tool
* starts with what it is and what setting it up installs, for the agent to
* explain before asking.
*/
export const EXTERNAL_TOOL_ABOUT = {
adb: "adb is Android's command-line tool for talking to phones and emulators; setting it up installs Google's Android SDK Platform-Tools.",
agentenv:
"agentenv-framework packages desktop apps as environments for AI agents; setting it up installs it as a uv tool.",
apktool:
"Apktool is an open-source tool that unpacks Android apps into their resources and code; setting it up installs Apktool, which needs Java.",
binwalk:
"Binwalk is an open-source tool that finds files and code inside firmware images; setting it up installs Binwalk.",
chromium:
"REA resolves JavaScript modules in a Chromium-based browser such as Google Chrome; setting one up installs that browser.",
docker:
"Docker runs programs in isolated containers, and REA builds each desktop environment inside one; setting it up installs Docker Engine.",
gdb: "GDB is the GNU debugger, an open-source tool for inspecting programs and crash dumps; setting it up installs GDB.",
ghidra:
"Ghidra is an open-source reverse-engineering tool that turns compiled programs into readable code; setting it up installs Java and Ghidra.",
hopper:
"Hopper Disassembler is a reverse-engineering app for macOS and Linux that turns compiled programs into readable code; REA works with its free demo mode, which has the vendor's demo limits. Setting it up installs the Hopper app.",
ida: "IDA is Hex-Rays' reverse-engineering tool that turns compiled programs into readable code; setting it up installs IDA and its MCP server.",
jadx: "JADX is an open-source tool that turns Android apps back into readable Java code; setting it up downloads its jadx-headless-mcp JAR and needs a full Java JDK.",
jeb: "JEB is PNF Software's reverse-engineering tool for Android apps and native code; using it needs JEB installed and running its MCP server.",
kuna: "Kuna is an open-source decompiler, shipped as one kuna executable, that turns compiled programs into readable code; setting it up installs that executable.",
mitmproxy:
"mitmdump is part of mitmproxy, an open-source tool for capturing and reading web traffic; setting it up installs mitmproxy.",
objdump:
"objdump is an open-source GNU binutils tool that lists a program's machine code; setting it up installs binutils.",
procps:
"procps provides the standard ps program that lists running processes; setting it up installs a system package with sudo.",
pwntools:
"pwntools is an open-source Python library for working with compiled programs; setting it up installs Python packages.",
rizin:
"Rizin is an open-source reverse-engineering framework; setting it up installs Rizin.",
sigrok:
"sigrok-cli is the open-source sigrok tool that decodes logic-analyzer recordings; setting it up installs sigrok-cli and its decoders.",
tshark:
"TShark is the command-line part of Wireshark, the open-source network-packet analyzer; setting it up installs Wireshark's command-line tools.",
unblob:
"Unblob is an open-source tool that unpacks firmware images and archives; setting it up installs Unblob and its helper programs.",
wabt: "WABT, the WebAssembly Binary Toolkit, is a set of open-source tools that check and print WebAssembly modules; setting it up installs WABT.",
wakaru:
"Wakaru is an open-source tool that unminifies and unbundles JavaScript; setting it up installs Wakaru.",
xprop:
"xprop is a small X11 tool, in the x11-utils package, that reads window details; setting it up installs a system package with sudo.",
yara: "YARA is an open-source tool that scans files for patterns described in rules; setting it up installs YARA.",
} as const;
export type ExternalToolName = keyof typeof EXTERNAL_TOOL_ABOUT;
/** The sentence that keeps the install decision with the person. */
export const ASK_BEFORE_INSTALLING =
"Explain this to the person and ask before installing it.";
/** Repair for a tool that is not set up: what it is, ask first, then the steps. */
export const toolSetupRemediation = (
tool: ExternalToolName,
steps: string,
): string => `${EXTERNAL_TOOL_ABOUT[tool]} ${ASK_BEFORE_INSTALLING} ${steps}`;
+7 -1
View File
@@ -1,4 +1,5 @@
import { createTestArtifactResourceScope } from "../../tests/fixtures/artifactResourceScope.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { cleanupOwnedProcessGroup } from "../process/ProcessOwnership.js";
import { EventEmitter } from "node:events";
import { chmod, mkdir, writeFile } from "node:fs/promises";
@@ -229,7 +230,12 @@ test("names the host and tool requirement of an unconfigured engine", async () =
expect(projectAnalysisError(refusal)).toMatchObject({
code: "capability_unavailable",
message: refusal.reason,
remediation: { action: refusal.reason },
remediation: {
action: toolSetupRemediation(
"binwalk",
"Set REA_BINWALK_COMMAND to the absolute path of Binwalk 3.1.x (verified with 3.1.0).",
),
},
});
expect(refusal.reason).toContain("REA_BINWALK_COMMAND");
});
+11 -6
View File
@@ -1,4 +1,5 @@
import { capturedProviderOutput } from "../process/capturedProviderOutput.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import {
processInspectionCancellationError,
retainProcessInspectionCleanup,
@@ -143,12 +144,16 @@ export const resolveFirmwareCommand = async (
});
}
const configured = environment[variable];
if (configured === undefined || !isAbsolute(configured))
throw firmwareToolUnavailable(
engine,
operation,
`This integration requires an absolute ${variable} path to the caller-supplied tool`,
);
if (configured === undefined || !isAbsolute(configured)) {
const reason = `This integration requires an absolute ${variable} path to the caller-supplied tool`;
throw new AnalysisCapabilityUnavailableError(engine, operation, reason, {
userMessage: reason,
remediationAction: toolSetupRemediation(
engine,
`Set ${variable} to the absolute path of ${FIRMWARE_TOOL_REQUIREMENTS[engine].requirement}.`,
),
});
}
const selection = await selectArtifactCommandPath(configured, signal).catch(
(cause: unknown) => {
if (cause instanceof ArtifactReaderFailure) throw cause;
+4 -1
View File
@@ -2,6 +2,7 @@ import {
unknownTarget,
type SessionTargetIdentity,
} from "../domain/targetIdentity.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { capturedProviderOutput } from "../process/capturedProviderOutput.js";
import {
observeDebuggerLaunchFile,
@@ -144,8 +145,10 @@ const gdbLaunchUnavailable = (
{
...details,
userMessage: reason,
remediationAction:
remediationAction: toolSetupRemediation(
"gdb",
"Set REA_GDB_COMMAND to an installed executable GDB command, or make that command available on PATH. Check execute permission on the command and search permission on its parent directories before retrying.",
),
},
);
};
+6 -1
View File
@@ -1,4 +1,5 @@
import { posix, win32 } from "node:path";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import type { ProviderRejectionCode } from "../domain/providerSelection.js";
import type { Result } from "../domain/result.js";
@@ -29,6 +30,7 @@ import {
ghidraReleaseCompatibility,
ghidraReleaseLine,
ghidraVersionDetail,
SUPPORTED_GHIDRA_JAVA_MAJOR,
SUPPORTED_GHIDRA_VERSION,
} from "./GhidraReleasePolicy.js";
@@ -163,7 +165,10 @@ const configurationCheck = (
passed: installDir !== null,
code: "not_configured",
detail: installDir ?? "GHIDRA_INSTALL_DIR is not set",
remediation: `Set GHIDRA_INSTALL_DIR to an extracted Ghidra ${ghidraReleaseLine()} release directory.`,
remediation: toolSetupRemediation(
"ghidra",
`Install a 64-bit JDK ${String(SUPPORTED_GHIDRA_JAVA_MAJOR)} or newer and extract a Ghidra ${ghidraReleaseLine()} release, then set GHIDRA_INSTALL_DIR to that release directory.`,
),
});
const settings = relative.join(" and ");
return installationCheck({
+5 -3
View File
@@ -70,7 +70,10 @@ import {
import { analysisClientFailureForOperation } from "../providers/AnalysisClientFailure.js";
import { hopperCapabilities } from "./HopperProviderCapabilities.js";
import { HOPPER_PROVIDER_IDENTITY } from "./HopperProviderMetadata.js";
import {
HOPPER_LAUNCHER_MISSING_REMEDIATION,
HOPPER_PROVIDER_IDENTITY,
} from "./HopperProviderMetadata.js";
import { errorMessage } from "../kernel/errorMessage.js";
/** Concrete analysis provider backed by REA's private Hopper bridge. */
@@ -152,8 +155,7 @@ export class HopperProvider implements AnalysisProviderCandidate {
status: "unavailable",
code: "executable_missing",
reason: `Hopper launcher is missing or not executable: ${this.#launcherSpelling}`,
remediation:
"Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH to an executable Hopper launcher in the environment that starts REA, then restart REA.",
remediation: HOPPER_LAUNCHER_MISSING_REMEDIATION,
diagnostics,
};
}
+7
View File
@@ -1,4 +1,5 @@
import type { ProviderIdentity } from "../ports/AnalysisProvider.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import type { OfficialToolName } from "../contracts/officialToolContracts.js";
/** Public identity committed by every Hopper-backed observation. */
@@ -8,6 +9,12 @@ export const HOPPER_PROVIDER_IDENTITY: ProviderIdentity = Object.freeze({
version: null,
});
/** Repair when no Hopper launcher is found: what Hopper is, then how to add it. */
export const HOPPER_LAUNCHER_MISSING_REMEDIATION = toolSetupRemediation(
"hopper",
"Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH to an executable Hopper launcher in the environment that starts REA, then restart REA.",
);
/** Analyst operations implemented by REA's private Hopper bridge. */
export const HOPPER_OPERATIONS = Object.freeze([
"address_name",
+7
View File
@@ -1,4 +1,5 @@
import { WindowsChangeTimeConfigurationError } from "../config/windowsChangeTimeSettle.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { MAX_NODE_TIMER_DELAY_MS } from "../domain/analysisResourceLimits.js";
import { isAbsolute } from "node:path";
import { z } from "zod";
@@ -417,3 +418,9 @@ export const idaConfigurationError = (
...(cause === undefined ? {} : { cause }),
settings: [{ setting: "REA_IDA_MCP_CONFIG", constraint }],
});
/** Remediation when no IDA registration is selected: what IDA is, then how. */
export const IDA_NOT_CONFIGURED_REMEDIATION = toolSetupRemediation(
"ida",
"Set REA_IDA_MCP_CONFIG to your upstream IDA MCP registration JSON; see docs/providers/ida-provider.md.",
);
+2 -1
View File
@@ -3,6 +3,7 @@ import type {
DoctorProviderInspection,
} from "../ports/DoctorProviderInspection.js";
import {
IDA_NOT_CONFIGURED_REMEDIATION,
readIdaConfiguration,
type IdaConfiguration,
} from "./IdaConfiguration.js";
@@ -70,7 +71,7 @@ export const inspectIdaRegistration = async (
remediation:
parsed !== undefined && !parsed.ok
? projectAnalysisError(parsed.error).remediation.action
: "Set REA_IDA_MCP_CONFIG to your upstream IDA MCP registration JSON; see docs/providers/ida-provider.md.",
: IDA_NOT_CONFIGURED_REMEDIATION,
classification:
path === undefined ? "missing_analysis_engine" : "config_drift",
},
+6
View File
@@ -16,6 +16,7 @@ import {
} from "../../tests/fixtures/idaMcp.js";
import { inspectIdaRegistration } from "./IdaDoctor.js";
import { IdaProvider } from "./IdaProvider.js";
import { IDA_NOT_CONFIGURED_REMEDIATION } from "./IdaConfiguration.js";
import { rawLoadAtEntry } from "../domain/rawBinary.fixture.js";
it.each([
@@ -56,6 +57,11 @@ it.each([
expect(snapshot.availability.diagnostics).not.toHaveProperty(
"configuration_remediation",
);
// An unset registration keeps IDA's explanation in the repair itself.
if (!selected && snapshot.availability.status === "unavailable")
expect(snapshot.availability.remediation).toBe(
IDA_NOT_CONFIGURED_REMEDIATION,
);
// Doctor reports the runtime's repair for a selected registration.
if (selected && snapshot.availability.status === "unavailable") {
const doctor = await inspectIdaRegistration(path, {
+11 -4
View File
@@ -29,7 +29,7 @@ import type {
ProviderTargetSupport,
} from "../ports/AnalysisProvider.js";
import type { AppConfig } from "../config/types.js";
import type { ConfigurationError } from "../domain/configurationErrors.js";
import { ConfigurationError } from "../domain/configurationErrors.js";
import { idaRegistrationDigest } from "./IdaRegistrationIdentity.js";
import { isDeepStrictEqual } from "node:util";
import type { Result } from "../domain/result.js";
@@ -39,6 +39,7 @@ import {
IDA_COMPATIBILITY_PROFILES,
type IdaConfiguration,
idaConfigurationError,
IDA_NOT_CONFIGURED_REMEDIATION,
} from "./IdaConfiguration.js";
import {
createIdaMcpConnection,
@@ -481,9 +482,15 @@ export class IdaProvider implements AnalysisProviderCandidate {
const readIdaConfigurationNotConfigured = () =>
err(
idaConfigurationError(
"Set REA_IDA_MCP_CONFIG to an upstream IDA MCP JSON registration; see docs/providers/ida-provider.md.",
),
new ConfigurationError("REA_IDA_MCP_CONFIG is not set.", {
settings: [
{
setting: "REA_IDA_MCP_CONFIG",
constraint: "must name an upstream IDA MCP registration JSON file",
},
],
remediationAction: IDA_NOT_CONFIGURED_REMEDIATION,
}),
);
/** Project IDA's admission refusal into provider availability. */
+7 -2
View File
@@ -1,4 +1,5 @@
import { JEB_PROVIDER_IDENTITY } from "./JebProviderIdentity.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import {
JebMcpCleanupFailure,
JebMcpPhysicalFailure,
@@ -56,7 +57,11 @@ import {
} from "./JebMcpConnection.js";
import { errorMessage } from "../kernel/errorMessage.js";
const JEB_CONNECTION_REMEDIATION = `Start a JEB client serving MCP (default ${DEFAULT_JEB_MCP_ENDPOINT}) or set REA_JEB_MCP_URL to the running endpoint.`;
const JEB_CONNECTION_STEPS = `Start a JEB client serving MCP (default ${DEFAULT_JEB_MCP_ENDPOINT}) or set REA_JEB_MCP_URL to the running endpoint.`;
const JEB_CONNECTION_REMEDIATION = toolSetupRemediation(
"jeb",
JEB_CONNECTION_STEPS,
);
export interface JebProviderOptions {
/** Caller environment carrying REA_JEB_MCP_URL. */
@@ -619,7 +624,7 @@ export class JebProvider implements JebAnalysisPort {
"jeb",
operation,
errorMessage(physical),
{ cause, diagnostics, userMessage: JEB_CONNECTION_REMEDIATION },
{ cause, diagnostics, userMessage: JEB_CONNECTION_STEPS },
);
},
};
+10 -5
View File
@@ -21,6 +21,7 @@ import { providerStartupTimeoutSchema } from "../config/providerStartupTimeout.j
import { err, ok, type Result } from "../domain/result.js";
import {
KUNA_COMMAND_REMEDIATION,
KUNA_NOT_CONFIGURED_REMEDIATION,
KUNA_UNSUPPORTED_HOST_REMEDIATION,
} from "./KunaRelease.js";
import { analysisSettingLimit } from "../domain/analysisSettingDefinitions.js";
@@ -195,9 +196,11 @@ const failure = (
remediation:
code === "unsupported_host"
? KUNA_UNSUPPORTED_HOST_REMEDIATION
: setting === null || setting === "REA_KUNA_COMMAND"
? KUNA_COMMAND_REMEDIATION
: `Correct ${setting} to meet the reported constraint, or unset it to use its default. Restart REA after changing the environment.`,
: code === "not_configured"
? KUNA_NOT_CONFIGURED_REMEDIATION
: setting === null || setting === "REA_KUNA_COMMAND"
? KUNA_COMMAND_REMEDIATION
: `Correct ${setting} to meet the reported constraint, or unset it to use its default. Restart REA after changing the environment.`,
});
/**
@@ -286,6 +289,10 @@ export const readKunaConfiguration = (
environment: Readonly<NodeJS.ProcessEnv>,
platform: NodeJS.Platform,
): Result<KunaConfiguration, KunaConfigurationFailure> => {
// Host support comes first: no setting makes this host usable, so an
// unset command must not read as a repair the person could make.
if (platform !== "darwin" && platform !== "linux")
return failure("unsupported_host", KUNA_UNSUPPORTED_HOST_REMEDIATION);
const command = environment.REA_KUNA_COMMAND;
if (command === undefined || command.length === 0)
return failure("not_configured", "REA_KUNA_COMMAND is not set.");
@@ -295,8 +302,6 @@ export const readKunaConfiguration = (
`REA_KUNA_COMMAND must be an absolute path; received ${command}. ${KUNA_COMMAND_REMEDIATION}`,
"REA_KUNA_COMMAND",
);
if (platform !== "darwin" && platform !== "linux")
return failure("unsupported_host", KUNA_UNSUPPORTED_HOST_REMEDIATION);
const cacheRoot = environment.REA_KUNA_CACHE_DIR;
if (cacheRoot !== undefined && !isAbsolute(cacheRoot))
+8
View File
@@ -1,3 +1,5 @@
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
/** Kuna release whose CLI and project layout REA verified; others report as unverified. */
export const KUNA_VERIFIED_VERSION = "1.1000";
@@ -14,6 +16,12 @@ export const KUNA_PROVIDER_ID = "kuna";
/** Remediation when `REA_KUNA_COMMAND` is missing or not an absolute path. */
export const KUNA_COMMAND_REMEDIATION = `Set REA_KUNA_COMMAND to the absolute path of a caller-supplied kuna executable (verified with ${KUNA_VERIFIED_VERSION}). REA does not download, install or update Kuna.`;
/** Remediation when no Kuna is selected: what Kuna is, then how to select one. */
export const KUNA_NOT_CONFIGURED_REMEDIATION = toolSetupRemediation(
"kuna",
KUNA_COMMAND_REMEDIATION,
);
/** Remediation when the host cannot supervise a Kuna process tree. */
export const KUNA_UNSUPPORTED_HOST_REMEDIATION =
"Use Linux or macOS for the Kuna provider. Windows process-tree ownership for Kuna is not verified.";
+1
View File
@@ -1,4 +1,5 @@
import { finalizedResult, runOwned } from "../../providers/runOwned.js";
import { toolSetupRemediation } from "../../domain/toolSetupRemediation.js";
import {
capturedProviderOutput,
providerResultDiagnostics,
+5 -1
View File
@@ -1,3 +1,5 @@
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
/** Source-owned static provider identity and public operation names. */
export const OBJDUMP_PROVIDER_IDENTITY = {
id: "objdump.command",
@@ -9,6 +11,8 @@ export const OBJDUMP_PROVIDER_IDENTITY = {
export const OBJDUMP_COMMAND_REPAIR = {
provider: "objdump",
setting: "REA_OBJDUMP_COMMAND",
remediationAction:
remediationAction: toolSetupRemediation(
"objdump",
"Set REA_OBJDUMP_COMMAND to an installed executable GNU objdump command, or make that command available on PATH. Check execute permission on the command and search permission on its parent directories before retrying.",
),
} as const;
+8 -2
View File
@@ -2,6 +2,7 @@ import {
isExecutableFileSync,
isRegularFileSync,
} from "../filesystem/regularFileProbe.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { isAbsolute } from "node:path";
import {
@@ -58,7 +59,11 @@ export const TSHARK_COMMAND_ENV = "REA_TSHARK_COMMAND";
export const CAPINFOS_COMMAND_ENV = "REA_CAPINFOS_COMMAND";
/** Repair for any unusable caller-selected Wireshark tool; shared by readiness and execution. */
export const PCAP_TOOL_REMEDIATION = `Supply Wireshark 4.x tshark and capinfos on PATH or through absolute ${TSHARK_COMMAND_ENV} and ${CAPINFOS_COMMAND_ENV}; REA does not install them.`;
const PCAP_TOOL_STEPS = `Supply Wireshark 4.x tshark and capinfos on PATH or through absolute ${TSHARK_COMMAND_ENV} and ${CAPINFOS_COMMAND_ENV}; REA does not install them.`;
export const PCAP_TOOL_REMEDIATION = toolSetupRemediation(
"tshark",
PCAP_TOOL_STEPS,
);
/**
* Host-tool refusals concern the caller's Wireshark installation, not the
@@ -71,8 +76,9 @@ export const pcapToolUnavailable = (
options?: AnalysisErrorOptions,
): AnalysisCapabilityUnavailableError =>
new AnalysisCapabilityUnavailableError("pcap", operation, reason, {
remediationAction: PCAP_TOOL_REMEDIATION,
...options,
userMessage: `${/[.!?]$/u.test(reason) ? reason : `${reason}.`} ${PCAP_TOOL_REMEDIATION}`,
userMessage: /[.!?]$/u.test(reason) ? reason : `${reason}.`,
});
/** How one caller-supplied Wireshark tool was selected. */
+5 -1
View File
@@ -1,3 +1,5 @@
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
/** Source-owned static provider identity and public operation names. */
export const RIZIN_PROVIDER_IDENTITY = {
id: "rizin",
@@ -9,6 +11,8 @@ export const RIZIN_PROVIDER_IDENTITY = {
export const RIZIN_COMMAND_REPAIR = {
provider: "rizin",
setting: "REA_RIZIN_COMMAND",
remediationAction:
remediationAction: toolSetupRemediation(
"rizin",
"Set REA_RIZIN_COMMAND to an installed executable Rizin command, or make that command available on PATH. Check execute permission on the command and search permission on its parent directories before retrying.",
),
} as const;
+5 -5
View File
@@ -13,7 +13,10 @@ import { registerServiceTools } from "./serviceToolBindings.js";
import type { SessionLifecycleOptions } from "./sessionLifecycle.js";
import type { SessionStatusToolOptions } from "./sessionStatusTool.js";
import { sessionAvailabilityPolicy } from "./sessionAvailabilityPolicy.js";
import type { AvailabilityPolicy } from "../application/CapabilityInventory.js";
import {
type AvailabilityPolicy,
UNCONFIGURED_JADX_REMEDIATION,
} from "../application/CapabilityInventory.js";
import { withAdmittedAnalysis } from "./analysisAdmission.js";
import { errorMessage } from "../kernel/errorMessage.js";
import type { ArtifactPathInspectionDependencies } from "../application/artifacts/ArtifactPathInspection.js";
@@ -152,9 +155,6 @@ const missingAndroidAvailability = async (): Promise<ProviderAvailability> => ({
status: "unavailable",
code: "not_configured",
reason: "No Android JADX analysis provider is configured.",
// The Android boundary owns the versioned remediation; this composition
// default names no release so it cannot drift from the pinned engine.
remediation:
"Set REA_JADX_MCP_JAR to a caller-supplied jadx-headless-mcp JAR (rea doctor --provider jadx names its download URL and SHA-256) and provide a full JDK on Linux, macOS, or Windows x64 with its matching bundled native controls.",
remediation: UNCONFIGURED_JADX_REMEDIATION,
diagnostics: { configured: false },
});
+4 -1
View File
@@ -1,4 +1,5 @@
import { capturedProviderOutput } from "../process/capturedProviderOutput.js";
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
import { classifyProviderFailure } from "../providers/classifyProviderFailure.js";
import {
recordingProducerFailureDialect,
@@ -467,8 +468,10 @@ export class SigrokRecordingProvider implements SignalRecordingPort {
},
effectiveLimits,
observedOutput: capturedOutput,
configurationHelp:
configurationHelp: toolSetupRemediation(
"sigrok",
"On Linux, configure sigrok-cli 0.7.2 through REA_SIGROK_COMMAND and util-linux prlimit through REA_SIGROK_PRLIMIT_COMMAND (default /usr/bin/prlimit).",
),
configurationDiagnostics: (failure) =>
failure instanceof UnattributedVersionProbeFailure
? { version_probe_status_owner: failure.statusOwner }
+9 -1
View File
@@ -1,4 +1,8 @@
import { MAX_NODE_TIMER_DELAY_MS } from "../domain/analysisResourceLimits.js";
import {
ASK_BEFORE_INSTALLING,
EXTERNAL_TOOL_ABOUT,
} from "../domain/toolSetupRemediation.js";
import { analysisSettingLimit } from "../domain/analysisSettingDefinitions.js";
import {
ArtifactReaderFailure,
@@ -113,7 +117,11 @@ export const wabtConfigurationRecoveryAction = (cause?: unknown): string => {
: code === "ENOENT"
? "The reported configured tool is missing. "
: "";
return `${action}Set absolute REA_WABT_BIN_DIRECTORY to a directory that contains wasm-validate, wasm-objdump and wasm2wat from one WABT installation; each --version must report ${WABT_ACCEPTED_RANGE} on stdout with empty stderr. Releases in that range other than ${WABT_VERSION} are admitted and reported as the observed banner. Correct the reported tool path, access or release before retrying, not the WASM input. Set this in the shell for the next CLI call, or in the MCP server launch environment and restart that server; a shell export does not update a running MCP server. Do not repeat the unchanged call or install tools implicitly.`;
const about =
code === undefined || code === "ENOENT"
? `${EXTERNAL_TOOL_ABOUT.wabt} ${ASK_BEFORE_INSTALLING} `
: "";
return `${about}${action}Set absolute REA_WABT_BIN_DIRECTORY to a directory that contains wasm-validate, wasm-objdump and wasm2wat from one WABT installation; each --version must report ${WABT_ACCEPTED_RANGE} on stdout with empty stderr. Releases in that range other than ${WABT_VERSION} are admitted and reported as the observed banner. Correct the reported tool path, access or release before retrying, not the WASM input. Set this in the shell for the next CLI call, or in the MCP server launch environment and restart that server; a shell export does not update a running MCP server. Do not repeat the unchanged call or install tools implicitly.`;
};
/** The configured WABT installation cannot run this call. */
const wabtUnavailable = (
+6 -2
View File
@@ -1,3 +1,5 @@
import { toolSetupRemediation } from "../domain/toolSetupRemediation.js";
/** Caller-selected yara command; its implementation and version are not observed. */
export const YARA_PROVIDER_IDENTITY = {
id: "yara.command",
@@ -9,5 +11,7 @@ export const YARA_PROVIDER_IDENTITY = {
export const YARA_COMMAND_SETTING = "REA_YARA_COMMAND";
/** How a caller repairs a yara command that cannot be started. */
export const YARA_COMMAND_REMEDIATION =
"Install YARA 4.x, then make the yara command available on PATH or set REA_YARA_COMMAND to its executable. REA does not install yara or download rules. Other tools remain available.";
export const YARA_COMMAND_REMEDIATION = toolSetupRemediation(
"yara",
"Install YARA 4.x, then make the yara command available on PATH or set REA_YARA_COMMAND to its executable. REA does not install yara or download rules. Other tools remain available.",
);
+19 -9
View File
@@ -6,6 +6,7 @@ import {
unlink,
writeFile,
} from "node:fs/promises";
import { toolSetupRemediation } from "../../../src/domain/toolSetupRemediation.js";
import { createHash } from "node:crypto";
import { crc32 } from "node:zlib";
import { basename, dirname, join } from "node:path";
@@ -235,27 +236,32 @@ exit 1
const MISSING_ADB =
process.platform === "win32" ? "C:\\nonexistent\\adb" : "/nonexistent/adb";
const adbMissingRepair = toolSetupRemediation("adb", "Set REA_ADB_PATH");
it.each([
[
["inspect-adb-client", "--json"],
MISSING_ADB,
`The selected adb binary was not found: ${MISSING_ADB}. Set REA_ADB_PATH`,
`The selected adb binary was not found: ${MISSING_ADB}`,
adbMissingRepair,
],
[
["list-adb-devices", "--json"],
MISSING_ADB,
`The selected adb binary was not found: ${MISSING_ADB}. Set REA_ADB_PATH`,
`The selected adb binary was not found: ${MISSING_ADB}`,
adbMissingRepair,
],
[
["list-adb-devices", "--json"],
"relative/adb",
"REA_ADB_PATH must be an absolute path to the adb binary.",
"REA_ADB_PATH must be an absolute path to the adb binary",
"Set REA_ADB_PATH to an absolute adb executable path",
],
])(
"%j with REA_ADB_PATH=%s names the host requirement",
async (argv, binary, reason) => {
async (argv, binary, reason, repair) => {
const result = await serve(argv, { REA_ADB_PATH: binary });
expectConfigurationRefusal(result, reason);
expectConfigurationRefusal(result, reason, repair);
},
);
@@ -281,7 +287,8 @@ printf 'Android Debug Bridge version 1.0.41\\nVersion 34.0.5-cli\\n'
const result = await serve(argv, { REA_ADB_PATH: binary });
expectConfigurationRefusal(
result,
`Execution of the selected adb binary was denied (EACCES): ${binary}. Set REA_ADB_PATH to an absolute path to the adb executable file, not a directory`,
`Execution of the selected adb binary was denied (EACCES): ${binary}`,
"Set REA_ADB_PATH to an absolute path to the adb executable file, not a directory",
);
const { details } = JSON.parse(result.stdout) as {
details: { diagnostics: Record<string, unknown> };
@@ -306,7 +313,8 @@ printf 'Android Debug Bridge version 1.0.41\\nVersion 34.0.5-cli\\n'
});
expectConfigurationRefusal(
refused,
`The selected adb binary was not found: ${binary}. Set REA_ADB_PATH`,
`The selected adb binary was not found: ${binary}`,
adbMissingRepair,
);
const { details } = JSON.parse(refused.stdout) as {
details: { diagnostics: Record<string, unknown> };
@@ -363,7 +371,8 @@ it.skipIf(process.platform === "win32")(
);
expectConfigurationRefusal(
{ stdout, exitCode: 1 },
"Execution of the selected adb binary was denied (EACCES): adb. Make sure the adb found on PATH is a file with execute permission, not a directory",
"Execution of the selected adb binary was denied (EACCES): adb",
"Make sure the adb found on PATH is a file with execute permission, not a directory",
);
},
);
@@ -538,7 +547,8 @@ it.each([16, 17])(
if (count === 16) {
expectConfigurationRefusal(
result,
`The selected adb binary was not found: ${missingAdb}. Set REA_ADB_PATH`,
`The selected adb binary was not found: ${missingAdb}`,
adbMissingRepair,
);
} else {
expect(JSON.parse(result.stdout)).toMatchObject({
+15 -5
View File
@@ -1,4 +1,5 @@
import { expect, it } from "vitest";
import { toolSetupRemediation } from "../../../src/domain/toolSetupRemediation.js";
import {
expectConfigurationRefusal,
@@ -10,27 +11,35 @@ const MISSING_APKTOOL =
? "C:\\nonexistent\\apktool"
: "/nonexistent/apktool";
const apktoolMissingRepair = toolSetupRemediation(
"apktool",
"Set REA_APKTOOL_COMMAND",
);
it.each([
[
["inspect-apktool-client", "--json"],
MISSING_APKTOOL,
`The selected apktool launcher was not found: ${MISSING_APKTOOL}. Set REA_APKTOOL_COMMAND`,
`The selected apktool launcher was not found: ${MISSING_APKTOOL}`,
apktoolMissingRepair,
],
[
["decode-android-resources", "/targets/app.apk", "--json"],
MISSING_APKTOOL,
`The selected apktool launcher was not found: ${MISSING_APKTOOL}. Set REA_APKTOOL_COMMAND`,
`The selected apktool launcher was not found: ${MISSING_APKTOOL}`,
apktoolMissingRepair,
],
[
["decode-android-resources", "/targets/app.apk", "--json"],
"relative/apktool",
"REA_APKTOOL_COMMAND must be an absolute path to the apktool launcher.",
"REA_APKTOOL_COMMAND must be an absolute path to the apktool launcher",
"Set REA_APKTOOL_COMMAND to an absolute apktool launcher path",
],
])(
"%j with REA_APKTOOL_COMMAND=%s names the host requirement",
async (argv, command, reason) => {
async (argv, command, reason, repair) => {
const result = await serve(argv, { REA_APKTOOL_COMMAND: command });
expectConfigurationRefusal(result, reason);
expectConfigurationRefusal(result, reason, repair);
},
);
@@ -67,6 +76,7 @@ it("reports each invocation's effective exit status and restores the host status
expectConfigurationRefusal(
failed,
"The selected apktool launcher was not found",
apktoolMissingRepair,
);
expect(process.exitCode).toBe(23);
+6 -2
View File
@@ -12,10 +12,14 @@ export const serveCli = async (
environment: Readonly<Record<string, string | undefined>> = {},
): Promise<ServedCli> => serveInProcessCli(createCli(environment), argv);
/** A host tool configuration refusal names what to configure, not the target. */
/**
* A host tool configuration refusal names what to configure, not the target.
* The message is the refusal reason; the action is the owner's repair.
*/
export const expectConfigurationRefusal = (
result: ServedCli,
reason: string,
repair: string,
): void => {
expect(result.exitCode, result.stdout).toBe(1);
const output = JSON.parse(result.stdout) as {
@@ -25,5 +29,5 @@ export const expectConfigurationRefusal = (
};
expect(output.code).toBe("capability_unavailable");
expect(output.message).toEqual(expect.stringContaining(reason));
expect(output.remediation?.action).toEqual(expect.stringContaining(reason));
expect(output.remediation?.action).toEqual(expect.stringContaining(repair));
};
+47 -2
View File
@@ -917,6 +917,10 @@ describe("interactive setup completion", () => {
clients: Record<string, { status: string }>,
registrations: readonly { client: string; state: string }[],
environment: Readonly<Record<string, string>> = {},
host: {
readonly providers: readonly string[];
readonly platform: NodeJS.Platform;
} = { providers: ["hopper", "ghidra"], platform: "linux" },
) =>
execute(
process.execPath,
@@ -933,12 +937,12 @@ describe("interactive setup completion", () => {
clients,
doctor: {
healthy: true,
availableProviders: ["hopper", "ghidra"],
availableProviders: host.providers,
checks: [],
identity: { skill: { state: "aligned" }, registrations },
},
})};`,
"renderInteractiveSetupResult({ ...result, nextStep: setupNextStep(result.clients, result.doctor) });",
`renderInteractiveSetupResult({ ...result, nextStep: setupNextStep(result.clients, result.doctor, ${JSON.stringify(host.platform)}) });`,
].join("\n"),
],
{
@@ -973,6 +977,47 @@ describe("interactive setup completion", () => {
);
});
it("names a native analysis tool for this operating system only when none is ready", async () => {
const connected = [{ client: "codex", state: "aligned" }];
const windows = await renderReady(
{},
connected,
{},
{
providers: ["jadx"],
platform: "win32",
},
);
expect(windows.stderr).toContain(
"To look inside programs such as .exe files, add Ghidra, a free tool that turns compiled programs into readable code: rea.tools/get-started/#ghidra. You can ask your agent to set it up.",
);
expect(windows.stderr).not.toContain("Hopper");
const mac = await renderReady(
{},
connected,
{},
{
providers: [],
platform: "darwin",
},
);
expect(mac.stderr).toContain(
"add Hopper (its free demo mode works with REA) or Ghidra: rea.tools/get-started/#native.",
);
const ready = await renderReady(
{},
connected,
{},
{
providers: ["ghidra"],
platform: "win32",
},
);
expect(ready.stderr).not.toContain("rea.tools/get-started");
});
it("tells a person to open an agent that was already connected", async () => {
const { stderr } = await renderReady({}, [
{ client: "codex", state: "aligned" },
+8 -1
View File
@@ -1,5 +1,6 @@
import { it } from "vitest";
import { PCAP_TOOL_REMEDIATION } from "../../../src/pcap/PcapConfiguration.js";
import { expectConfigurationRefusal, serveCli } from "./cliServeHarness.js";
it.each([
@@ -15,8 +16,13 @@ it.each([
expectConfigurationRefusal(
result,
"The selected tshark executable /nonexistent/tshark could not be found",
PCAP_TOOL_REMEDIATION,
);
expectConfigurationRefusal(
result,
"The selected tshark executable /nonexistent/tshark could not be found",
"through absolute REA_TSHARK_COMMAND",
);
expectConfigurationRefusal(result, "through absolute REA_TSHARK_COMMAND");
});
it("names a relative tool selection as configuration to fix", async () => {
@@ -26,5 +32,6 @@ it("names a relative tool selection as configuration to fix", async () => {
expectConfigurationRefusal(
result,
"REA_TSHARK_COMMAND must be an absolute path to the tshark binary",
PCAP_TOOL_REMEDIATION,
);
});
+2 -10
View File
@@ -7,10 +7,7 @@ import { phaseArrival } from "../../support/lifecycleHarness.js";
import { withVerifierCleanup } from "../../../scripts/lib/verifier-cleanup.mjs";
import { PcapProvider } from "../../../src/pcap/PcapProvider.js";
import {
CAPINFOS_COMMAND_ENV,
TSHARK_COMMAND_ENV,
} from "../../../src/pcap/PcapConfiguration.js";
import { PCAP_TOOL_REMEDIATION } from "../../../src/pcap/PcapConfiguration.js";
import { primaryAnalysisError } from "../../../src/domain/analysisErrorBase.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import {
@@ -455,12 +452,7 @@ it("reports relative configuration and missing capinfos as capability gaps", asy
code: "capability_unavailable",
details: { provider_id: "pcap", operation: "inspect_pcap_client" },
});
expect(projected.message).toContain(TSHARK_COMMAND_ENV);
expect(projected.message).toContain(CAPINFOS_COMMAND_ENV);
expect(projected.message).toContain("Wireshark 4.x");
expect(projected.message).toContain("PATH");
expect(projected.message).toContain("absolute");
expect(projected.message).toContain("does not install");
expect(projected.remediation.action).toBe(PCAP_TOOL_REMEDIATION);
}
});
@@ -25,10 +25,7 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { PcapProvider } from "../../../src/pcap/PcapProvider.js";
import { createPcapAnalysisService } from "../../../src/application/ProviderOperationServices.js";
import {
CAPINFOS_COMMAND_ENV,
TSHARK_COMMAND_ENV,
} from "../../../src/pcap/PcapConfiguration.js";
import { PCAP_TOOL_REMEDIATION } from "../../../src/pcap/PcapConfiguration.js";
import { PcapSnapshot } from "../../../src/pcap/PcapSnapshot.js";
import {
AnalysisCleanupLease,
@@ -283,12 +280,7 @@ it("projects a missing configured tool as a capability gap", async () => {
code: "capability_unavailable",
details: { provider_id: "pcap", operation: "inspect_pcap_client" },
});
expect(projected.message).toContain(TSHARK_COMMAND_ENV);
expect(projected.message).toContain(CAPINFOS_COMMAND_ENV);
expect(projected.message).toContain("Wireshark 4.x");
expect(projected.message).toContain("PATH");
expect(projected.message).toContain("absolute");
expect(projected.message).toContain("does not install");
expect(projected.remediation.action).toBe(PCAP_TOOL_REMEDIATION);
});
it.skipIf(isWindows)(
@@ -616,8 +608,8 @@ it.each(["tshark", "capinfos"] as const)(
message: expect.stringContaining(root),
details: { provider_id: "pcap", operation: "inspect_pcap_client" },
});
expect(projectAnalysisError(result.error).message).toContain(
"Wireshark 4.x",
expect(projectAnalysisError(result.error).remediation.action).toBe(
PCAP_TOOL_REMEDIATION,
);
},
);
@@ -185,14 +185,15 @@ it("distinguishes an unset command from an invalid one", async () => {
});
});
it("declares Windows hosts unsupported before touching the command", async () => {
expect(
await inspectKunaInstallation(
{ REA_KUNA_COMMAND: "/opt/kuna/kuna" },
{ platform: "win32" },
),
).toMatchObject({ ok: false, error: { code: "unsupported_host" } });
});
// An unset command on Windows is unsupported, not a setting to configure.
it.each([{ REA_KUNA_COMMAND: "/opt/kuna/kuna" }, {}])(
"declares Windows hosts unsupported before touching the command (%o)",
async (environment) => {
expect(
await inspectKunaInstallation(environment, { platform: "win32" }),
).toMatchObject({ ok: false, error: { code: "unsupported_host" } });
},
);
it("parses cache, timeout and job settings at the configuration boundary", () => {
const environment = {