From 74965d9088cca6e048a62352567b95c63c6621d2 Mon Sep 17 00:00:00 2001
From: N0zoM1z0 <1705004398@qq.com>
Date: Tue, 21 Jul 2026 23:42:28 +0800
Subject: [PATCH] fix(cli): route JavaScript applications from analyze
---
README.md | 9 ++-
...nService.analyzeJavaScriptApplication.html | 2 +-
...analyzeJavaScriptApplicationValidated.html | 2 +-
...iptStaticAnalysisHelpers.argumentNode.html | 4 +-
...taticAnalysisHelpers.endpointArgument.html | 4 +-
...ticAnalysisHelpers.factoryRequireName.html | 4 +-
...ptStaticAnalysisHelpers.moduleFactory.html | 6 +-
...ticAnalysisHelpers.modulePropertyName.html | 4 +-
...webBundleAnalyzerAst.endpointArgument.html | 4 +-
...main_webBundleAnalyzerAst.objectValue.html | 4 +-
docs/javascript-artifact-reconstruction.md | 12 +++-
scripts/verify-package-artifact.mjs | 21 ++++++-
.../JavaScriptApplicationService.ts | 12 +++-
src/cli/coreAnalysisCommands.ts | 59 +++++++++++++++---
src/cli/javascriptApplicationAnalysis.ts | 24 +++++++
src/cliElectronCommands.ts | 62 +++++++------------
tests/electronCli.test.ts | 62 +++++++++++++++++++
17 files changed, 227 insertions(+), 68 deletions(-)
create mode 100644 src/cli/javascriptApplicationAnalysis.ts
diff --git a/README.md b/README.md
index d73dd73b0..28b888e3f 100644
--- a/README.md
+++ b/README.md
@@ -262,7 +262,7 @@ Uninstall preserves Hopper, Node.js, evidence, captures, external evidence roots
| Inspect or decompile one part of an app from the Terminal | `rea analyze` or `rea decompile` |
| Validate, canonicalize, or compare Evidence v2 bundles | `rea evidence-import`, `rea evidence-export`, or `rea compare` |
| Run or resume a persistent two-version artifact analysis | `rea investigate-versions` |
-| Map a local JavaScript/Electron application without executing it | `rea analyze-javascript-application` |
+| Map a local JavaScript/Electron application without executing it | `rea analyze PATH --approved` or `rea analyze-javascript-application` |
| Reuse immutable analysis results without relaunching a provider | Pass `--snapshot /approved/path/analysis.json` to a deep-analysis command |
| Import source as historical reference | `rea import-reference-source` |
| Capture or compare controlled process behavior | `rea capture-process` or `rea compare-process-captures` |
@@ -276,9 +276,16 @@ rea evidence-import /absolute/path/to/evidence/bundle.json
rea evidence-export /absolute/path/to/evidence/bundle.json /absolute/path/to/evidence/canonical.json
rea compare /absolute/path/to/evidence/left.json /absolute/path/to/evidence/right.json
rea investigate-versions /absolute/path/to/releases/v1 /absolute/path/to/releases/v2 /absolute/path/to/evidence/releases.json --yes --workspace-name releases
+rea analyze /absolute/path/to/releases/app.asar --approved --json
rea analyze-javascript-application /absolute/path/to/releases/app.asar --approved --json
```
+For a directory or `.asar`, generic `rea analyze` automatically selects the
+static JavaScript application provider when neither `--provider` nor
+`--snapshot` is supplied. The dedicated command remains available for explicit
+format and resource-limit controls. Both routes require `--approved` and an
+administrator-approved investigation input root.
+
If REA is registered with an MCP client, run approved `rea setup` while the
explicit investigation-root variable is set, then restart that client. Setup
copies this non-secret policy into the managed registration; changing the shell
diff --git a/docs/api/functions/application_JavaScriptApplicationService.analyzeJavaScriptApplication.html b/docs/api/functions/application_JavaScriptApplicationService.analyzeJavaScriptApplication.html
index 919c0efe2..a4429034a 100644
--- a/docs/api/functions/application_JavaScriptApplicationService.analyzeJavaScriptApplication.html
+++ b/docs/api/functions/application_JavaScriptApplicationService.analyzeJavaScriptApplication.html
@@ -26,7 +26,7 @@
options: ExecutionOptions = {}
Returns Promise<
Result<
| {
analysis_profile: {
digest: string;
parameters: Record<string, JSONType>;
provider: { id: string; name: string; version: string };
provider_profile_schema_version: number;
schema_version: 1;
};
authority: | "shipped-artifact"
| "controlled-replay"
| "historical-reference"
| "external-service"
| "analyst-inference";
confidence: "observed"
| "derived"
| "inferred";
environment:
| {
architecture: string;
id: string;
isolation: "process"
| "none"
| "container"
| "virtual-machine";
platform: string;
}
| null;
evidence_id: string;
evidence_links: string[];
limitations: string[];
locations: (
| { address: string; kind: "address" }
| { end: string; kind: "address-range"; start: string }
| { kind: "artifact-path"; path: string }
| { kind: "file-offset"; offset: number }
| { end: number; kind: "file-offset-range"; start: number }
)[];
normalized_result: JSONType;
operation: string;
parameters: Record<string, JSONType>;
predicate_type: string;
provider: { id: string; name: string; version: string | null };
raw_result: JSONType;
schema_version: 2;
subject:
| {
architecture: "x86"
| "x86_64"
| "arm"
| "arm64"
| null;
digest: { sha256: string };
format:
| "unknown"
| "file"
| "directory"
| "javascript"
| "source-map"
| "plist"
| "entitlements"
| "dmg"
| "zip"
| "pkg"
| "asar"
| "javascript-bundle"
| "mach-o-universal"
| "mach-o"
| "elf"
| "pe"
| "hopper"
| "analysis-database"
| "ipa"
| "apk";
local_path: string;
name: string;
}
| null;
}
| {
authority: | "shipped-artifact"
| "controlled-replay"
| "historical-reference"
| "external-service"
| "analyst-inference";
confidence: "observed"
| "derived"
| "inferred";
environment:
| {
architecture: string;
id: string;
isolation: "process"
| "none"
| "container"
| "virtual-machine";
platform: string;
}
| null;
evidence_id: string;
evidence_links: string[];
limitations: string[];
locations: (
| { address: string; kind: "address" }
| { end: string; kind: "address-range"; start: string }
| { kind: "artifact-path"; path: string }
| { kind: "file-offset"; offset: number }
| { end: number; kind: "file-offset-range"; start: number }
)[];
normalized_result: JSONType;
operation: string;
parameters: Record<string, JSONType>;
predicate_type: string;
provider: { id: string; name: string; version: string | null };
raw_result: JSONType;
schema_version: 2;
subject:
| {
architecture: "x86"
| "x86_64"
| "arm"
| "arm64"
| null;
digest: { sha256: string };
format:
| "unknown"
| "file"
| "directory"
| "javascript"
| "source-map"
| "plist"
| "entitlements"
| "dmg"
| "zip"
| "pkg"
| "asar"
| "javascript-bundle"
| "mach-o-universal"
| "mach-o"
| "elf"
| "pe"
| "hopper"
| "analysis-database"
| "ipa"
| "apk";
local_path: string;
name: string;
}
| null;
},
AnalysisError,
>,
>
+Defined in src/application/JavaScriptApplicationService.ts:27
+Defined in src/application/JavaScriptApplicationService.ts:45
Returns string | undefined
diff --git a/docs/api/functions/domain_javascriptStaticAnalysisHelpers.factoryRequireName.html b/docs/api/functions/domain_javascriptStaticAnalysisHelpers.factoryRequireName.html
index c1ee14e43..0fbc92cc4 100644
--- a/docs/api/functions/domain_javascriptStaticAnalysisHelpers.factoryRequireName.html
+++ b/docs/api/functions/domain_javascriptStaticAnalysisHelpers.factoryRequireName.html
@@ -14,14 +14,14 @@
-
-
factoryRequireName( factory: ArrowFunctionExpression | FunctionExpression | ObjectMethod,): string | null
+factoryRequireName( factory: FunctionExpression | ArrowFunctionExpression | ObjectMethod,): string | null
Parameters
-- factory: ArrowFunctionExpression | FunctionExpression | ObjectMethod
+
- factory: FunctionExpression | ArrowFunctionExpression | ObjectMethod
Returns string | null
diff --git a/docs/api/functions/domain_javascriptStaticAnalysisHelpers.moduleFactory.html b/docs/api/functions/domain_javascriptStaticAnalysisHelpers.moduleFactory.html
index beedcbed5..d2c4f0cb1 100644
--- a/docs/api/functions/domain_javascriptStaticAnalysisHelpers.moduleFactory.html
+++ b/docs/api/functions/domain_javascriptStaticAnalysisHelpers.moduleFactory.html
@@ -14,15 +14,15 @@
-
-
moduleFactory( property: ObjectMethod | ObjectProperty | SpreadElement,): ArrowFunctionExpression | FunctionExpression | ObjectMethod | undefined
+moduleFactory( property: SpreadElement | ObjectMethod | ObjectProperty,): FunctionExpression | ArrowFunctionExpression | ObjectMethod | undefined
Parameters
-- property: ObjectMethod | ObjectProperty | SpreadElement
-
Returns ArrowFunctionExpression | FunctionExpression | ObjectMethod | undefined
+Returns FunctionExpression | ArrowFunctionExpression | ObjectMethod | undefined
diff --git a/docs/api/functions/domain_webBundleAnalyzerAst.endpointArgument.html b/docs/api/functions/domain_webBundleAnalyzerAst.endpointArgument.html
index 3dc31ca82..871bf3d41 100644
--- a/docs/api/functions/domain_webBundleAnalyzerAst.endpointArgument.html
+++ b/docs/api/functions/domain_webBundleAnalyzerAst.endpointArgument.html
@@ -14,7 +14,7 @@
-
-
endpointArgument( name: string, args: readonly (
ArgumentPlaceholder | JSXNamespacedName | SpreadElement | Expression )
[],): string | undefined
+endpointArgument( name: string, args: readonly (
Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder )
[],): string | undefined
@@ -22,7 +22,7 @@
Parameters
- name: string
-- args: readonly (ArgumentPlaceholder | JSXNamespacedName | SpreadElement | Expression)[]
+ - args: readonly (Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder)[]
Returns string | undefined
diff --git a/docs/api/functions/domain_webBundleAnalyzerAst.objectValue.html b/docs/api/functions/domain_webBundleAnalyzerAst.objectValue.html
index fbfa77e0a..c36fa2fc1 100644
--- a/docs/api/functions/domain_webBundleAnalyzerAst.objectValue.html
+++ b/docs/api/functions/domain_webBundleAnalyzerAst.objectValue.html
@@ -14,14 +14,14 @@
-
-
objectValue( object: ObjectExpression, name: string,): | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BigIntLiteral | BinaryExpressionIn | BinaryExpressionNotIn | BindExpression | BooleanLiteral | CallExpression | ClassExpression | ConditionalExpression | DoExpression | FunctionExpression | Identifier | ImportExpression | JSXElement | JSXFragment | LogicalExpression | MemberExpressionComputed | MemberExpressionNonComputed | MetaProperty | ModuleExpression | NewExpression | NullLiteral | NumericLiteral | ObjectExpression | ObjectPattern | OptionalCallExpression | OptionalMemberExpressionComputed | OptionalMemberExpressionNonComputed | ParenthesizedExpression | RegExpLiteral | RestElement | SequenceExpression | StringLiteral | TSAsExpression | TSInstantiationExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion | TaggedTemplateExpression | TemplateLiteral | ThisExpression | TopicReference | TypeCastExpression | UnaryExpression | UpdateExpression | VoidPattern | YieldExpression | undefined
+objectValue( object: ObjectExpression, name: string,): | ArrayExpression | AssignmentExpression | BinaryExpressionIn | BinaryExpressionNotIn | CallExpression | ConditionalExpression | FunctionExpression | Identifier | StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | LogicalExpression | MemberExpressionComputed | MemberExpressionNonComputed | NewExpression | ObjectExpression | SequenceExpression | ParenthesizedExpression | ThisExpression | UnaryExpression | UpdateExpression | ArrowFunctionExpression | ClassExpression | MetaProperty | TaggedTemplateExpression | TemplateLiteral | YieldExpression | AwaitExpression | ImportExpression | BigIntLiteral | OptionalMemberExpressionComputed | OptionalMemberExpressionNonComputed | OptionalCallExpression | TypeCastExpression | JSXElement | JSXFragment | BindExpression | DoExpression | ModuleExpression | TopicReference | TSInstantiationExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | ArrayPattern | AssignmentPattern | ObjectPattern | RestElement | VoidPattern | undefined
Parameters
- object: ObjectExpression
- name: string
-
Returns
| ArrayExpression
| ArrayPattern
| ArrowFunctionExpression
| AssignmentExpression
| AssignmentPattern
| AwaitExpression
| BigIntLiteral
| BinaryExpressionIn
| BinaryExpressionNotIn
| BindExpression
| BooleanLiteral
| CallExpression
| ClassExpression
| ConditionalExpression
| DoExpression
| FunctionExpression
| Identifier
| ImportExpression
| JSXElement
| JSXFragment
| LogicalExpression
| MemberExpressionComputed
| MemberExpressionNonComputed
| MetaProperty
| ModuleExpression
| NewExpression
| NullLiteral
| NumericLiteral
| ObjectExpression
| ObjectPattern
| OptionalCallExpression
| OptionalMemberExpressionComputed
| OptionalMemberExpressionNonComputed
| ParenthesizedExpression
| RegExpLiteral
| RestElement
| SequenceExpression
| StringLiteral
| TSAsExpression
| TSInstantiationExpression
| TSNonNullExpression
| TSSatisfiesExpression
| TSTypeAssertion
| TaggedTemplateExpression
| TemplateLiteral
| ThisExpression
| TopicReference
| TypeCastExpression
| UnaryExpression
| UpdateExpression
| VoidPattern
| YieldExpression
| undefined
Normalize one Babel call/new argument into the inert node shared by inspectors.