feat(target): explain static WASM inspection after native rejection
Explain recognized WASM v1 native-admission rejection with an exact call to the existing static inspection tool and its caller-supplied WABT prerequisites. Preserve selected paths, explicit raw-binary choices, typed missing-tool outcomes and connection usability. Refs #1852 Co-authored-by: SII-YDD <38822679+SII-YDD@users.noreply.github.com> Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
co-authored by
Ysopwnable
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Kaoru0822
parent
89f5e489ad
commit
1f17ac8228
@@ -247,6 +247,15 @@ const detectArtifactFormat = async (
|
||||
const magic = Buffer.alloc(8);
|
||||
const observed = await handle.read(magic, 0, magic.length, 0);
|
||||
throwIfTargetResolutionCancelled(signal);
|
||||
if (
|
||||
observed.bytesRead === 8 &&
|
||||
magic.equals(Buffer.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0]))
|
||||
)
|
||||
throw new BinaryTargetError(
|
||||
path,
|
||||
"WebAssembly v1 artifacts are not supported by the native opening route",
|
||||
{ constraint: "wasm_requires_static_inspection" },
|
||||
);
|
||||
if (hasZipSignature(magic.subarray(0, observed.bytesRead))) {
|
||||
// The HarmonyOS App Pack suffix `.app` is a root-input concept; a nested
|
||||
// ZIP member ending in `.app` keeps the generic zip classification.
|
||||
|
||||
@@ -421,7 +421,7 @@ export const systemDoctorHost = (
|
||||
name: "target",
|
||||
ok: false,
|
||||
classification:
|
||||
targetError?.constraint === "directory_requires_file"
|
||||
targetError?.constraint !== undefined
|
||||
? "unsupported_target"
|
||||
: "config_drift",
|
||||
detail: path,
|
||||
|
||||
@@ -76,6 +76,11 @@ export const analysisErrorRemediationAction = (
|
||||
error.constraint === "directory_requires_file"
|
||||
)
|
||||
return "For a JavaScript/Electron application directory, call analyze_javascript_application with input_path or run `rea analyze <directory>`. For binary analysis, select its executable file.";
|
||||
if (
|
||||
error instanceof BinaryTargetError &&
|
||||
error.constraint === "wasm_requires_static_inspection"
|
||||
)
|
||||
return `For static inspection, call inspect_wasm_artifact with ${JSON.stringify({ path: error.path })} or run \`rea inspect-wasm-artifact <path> --format json\`. This separate lane requires caller-supplied WABT 1.0.42 via absolute REA_WABT_BIN_DIRECTORY; check its availability in binary_session. REA does not execute WASM or install tools, and the header alone does not establish that the complete module is valid.`;
|
||||
if (
|
||||
error instanceof AnalysisAccessDeniedError ||
|
||||
(error instanceof BinaryTargetError && error.systemCode !== undefined)
|
||||
@@ -95,6 +100,11 @@ export const analysisErrorRemediationAction = (
|
||||
export const analysisErrorCategory = (
|
||||
error: AnalysisError,
|
||||
): AnalysisErrorProjection["category"] => {
|
||||
if (
|
||||
error instanceof BinaryTargetError &&
|
||||
error.constraint === "wasm_requires_static_inspection"
|
||||
)
|
||||
return "unsupported_target";
|
||||
if (
|
||||
error instanceof ProviderSelectionError &&
|
||||
error.reason === "provider_unavailable"
|
||||
@@ -213,6 +223,11 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
|
||||
)
|
||||
.join("; ")}.`;
|
||||
if (error instanceof NoBinaryOpenError) return error.message;
|
||||
if (
|
||||
error instanceof BinaryTargetError &&
|
||||
error.constraint === "wasm_requires_static_inspection"
|
||||
)
|
||||
return `${error.message}. Static WebAssembly inspection uses a separate optional WABT lane, not a native analysis engine.`;
|
||||
if (error instanceof BinaryTargetError)
|
||||
return error.constraint === "directory_requires_file"
|
||||
? "open_binary accepts files and macOS app bundles. This target is a directory; JavaScript/Electron application directories can be analyzed directly with analyze_javascript_application or `rea analyze <directory>`."
|
||||
|
||||
@@ -38,7 +38,9 @@ export class NoBinaryOpenError extends AnalysisError {
|
||||
|
||||
/** Additional constraints identified while admitting a filesystem target. */
|
||||
export interface BinaryTargetErrorOptions extends AnalysisErrorOptions {
|
||||
readonly constraint?: "directory_requires_file";
|
||||
readonly constraint?:
|
||||
| "directory_requires_file"
|
||||
| "wasm_requires_static_inspection";
|
||||
}
|
||||
|
||||
/** A supplied target path could not be safely opened as a supported app or binary. */
|
||||
|
||||
Reference in New Issue
Block a user