@pensar/apex 2.4.0 → 2.5.0-canary.2bbb0f6f
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/build/agent-20hb6mg7.js +20 -0
- package/build/{agent-5ejt5vpz.js → agent-71sn1cjn.js} +9 -8
- package/build/{agent-nhs1w5w0.js → agent-xnrz4bhp.js} +11 -10
- package/build/{apps-17wvz1d7.js → apps-ghf7kp1s.js} +72 -31
- package/build/{auth-z3h9859n.js → auth-p1nrv7re.js} +25 -20
- package/build/authentication-m1vj2f0s.js +20 -0
- package/build/blackboxAgent-hjfzgk93.js +20 -0
- package/build/blackboxPentest-9snp9gvp.js +70 -0
- package/build/{cli-0n4r54hq.js → cli-08fcc6d8.js} +1 -1
- package/build/{cli-gq40s5b3.js → cli-14j00zfh.js} +5 -3
- package/build/{cli-vnynf0js.js → cli-3bmqdcfh.js} +10 -4
- package/build/{cli-mavved45.js → cli-3ew5fs3f.js} +46 -25
- package/build/{cli-xshasbwe.js → cli-4mgj070h.js} +30 -4
- package/build/{cli-repbyhkk.js → cli-4vwnsyep.js} +1141 -525
- package/build/cli-53rm0rrz.js +15 -0
- package/build/cli-68260ckj.js +12136 -0
- package/build/cli-7q3ae3ft.js +6 -0
- package/build/{cli-5k33webc.js → cli-7sqb16dd.js} +45 -43
- package/build/{cli-9rhzhgx2.js → cli-8pk8znhw.js} +1 -1
- package/build/cli-9pbk8m32.js +32 -0
- package/build/{cli-72cvcqhg.js → cli-9ya3yktn.js} +1 -1
- package/build/{cli-vq52kp7j.js → cli-a8n64cef.js} +23 -5
- package/build/{cli-qqt4gj1w.js → cli-a9vq54sx.js} +5 -3
- package/build/{cli-swpbx60z.js → cli-avmhkjtv.js} +1 -1481
- package/build/{cli-tkc598ey.js → cli-f47dgye3.js} +411 -280
- package/build/{cli-k8kc47pq.js → cli-fw7sp0fp.js} +3 -3
- package/build/{cli-32z0017y.js → cli-g3cb8pj5.js} +2 -2
- package/build/{cli-tznv8pf1.js → cli-gbch9xmy.js} +1 -1
- package/build/cli-knd276ed.js +1485 -0
- package/build/{cli-2cbwdk78.js → cli-t7rhyqx5.js} +1 -1
- package/build/{cli-b1adytsy.js → cli-yge44bmk.js} +28 -5
- package/build/cli.js +641 -95
- package/build/{config-f1mj4nhd.js → config-cqw98n5y.js} +18 -15
- package/build/{doctor-ekneewa3.js → doctor-vzh1wmfa.js} +8 -7
- package/build/{fastStrike-8zka43xs.js → fastStrike-f441e9nr.js} +13 -10
- package/build/{fixes-b89s5haw.js → fixes-xxz52cf2.js} +25 -20
- package/build/getMachineId-bsd-xj3bn2fv.js +36 -0
- package/build/getMachineId-darwin-07jzjcx6.js +36 -0
- package/build/getMachineId-linux-ahngynxd.js +29 -0
- package/build/getMachineId-unsupported-vy43b44z.js +19 -0
- package/build/getMachineId-win-8x66cynz.js +38 -0
- package/build/{index-ghwf5z3v.js → index-23jj0234.js} +3 -3
- package/build/{index-6d22pyxt.js → index-3gavwzay.js} +1756 -1213
- package/build/{index-4ad3sdwk.js → index-4v5jc2td.js} +4 -4
- package/build/{index-mtq7kmxz.js → index-5wh7gq37.js} +4 -2
- package/build/{index-sf16jm0m.js → index-e7kq5rrd.js} +9 -7
- package/build/{index-rbzhk712.js → index-fxx38nc9.js} +11 -10
- package/build/{index-hqjdg6fg.js → index-j3dc7dks.js} +17 -9
- package/build/{index-y5w6n3tb.js → index-yc1dnj3n.js} +2 -2
- package/build/{issues-xx5bs4md.js → issues-zdag9ayw.js} +82 -26
- package/build/{logs-qtxe51w2.js → logs-f492cjgt.js} +25 -20
- package/build/{offesecAgent-b9e2xm6v.js → offesecAgent-pr0cmrqb.js} +10 -9
- package/build/pentest-1g3fzah5.js +30 -0
- package/build/{pentests-6ks3szc4.js → pentests-vstpzh9j.js} +26 -21
- package/build/{targetedPentest-s1ptvq8e.js → targetedPentest-wj3ae355.js} +11 -10
- package/build/{targets-sxygyj87.js → targets-806zxf1n.js} +27 -22
- package/build/threatModel-dc4jbhkf.js +29 -0
- package/build/{uninstall-tvsh81v8.js → uninstall-58ak2e2v.js} +6 -3
- package/build/{upload-7wdyyqmr.js → upload-kkktzh83.js} +8 -7
- package/build/{utils-7fwdkqk6.js → utils-1sawtwbj.js} +7 -6
- package/package.json +8 -2
- package/build/agent-mvpgvgks.js +0 -19
- package/build/authentication-3s97cpk4.js +0 -19
- package/build/blackboxAgent-gw0a1ca4.js +0 -19
- package/build/blackboxPentest-44333zss.js +0 -37
- package/build/main-mmjp338j.js +0 -324
- package/build/pentest-xtc1sjdw.js +0 -29
- package/build/threatModel-xsm6fwk5.js +0 -27
package/build/cli.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
+
import {
|
|
4
|
+
require_index_node_http,
|
|
5
|
+
require_index_shim,
|
|
6
|
+
require_src as require_src2,
|
|
7
|
+
require_src1 as require_src3,
|
|
8
|
+
require_src2 as require_src4,
|
|
9
|
+
require_src3 as require_src5,
|
|
10
|
+
require_src4 as require_src6
|
|
11
|
+
} from "./cli-68260ckj.js";
|
|
3
12
|
import"./cli-dm0fc0bm.js";
|
|
4
13
|
import {
|
|
5
14
|
createThreatModelPrompt
|
|
@@ -7,27 +16,358 @@ import {
|
|
|
7
16
|
import"./cli-c8131c4q.js";
|
|
8
17
|
import {
|
|
9
18
|
buildAuthConfig,
|
|
19
|
+
endAllActiveRootSpans,
|
|
20
|
+
init_active_root_spans,
|
|
10
21
|
init_ai1 as init_ai,
|
|
22
|
+
init_model_history,
|
|
11
23
|
init_models,
|
|
12
24
|
init_session,
|
|
13
25
|
init_structured,
|
|
14
26
|
init_toolset,
|
|
15
27
|
init_utils,
|
|
16
28
|
logger
|
|
17
|
-
} from "./cli-
|
|
18
|
-
import"./cli-
|
|
19
|
-
import"./cli-
|
|
29
|
+
} from "./cli-f47dgye3.js";
|
|
30
|
+
import"./cli-08fcc6d8.js";
|
|
31
|
+
import"./cli-avmhkjtv.js";
|
|
20
32
|
import"./cli-j54qa6tm.js";
|
|
21
|
-
import"./cli-
|
|
22
|
-
import"./cli-
|
|
33
|
+
import"./cli-9ya3yktn.js";
|
|
34
|
+
import"./cli-8pk8znhw.js";
|
|
23
35
|
import {
|
|
36
|
+
init_installation,
|
|
24
37
|
init_package,
|
|
25
|
-
package_default
|
|
26
|
-
|
|
38
|
+
package_default,
|
|
39
|
+
version
|
|
40
|
+
} from "./cli-3bmqdcfh.js";
|
|
41
|
+
import {
|
|
42
|
+
require_src
|
|
43
|
+
} from "./cli-knd276ed.js";
|
|
27
44
|
import {
|
|
45
|
+
__commonJS,
|
|
28
46
|
__require,
|
|
29
47
|
__toESM
|
|
30
48
|
} from "./cli-bc05qbss.js";
|
|
49
|
+
|
|
50
|
+
// node_modules/dotenv/lib/main.js
|
|
51
|
+
var require_main = __commonJS(function(exports, module) {
|
|
52
|
+
var fs = __require("fs");
|
|
53
|
+
var path = __require("path");
|
|
54
|
+
var os = __require("os");
|
|
55
|
+
var crypto = __require("crypto");
|
|
56
|
+
var TIPS = [
|
|
57
|
+
"◈ encrypted .env [www.dotenvx.com]",
|
|
58
|
+
"◈ secrets for agents [www.dotenvx.com]",
|
|
59
|
+
"⌁ auth for agents [www.vestauth.com]",
|
|
60
|
+
"⌘ custom filepath { path: '/custom/path/.env' }",
|
|
61
|
+
"⌘ enable debugging { debug: true }",
|
|
62
|
+
"⌘ override existing { override: true }",
|
|
63
|
+
"⌘ suppress logs { quiet: true }",
|
|
64
|
+
"⌘ multiple files { path: ['.env.local', '.env'] }"
|
|
65
|
+
];
|
|
66
|
+
function _getRandomTip() {
|
|
67
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
68
|
+
}
|
|
69
|
+
function parseBoolean(value) {
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
72
|
+
}
|
|
73
|
+
return Boolean(value);
|
|
74
|
+
}
|
|
75
|
+
function supportsAnsi() {
|
|
76
|
+
return process.stdout.isTTY;
|
|
77
|
+
}
|
|
78
|
+
function dim(text) {
|
|
79
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
80
|
+
}
|
|
81
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
82
|
+
function parse(src) {
|
|
83
|
+
const obj = {};
|
|
84
|
+
let lines = src.toString();
|
|
85
|
+
lines = lines.replace(/\r\n?/mg, `
|
|
86
|
+
`);
|
|
87
|
+
let match;
|
|
88
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
89
|
+
const key = match[1];
|
|
90
|
+
let value = match[2] || "";
|
|
91
|
+
value = value.trim();
|
|
92
|
+
const maybeQuote = value[0];
|
|
93
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
94
|
+
if (maybeQuote === '"') {
|
|
95
|
+
value = value.replace(/\\n/g, `
|
|
96
|
+
`);
|
|
97
|
+
value = value.replace(/\\r/g, "\r");
|
|
98
|
+
}
|
|
99
|
+
obj[key] = value;
|
|
100
|
+
}
|
|
101
|
+
return obj;
|
|
102
|
+
}
|
|
103
|
+
function _parseVault(options) {
|
|
104
|
+
options = options || {};
|
|
105
|
+
const vaultPath = _vaultPath(options);
|
|
106
|
+
options.path = vaultPath;
|
|
107
|
+
const result = DotenvModule.configDotenv(options);
|
|
108
|
+
if (!result.parsed) {
|
|
109
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
110
|
+
err.code = "MISSING_DATA";
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
const keys = _dotenvKey(options).split(",");
|
|
114
|
+
const length = keys.length;
|
|
115
|
+
let decrypted;
|
|
116
|
+
for (let i = 0;i < length; i++) {
|
|
117
|
+
try {
|
|
118
|
+
const key = keys[i].trim();
|
|
119
|
+
const attrs = _instructions(result, key);
|
|
120
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
121
|
+
break;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (i + 1 >= length) {
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return DotenvModule.parse(decrypted);
|
|
129
|
+
}
|
|
130
|
+
function _warn(message) {
|
|
131
|
+
console.error(`⚠ ${message}`);
|
|
132
|
+
}
|
|
133
|
+
function _debug(message) {
|
|
134
|
+
console.log(`┆ ${message}`);
|
|
135
|
+
}
|
|
136
|
+
function _log(message) {
|
|
137
|
+
console.log(`◇ ${message}`);
|
|
138
|
+
}
|
|
139
|
+
function _dotenvKey(options) {
|
|
140
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
141
|
+
return options.DOTENV_KEY;
|
|
142
|
+
}
|
|
143
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
144
|
+
return process.env.DOTENV_KEY;
|
|
145
|
+
}
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
function _instructions(result, dotenvKey) {
|
|
149
|
+
let uri;
|
|
150
|
+
try {
|
|
151
|
+
uri = new URL(dotenvKey);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
154
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
155
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
const key = uri.password;
|
|
161
|
+
if (!key) {
|
|
162
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
163
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
const environment = uri.searchParams.get("environment");
|
|
167
|
+
if (!environment) {
|
|
168
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
169
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
173
|
+
const ciphertext = result.parsed[environmentKey];
|
|
174
|
+
if (!ciphertext) {
|
|
175
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
176
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
return { ciphertext, key };
|
|
180
|
+
}
|
|
181
|
+
function _vaultPath(options) {
|
|
182
|
+
let possibleVaultPath = null;
|
|
183
|
+
if (options && options.path && options.path.length > 0) {
|
|
184
|
+
if (Array.isArray(options.path)) {
|
|
185
|
+
for (const filepath of options.path) {
|
|
186
|
+
if (fs.existsSync(filepath)) {
|
|
187
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
195
|
+
}
|
|
196
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
197
|
+
return possibleVaultPath;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
function _resolveHome(envPath) {
|
|
202
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
203
|
+
}
|
|
204
|
+
function _configVault(options) {
|
|
205
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
206
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
207
|
+
if (debug || !quiet) {
|
|
208
|
+
_log("loading env from encrypted .env.vault");
|
|
209
|
+
}
|
|
210
|
+
const parsed = DotenvModule._parseVault(options);
|
|
211
|
+
let processEnv = process.env;
|
|
212
|
+
if (options && options.processEnv != null) {
|
|
213
|
+
processEnv = options.processEnv;
|
|
214
|
+
}
|
|
215
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
216
|
+
return { parsed };
|
|
217
|
+
}
|
|
218
|
+
function configDotenv(options) {
|
|
219
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
220
|
+
let encoding = "utf8";
|
|
221
|
+
let processEnv = process.env;
|
|
222
|
+
if (options && options.processEnv != null) {
|
|
223
|
+
processEnv = options.processEnv;
|
|
224
|
+
}
|
|
225
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
226
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
227
|
+
if (options && options.encoding) {
|
|
228
|
+
encoding = options.encoding;
|
|
229
|
+
} else {
|
|
230
|
+
if (debug) {
|
|
231
|
+
_debug("no encoding is specified (UTF-8 is used by default)");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
let optionPaths = [dotenvPath];
|
|
235
|
+
if (options && options.path) {
|
|
236
|
+
if (!Array.isArray(options.path)) {
|
|
237
|
+
optionPaths = [_resolveHome(options.path)];
|
|
238
|
+
} else {
|
|
239
|
+
optionPaths = [];
|
|
240
|
+
for (const filepath of options.path) {
|
|
241
|
+
optionPaths.push(_resolveHome(filepath));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
let lastError;
|
|
246
|
+
const parsedAll = {};
|
|
247
|
+
for (const path2 of optionPaths) {
|
|
248
|
+
try {
|
|
249
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
250
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
if (debug) {
|
|
253
|
+
_debug(`failed to load ${path2} ${e.message}`);
|
|
254
|
+
}
|
|
255
|
+
lastError = e;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
259
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
260
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
261
|
+
if (debug || !quiet) {
|
|
262
|
+
const keysCount = Object.keys(populated).length;
|
|
263
|
+
const shortPaths = [];
|
|
264
|
+
for (const filePath of optionPaths) {
|
|
265
|
+
try {
|
|
266
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
267
|
+
shortPaths.push(relative);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
if (debug) {
|
|
270
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
271
|
+
}
|
|
272
|
+
lastError = e;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
276
|
+
}
|
|
277
|
+
if (lastError) {
|
|
278
|
+
return { parsed: parsedAll, error: lastError };
|
|
279
|
+
} else {
|
|
280
|
+
return { parsed: parsedAll };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function config(options) {
|
|
284
|
+
if (_dotenvKey(options).length === 0) {
|
|
285
|
+
return DotenvModule.configDotenv(options);
|
|
286
|
+
}
|
|
287
|
+
const vaultPath = _vaultPath(options);
|
|
288
|
+
if (!vaultPath) {
|
|
289
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
290
|
+
return DotenvModule.configDotenv(options);
|
|
291
|
+
}
|
|
292
|
+
return DotenvModule._configVault(options);
|
|
293
|
+
}
|
|
294
|
+
function decrypt(encrypted, keyStr) {
|
|
295
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
296
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
297
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
298
|
+
const authTag = ciphertext.subarray(-16);
|
|
299
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
300
|
+
try {
|
|
301
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
302
|
+
aesgcm.setAuthTag(authTag);
|
|
303
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
304
|
+
} catch (error) {
|
|
305
|
+
const isRange = error instanceof RangeError;
|
|
306
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
307
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
308
|
+
if (isRange || invalidKeyLength) {
|
|
309
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
310
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
311
|
+
throw err;
|
|
312
|
+
} else if (decryptionFailed) {
|
|
313
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
314
|
+
err.code = "DECRYPTION_FAILED";
|
|
315
|
+
throw err;
|
|
316
|
+
} else {
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function populate(processEnv, parsed, options = {}) {
|
|
322
|
+
const debug = Boolean(options && options.debug);
|
|
323
|
+
const override = Boolean(options && options.override);
|
|
324
|
+
const populated = {};
|
|
325
|
+
if (typeof parsed !== "object") {
|
|
326
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
327
|
+
err.code = "OBJECT_REQUIRED";
|
|
328
|
+
throw err;
|
|
329
|
+
}
|
|
330
|
+
for (const key of Object.keys(parsed)) {
|
|
331
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
332
|
+
if (override === true) {
|
|
333
|
+
processEnv[key] = parsed[key];
|
|
334
|
+
populated[key] = parsed[key];
|
|
335
|
+
}
|
|
336
|
+
if (debug) {
|
|
337
|
+
if (override === true) {
|
|
338
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
339
|
+
} else {
|
|
340
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
processEnv[key] = parsed[key];
|
|
345
|
+
populated[key] = parsed[key];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return populated;
|
|
349
|
+
}
|
|
350
|
+
var DotenvModule = {
|
|
351
|
+
configDotenv,
|
|
352
|
+
_configVault,
|
|
353
|
+
_parseVault,
|
|
354
|
+
config,
|
|
355
|
+
decrypt,
|
|
356
|
+
parse,
|
|
357
|
+
populate
|
|
358
|
+
};
|
|
359
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
360
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
361
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
362
|
+
module.exports.config = DotenvModule.config;
|
|
363
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
364
|
+
module.exports.parse = DotenvModule.parse;
|
|
365
|
+
module.exports.populate = DotenvModule.populate;
|
|
366
|
+
module.exports = DotenvModule;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// src/cli.ts
|
|
370
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
31
371
|
// package.json
|
|
32
372
|
var package_default2 = {
|
|
33
373
|
author: "Pensar",
|
|
@@ -47,6 +387,10 @@ var package_default2 = {
|
|
|
47
387
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
48
388
|
"@openrouter/ai-sdk-provider": "^2.9.1",
|
|
49
389
|
"@opentelemetry/api": "^1.9.1",
|
|
390
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
|
391
|
+
"@opentelemetry/otlp-exporter-base": "^0.221.0",
|
|
392
|
+
"@opentelemetry/otlp-transformer": "^0.221.0",
|
|
393
|
+
"@opentelemetry/resources": "^2.10.0",
|
|
50
394
|
"@opentui/core": "^0.1.107",
|
|
51
395
|
"@opentui/react": "^0.1.107",
|
|
52
396
|
"@pensar/surface": "0.3.0",
|
|
@@ -70,6 +414,8 @@ var package_default2 = {
|
|
|
70
414
|
description: "AI-powered penetration testing CLI tool with terminal UI",
|
|
71
415
|
devDependencies: {
|
|
72
416
|
"@biomejs/biome": "2.4.14",
|
|
417
|
+
"@opentelemetry/context-async-hooks": "^2.10.0",
|
|
418
|
+
"@opentelemetry/sdk-trace-base": "^2.10.0",
|
|
73
419
|
"@types/bun": "^1.3.14",
|
|
74
420
|
"@types/mailparser": "^3.4.6",
|
|
75
421
|
"@types/mime-types": "^3.0.1",
|
|
@@ -116,7 +462,7 @@ var package_default2 = {
|
|
|
116
462
|
url: "https://github.com/pensarai/apex.git"
|
|
117
463
|
},
|
|
118
464
|
scripts: {
|
|
119
|
-
build: "bun build src/cli.ts --outdir build --target node --format esm --splitting --external @opentui/core --external @opentui/react --external @opentui/react/* --external react --external react/jsx-runtime --external react/jsx-dev-runtime --external react-reconciler --external weave --external electron --external chromium-bidi --external camoufox-js",
|
|
465
|
+
build: "rm -rf build && bun build src/cli.ts --outdir build --target node --format esm --splitting --external @opentui/core --external @opentui/react --external @opentui/react/* --external react --external react/jsx-runtime --external react/jsx-dev-runtime --external react-reconciler --external weave --external electron --external chromium-bidi --external camoufox-js",
|
|
120
466
|
"build:binaries": "bun run generate:ascii && mkdir -p dist && bun run build:binary:macos-arm64 && bun run build:binary:macos-x64 && bun run build:binary:linux-x64 && bun run build:binary:linux-arm64",
|
|
121
467
|
"build:binary": "bun run generate:ascii && bun build src/cli.ts --compile --external electron --external chromium-bidi --external camoufox-js --outfile pensar",
|
|
122
468
|
"build:binary:linux-arm64": "bun build src/cli.ts --compile --external electron --external chromium-bidi --external camoufox-js --target=bun-linux-arm64 --outfile dist/pensar-linux-arm64",
|
|
@@ -144,14 +490,29 @@ var package_default2 = {
|
|
|
144
490
|
tsc: "tsc --noEmit"
|
|
145
491
|
},
|
|
146
492
|
type: "module",
|
|
147
|
-
version: "2.
|
|
493
|
+
version: "2.5.0-canary.2bbb0f6f"
|
|
148
494
|
};
|
|
149
495
|
|
|
150
496
|
// src/core/ai/index.ts
|
|
151
497
|
init_ai();
|
|
498
|
+
init_model_history();
|
|
152
499
|
init_models();
|
|
153
500
|
init_utils();
|
|
154
501
|
|
|
502
|
+
// src/core/api/clientIdentity.ts
|
|
503
|
+
init_installation();
|
|
504
|
+
var currentCommand;
|
|
505
|
+
function setCurrentCommand(command) {
|
|
506
|
+
currentCommand = normalizeCommand(command);
|
|
507
|
+
}
|
|
508
|
+
var COMMAND_SHAPE = /^[a-z][a-z0-9-]{0,31}$/;
|
|
509
|
+
function normalizeCommand(command) {
|
|
510
|
+
if (!command)
|
|
511
|
+
return;
|
|
512
|
+
const trimmed = command.trim().toLowerCase();
|
|
513
|
+
return COMMAND_SHAPE.test(trimmed) ? trimmed : undefined;
|
|
514
|
+
}
|
|
515
|
+
|
|
155
516
|
// src/core/cli/logLevelArgs.ts
|
|
156
517
|
var VALID_LOG_LEVELS = new Set([
|
|
157
518
|
"DEBUG",
|
|
@@ -371,7 +732,7 @@ class AgentEventBus {
|
|
|
371
732
|
// src/core/installation/index.ts
|
|
372
733
|
init_package();
|
|
373
734
|
import { spawnSync } from "node:child_process";
|
|
374
|
-
function
|
|
735
|
+
function getCurrentVersion2() {
|
|
375
736
|
return package_default.version;
|
|
376
737
|
}
|
|
377
738
|
function isNewerVersion(current, latest) {
|
|
@@ -436,7 +797,7 @@ function getUpgradeCommandString(method) {
|
|
|
436
797
|
return `${cmd} ${args.join(" ")}`;
|
|
437
798
|
}
|
|
438
799
|
function runUpgrade(method, options) {
|
|
439
|
-
const currentVersion =
|
|
800
|
+
const currentVersion = getCurrentVersion2();
|
|
440
801
|
const { cmd, args } = getUpgradeCommand(method);
|
|
441
802
|
const interactive = options?.interactive ?? false;
|
|
442
803
|
const result = spawnSync(cmd, args, {
|
|
@@ -461,7 +822,7 @@ function runUpgrade(method, options) {
|
|
|
461
822
|
};
|
|
462
823
|
}
|
|
463
824
|
async function upgrade(options) {
|
|
464
|
-
const currentVersion =
|
|
825
|
+
const currentVersion = getCurrentVersion2();
|
|
465
826
|
let latestVersion;
|
|
466
827
|
try {
|
|
467
828
|
latestVersion = await getLatestVersion();
|
|
@@ -508,6 +869,179 @@ import os from "node:os";
|
|
|
508
869
|
import path from "node:path";
|
|
509
870
|
var ERROR_LOG_PATH = path.join(os.homedir(), ".pensar", "error.log");
|
|
510
871
|
|
|
872
|
+
// src/core/observability/runtime.ts
|
|
873
|
+
init_package();
|
|
874
|
+
init_active_root_spans();
|
|
875
|
+
var import_api = __toESM(require_src(), 1);
|
|
876
|
+
var import_context_async_hooks = __toESM(require_src2(), 1);
|
|
877
|
+
var import_exporter_trace_otlp_http = __toESM(require_src6(), 1);
|
|
878
|
+
var import_otlp_exporter_base = __toESM(require_src3(), 1);
|
|
879
|
+
var import_node_http = __toESM(require_index_node_http(), 1);
|
|
880
|
+
var import_otlp_transformer = __toESM(require_src5(), 1);
|
|
881
|
+
var import_resources = __toESM(require_src4(), 1);
|
|
882
|
+
var import_sdk_trace_base = __toESM(require_index_shim(), 1);
|
|
883
|
+
import { randomUUID } from "node:crypto";
|
|
884
|
+
var DEFAULT_SHUTDOWN_TIMEOUT_MS = 5000;
|
|
885
|
+
function withTimeout(promise, timeoutMs) {
|
|
886
|
+
return new Promise((resolve) => {
|
|
887
|
+
let settled = false;
|
|
888
|
+
const settle = (result) => {
|
|
889
|
+
if (settled)
|
|
890
|
+
return;
|
|
891
|
+
settled = true;
|
|
892
|
+
clearTimeout(timer);
|
|
893
|
+
resolve(result);
|
|
894
|
+
};
|
|
895
|
+
const timer = setTimeout(() => settle("timed-out"), timeoutMs);
|
|
896
|
+
promise.then(() => settle("completed"), () => settle("completed"));
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
var NOOP_RUNTIME = {
|
|
900
|
+
async forceFlush() {},
|
|
901
|
+
async shutdown() {
|
|
902
|
+
return "completed";
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
function isOtelSdkDisabled(env) {
|
|
906
|
+
return env.OTEL_SDK_DISABLED === "true";
|
|
907
|
+
}
|
|
908
|
+
function resolveTracesEndpoint(env) {
|
|
909
|
+
const specific = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?.trim();
|
|
910
|
+
if (specific)
|
|
911
|
+
return specific;
|
|
912
|
+
const generic = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
|
|
913
|
+
if (!generic)
|
|
914
|
+
return null;
|
|
915
|
+
return `${generic.endsWith("/") ? generic : `${generic}/`}v1/traces`;
|
|
916
|
+
}
|
|
917
|
+
function resolveTracesProtocol(env) {
|
|
918
|
+
const raw = (env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ?? env.OTEL_EXPORTER_OTLP_PROTOCOL ?? "").trim();
|
|
919
|
+
return raw === "http/protobuf" ? "http/protobuf" : "http/json";
|
|
920
|
+
}
|
|
921
|
+
function parseResourceAttributes(env) {
|
|
922
|
+
const raw = env.OTEL_RESOURCE_ATTRIBUTES;
|
|
923
|
+
if (!raw)
|
|
924
|
+
return {};
|
|
925
|
+
const attrs = {};
|
|
926
|
+
for (const pair of raw.split(",")) {
|
|
927
|
+
const eq = pair.indexOf("=");
|
|
928
|
+
if (eq <= 0)
|
|
929
|
+
continue;
|
|
930
|
+
const key = pair.slice(0, eq).trim();
|
|
931
|
+
const value = pair.slice(eq + 1).trim();
|
|
932
|
+
if (key && value)
|
|
933
|
+
attrs[key] = value;
|
|
934
|
+
}
|
|
935
|
+
return attrs;
|
|
936
|
+
}
|
|
937
|
+
function buildResource(env) {
|
|
938
|
+
const resourceAttributes = parseResourceAttributes(env);
|
|
939
|
+
return import_resources.resourceFromAttributes({
|
|
940
|
+
"service.version": version,
|
|
941
|
+
"service.instance.id": randomUUID(),
|
|
942
|
+
...resourceAttributes,
|
|
943
|
+
"service.name": env.OTEL_SERVICE_NAME?.trim() || resourceAttributes["service.name"] || "apex"
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function createTraceExporter(protocol) {
|
|
947
|
+
if (protocol === "http/json") {
|
|
948
|
+
return new import_exporter_trace_otlp_http.OTLPTraceExporter;
|
|
949
|
+
}
|
|
950
|
+
return new import_otlp_exporter_base.OTLPExporterBase(import_node_http.createOtlpHttpExportDelegate(import_node_http.convertLegacyHttpOptions({}, "TRACES", "v1/traces", {
|
|
951
|
+
"Content-Type": "application/x-protobuf"
|
|
952
|
+
}), import_otlp_transformer.ProtobufTraceSerializer, "otlp_http_span_exporter", import_otlp_transformer.TraceExporterMetricsHelper, undefined));
|
|
953
|
+
}
|
|
954
|
+
var activeRuntime = null;
|
|
955
|
+
function startObservabilityRuntime(env = process.env, opts) {
|
|
956
|
+
if (activeRuntime)
|
|
957
|
+
return activeRuntime;
|
|
958
|
+
if (isOtelSdkDisabled(env))
|
|
959
|
+
return NOOP_RUNTIME;
|
|
960
|
+
if (!resolveTracesEndpoint(env))
|
|
961
|
+
return NOOP_RUNTIME;
|
|
962
|
+
const shutdownTimeoutMs = opts?.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS;
|
|
963
|
+
const exporter = createTraceExporter(resolveTracesProtocol(env));
|
|
964
|
+
const provider = new import_sdk_trace_base.BasicTracerProvider({
|
|
965
|
+
resource: buildResource(env),
|
|
966
|
+
spanProcessors: opts?.spanProcessors ?? [new import_sdk_trace_base.BatchSpanProcessor(exporter)]
|
|
967
|
+
});
|
|
968
|
+
const contextManager = new import_context_async_hooks.AsyncLocalStorageContextManager;
|
|
969
|
+
contextManager.enable();
|
|
970
|
+
import_api.trace.setGlobalTracerProvider(provider);
|
|
971
|
+
import_api.context.setGlobalContextManager(contextManager);
|
|
972
|
+
let shutdownPromise = null;
|
|
973
|
+
const runtime = {
|
|
974
|
+
async forceFlush() {
|
|
975
|
+
await provider.forceFlush();
|
|
976
|
+
},
|
|
977
|
+
shutdown() {
|
|
978
|
+
if (!shutdownPromise) {
|
|
979
|
+
const shutdownWork = (async () => {
|
|
980
|
+
endAllActiveRootSpans();
|
|
981
|
+
try {
|
|
982
|
+
await provider.forceFlush();
|
|
983
|
+
} finally {
|
|
984
|
+
await provider.shutdown();
|
|
985
|
+
}
|
|
986
|
+
})();
|
|
987
|
+
shutdownPromise = withTimeout(shutdownWork, shutdownTimeoutMs).then((result) => {
|
|
988
|
+
contextManager.disable();
|
|
989
|
+
import_api.trace.disable();
|
|
990
|
+
import_api.context.disable();
|
|
991
|
+
return result;
|
|
992
|
+
}).finally(() => {
|
|
993
|
+
activeRuntime = null;
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
return shutdownPromise;
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
activeRuntime = runtime;
|
|
1000
|
+
return runtime;
|
|
1001
|
+
}
|
|
1002
|
+
function installObservabilityExitHandlers(runtime, opts) {
|
|
1003
|
+
let exitPromise = null;
|
|
1004
|
+
let exitCode = 0;
|
|
1005
|
+
let fatalSeen = false;
|
|
1006
|
+
const reportError = (error, source) => {
|
|
1007
|
+
try {
|
|
1008
|
+
opts?.onError?.(error, source);
|
|
1009
|
+
} catch {}
|
|
1010
|
+
};
|
|
1011
|
+
const exitWith = (code, error, source) => {
|
|
1012
|
+
let pendingReport = null;
|
|
1013
|
+
if (error !== undefined && !fatalSeen) {
|
|
1014
|
+
fatalSeen = true;
|
|
1015
|
+
exitCode = 1;
|
|
1016
|
+
const fatalSource = source ?? "uncaughtException";
|
|
1017
|
+
pendingReport = () => reportError(error, fatalSource);
|
|
1018
|
+
} else if (!fatalSeen && exitCode === 0) {
|
|
1019
|
+
exitCode = code;
|
|
1020
|
+
}
|
|
1021
|
+
if (exitPromise) {
|
|
1022
|
+
pendingReport?.();
|
|
1023
|
+
return exitPromise;
|
|
1024
|
+
}
|
|
1025
|
+
try {
|
|
1026
|
+
opts?.cleanup?.(code);
|
|
1027
|
+
} catch (cleanupError) {
|
|
1028
|
+
if (!fatalSeen) {
|
|
1029
|
+
fatalSeen = true;
|
|
1030
|
+
exitCode = 1;
|
|
1031
|
+
pendingReport = () => reportError(cleanupError, "uncaughtException");
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
pendingReport?.();
|
|
1035
|
+
exitPromise = runtime.shutdown().catch(() => {}).then(() => process.exit(exitCode));
|
|
1036
|
+
return exitPromise;
|
|
1037
|
+
};
|
|
1038
|
+
process.on("SIGINT", () => void exitWith(130));
|
|
1039
|
+
process.on("SIGTERM", () => void exitWith(143));
|
|
1040
|
+
process.on("uncaughtException", (error) => void exitWith(1, error, "uncaughtException"));
|
|
1041
|
+
process.on("unhandledRejection", (reason) => void exitWith(1, reason, "unhandledRejection"));
|
|
1042
|
+
return exitWith;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
511
1045
|
// src/tui/utils/command-flags.ts
|
|
512
1046
|
import { readFileSync } from "node:fs";
|
|
513
1047
|
import { isAbsolute, resolve } from "node:path";
|
|
@@ -537,7 +1071,8 @@ function resolveThreatModelPrompt(value) {
|
|
|
537
1071
|
|
|
538
1072
|
// src/cli.ts
|
|
539
1073
|
var args = process.argv.slice(2);
|
|
540
|
-
var
|
|
1074
|
+
var version2 = package_default2.version;
|
|
1075
|
+
import_dotenv.config();
|
|
541
1076
|
var OBFUSCATE_FLAGS = new Set(["--obfuscate", "--redact", "-O"]);
|
|
542
1077
|
var obfuscateRequested = args.some((a) => OBFUSCATE_FLAGS.has(a));
|
|
543
1078
|
if (obfuscateRequested) {
|
|
@@ -592,7 +1127,7 @@ function attachCliAgentStreamListeners(bus) {
|
|
|
592
1127
|
async function createInstrumentedBus(session) {
|
|
593
1128
|
const bus = new AgentEventBus;
|
|
594
1129
|
attachCliAgentStreamListeners(bus);
|
|
595
|
-
const { attachWandbToEventBus } = await import("./upload-
|
|
1130
|
+
const { attachWandbToEventBus } = await import("./upload-kkktzh83.js");
|
|
596
1131
|
const wandbCleanup = await attachWandbToEventBus(session, bus).catch((e) => {
|
|
597
1132
|
console.warn("[wandb] Tracing disabled:", e.message);
|
|
598
1133
|
return null;
|
|
@@ -609,7 +1144,7 @@ async function resolveCliHeaders() {
|
|
|
609
1144
|
const { parseHeaderLine: parseHeaderLine2, parseHeadersFromFile, formatParseError: formatParseError2 } = await import("./parse-rtccymzn.js");
|
|
610
1145
|
const merged = {};
|
|
611
1146
|
if (!noGlobal) {
|
|
612
|
-
const { config: appConfig } = await import("./index-
|
|
1147
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
613
1148
|
const cfg = await appConfig.get();
|
|
614
1149
|
if (cfg.defaultHeaders) {
|
|
615
1150
|
Object.assign(merged, cfg.defaultHeaders);
|
|
@@ -643,8 +1178,8 @@ async function resolveCliModel() {
|
|
|
643
1178
|
const explicit = getArg("--model");
|
|
644
1179
|
if (explicit)
|
|
645
1180
|
return explicit;
|
|
646
|
-
const { config: appConfig } = await import("./index-
|
|
647
|
-
const { getDefaultModelForConfig } = await import("./utils-
|
|
1181
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
1182
|
+
const { getDefaultModelForConfig } = await import("./utils-1sawtwbj.js");
|
|
648
1183
|
const pensarConfig = await appConfig.get();
|
|
649
1184
|
const defaultModel = getDefaultModelForConfig(pensarConfig);
|
|
650
1185
|
if (!defaultModel) {
|
|
@@ -731,11 +1266,9 @@ Global options:
|
|
|
731
1266
|
`);
|
|
732
1267
|
}
|
|
733
1268
|
async function runPentest() {
|
|
734
|
-
const {
|
|
735
|
-
|
|
736
|
-
const {
|
|
737
|
-
const { sessions: sessions2 } = await import("./index-sf16jm0m.js");
|
|
738
|
-
const { config: appConfig } = await import("./index-y5w6n3tb.js");
|
|
1269
|
+
const { runPentestAgent } = await import("./blackboxPentest-9snp9gvp.js");
|
|
1270
|
+
const { sessions: sessions2 } = await import("./index-e7kq5rrd.js");
|
|
1271
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
739
1272
|
const target = getArgRequired("--target");
|
|
740
1273
|
const cwd = getArg("--cwd");
|
|
741
1274
|
const mode = getArg("--mode");
|
|
@@ -806,14 +1339,11 @@ Report: ${reportPath}` : ""}`);
|
|
|
806
1339
|
} finally {
|
|
807
1340
|
await wandbCleanup();
|
|
808
1341
|
}
|
|
809
|
-
process.exit(0);
|
|
810
1342
|
}
|
|
811
1343
|
async function runTargetedPentest() {
|
|
812
|
-
const {
|
|
813
|
-
|
|
814
|
-
const {
|
|
815
|
-
const { sessions: sessions2 } = await import("./index-sf16jm0m.js");
|
|
816
|
-
const { config: appConfig } = await import("./index-y5w6n3tb.js");
|
|
1344
|
+
const { runTargetedPentestAgent } = await import("./targetedPentest-wj3ae355.js");
|
|
1345
|
+
const { sessions: sessions2 } = await import("./index-e7kq5rrd.js");
|
|
1346
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
817
1347
|
const target = getArgRequired("--target");
|
|
818
1348
|
const objectives = getAllArgs("--objective");
|
|
819
1349
|
const pensarConfig = await appConfig.get();
|
|
@@ -860,13 +1390,10 @@ POCs: ${pocsPath}`);
|
|
|
860
1390
|
} finally {
|
|
861
1391
|
await wandbCleanup();
|
|
862
1392
|
}
|
|
863
|
-
process.exit(0);
|
|
864
1393
|
}
|
|
865
1394
|
async function runThreatModel() {
|
|
866
|
-
const {
|
|
867
|
-
config();
|
|
868
|
-
const { runThreatModelWorkflow } = await import("./threatModel-xsm6fwk5.js");
|
|
869
|
-
const { config: appConfig } = await import("./index-y5w6n3tb.js");
|
|
1395
|
+
const { runThreatModelWorkflow } = await import("./threatModel-dc4jbhkf.js");
|
|
1396
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
870
1397
|
const path2 = await import("path");
|
|
871
1398
|
const pensarConfig = await appConfig.get();
|
|
872
1399
|
const model = await resolveCliModel();
|
|
@@ -900,16 +1427,14 @@ ${sep}
|
|
|
900
1427
|
Threat model written to: ${resolvedPath}`);
|
|
901
1428
|
}
|
|
902
1429
|
async function runOperator() {
|
|
903
|
-
const {
|
|
904
|
-
|
|
905
|
-
const {
|
|
906
|
-
const {
|
|
907
|
-
const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-hqjdg6fg.js");
|
|
908
|
-
const { config: appConfig } = await import("./index-y5w6n3tb.js");
|
|
1430
|
+
const { runOffensiveSecurityAgent } = await import("./offesecAgent-pr0cmrqb.js");
|
|
1431
|
+
const { sessions: sessions2, normalizeMessages, getResumeMessages } = await import("./index-e7kq5rrd.js");
|
|
1432
|
+
const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-j3dc7dks.js");
|
|
1433
|
+
const { config: appConfig } = await import("./index-yc1dnj3n.js");
|
|
909
1434
|
const { createInterface } = await import("readline");
|
|
910
1435
|
const { readFileSync: readFileSync2, existsSync } = await import("fs");
|
|
911
1436
|
const path2 = await import("path");
|
|
912
|
-
const { stepCountIs } = await import("./index-
|
|
1437
|
+
const { stepCountIs } = await import("./index-5wh7gq37.js");
|
|
913
1438
|
const promptRaw = getArg("-p") ?? getArg("--prompt");
|
|
914
1439
|
if (!promptRaw) {
|
|
915
1440
|
console.error("Error: -p <prompt> is required");
|
|
@@ -997,7 +1522,7 @@ ${sep}
|
|
|
997
1522
|
Session: ${session.rootPath}`);
|
|
998
1523
|
}
|
|
999
1524
|
async function runUpgrade2() {
|
|
1000
|
-
const currentVersion =
|
|
1525
|
+
const currentVersion = getCurrentVersion2();
|
|
1001
1526
|
console.log(`Current version: v${currentVersion}
|
|
1002
1527
|
Checking for updates...`);
|
|
1003
1528
|
const result = await upgrade({ interactive: true });
|
|
@@ -1005,60 +1530,81 @@ Checking for updates...`);
|
|
|
1005
1530
|
${result.message}`);
|
|
1006
1531
|
process.exit(result.success ? 0 : 1);
|
|
1007
1532
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
} else if (command === "
|
|
1019
|
-
|
|
1020
|
-
} else if (command === "
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
} else if (command === "
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
} else if (command === "
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
} else if (
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1533
|
+
var observabilityRuntime = startObservabilityRuntime();
|
|
1534
|
+
var exitAfterObservabilityShutdown = args.length !== 0 ? installObservabilityExitHandlers(observabilityRuntime, {
|
|
1535
|
+
onError: (error) => {
|
|
1536
|
+
console.error("Uncaught exception:", error);
|
|
1537
|
+
}
|
|
1538
|
+
}) : null;
|
|
1539
|
+
setCurrentCommand(command);
|
|
1540
|
+
try {
|
|
1541
|
+
if (hasFlag("-p") || command === "--prompt") {
|
|
1542
|
+
await runOperator();
|
|
1543
|
+
} else if (command === "version" || command === "--version" || command === "-v") {
|
|
1544
|
+
console.log(`v${version2}`);
|
|
1545
|
+
} else if (command === "help" || command === "--help" || command === "-h") {
|
|
1546
|
+
showHelp();
|
|
1547
|
+
} else if (command === "upgrade" || command === "update") {
|
|
1548
|
+
await runUpgrade2();
|
|
1549
|
+
} else if (command === "pentest") {
|
|
1550
|
+
await runPentest();
|
|
1551
|
+
} else if (command === "targeted-pentest") {
|
|
1552
|
+
await runTargetedPentest();
|
|
1553
|
+
} else if (command === "login" || command === "auth") {
|
|
1554
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1555
|
+
await import("./auth-p1nrv7re.js");
|
|
1556
|
+
} else if (command === "uninstall") {
|
|
1557
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1558
|
+
await import("./uninstall-58ak2e2v.js");
|
|
1559
|
+
} else if (command === "apps") {
|
|
1560
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1561
|
+
await import("./apps-ghf7kp1s.js");
|
|
1562
|
+
} else if (command === "pentests") {
|
|
1563
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1564
|
+
await import("./pentests-vstpzh9j.js");
|
|
1565
|
+
} else if (command === "targets") {
|
|
1566
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1567
|
+
await import("./targets-806zxf1n.js");
|
|
1568
|
+
} else if (command === "issues") {
|
|
1569
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1570
|
+
await import("./issues-zdag9ayw.js");
|
|
1571
|
+
} else if (command === "fixes") {
|
|
1572
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1573
|
+
await import("./fixes-xxz52cf2.js");
|
|
1574
|
+
} else if (command === "logs") {
|
|
1575
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1576
|
+
await import("./logs-f492cjgt.js");
|
|
1577
|
+
} else if (command === "config") {
|
|
1578
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
1579
|
+
await import("./config-cqw98n5y.js");
|
|
1580
|
+
} else if (command === "threat-model") {
|
|
1581
|
+
await runThreatModel();
|
|
1582
|
+
} else if (command === "doctor") {
|
|
1583
|
+
const { runDoctor } = await import("./doctor-vzh1wmfa.js");
|
|
1584
|
+
await runDoctor();
|
|
1585
|
+
} else if (args.length === 0) {
|
|
1586
|
+
if (process.env.PENSAR_NO_TUI === "1") {
|
|
1587
|
+
console.error("TUI mode requires Bun. Install Bun (https://bun.sh) or use a standalone binary release for interactive mode.");
|
|
1588
|
+
console.error("All other commands work with Node \u2014 run 'pensar --help'.");
|
|
1589
|
+
process.exit(1);
|
|
1590
|
+
}
|
|
1591
|
+
await import("./index-3gavwzay.js");
|
|
1592
|
+
} else {
|
|
1593
|
+
console.error(`Error: Unknown command '${command}'`);
|
|
1594
|
+
console.error();
|
|
1595
|
+
console.error("Run 'pensar --help' for usage information");
|
|
1056
1596
|
process.exit(1);
|
|
1057
1597
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1598
|
+
} catch (error) {
|
|
1599
|
+
if (exitAfterObservabilityShutdown !== null) {
|
|
1600
|
+
await exitAfterObservabilityShutdown(1, error, "uncaughtException");
|
|
1601
|
+
}
|
|
1602
|
+
throw error;
|
|
1603
|
+
} finally {
|
|
1604
|
+
if (exitAfterObservabilityShutdown !== null) {
|
|
1605
|
+
const shutdownResult = await observabilityRuntime.shutdown().catch(() => "completed");
|
|
1606
|
+
if (shutdownResult === "timed-out" || command === "pentest" || command === "targeted-pentest") {
|
|
1607
|
+
await exitAfterObservabilityShutdown(typeof process.exitCode === "number" ? process.exitCode : 0);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1064
1610
|
}
|