@zhuixin/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +619 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_node_child_process = require("child_process");
|
|
28
|
+
var import_node_fs = __toESM(require("fs"));
|
|
29
|
+
var import_node_path = __toESM(require("path"));
|
|
30
|
+
var import_metadata = require("@zhuixin/metadata");
|
|
31
|
+
var import_shared = require("@zhuixin/shared");
|
|
32
|
+
var GOALS = [
|
|
33
|
+
"tech_stack",
|
|
34
|
+
"feature_map",
|
|
35
|
+
"network",
|
|
36
|
+
"native_risk",
|
|
37
|
+
"report"
|
|
38
|
+
];
|
|
39
|
+
function usage() {
|
|
40
|
+
console.log(`AppTrace 0.1.0
|
|
41
|
+
|
|
42
|
+
Usage:
|
|
43
|
+
apptrace setup [--json] [--install] [--write-config <path>]
|
|
44
|
+
apptrace doctor [--json]
|
|
45
|
+
apptrace auth login
|
|
46
|
+
apptrace auth status
|
|
47
|
+
apptrace targets add <app-store-url-or-id>
|
|
48
|
+
apptrace targets list
|
|
49
|
+
apptrace analyze [app-store-url-or-id] [--target <target-id>] [--goals ...] [--force]
|
|
50
|
+
apptrace report <target-id>
|
|
51
|
+
apptrace jobs get <job-id>
|
|
52
|
+
apptrace search <target-id> [query] [--type route,module] [--limit 50]
|
|
53
|
+
apptrace native search <target-id> <query> [--kind procedures|strings]
|
|
54
|
+
apptrace native decompile <target-id> <function-name>
|
|
55
|
+
apptrace evidence <target-id>
|
|
56
|
+
apptrace compare <target-id> <left-artifact-id> <right-artifact-id> [--force]
|
|
57
|
+
apptrace capabilities [target-id]
|
|
58
|
+
apptrace engine install <engine-file> [--sha256 <digest>]
|
|
59
|
+
apptrace mcp
|
|
60
|
+
|
|
61
|
+
Examples:
|
|
62
|
+
apptrace analyze https://apps.apple.com/cn/app/id1616124777
|
|
63
|
+
apptrace analyze 1616124777 --goals tech_stack,feature_map,native_risk,report
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
function option(args, name) {
|
|
67
|
+
const index = args.indexOf(name);
|
|
68
|
+
if (index >= 0 && args[index + 1]) return args[index + 1];
|
|
69
|
+
const prefix = `${name}=`;
|
|
70
|
+
const inline = args.find((arg) => arg.startsWith(prefix));
|
|
71
|
+
return inline ? inline.slice(prefix.length) : void 0;
|
|
72
|
+
}
|
|
73
|
+
function hasFlag(args, name) {
|
|
74
|
+
return args.includes(name);
|
|
75
|
+
}
|
|
76
|
+
function positional(args) {
|
|
77
|
+
return args.find((arg) => !arg.startsWith("--"));
|
|
78
|
+
}
|
|
79
|
+
function parseGoals(value) {
|
|
80
|
+
if (!value) return ["tech_stack", "feature_map", "report"];
|
|
81
|
+
const goals = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
82
|
+
const invalid = goals.filter(
|
|
83
|
+
(goal) => !GOALS.includes(goal)
|
|
84
|
+
);
|
|
85
|
+
if (invalid.length > 0) {
|
|
86
|
+
throw new import_metadata.CoreFailure(
|
|
87
|
+
"INVALID_INPUT",
|
|
88
|
+
`\u672A\u77E5\u5206\u6790\u76EE\u6807\uFF1A${invalid.join(", ")}\u3002\u53EF\u9009\uFF1A${GOALS.join(", ")}`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return goals;
|
|
92
|
+
}
|
|
93
|
+
function printJson(value) {
|
|
94
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
function printError(error) {
|
|
98
|
+
if (error instanceof import_metadata.CoreFailure) {
|
|
99
|
+
console.error(`${error.code}: ${error.message}`);
|
|
100
|
+
if (error.code === "AUTH_REQUIRED" || error.code === "KEYCHAIN_LOCKED") {
|
|
101
|
+
console.error("Next: apptrace auth login");
|
|
102
|
+
} else if (error.code === "LICENSE_REQUIRED") {
|
|
103
|
+
console.error("Next: \u5728 iPhone App Store \u83B7\u53D6\u6216\u8D2D\u4E70\u8BE5\u5E94\u7528\u540E\u91CD\u8BD5\u3002");
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
console.error(error instanceof Error ? error.stack ?? error.message : String(error));
|
|
108
|
+
}
|
|
109
|
+
function withCore(operation) {
|
|
110
|
+
const core = new import_metadata.CoreServer({ config: (0, import_metadata.loadConfig)(), emit: () => {
|
|
111
|
+
} });
|
|
112
|
+
return operation(core).finally(() => core.close());
|
|
113
|
+
}
|
|
114
|
+
function interactive(command, args, env) {
|
|
115
|
+
return new Promise((resolve, reject) => {
|
|
116
|
+
const isWindowsCommand = process.platform === "win32" && [".cmd", ".bat"].includes(import_node_path.default.extname(command).toLowerCase());
|
|
117
|
+
const child = isWindowsCommand ? (0, import_node_child_process.spawn)(
|
|
118
|
+
process.env.ComSpec || "cmd.exe",
|
|
119
|
+
["/d", "/s", "/c", `"${command}" ${args.join(" ")}`],
|
|
120
|
+
{
|
|
121
|
+
stdio: "inherit",
|
|
122
|
+
windowsVerbatimArguments: true,
|
|
123
|
+
env: env ? { ...process.env, ...env } : process.env
|
|
124
|
+
}
|
|
125
|
+
) : (0, import_node_child_process.spawn)(command, args, {
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
env: env ? { ...process.env, ...env } : process.env
|
|
128
|
+
});
|
|
129
|
+
child.on("error", reject);
|
|
130
|
+
child.on("exit", (code) => resolve(code));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function doctor(json) {
|
|
134
|
+
const config = (0, import_metadata.loadConfig)();
|
|
135
|
+
await withCore(async (core) => {
|
|
136
|
+
const health = await core.handle(import_shared.CHANNELS.health, {});
|
|
137
|
+
const capabilities2 = await core.handle(
|
|
138
|
+
import_shared.CHANNELS.capabilitiesList,
|
|
139
|
+
{}
|
|
140
|
+
);
|
|
141
|
+
const result = { config, health, capabilities: capabilities2 };
|
|
142
|
+
if (json) {
|
|
143
|
+
printJson(result);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
console.log(`workspace: ${health.workspaceRoot}`);
|
|
147
|
+
console.log(`host: ${health.hostPlatform}`);
|
|
148
|
+
console.log(`store: ${health.store}`);
|
|
149
|
+
console.log("tools:");
|
|
150
|
+
for (const tool of health.tools ?? []) {
|
|
151
|
+
console.log(
|
|
152
|
+
` ${tool.available ? "OK " : "MISS"} ${tool.label}: ${tool.path}`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
console.log("capabilities:");
|
|
156
|
+
for (const capability of capabilities2) {
|
|
157
|
+
console.log(
|
|
158
|
+
` ${capability.available ? "OK " : "NO "} ${capability.id}${capability.reason ? ` \u2014 ${capability.reason}` : ""}`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function createEngineLauncher(workspaceRoot) {
|
|
164
|
+
const reaScript = require.resolve("rea-agents/scripts/rea.mjs");
|
|
165
|
+
const tools = import_node_path.default.join(workspaceRoot, "tools");
|
|
166
|
+
const javaHome = import_node_path.default.join(tools, "jdk");
|
|
167
|
+
const ghidraHome = import_node_path.default.join(tools, "ghidra_12.1.4_PUBLIC");
|
|
168
|
+
const ghidraUserHome = import_node_path.default.join(workspaceRoot, ".ghidra-home");
|
|
169
|
+
import_node_fs.default.mkdirSync(import_node_path.default.join(tools, "bin"), { recursive: true, mode: 448 });
|
|
170
|
+
import_node_fs.default.mkdirSync(ghidraUserHome, { recursive: true, mode: 448 });
|
|
171
|
+
const launcher = import_node_path.default.join(
|
|
172
|
+
tools,
|
|
173
|
+
"bin",
|
|
174
|
+
process.platform === "win32" ? "rea.cmd" : "rea"
|
|
175
|
+
);
|
|
176
|
+
if (process.platform === "win32") {
|
|
177
|
+
import_node_fs.default.writeFileSync(
|
|
178
|
+
launcher,
|
|
179
|
+
[
|
|
180
|
+
"@echo off",
|
|
181
|
+
`set "JAVA_HOME=${javaHome}"`,
|
|
182
|
+
`set "GHIDRA_INSTALL_DIR=${ghidraHome}"`,
|
|
183
|
+
`set "GHIDRA_USER_HOME=${ghidraUserHome}"`,
|
|
184
|
+
'set "PATH=%JAVA_HOME%\\bin;%PATH%"',
|
|
185
|
+
`"${process.execPath}" "${reaScript}" %*`,
|
|
186
|
+
""
|
|
187
|
+
].join("\r\n"),
|
|
188
|
+
{ mode: 448 }
|
|
189
|
+
);
|
|
190
|
+
} else {
|
|
191
|
+
import_node_fs.default.writeFileSync(
|
|
192
|
+
launcher,
|
|
193
|
+
[
|
|
194
|
+
"#!/usr/bin/env bash",
|
|
195
|
+
"set -euo pipefail",
|
|
196
|
+
`export JAVA_HOME=${JSON.stringify(javaHome)}`,
|
|
197
|
+
`export GHIDRA_INSTALL_DIR=${JSON.stringify(ghidraHome)}`,
|
|
198
|
+
`export GHIDRA_USER_HOME=${JSON.stringify(ghidraUserHome)}`,
|
|
199
|
+
'export PATH="$JAVA_HOME/bin:$PATH"',
|
|
200
|
+
'export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:-} -Duser.home=$GHIDRA_USER_HOME"',
|
|
201
|
+
`exec ${JSON.stringify(process.execPath)} ${JSON.stringify(reaScript)} "$@"`,
|
|
202
|
+
""
|
|
203
|
+
].join("\n"),
|
|
204
|
+
{ mode: 448 }
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return launcher;
|
|
208
|
+
}
|
|
209
|
+
async function installTools(config, json = false) {
|
|
210
|
+
if (import_node_fs.default.existsSync(config.enginePath) && import_node_fs.default.existsSync(config.ipatoolPath)) {
|
|
211
|
+
process.stderr.write("Tools already available; download skipped.\n");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (process.platform === "win32" && process.arch === "x64") {
|
|
215
|
+
const script2 = import_node_path.default.resolve(__dirname, "../../scripts/bootstrap-tools.ps1");
|
|
216
|
+
if (!import_node_fs.default.existsSync(script2)) {
|
|
217
|
+
throw new import_metadata.CoreFailure("TOOL_INSTALLER_MISSING", `\u627E\u4E0D\u5230\u5B89\u88C5\u811A\u672C\uFF1A${script2}`);
|
|
218
|
+
}
|
|
219
|
+
process.stderr.write(
|
|
220
|
+
"Installing JDK, Ghidra and ipatool for Windows x64. This can take several minutes.\n"
|
|
221
|
+
);
|
|
222
|
+
const code2 = await interactive("powershell.exe", [
|
|
223
|
+
"-NoProfile",
|
|
224
|
+
"-ExecutionPolicy",
|
|
225
|
+
"Bypass",
|
|
226
|
+
"-File",
|
|
227
|
+
script2,
|
|
228
|
+
"-WorkspaceRoot",
|
|
229
|
+
config.workspaceRoot
|
|
230
|
+
], {
|
|
231
|
+
APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,
|
|
232
|
+
APPTRACE_TOOLS_DIR: import_node_path.default.join(config.workspaceRoot, "tools"),
|
|
233
|
+
...process.env.APPTRACE_IPATOOL_SHA256 ? { APPTRACE_IPATOOL_SHA256: process.env.APPTRACE_IPATOOL_SHA256 } : {}
|
|
234
|
+
});
|
|
235
|
+
if (code2 !== 0) {
|
|
236
|
+
throw new import_metadata.CoreFailure(
|
|
237
|
+
"TOOL_INSTALL_FAILED",
|
|
238
|
+
`\u5DE5\u5177\u5B89\u88C5\u5931\u8D25\uFF0C\u9000\u51FA\u7801\uFF1A${code2 ?? "unknown"}`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
const launcher2 = createEngineLauncher(config.workspaceRoot);
|
|
242
|
+
process.stderr.write(`Analysis engine launcher: ${launcher2}
|
|
243
|
+
`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (process.platform !== "darwin" || process.arch !== "arm64") {
|
|
247
|
+
throw new import_metadata.CoreFailure(
|
|
248
|
+
"TOOL_INSTALL_UNSUPPORTED",
|
|
249
|
+
"v1 \u81EA\u52A8\u5B89\u88C5\u5668\u5F53\u524D\u53EA\u652F\u6301 macOS arm64\uFF1B\u5176\u4ED6\u5E73\u53F0\u8BF7\u4F7F\u7528 APPTRACE_ENGINE_PATH \u548C APPTRACE_IPATOOL_PATH\u3002"
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
const script = import_node_path.default.resolve(__dirname, "../../scripts/bootstrap-tools.sh");
|
|
253
|
+
if (!import_node_fs.default.existsSync(script)) {
|
|
254
|
+
throw new import_metadata.CoreFailure("TOOL_INSTALLER_MISSING", `\u627E\u4E0D\u5230\u5B89\u88C5\u811A\u672C\uFF1A${script}`);
|
|
255
|
+
}
|
|
256
|
+
process.stderr.write(
|
|
257
|
+
"Installing JDK, Ghidra and ipatool. This can take several minutes.\n"
|
|
258
|
+
);
|
|
259
|
+
const code = await interactive("/bin/bash", [script], {
|
|
260
|
+
APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,
|
|
261
|
+
APPTRACE_TOOLS_DIR: import_node_path.default.join(config.workspaceRoot, "tools")
|
|
262
|
+
});
|
|
263
|
+
if (code !== 0) {
|
|
264
|
+
throw new import_metadata.CoreFailure(
|
|
265
|
+
"TOOL_INSTALL_FAILED",
|
|
266
|
+
`\u5DE5\u5177\u5B89\u88C5\u5931\u8D25\uFF0C\u9000\u51FA\u7801\uFF1A${code ?? "unknown"}`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
const launcher = createEngineLauncher(config.workspaceRoot);
|
|
270
|
+
process.stderr.write(`Analysis engine launcher: ${launcher}
|
|
271
|
+
`);
|
|
272
|
+
}
|
|
273
|
+
async function setup(json, args) {
|
|
274
|
+
const configPath = option(args, "--write-config");
|
|
275
|
+
const config = (0, import_metadata.loadConfig)();
|
|
276
|
+
if (hasFlag(args, "--install")) {
|
|
277
|
+
await installTools(config, json);
|
|
278
|
+
}
|
|
279
|
+
await doctor(json);
|
|
280
|
+
if (json && !configPath) return;
|
|
281
|
+
const serverEntry = import_node_path.default.resolve(__dirname, "../../mcp/dist/index.js");
|
|
282
|
+
const env = {
|
|
283
|
+
APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,
|
|
284
|
+
APPTRACE_ENGINE_PATH: config.enginePath,
|
|
285
|
+
APPTRACE_ANALYSIS_ENGINE_PATH: config.analysisEnginePath,
|
|
286
|
+
APPTRACE_IPATOOL_PATH: config.ipatoolPath
|
|
287
|
+
};
|
|
288
|
+
if (configPath) {
|
|
289
|
+
const absolute = import_node_path.default.resolve(configPath);
|
|
290
|
+
const extension = import_node_path.default.extname(absolute).toLowerCase();
|
|
291
|
+
if (extension === ".json") {
|
|
292
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(absolute), { recursive: true, mode: 448 });
|
|
293
|
+
import_node_fs.default.writeFileSync(
|
|
294
|
+
absolute,
|
|
295
|
+
`${JSON.stringify(
|
|
296
|
+
{
|
|
297
|
+
mcpServers: {
|
|
298
|
+
apptrace: {
|
|
299
|
+
command: process.execPath,
|
|
300
|
+
args: [serverEntry],
|
|
301
|
+
env
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
null,
|
|
306
|
+
2
|
|
307
|
+
)}
|
|
308
|
+
`,
|
|
309
|
+
{ mode: 384 }
|
|
310
|
+
);
|
|
311
|
+
} else if (extension === ".toml") {
|
|
312
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(absolute), { recursive: true, mode: 448 });
|
|
313
|
+
const toml = [
|
|
314
|
+
"[mcp_servers.apptrace]",
|
|
315
|
+
`command = ${JSON.stringify(process.execPath)}`,
|
|
316
|
+
`args = [${JSON.stringify(serverEntry)}]`,
|
|
317
|
+
`env = { APPTRACE_WORKSPACE_ROOT = ${JSON.stringify(
|
|
318
|
+
env.APPTRACE_WORKSPACE_ROOT
|
|
319
|
+
)}, APPTRACE_ENGINE_PATH = ${JSON.stringify(
|
|
320
|
+
env.APPTRACE_ENGINE_PATH
|
|
321
|
+
)}, APPTRACE_ANALYSIS_ENGINE_PATH = ${JSON.stringify(
|
|
322
|
+
env.APPTRACE_ANALYSIS_ENGINE_PATH
|
|
323
|
+
)}, APPTRACE_IPATOOL_PATH = ${JSON.stringify(
|
|
324
|
+
env.APPTRACE_IPATOOL_PATH
|
|
325
|
+
)} }`,
|
|
326
|
+
""
|
|
327
|
+
].join("\n");
|
|
328
|
+
import_node_fs.default.writeFileSync(absolute, toml, { mode: 384 });
|
|
329
|
+
} else {
|
|
330
|
+
throw new import_metadata.CoreFailure(
|
|
331
|
+
"INVALID_CONFIG_FORMAT",
|
|
332
|
+
"--write-config \u53EA\u652F\u6301 .json \u6216 .toml \u6587\u4EF6\u3002"
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
if (json) {
|
|
336
|
+
process.stderr.write(`MCP config written: ${absolute}
|
|
337
|
+
`);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
console.log(`MCP config written: ${absolute}`);
|
|
341
|
+
}
|
|
342
|
+
console.log(`
|
|
343
|
+
MCP configuration:
|
|
344
|
+
|
|
345
|
+
[mcp_servers.apptrace]
|
|
346
|
+
command = "${process.execPath.replace(/\\/g, "\\\\")}"
|
|
347
|
+
args = ["${serverEntry.replace(/\\/g, "\\\\")}"]
|
|
348
|
+
env = { APPTRACE_WORKSPACE_ROOT = "${env.APPTRACE_WORKSPACE_ROOT.replace(/\\/g, "\\\\")}", APPTRACE_ENGINE_PATH = "${env.APPTRACE_ENGINE_PATH.replace(/\\/g, "\\\\")}", APPTRACE_ANALYSIS_ENGINE_PATH = "${env.APPTRACE_ANALYSIS_ENGINE_PATH.replace(/\\/g, "\\\\")}", APPTRACE_IPATOOL_PATH = "${env.APPTRACE_IPATOOL_PATH.replace(/\\/g, "\\\\")}" }
|
|
349
|
+
|
|
350
|
+
\u9996\u6B21\u5199\u5165\u914D\u7F6E\u540E\u91CD\u8F7D\u4E00\u6B21 Agent \u5BA2\u6237\u7AEF\u3002
|
|
351
|
+
`);
|
|
352
|
+
}
|
|
353
|
+
async function authLogin() {
|
|
354
|
+
const config = (0, import_metadata.loadConfig)();
|
|
355
|
+
const code = await interactive(config.ipatoolPath, ["auth", "login"]);
|
|
356
|
+
if (code !== 0) {
|
|
357
|
+
throw new import_metadata.CoreFailure(
|
|
358
|
+
"AUTH_FAILED",
|
|
359
|
+
`ipatool \u767B\u5F55\u6CA1\u6709\u6210\u529F\uFF0C\u9000\u51FA\u7801\uFF1A${code ?? "unknown"}`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
await authStatus();
|
|
363
|
+
}
|
|
364
|
+
async function authStatus() {
|
|
365
|
+
await withCore(async (core) => {
|
|
366
|
+
const status = await core.handle(import_shared.CHANNELS.accountStatus, { force: true });
|
|
367
|
+
printJson(status);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async function addTarget(source) {
|
|
371
|
+
await withCore(async (core) => {
|
|
372
|
+
const resolved = await core.handle(import_shared.CHANNELS.targetsResolve, {
|
|
373
|
+
input: source
|
|
374
|
+
});
|
|
375
|
+
const target = await core.handle(import_shared.CHANNELS.targetsCreate, {
|
|
376
|
+
resolutionId: resolved.resolutionId
|
|
377
|
+
});
|
|
378
|
+
printJson(target);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async function listTargets() {
|
|
382
|
+
await withCore(async (core) => {
|
|
383
|
+
printJson(await core.handle(import_shared.CHANNELS.targetsList, {}));
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async function analyze(source, args) {
|
|
387
|
+
const goals = parseGoals(option(args, "--goals"));
|
|
388
|
+
const json = hasFlag(args, "--json");
|
|
389
|
+
const force = hasFlag(args, "--force");
|
|
390
|
+
const targetId = option(args, "--target");
|
|
391
|
+
if (!source && !targetId) {
|
|
392
|
+
throw new import_metadata.CoreFailure("SOURCE_REQUIRED", "\u7F3A\u5C11\u5E94\u7528\u94FE\u63A5\u3001ID \u6216 --target\u3002");
|
|
393
|
+
}
|
|
394
|
+
await withCore(async (core) => {
|
|
395
|
+
const service = new import_metadata.AppAnalysisService(core);
|
|
396
|
+
const result = await service.analyzeApp({
|
|
397
|
+
source: targetId ? void 0 : source,
|
|
398
|
+
targetId,
|
|
399
|
+
goals,
|
|
400
|
+
force,
|
|
401
|
+
onProgress: (event) => {
|
|
402
|
+
if (!json) {
|
|
403
|
+
process.stderr.write(
|
|
404
|
+
`[${event.step}] ${event.status}${event.message ? ` \u2014 ${event.message}` : ""}
|
|
405
|
+
`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
if (json) {
|
|
411
|
+
printJson(result);
|
|
412
|
+
} else {
|
|
413
|
+
printAnalysis(result);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function printAnalysis(result) {
|
|
418
|
+
console.log(`
|
|
419
|
+
${result.targetName}`);
|
|
420
|
+
console.log(`Target: ${result.targetId}`);
|
|
421
|
+
console.log(`Artifact: ${result.artifact.sha256}`);
|
|
422
|
+
console.log(
|
|
423
|
+
`Technology: ${result.technology?.hints.join(" / ") || "unknown"}`
|
|
424
|
+
);
|
|
425
|
+
console.log(`Routes: ${result.routes?.count ?? 0}`);
|
|
426
|
+
console.log(`Modules: ${result.modules?.count ?? 0}`);
|
|
427
|
+
console.log(`Network endpoints: ${result.networkEndpoints?.count ?? 0}`);
|
|
428
|
+
if (result.native) {
|
|
429
|
+
console.log(
|
|
430
|
+
`Native: ${result.native.procedureCount ?? "?"} procedures, ${result.native.stringCount ?? "?"} strings`
|
|
431
|
+
);
|
|
432
|
+
if (result.native.warning) console.log(`Warning: ${result.native.warning}`);
|
|
433
|
+
}
|
|
434
|
+
if (result.reportPath) console.log(`Report: ${result.reportPath}`);
|
|
435
|
+
for (const evidencePath of result.evidencePaths) {
|
|
436
|
+
console.log(`Evidence: ${evidencePath}`);
|
|
437
|
+
}
|
|
438
|
+
if (result.limitations.length > 0) {
|
|
439
|
+
console.log("Limitations:");
|
|
440
|
+
for (const limitation of result.limitations.slice(0, 6)) {
|
|
441
|
+
console.log(` - ${limitation}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async function report(targetId) {
|
|
446
|
+
await withCore(async (core) => {
|
|
447
|
+
const service = new import_metadata.AppAnalysisService(core);
|
|
448
|
+
printJson(await service.runCapability(targetId, "generate:report"));
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
async function getJob(jobId) {
|
|
452
|
+
await withCore(async (core) => {
|
|
453
|
+
const result = await core.handle(import_shared.CHANNELS.jobsGet, { jobId });
|
|
454
|
+
printJson({ ...result, events: result.events.slice(-50) });
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async function searchFindings(targetId, query, args) {
|
|
458
|
+
const types = option(args, "--type")?.split(",").map((value) => value.trim()).filter(Boolean);
|
|
459
|
+
const limit = Number(option(args, "--limit") ?? 50);
|
|
460
|
+
await withCore(async (core) => {
|
|
461
|
+
printJson(
|
|
462
|
+
await core.handle(import_shared.CHANNELS.findingsSearch, {
|
|
463
|
+
targetId,
|
|
464
|
+
query,
|
|
465
|
+
types,
|
|
466
|
+
limit: Number.isFinite(limit) ? limit : 50
|
|
467
|
+
})
|
|
468
|
+
);
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
async function nativeCommand(action, args) {
|
|
472
|
+
const targetId = args[0];
|
|
473
|
+
const value = args[1];
|
|
474
|
+
if (!targetId || !value) {
|
|
475
|
+
throw new import_metadata.CoreFailure(
|
|
476
|
+
"INVALID_INPUT",
|
|
477
|
+
"\u7528\u6CD5\uFF1Aapptrace native <search|decompile> <target-id> <query-or-function>"
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
await withCore(async (core) => {
|
|
481
|
+
const service = new import_metadata.AppAnalysisService(core);
|
|
482
|
+
if (action === "search") {
|
|
483
|
+
printJson(
|
|
484
|
+
await service.runCapability(targetId, "native:search", {
|
|
485
|
+
query: value,
|
|
486
|
+
kind: option(args, "--kind") ?? "procedures",
|
|
487
|
+
mode: option(args, "--mode") ?? "literal"
|
|
488
|
+
})
|
|
489
|
+
);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (action === "decompile") {
|
|
493
|
+
printJson(
|
|
494
|
+
await service.runCapability(targetId, "native:decompile", {
|
|
495
|
+
functionName: value
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
throw new import_metadata.CoreFailure(
|
|
501
|
+
"INVALID_INPUT",
|
|
502
|
+
"\u539F\u751F\u547D\u4EE4\u53EA\u652F\u6301 search \u6216 decompile\u3002"
|
|
503
|
+
);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
async function evidence(targetId) {
|
|
507
|
+
await withCore(async (core) => {
|
|
508
|
+
printJson(
|
|
509
|
+
await core.handle(import_shared.CHANNELS.evidenceList, {
|
|
510
|
+
targetId
|
|
511
|
+
})
|
|
512
|
+
);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
async function installEngine(file, args) {
|
|
516
|
+
const config = (0, import_metadata.loadConfig)();
|
|
517
|
+
const expected = option(args, "--sha256");
|
|
518
|
+
const installed = (0, import_metadata.installEngineArtifact)(config.workspaceRoot, file, expected);
|
|
519
|
+
printJson(installed);
|
|
520
|
+
}
|
|
521
|
+
async function compare(targetId, leftArtifactId, rightArtifactId, args) {
|
|
522
|
+
if (!targetId || !leftArtifactId || !rightArtifactId) {
|
|
523
|
+
throw new import_metadata.CoreFailure(
|
|
524
|
+
"INVALID_INPUT",
|
|
525
|
+
"\u7528\u6CD5\uFF1Aapptrace compare <target-id> <left-artifact-id> <right-artifact-id>"
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
await withCore(async (core) => {
|
|
529
|
+
printJson(
|
|
530
|
+
await new import_metadata.VersionComparisonService(core).compare(
|
|
531
|
+
targetId,
|
|
532
|
+
leftArtifactId,
|
|
533
|
+
rightArtifactId,
|
|
534
|
+
{ force: hasFlag(args, "--force") }
|
|
535
|
+
)
|
|
536
|
+
);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async function capabilities(targetId) {
|
|
540
|
+
await withCore(async (core) => {
|
|
541
|
+
printJson(
|
|
542
|
+
await core.handle(import_shared.CHANNELS.capabilitiesList, {
|
|
543
|
+
...targetId ? { targetId } : {}
|
|
544
|
+
})
|
|
545
|
+
);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
async function main() {
|
|
549
|
+
const [command, subcommand, ...args] = process.argv.slice(2);
|
|
550
|
+
if (!command || ["help", "-h", "--help"].includes(command)) {
|
|
551
|
+
usage();
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (command === "setup") {
|
|
555
|
+
const setupArgs = subcommand?.startsWith("--") && subcommand ? [subcommand, ...args] : args;
|
|
556
|
+
return setup(hasFlag(setupArgs, "--json"), setupArgs);
|
|
557
|
+
}
|
|
558
|
+
if (command === "doctor") {
|
|
559
|
+
const doctorArgs = subcommand?.startsWith("--") && subcommand ? [subcommand, ...args] : args;
|
|
560
|
+
return doctor(hasFlag(doctorArgs, "--json"));
|
|
561
|
+
}
|
|
562
|
+
if (command === "auth") {
|
|
563
|
+
if (subcommand === "login") return authLogin();
|
|
564
|
+
if (subcommand === "status") return authStatus();
|
|
565
|
+
}
|
|
566
|
+
if (command === "targets") {
|
|
567
|
+
if (subcommand === "add") {
|
|
568
|
+
const source = positional(args);
|
|
569
|
+
if (!source) throw new import_metadata.CoreFailure("SOURCE_REQUIRED", "\u7F3A\u5C11\u5E94\u7528\u94FE\u63A5\u6216 ID\u3002");
|
|
570
|
+
return addTarget(source);
|
|
571
|
+
}
|
|
572
|
+
if (subcommand === "list") return listTargets();
|
|
573
|
+
}
|
|
574
|
+
if (command === "analyze") {
|
|
575
|
+
const analyzeArgs = subcommand?.startsWith("--") && subcommand ? [subcommand, ...args] : args;
|
|
576
|
+
const source = subcommand && !subcommand.startsWith("--") ? subcommand : positional(analyzeArgs);
|
|
577
|
+
return analyze(source, analyzeArgs);
|
|
578
|
+
}
|
|
579
|
+
if (command === "report") {
|
|
580
|
+
if (!subcommand) throw new import_metadata.CoreFailure("TARGET_REQUIRED", "\u7F3A\u5C11 target ID\u3002");
|
|
581
|
+
return report(subcommand);
|
|
582
|
+
}
|
|
583
|
+
if (command === "jobs" && subcommand === "get") {
|
|
584
|
+
const jobId = positional(args);
|
|
585
|
+
if (!jobId) throw new import_metadata.CoreFailure("JOB_REQUIRED", "\u7F3A\u5C11 job ID\u3002");
|
|
586
|
+
return getJob(jobId);
|
|
587
|
+
}
|
|
588
|
+
if (command === "search") {
|
|
589
|
+
if (!subcommand) throw new import_metadata.CoreFailure("TARGET_REQUIRED", "\u7F3A\u5C11 target ID\u3002");
|
|
590
|
+
return searchFindings(subcommand, args[0], args);
|
|
591
|
+
}
|
|
592
|
+
if (command === "native") return nativeCommand(subcommand, args);
|
|
593
|
+
if (command === "evidence") {
|
|
594
|
+
if (!subcommand) throw new import_metadata.CoreFailure("TARGET_REQUIRED", "\u7F3A\u5C11 target ID\u3002");
|
|
595
|
+
return evidence(subcommand);
|
|
596
|
+
}
|
|
597
|
+
if (command === "engine" && subcommand === "install") {
|
|
598
|
+
const file = args[0];
|
|
599
|
+
if (!file) throw new import_metadata.CoreFailure("ENGINE_REQUIRED", "\u7F3A\u5C11 engine \u6587\u4EF6\u8DEF\u5F84\u3002");
|
|
600
|
+
return installEngine(file, args);
|
|
601
|
+
}
|
|
602
|
+
if (command === "compare") {
|
|
603
|
+
if (!subcommand) throw new import_metadata.CoreFailure("TARGET_REQUIRED", "\u7F3A\u5C11 target ID\u3002");
|
|
604
|
+
return compare(subcommand, args[0], args[1], args);
|
|
605
|
+
}
|
|
606
|
+
if (command === "capabilities") return capabilities(subcommand);
|
|
607
|
+
if (command === "mcp") {
|
|
608
|
+
const { startMcpServer } = await import("@zhuixin/mcp");
|
|
609
|
+
await startMcpServer((0, import_metadata.loadConfig)());
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
usage();
|
|
613
|
+
throw new import_metadata.CoreFailure("UNKNOWN_COMMAND", `\u672A\u77E5\u547D\u4EE4\uFF1A${command}`);
|
|
614
|
+
}
|
|
615
|
+
void main().catch((error) => {
|
|
616
|
+
printError(error);
|
|
617
|
+
process.exitCode = 1;
|
|
618
|
+
});
|
|
619
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n AppAnalysisService,\n CoreFailure,\n CoreServer,\n installEngineArtifact,\n VersionComparisonService,\n loadConfig,\n type AnalysisGoal,\n type AnalyzeAppResult\n} from \"@zhuixin/metadata\";\nimport {\n CHANNELS,\n type CapabilityDescriptor,\n type HealthInfo,\n type JobRecord,\n type TargetRecord\n} from \"@zhuixin/shared\";\n\nconst GOALS: AnalysisGoal[] = [\n \"tech_stack\",\n \"feature_map\",\n \"network\",\n \"native_risk\",\n \"report\"\n];\n\nfunction usage(): void {\n console.log(`AppTrace 0.1.0\n\nUsage:\n apptrace setup [--json] [--install] [--write-config <path>]\n apptrace doctor [--json]\n apptrace auth login\n apptrace auth status\n apptrace targets add <app-store-url-or-id>\n apptrace targets list\n apptrace analyze [app-store-url-or-id] [--target <target-id>] [--goals ...] [--force]\n apptrace report <target-id>\n apptrace jobs get <job-id>\n apptrace search <target-id> [query] [--type route,module] [--limit 50]\n apptrace native search <target-id> <query> [--kind procedures|strings]\n apptrace native decompile <target-id> <function-name>\n apptrace evidence <target-id>\n apptrace compare <target-id> <left-artifact-id> <right-artifact-id> [--force]\n apptrace capabilities [target-id]\n apptrace engine install <engine-file> [--sha256 <digest>]\n apptrace mcp\n\nExamples:\n apptrace analyze https://apps.apple.com/cn/app/id1616124777\n apptrace analyze 1616124777 --goals tech_stack,feature_map,native_risk,report\n`);\n}\n\nfunction option(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n if (index >= 0 && args[index + 1]) return args[index + 1];\n const prefix = `${name}=`;\n const inline = args.find((arg) => arg.startsWith(prefix));\n return inline ? inline.slice(prefix.length) : undefined;\n}\n\nfunction hasFlag(args: string[], name: string): boolean {\n return args.includes(name);\n}\n\nfunction positional(args: string[]): string | undefined {\n return args.find((arg) => !arg.startsWith(\"--\"));\n}\n\nfunction parseGoals(value: string | undefined): AnalysisGoal[] {\n if (!value) return [\"tech_stack\", \"feature_map\", \"report\"];\n const goals = value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n const invalid = goals.filter(\n (goal): goal is string => !GOALS.includes(goal as AnalysisGoal)\n );\n if (invalid.length > 0) {\n throw new CoreFailure(\n \"INVALID_INPUT\",\n `未知分析目标:${invalid.join(\", \")}。可选:${GOALS.join(\", \")}`\n );\n }\n return goals as AnalysisGoal[];\n}\n\nfunction printJson(value: unknown): void {\n process.stdout.write(`${JSON.stringify(value, null, 2)}\\n`);\n}\n\nfunction printError(error: unknown): void {\n if (error instanceof CoreFailure) {\n console.error(`${error.code}: ${error.message}`);\n if (error.code === \"AUTH_REQUIRED\" || error.code === \"KEYCHAIN_LOCKED\") {\n console.error(\"Next: apptrace auth login\");\n } else if (error.code === \"LICENSE_REQUIRED\") {\n console.error(\"Next: 在 iPhone App Store 获取或购买该应用后重试。\");\n }\n return;\n }\n console.error(error instanceof Error ? error.stack ?? error.message : String(error));\n}\n\nfunction withCore<T>(operation: (core: CoreServer) => Promise<T>): Promise<T> {\n const core = new CoreServer({ config: loadConfig(), emit: () => {} });\n return operation(core).finally(() => core.close());\n}\n\nfunction interactive(\n command: string,\n args: string[],\n env?: NodeJS.ProcessEnv\n): Promise<number | null> {\n return new Promise((resolve, reject) => {\n const isWindowsCommand =\n process.platform === \"win32\" &&\n [\".cmd\", \".bat\"].includes(path.extname(command).toLowerCase());\n const child = isWindowsCommand\n ? spawn(\n process.env.ComSpec || \"cmd.exe\",\n [\"/d\", \"/s\", \"/c\", `\"${command}\" ${args.join(\" \")}`],\n {\n stdio: \"inherit\",\n windowsVerbatimArguments: true,\n env: env ? { ...process.env, ...env } : process.env\n }\n )\n : spawn(command, args, {\n stdio: \"inherit\",\n env: env ? { ...process.env, ...env } : process.env\n });\n child.on(\"error\", reject);\n child.on(\"exit\", (code) => resolve(code));\n });\n}\n\nasync function doctor(json: boolean): Promise<void> {\n const config = loadConfig();\n await withCore(async (core) => {\n const health = (await core.handle(CHANNELS.health, {})) as HealthInfo;\n const capabilities = (await core.handle(\n CHANNELS.capabilitiesList,\n {}\n )) as CapabilityDescriptor[];\n const result = { config, health, capabilities };\n if (json) {\n printJson(result);\n return;\n }\n console.log(`workspace: ${health.workspaceRoot}`);\n console.log(`host: ${health.hostPlatform}`);\n console.log(`store: ${health.store}`);\n console.log(\"tools:\");\n for (const tool of health.tools ?? []) {\n console.log(\n ` ${tool.available ? \"OK \" : \"MISS\"} ${tool.label}: ${tool.path}`\n );\n }\n console.log(\"capabilities:\");\n for (const capability of capabilities) {\n console.log(\n ` ${capability.available ? \"OK \" : \"NO \"} ${capability.id}${\n capability.reason ? ` — ${capability.reason}` : \"\"\n }`\n );\n }\n });\n}\n\nfunction createEngineLauncher(workspaceRoot: string): string {\n const reaScript = require.resolve(\"rea-agents/scripts/rea.mjs\");\n const tools = path.join(workspaceRoot, \"tools\");\n const javaHome = path.join(tools, \"jdk\");\n const ghidraHome = path.join(tools, \"ghidra_12.1.4_PUBLIC\");\n const ghidraUserHome = path.join(workspaceRoot, \".ghidra-home\");\n fs.mkdirSync(path.join(tools, \"bin\"), { recursive: true, mode: 0o700 });\n fs.mkdirSync(ghidraUserHome, { recursive: true, mode: 0o700 });\n const launcher = path.join(\n tools,\n \"bin\",\n process.platform === \"win32\" ? \"rea.cmd\" : \"rea\"\n );\n if (process.platform === \"win32\") {\n fs.writeFileSync(\n launcher,\n [\n \"@echo off\",\n `set \"JAVA_HOME=${javaHome}\"`,\n `set \"GHIDRA_INSTALL_DIR=${ghidraHome}\"`,\n `set \"GHIDRA_USER_HOME=${ghidraUserHome}\"`,\n 'set \"PATH=%JAVA_HOME%\\\\bin;%PATH%\"',\n `\"${process.execPath}\" \"${reaScript}\" %*`,\n \"\"\n ].join(\"\\r\\n\"),\n { mode: 0o700 }\n );\n } else {\n fs.writeFileSync(\n launcher,\n [\n \"#!/usr/bin/env bash\",\n \"set -euo pipefail\",\n `export JAVA_HOME=${JSON.stringify(javaHome)}`,\n `export GHIDRA_INSTALL_DIR=${JSON.stringify(ghidraHome)}`,\n `export GHIDRA_USER_HOME=${JSON.stringify(ghidraUserHome)}`,\n 'export PATH=\"$JAVA_HOME/bin:$PATH\"',\n 'export JAVA_TOOL_OPTIONS=\"${JAVA_TOOL_OPTIONS:-} -Duser.home=$GHIDRA_USER_HOME\"',\n `exec ${JSON.stringify(process.execPath)} ${JSON.stringify(reaScript)} \"$@\"`,\n \"\"\n ].join(\"\\n\"),\n { mode: 0o700 }\n );\n }\n return launcher;\n}\n\nasync function installTools(\n config: ReturnType<typeof loadConfig>,\n json = false\n): Promise<void> {\n if (\n fs.existsSync(config.enginePath) &&\n fs.existsSync(config.ipatoolPath)\n ) {\n process.stderr.write(\"Tools already available; download skipped.\\n\");\n return;\n }\n if (process.platform === \"win32\" && process.arch === \"x64\") {\n const script = path.resolve(__dirname, \"../../scripts/bootstrap-tools.ps1\");\n if (!fs.existsSync(script)) {\n throw new CoreFailure(\"TOOL_INSTALLER_MISSING\", `找不到安装脚本:${script}`);\n }\n process.stderr.write(\n \"Installing JDK, Ghidra and ipatool for Windows x64. This can take several minutes.\\n\"\n );\n const code = await interactive(\"powershell.exe\", [\n \"-NoProfile\",\n \"-ExecutionPolicy\",\n \"Bypass\",\n \"-File\",\n script,\n \"-WorkspaceRoot\",\n config.workspaceRoot\n ], {\n APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,\n APPTRACE_TOOLS_DIR: path.join(config.workspaceRoot, \"tools\"),\n ...(process.env.APPTRACE_IPATOOL_SHA256\n ? { APPTRACE_IPATOOL_SHA256: process.env.APPTRACE_IPATOOL_SHA256 }\n : {})\n });\n if (code !== 0) {\n throw new CoreFailure(\n \"TOOL_INSTALL_FAILED\",\n `工具安装失败,退出码:${code ?? \"unknown\"}`\n );\n }\n const launcher = createEngineLauncher(config.workspaceRoot);\n process.stderr.write(`Analysis engine launcher: ${launcher}\\n`);\n return;\n }\n if (process.platform !== \"darwin\" || process.arch !== \"arm64\") {\n throw new CoreFailure(\n \"TOOL_INSTALL_UNSUPPORTED\",\n \"v1 自动安装器当前只支持 macOS arm64;其他平台请使用 APPTRACE_ENGINE_PATH 和 APPTRACE_IPATOOL_PATH。\"\n );\n }\n const script = path.resolve(__dirname, \"../../scripts/bootstrap-tools.sh\");\n if (!fs.existsSync(script)) {\n throw new CoreFailure(\"TOOL_INSTALLER_MISSING\", `找不到安装脚本:${script}`);\n }\n process.stderr.write(\n \"Installing JDK, Ghidra and ipatool. This can take several minutes.\\n\"\n );\n const code = await interactive(\"/bin/bash\", [script], {\n APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,\n APPTRACE_TOOLS_DIR: path.join(config.workspaceRoot, \"tools\")\n });\n if (code !== 0) {\n throw new CoreFailure(\n \"TOOL_INSTALL_FAILED\",\n `工具安装失败,退出码:${code ?? \"unknown\"}`\n );\n }\n const launcher = createEngineLauncher(config.workspaceRoot);\n process.stderr.write(`Analysis engine launcher: ${launcher}\\n`);\n}\n\nasync function setup(json: boolean, args: string[]): Promise<void> {\n const configPath = option(args, \"--write-config\");\n const config = loadConfig();\n if (hasFlag(args, \"--install\")) {\n await installTools(config, json);\n }\n await doctor(json);\n if (json && !configPath) return;\n const serverEntry = path.resolve(__dirname, \"../../mcp/dist/index.js\");\n const env = {\n APPTRACE_WORKSPACE_ROOT: config.workspaceRoot,\n APPTRACE_ENGINE_PATH: config.enginePath,\n APPTRACE_ANALYSIS_ENGINE_PATH: config.analysisEnginePath,\n APPTRACE_IPATOOL_PATH: config.ipatoolPath\n };\n if (configPath) {\n const absolute = path.resolve(configPath);\n const extension = path.extname(absolute).toLowerCase();\n if (extension === \".json\") {\n fs.mkdirSync(path.dirname(absolute), { recursive: true, mode: 0o700 });\n fs.writeFileSync(\n absolute,\n `${JSON.stringify(\n {\n mcpServers: {\n apptrace: {\n command: process.execPath,\n args: [serverEntry],\n env\n }\n }\n },\n null,\n 2\n )}\\n`,\n { mode: 0o600 }\n );\n } else if (extension === \".toml\") {\n fs.mkdirSync(path.dirname(absolute), { recursive: true, mode: 0o700 });\n const toml = [\n \"[mcp_servers.apptrace]\",\n `command = ${JSON.stringify(process.execPath)}`,\n `args = [${JSON.stringify(serverEntry)}]`,\n `env = { APPTRACE_WORKSPACE_ROOT = ${JSON.stringify(\n env.APPTRACE_WORKSPACE_ROOT\n )}, APPTRACE_ENGINE_PATH = ${JSON.stringify(\n env.APPTRACE_ENGINE_PATH\n )}, APPTRACE_ANALYSIS_ENGINE_PATH = ${JSON.stringify(\n env.APPTRACE_ANALYSIS_ENGINE_PATH\n )}, APPTRACE_IPATOOL_PATH = ${JSON.stringify(\n env.APPTRACE_IPATOOL_PATH\n )} }`,\n \"\"\n ].join(\"\\n\");\n fs.writeFileSync(absolute, toml, { mode: 0o600 });\n } else {\n throw new CoreFailure(\n \"INVALID_CONFIG_FORMAT\",\n \"--write-config 只支持 .json 或 .toml 文件。\"\n );\n }\n if (json) {\n process.stderr.write(`MCP config written: ${absolute}\\n`);\n return;\n }\n console.log(`MCP config written: ${absolute}`);\n }\n console.log(`\nMCP configuration:\n\n[mcp_servers.apptrace]\ncommand = \"${process.execPath.replace(/\\\\/g, \"\\\\\\\\\")}\"\nargs = [\"${serverEntry.replace(/\\\\/g, \"\\\\\\\\\")}\"]\nenv = { APPTRACE_WORKSPACE_ROOT = \"${env.APPTRACE_WORKSPACE_ROOT.replace(/\\\\/g, \"\\\\\\\\\")}\", APPTRACE_ENGINE_PATH = \"${env.APPTRACE_ENGINE_PATH.replace(/\\\\/g, \"\\\\\\\\\")}\", APPTRACE_ANALYSIS_ENGINE_PATH = \"${env.APPTRACE_ANALYSIS_ENGINE_PATH.replace(/\\\\/g, \"\\\\\\\\\")}\", APPTRACE_IPATOOL_PATH = \"${env.APPTRACE_IPATOOL_PATH.replace(/\\\\/g, \"\\\\\\\\\")}\" }\n\n首次写入配置后重载一次 Agent 客户端。\n`);\n}\n\nasync function authLogin(): Promise<void> {\n const config = loadConfig();\n const code = await interactive(config.ipatoolPath, [\"auth\", \"login\"]);\n if (code !== 0) {\n throw new CoreFailure(\n \"AUTH_FAILED\",\n `ipatool 登录没有成功,退出码:${code ?? \"unknown\"}`\n );\n }\n await authStatus();\n}\n\nasync function authStatus(): Promise<void> {\n await withCore(async (core) => {\n const status = await core.handle(CHANNELS.accountStatus, { force: true });\n printJson(status);\n });\n}\n\nasync function addTarget(source: string): Promise<void> {\n await withCore(async (core) => {\n const resolved = (await core.handle(CHANNELS.targetsResolve, {\n input: source\n })) as { resolutionId: string };\n const target = (await core.handle(CHANNELS.targetsCreate, {\n resolutionId: resolved.resolutionId\n })) as TargetRecord;\n printJson(target);\n });\n}\n\nasync function listTargets(): Promise<void> {\n await withCore(async (core) => {\n printJson(await core.handle(CHANNELS.targetsList, {}));\n });\n}\n\nasync function analyze(source: string | undefined, args: string[]): Promise<void> {\n const goals = parseGoals(option(args, \"--goals\"));\n const json = hasFlag(args, \"--json\");\n const force = hasFlag(args, \"--force\");\n const targetId = option(args, \"--target\");\n if (!source && !targetId) {\n throw new CoreFailure(\"SOURCE_REQUIRED\", \"缺少应用链接、ID 或 --target。\");\n }\n await withCore(async (core) => {\n const service = new AppAnalysisService(core);\n const result = await service.analyzeApp({\n source: targetId ? undefined : source,\n targetId,\n goals,\n force,\n onProgress: (event) => {\n if (!json) {\n process.stderr.write(\n `[${event.step}] ${event.status}${\n event.message ? ` — ${event.message}` : \"\"\n }\\n`\n );\n }\n }\n });\n if (json) {\n printJson(result);\n } else {\n printAnalysis(result);\n }\n });\n}\n\nfunction printAnalysis(result: AnalyzeAppResult): void {\n console.log(`\\n${result.targetName}`);\n console.log(`Target: ${result.targetId}`);\n console.log(`Artifact: ${result.artifact.sha256}`);\n console.log(\n `Technology: ${result.technology?.hints.join(\" / \") || \"unknown\"}`\n );\n console.log(`Routes: ${result.routes?.count ?? 0}`);\n console.log(`Modules: ${result.modules?.count ?? 0}`);\n console.log(`Network endpoints: ${result.networkEndpoints?.count ?? 0}`);\n if (result.native) {\n console.log(\n `Native: ${result.native.procedureCount ?? \"?\"} procedures, ${\n result.native.stringCount ?? \"?\"\n } strings`\n );\n if (result.native.warning) console.log(`Warning: ${result.native.warning}`);\n }\n if (result.reportPath) console.log(`Report: ${result.reportPath}`);\n for (const evidencePath of result.evidencePaths) {\n console.log(`Evidence: ${evidencePath}`);\n }\n if (result.limitations.length > 0) {\n console.log(\"Limitations:\");\n for (const limitation of result.limitations.slice(0, 6)) {\n console.log(` - ${limitation}`);\n }\n }\n}\n\nasync function report(targetId: string): Promise<void> {\n await withCore(async (core) => {\n const service = new AppAnalysisService(core);\n printJson(await service.runCapability(targetId, \"generate:report\"));\n });\n}\n\nasync function getJob(jobId: string): Promise<void> {\n await withCore(async (core) => {\n const result = (await core.handle(CHANNELS.jobsGet, { jobId })) as {\n job: JobRecord;\n events: unknown[];\n };\n printJson({ ...result, events: result.events.slice(-50) });\n });\n}\n\nasync function searchFindings(\n targetId: string,\n query: string | undefined,\n args: string[]\n): Promise<void> {\n const types = option(args, \"--type\")\n ?.split(\",\")\n .map((value) => value.trim())\n .filter(Boolean);\n const limit = Number(option(args, \"--limit\") ?? 50);\n await withCore(async (core) => {\n printJson(\n await core.handle(CHANNELS.findingsSearch, {\n targetId,\n query,\n types,\n limit: Number.isFinite(limit) ? limit : 50\n })\n );\n });\n}\n\nasync function nativeCommand(\n action: string | undefined,\n args: string[]\n): Promise<void> {\n const targetId = args[0];\n const value = args[1];\n if (!targetId || !value) {\n throw new CoreFailure(\n \"INVALID_INPUT\",\n \"用法:apptrace native <search|decompile> <target-id> <query-or-function>\"\n );\n }\n await withCore(async (core) => {\n const service = new AppAnalysisService(core);\n if (action === \"search\") {\n printJson(\n await service.runCapability(targetId, \"native:search\", {\n query: value,\n kind: option(args, \"--kind\") ?? \"procedures\",\n mode: option(args, \"--mode\") ?? \"literal\"\n })\n );\n return;\n }\n if (action === \"decompile\") {\n printJson(\n await service.runCapability(targetId, \"native:decompile\", {\n functionName: value\n })\n );\n return;\n }\n throw new CoreFailure(\n \"INVALID_INPUT\",\n \"原生命令只支持 search 或 decompile。\"\n );\n });\n}\n\nasync function evidence(targetId: string): Promise<void> {\n await withCore(async (core) => {\n printJson(\n await core.handle(CHANNELS.evidenceList, {\n targetId\n })\n );\n });\n}\n\nasync function installEngine(file: string, args: string[]): Promise<void> {\n const config = loadConfig();\n const expected = option(args, \"--sha256\");\n const installed = installEngineArtifact(config.workspaceRoot, file, expected);\n printJson(installed);\n}\n\nasync function compare(\n targetId: string | undefined,\n leftArtifactId: string | undefined,\n rightArtifactId: string | undefined,\n args: string[]\n): Promise<void> {\n if (!targetId || !leftArtifactId || !rightArtifactId) {\n throw new CoreFailure(\n \"INVALID_INPUT\",\n \"用法:apptrace compare <target-id> <left-artifact-id> <right-artifact-id>\"\n );\n }\n await withCore(async (core) => {\n printJson(\n await new VersionComparisonService(core).compare(\n targetId,\n leftArtifactId,\n rightArtifactId,\n { force: hasFlag(args, \"--force\") }\n )\n );\n });\n}\n\nasync function capabilities(targetId?: string): Promise<void> {\n await withCore(async (core) => {\n printJson(\n await core.handle(CHANNELS.capabilitiesList, {\n ...(targetId ? { targetId } : {})\n })\n );\n });\n}\n\nasync function main(): Promise<void> {\n const [command, subcommand, ...args] = process.argv.slice(2);\n if (!command || [\"help\", \"-h\", \"--help\"].includes(command)) {\n usage();\n return;\n }\n if (command === \"setup\") {\n const setupArgs =\n subcommand?.startsWith(\"--\") && subcommand\n ? [subcommand, ...args]\n : args;\n return setup(hasFlag(setupArgs, \"--json\"), setupArgs);\n }\n if (command === \"doctor\") {\n const doctorArgs =\n subcommand?.startsWith(\"--\") && subcommand\n ? [subcommand, ...args]\n : args;\n return doctor(hasFlag(doctorArgs, \"--json\"));\n }\n if (command === \"auth\") {\n if (subcommand === \"login\") return authLogin();\n if (subcommand === \"status\") return authStatus();\n }\n if (command === \"targets\") {\n if (subcommand === \"add\") {\n const source = positional(args);\n if (!source) throw new CoreFailure(\"SOURCE_REQUIRED\", \"缺少应用链接或 ID。\");\n return addTarget(source);\n }\n if (subcommand === \"list\") return listTargets();\n }\n if (command === \"analyze\") {\n const analyzeArgs =\n subcommand?.startsWith(\"--\") && subcommand\n ? [subcommand, ...args]\n : args;\n const source =\n subcommand && !subcommand.startsWith(\"--\")\n ? subcommand\n : positional(analyzeArgs);\n return analyze(source, analyzeArgs);\n }\n if (command === \"report\") {\n if (!subcommand) throw new CoreFailure(\"TARGET_REQUIRED\", \"缺少 target ID。\");\n return report(subcommand);\n }\n if (command === \"jobs\" && subcommand === \"get\") {\n const jobId = positional(args);\n if (!jobId) throw new CoreFailure(\"JOB_REQUIRED\", \"缺少 job ID。\");\n return getJob(jobId);\n }\n if (command === \"search\") {\n if (!subcommand) throw new CoreFailure(\"TARGET_REQUIRED\", \"缺少 target ID。\");\n return searchFindings(subcommand, args[0], args);\n }\n if (command === \"native\") return nativeCommand(subcommand, args);\n if (command === \"evidence\") {\n if (!subcommand) throw new CoreFailure(\"TARGET_REQUIRED\", \"缺少 target ID。\");\n return evidence(subcommand);\n }\n if (command === \"engine\" && subcommand === \"install\") {\n const file = args[0];\n if (!file) throw new CoreFailure(\"ENGINE_REQUIRED\", \"缺少 engine 文件路径。\");\n return installEngine(file, args);\n }\n if (command === \"compare\") {\n if (!subcommand) throw new CoreFailure(\"TARGET_REQUIRED\", \"缺少 target ID。\");\n return compare(subcommand, args[0], args[1], args);\n }\n if (command === \"capabilities\") return capabilities(subcommand);\n if (command === \"mcp\") {\n const { startMcpServer } = await import(\"@zhuixin/mcp\");\n await startMcpServer(loadConfig());\n return;\n }\n usage();\n throw new CoreFailure(\"UNKNOWN_COMMAND\", `未知命令:${command}`);\n}\n\nvoid main().catch((error) => {\n printError(error);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gCAAsB;AACtB,qBAAe;AACf,uBAAiB;AACjB,sBASO;AACP,oBAMO;AAEP,IAAM,QAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,QAAc;AACrB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAwBb;AACD;AAEA,SAAS,OAAO,MAAgB,MAAkC;AAChE,QAAM,QAAQ,KAAK,QAAQ,IAAI;AAC/B,MAAI,SAAS,KAAK,KAAK,QAAQ,CAAC,EAAG,QAAO,KAAK,QAAQ,CAAC;AACxD,QAAM,SAAS,GAAG,IAAI;AACtB,QAAM,SAAS,KAAK,KAAK,CAAC,QAAQ,IAAI,WAAW,MAAM,CAAC;AACxD,SAAO,SAAS,OAAO,MAAM,OAAO,MAAM,IAAI;AAChD;AAEA,SAAS,QAAQ,MAAgB,MAAuB;AACtD,SAAO,KAAK,SAAS,IAAI;AAC3B;AAEA,SAAS,WAAW,MAAoC;AACtD,SAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,IAAI,WAAW,IAAI,CAAC;AACjD;AAEA,SAAS,WAAW,OAA2C;AAC7D,MAAI,CAAC,MAAO,QAAO,CAAC,cAAc,eAAe,QAAQ;AACzD,QAAM,QAAQ,MACX,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;AACjB,QAAM,UAAU,MAAM;AAAA,IACpB,CAAC,SAAyB,CAAC,MAAM,SAAS,IAAoB;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
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhuixin/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "AppTrace CLI for evidence-backed application analysis",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/zhuixin-labs/app-evidence.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/zhuixin-labs/app-evidence",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/zhuixin-labs/app-evidence/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"ai-agents",
|
|
18
|
+
"app-analysis",
|
|
19
|
+
"static-analysis",
|
|
20
|
+
"ios",
|
|
21
|
+
"ipa"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.19"
|
|
28
|
+
},
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"bin": {
|
|
31
|
+
"apptrace": "dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"rea-agents": "6.4.0",
|
|
38
|
+
"@zhuixin/metadata": "0.1.0",
|
|
39
|
+
"@zhuixin/shared": "0.1.0",
|
|
40
|
+
"@zhuixin/mcp": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"tsup": "^8.5.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup",
|
|
47
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
48
|
+
}
|
|
6
49
|
}
|
package/README.md
DELETED