@pensar/apex 1.8.0 → 1.8.2-canary.fb75c486

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.
Files changed (70) hide show
  1. package/README.md +11 -0
  2. package/build/agent-6dj1qm50.js +221 -0
  3. package/build/agent-6xr8vpgm.js +28 -0
  4. package/build/agent-x1htbpe3.js +22 -0
  5. package/build/apps-t0gmwc7z.js +446 -0
  6. package/build/{auth-dxjgy41e.js → auth-p4r1m7xq.js} +50 -13
  7. package/build/authentication-je2b0c3w.js +22 -0
  8. package/build/blackboxAgent-a4jnt0y5.js +22 -0
  9. package/build/{blackboxPentest-8ps4yvbk.js → blackboxPentest-b5741n3h.js} +19 -17
  10. package/build/{cli-y61d9433.js → cli-0tnv1vkp.js} +138 -38
  11. package/build/{cli-jg7r7y5n.js → cli-4xb21y6g.js} +30 -2
  12. package/build/{cli-k0tckznm.js → cli-6p7d2k55.js} +39701 -31695
  13. package/build/cli-87zakjb2.js +17 -0
  14. package/build/{authentication-e30mfzbe.js → cli-8frjr68r.js} +11 -18
  15. package/build/cli-8xknm7d9.js +204 -0
  16. package/build/cli-9egg9azd.js +22 -0
  17. package/build/cli-9fsre5pt.js +0 -0
  18. package/build/cli-abbka8n3.js +501 -0
  19. package/build/{cli-3y0dgy56.js → cli-c8131c4q.js} +2 -2
  20. package/build/cli-e08r86zk.js +24 -0
  21. package/build/{cli-0ghkg3w6.js → cli-e6rgwtpb.js} +19950 -18556
  22. package/build/cli-g5h24ny8.js +197 -0
  23. package/build/{cli-nr1cjfr9.js → cli-gtcd5c3f.js} +26 -7
  24. package/build/cli-k0730f59.js +52 -0
  25. package/build/{cli-tp1tqn3k.js → cli-mswm4k81.js} +1 -1
  26. package/build/{cli-m788e4f3.js → cli-q8dfq25x.js} +584 -33
  27. package/build/cli-rhry8mat.js +7213 -0
  28. package/build/{cli-g8t710ew.js → cli-ryy39d77.js} +253 -250
  29. package/build/cli-s1nckt4k.js +20 -0
  30. package/build/{cli-k4hrygff.js → cli-v9ds4jb8.js} +9 -5
  31. package/build/{cli-dqt80sw3.js → cli-w5990vr6.js} +199 -68
  32. package/build/{cli-3w2syxpv.js → cli-wfmdch3r.js} +102695 -104816
  33. package/build/cli.js +351 -280
  34. package/build/config-3bvtf3j8.js +188 -0
  35. package/build/{doctor-8tva8j99.js → doctor-2bkpddws.js} +1 -1
  36. package/build/{fixes-q5bhgxhc.js → fixes-60k3ts71.js} +23 -4
  37. package/build/{index-pfee23kv.js → index-0gp3x2r8.js} +19306 -18954
  38. package/build/index-861hkebg.js +12 -0
  39. package/build/{index-y5xpp21a.js → index-acc00eq4.js} +77 -108
  40. package/build/index-acdgrqa0.js +36 -0
  41. package/build/{index-e898mdyh.js → index-cfberehw.js} +4 -2
  42. package/build/{index-wfeb2gcc.js → index-hxn4rk8f.js} +9 -11
  43. package/build/{index-dw1xbhfn.js → index-vc29b21w.js} +161 -26
  44. package/build/index-vwt27stc.js +184 -0
  45. package/build/{issues-qbmdneej.js → issues-1bynat5q.js} +33 -9
  46. package/build/{logs-xm5vbymy.js → logs-e78vx2dy.js} +23 -4
  47. package/build/{main-3d7dfdvs.js → main-3zneyg7p.js} +93 -17
  48. package/build/{offesecAgent-re6kt2ff.js → offesecAgent-w9m0svwk.js} +14 -11
  49. package/build/parse-15kqmy2v.js +207 -0
  50. package/build/pentest-gpvqpvmd.js +31 -0
  51. package/build/{pentests-e3rj5845.js → pentests-nq7wa8yb.js} +36 -17
  52. package/build/{targetedPentest-fs0v570s.js → targetedPentest-fjxqn089.js} +15 -12
  53. package/build/threatModel-9yqx7d7x.js +29 -0
  54. package/build/{uninstall-qb2xbh2t.js → uninstall-9zbf4cwc.js} +6 -4
  55. package/build/{utils-jf52rmrb.js → utils-dh1t2r1e.js} +13 -10
  56. package/package.json +86 -88
  57. package/build/agent-4d8j2jsw.js +0 -278
  58. package/build/agent-z2s6h7n2.js +0 -19
  59. package/build/blackboxAgent-j9pczwym.js +0 -19
  60. package/build/cli-03z6pswp.js +0 -1423
  61. package/build/cli-0fy9j5dw.js +0 -61
  62. package/build/cli-asyas1xb.js +0 -110
  63. package/build/cli-dj1dgw2n.js +0 -190
  64. package/build/cli-q7r2sth7.js +0 -103
  65. package/build/cli-vkwch0bc.js +0 -1207
  66. package/build/cli-wr7g9qcr.js +0 -645
  67. package/build/index-bz6f8jry.js +0 -32
  68. package/build/pentest-mfm4hake.js +0 -29
  69. package/build/projects-qk22qcbt.js +0 -35
  70. package/build/threatModel-xfvc6cch.js +0 -67
@@ -0,0 +1,12 @@
1
+ import {
2
+ config,
3
+ init_config
4
+ } from "./cli-9egg9azd.js";
5
+ import"./cli-gtcd5c3f.js";
6
+ import"./cli-g5h24ny8.js";
7
+ import"./cli-8rxa073f.js";
8
+ init_config();
9
+
10
+ export {
11
+ config
12
+ };
@@ -1,51 +1,48 @@
1
1
  import {
2
2
  CredentialManager,
3
- NotFoundError,
4
3
  RateLimiter,
5
4
  createDir,
6
5
  descending,
7
6
  generateRandomName,
8
7
  generateSessionName,
9
- locate,
10
8
  read,
11
- remove,
12
9
  schema,
13
10
  update,
14
11
  write,
15
12
  writeRaw
16
- } from "./cli-g8t710ew.js";
13
+ } from "./cli-ryy39d77.js";
17
14
  import {
18
15
  ToolsetStateSchema,
19
- exports_toolset,
20
- init_toolset,
21
- toggleTool
22
- } from "./cli-k0tckznm.js";
16
+ init_toolset
17
+ } from "./cli-s1nckt4k.js";
18
+ import"./cli-87zakjb2.js";
19
+ import"./cli-6p7d2k55.js";
20
+ import"./cli-w5990vr6.js";
23
21
  import {
24
22
  init_zod,
25
23
  zod_default
26
- } from "./cli-0ghkg3w6.js";
27
- import"./cli-dqt80sw3.js";
28
- import"./cli-asyas1xb.js";
24
+ } from "./cli-e6rgwtpb.js";
25
+ import"./cli-9egg9azd.js";
29
26
  import"./cli-gpnb45ck.js";
30
- import"./cli-nr1cjfr9.js";
27
+ import"./cli-gtcd5c3f.js";
31
28
  import {
32
- getCurrentVersion
33
- } from "./cli-dj1dgw2n.js";
34
- import"./cli-03z6pswp.js";
29
+ getCurrentVersion,
30
+ init_installation
31
+ } from "./cli-g5h24ny8.js";
35
32
  import {
36
- __require,
37
- __toCommonJS
33
+ __require
38
34
  } from "./cli-8rxa073f.js";
39
35
 
40
36
  // src/core/session/index.ts
41
37
  init_zod();
42
- import path from "path";
43
- import os from "os";
44
38
  import { existsSync, readFileSync } from "fs";
39
+ import os from "os";
40
+ import path from "path";
41
+ init_installation();
45
42
  init_toolset();
46
43
  var DEFAULT_OUTCOME_GUIDANCE = "Prove the exploit can be run but do not exfiltrate data or cause any harm to the system. " + "Create proof-of-concept exploits that demonstrate the vulnerability exists without causing damage.";
47
44
  var EXFIL_OUTCOME_GUIDANCE = "Exfiltrate data to extract the flag value. " + "Create proof-of-concept exploits that successfully extract the flag from the target system.";
48
- var DEFAULT_OFFENSIVE_HEADERS = {
45
+ var DEFAULT_HEADER_RECORD = {
49
46
  "User-Agent": "pensar-apex"
50
47
  };
51
48
  var AuthCredentialsObject = zod_default.object({
@@ -68,9 +65,10 @@ var ScopeConstraintsObject = zod_default.object({
68
65
  allowedPorts: zod_default.number().array().optional(),
69
66
  strictScope: zod_default.boolean().optional()
70
67
  });
68
+ var SessionHeadersRecord = zod_default.record(zod_default.string(), zod_default.string());
71
69
  var OffensiveHeadersConfigObject = zod_default.object({
72
- mode: zod_default.enum(["none", "default", "custom"]),
73
- headers: zod_default.record(zod_default.string(), zod_default.string()).optional()
70
+ mode: zod_default.enum(["none", "default", "custom"]).optional(),
71
+ headers: SessionHeadersRecord.optional()
74
72
  });
75
73
  var OperatorSettingsObject = zod_default.object({
76
74
  initialMode: zod_default.enum(["plan", "manual", "auto"]).default("manual"),
@@ -155,6 +153,7 @@ function resolveSmtpConfig(explicit) {
155
153
  return;
156
154
  }
157
155
  var SessionConfigObject = zod_default.object({
156
+ headers: SessionHeadersRecord.optional(),
158
157
  offensiveHeaders: OffensiveHeadersConfigObject.optional(),
159
158
  sessionType: zod_default.enum(["web-app"]).optional(),
160
159
  mode: zod_default.enum(["auto", "driver", "operator"]).optional(),
@@ -221,29 +220,40 @@ Security findings will be documented in the \`findings/\` directory as individua
221
220
  Testing in progress...
222
221
  `;
223
222
  }
224
- async function getExecution(sessionId) {
225
- try {
226
- const metadata = await read(["sessions", sessionId, "session"]);
227
- return metadata;
228
- } catch (e) {
229
- if (e instanceof NotFoundError) {
230
- return null;
231
- }
232
- throw e;
233
- }
234
- }
235
- function getOffensiveHeaders(session) {
236
- const config = session.config?.offensiveHeaders;
237
- if (!config || config.mode === "none") {
238
- return;
223
+ function normalizeDeprecatedHeaders(config) {
224
+ if (!config)
225
+ return config;
226
+ if (config.offensiveHeaders == null) {
227
+ const { offensiveHeaders: _drop, ...rest2 } = config;
228
+ return rest2;
239
229
  }
240
- if (config.mode === "default") {
241
- return DEFAULT_OFFENSIVE_HEADERS;
230
+ const { offensiveHeaders, ...rest } = config;
231
+ const restWithHeaders = rest;
232
+ if (restWithHeaders.headers !== undefined) {
233
+ return restWithHeaders;
242
234
  }
243
- if (config.mode === "custom" && config.headers) {
244
- return config.headers;
235
+ const oh = offensiveHeaders;
236
+ if (oh.mode === "none") {
237
+ return { ...restWithHeaders, headers: {} };
245
238
  }
246
- return;
239
+ let headers = {};
240
+ if (oh.mode === "default")
241
+ headers = { ...DEFAULT_HEADER_RECORD };
242
+ if (oh.headers)
243
+ headers = { ...headers, ...oh.headers };
244
+ return { ...restWithHeaders, headers };
245
+ }
246
+ function migrateLegacySessionData(input) {
247
+ if (!input || typeof input !== "object")
248
+ return input;
249
+ const root = input;
250
+ const config = root.config;
251
+ if (!config || typeof config !== "object")
252
+ return input;
253
+ const cfg = config;
254
+ if (!("offensiveHeaders" in cfg))
255
+ return input;
256
+ return { ...root, config: normalizeDeprecatedHeaders(cfg) };
247
257
  }
248
258
  var SessionInfoObject = zod_default.object({
249
259
  id: schema("session"),
@@ -263,6 +273,7 @@ var SessionInfoObject = zod_default.object({
263
273
  });
264
274
  async function create(input) {
265
275
  const name = input.name ?? generateRandomName();
276
+ const normalizedConfig = normalizeDeprecatedHeaders(input.config);
266
277
  const id = `${input.prefix ? input.prefix : ""}` + descending("session", input.id);
267
278
  const rootPath = getSessionRoot(id);
268
279
  const findingsPath = path.join(rootPath, "findings");
@@ -270,17 +281,25 @@ async function create(input) {
270
281
  const logsPath = path.join(rootPath, "logs");
271
282
  const pocsPath = path.join(rootPath, "pocs");
272
283
  const rateLimiter = new RateLimiter({
273
- requestsPerSecond: input.config?.requestsPerSecond
284
+ requestsPerSecond: normalizedConfig?.requestsPerSecond
274
285
  });
275
286
  let credentialManager;
276
- if (input.config?.authCredentials) {
287
+ if (normalizedConfig?.authCredentials) {
277
288
  credentialManager = new CredentialManager;
278
- const creds = Array.isArray(input.config.authCredentials) ? input.config.authCredentials : [input.config.authCredentials];
289
+ const creds = Array.isArray(normalizedConfig.authCredentials) ? normalizedConfig.authCredentials : [normalizedConfig.authCredentials];
279
290
  for (const cred of creds) {
280
291
  credentialManager.addFromAuthCredentials(cred);
281
292
  }
282
293
  }
283
- const smtpConfig = resolveSmtpConfig(input.config?.smtpConfig);
294
+ const smtpConfig = resolveSmtpConfig(normalizedConfig?.smtpConfig);
295
+ let snapshotHeaders;
296
+ if (normalizedConfig?.headers !== undefined) {
297
+ snapshotHeaders = { ...normalizedConfig.headers };
298
+ } else {
299
+ const { config: appConfig } = await import("./index-861hkebg.js");
300
+ const cfg = await appConfig.get();
301
+ snapshotHeaders = cfg.defaultHeaders ? { ...cfg.defaultHeaders } : { ...DEFAULT_HEADER_RECORD };
302
+ }
284
303
  const result = {
285
304
  id,
286
305
  version: getCurrentVersion(),
@@ -291,15 +310,10 @@ async function create(input) {
291
310
  updated: Date.now()
292
311
  },
293
312
  config: {
294
- ...input.config,
295
- mode: input.config?.mode || "auto",
296
- offensiveHeaders: input.config?.offensiveHeaders || {
297
- mode: "default",
298
- headers: {
299
- "User-Agent": "pensar-apex"
300
- }
301
- },
302
- outcomeGuidance: input.config?.outcomeGuidance || (input.config?.exfilMode ? EXFIL_OUTCOME_GUIDANCE : DEFAULT_OUTCOME_GUIDANCE),
313
+ ...normalizedConfig,
314
+ mode: normalizedConfig?.mode || "auto",
315
+ headers: snapshotHeaders,
316
+ outcomeGuidance: normalizedConfig?.outcomeGuidance || (normalizedConfig?.exfilMode ? EXFIL_OUTCOME_GUIDANCE : DEFAULT_OUTCOME_GUIDANCE),
303
317
  smtpConfig
304
318
  },
305
319
  _rateLimiter: rateLimiter,
@@ -332,7 +346,8 @@ async function create(input) {
332
346
  return result;
333
347
  }
334
348
  var get = async (id) => {
335
- const read2 = await read(["sessions", id, "session"]);
349
+ const raw = await read(["sessions", id, "session"]);
350
+ const read2 = migrateLegacySessionData(raw);
336
351
  if (read2.config?.requestsPerSecond) {
337
352
  read2._rateLimiter = new RateLimiter({
338
353
  requestsPerSecond: read2.config.requestsPerSecond
@@ -342,7 +357,6 @@ var get = async (id) => {
342
357
  }
343
358
  return read2;
344
359
  };
345
- var sessionPath = (id) => locate(["sessions", id], "");
346
360
  async function update2(id, editor) {
347
361
  const result = await update(["sessions", id, "session"], (draft) => {
348
362
  editor(draft);
@@ -382,23 +396,10 @@ var remove2 = async (input) => {
382
396
  console.error(e);
383
397
  }
384
398
  };
385
- var updateMessage = async (msg) => {
386
- await write(["sessions", msg.sessionId, "messages", msg.id], msg);
387
- return msg;
388
- };
389
399
  var RemoveMsgInput = zod_default.object({
390
400
  sessionId: schema("session"),
391
401
  messageId: schema("message")
392
402
  });
393
- var removeMessage = async (input) => {
394
- await remove([
395
- "sessions",
396
- input.sessionId,
397
- "messages",
398
- input.messageId
399
- ]);
400
- return input.messageId;
401
- };
402
403
  async function loadOperatorState(sessionId) {
403
404
  try {
404
405
  const session = await get(sessionId);
@@ -514,71 +515,39 @@ async function updateOperatorSettings(sessionId, settings) {
514
515
  }
515
516
  });
516
517
  }
517
- async function updateToolsetState(sessionId, toolsetState) {
518
+ async function updateSessionHeaders(sessionId, headers) {
518
519
  return await update2(sessionId, (session) => {
519
520
  if (!session.config) {
520
521
  session.config = {};
521
522
  }
522
- session.config.toolsetState = toolsetState;
523
- });
524
- }
525
- async function toggleTool2(sessionId, toolId, enabled) {
526
- return await update2(sessionId, (session) => {
527
- if (!session.config) {
528
- session.config = {};
529
- }
530
- if (!session.config.toolsetState) {
531
- const { createToolsetState } = (init_toolset(), __toCommonJS(exports_toolset));
532
- session.config.toolsetState = createToolsetState("web-pentest");
533
- }
534
- session.config.toolsetState = toggleTool(session.config.toolsetState, toolId, enabled);
523
+ session.config.headers = { ...headers };
535
524
  });
536
525
  }
537
526
  var sessions = {
538
527
  getSessionRoot,
539
- getOffensiveHeaders,
540
- DEFAULT_OUTCOME_GUIDANCE,
541
528
  EXFIL_OUTCOME_GUIDANCE,
542
529
  create,
543
530
  get,
544
- update: update2,
545
- list,
546
531
  remove: remove2,
547
- updateMessage,
548
- removeMessage,
549
532
  loadOperatorState,
550
533
  hasOperatorState,
551
534
  getResumeMessages,
552
535
  updateOperatorSettings,
553
- updateToolsetState,
554
- toggleTool: toggleTool2
536
+ updateSessionHeaders
555
537
  };
556
538
  export {
557
- updateToolsetState,
539
+ updateSessionHeaders,
558
540
  updateOperatorSettings,
559
- updateMessage,
560
- update2 as update,
561
- toggleTool2 as toggleTool,
562
541
  sessions,
563
- sessionPath,
564
- resolveSmtpConfig,
565
- removeMessage,
566
- remove2 as remove,
567
542
  normalizeMessages,
543
+ migrateLegacySessionData,
568
544
  loadOperatorState,
569
545
  list,
570
546
  hasOperatorState,
571
- getSessionsDir,
572
547
  getSessionRoot,
573
548
  getResumeMessages,
574
- getPensarDir,
575
- getOffensiveHeaders,
576
- getExecution,
577
549
  get,
578
- createSessionDirs,
579
550
  create,
580
551
  SessionInfoObject,
581
- EXFIL_OUTCOME_GUIDANCE,
582
- DEFAULT_OUTCOME_GUIDANCE,
583
- DEFAULT_OFFENSIVE_HEADERS
552
+ EXFIL_OUTCOME_GUIDANCE
584
553
  };
@@ -0,0 +1,36 @@
1
+ import {
2
+ AppsDiscoveryResultSchema,
3
+ DiscoverySummarySchema,
4
+ EndpointSchema,
5
+ RiskScoreBreakdownSchema,
6
+ RiskScoreSchema,
7
+ WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT,
8
+ WHITEBOX_DISCOVERY_SYSTEM_PROMPT,
9
+ WhiteboxAttackSurfaceAgent
10
+ } from "./cli-abbka8n3.js";
11
+ import"./cli-9fsre5pt.js";
12
+ import"./cli-k0730f59.js";
13
+ import"./cli-wfmdch3r.js";
14
+ import"./cli-mswm4k81.js";
15
+ import"./cli-ryy39d77.js";
16
+ import"./cli-c8131c4q.js";
17
+ import"./cli-s1nckt4k.js";
18
+ import"./cli-87zakjb2.js";
19
+ import"./cli-6p7d2k55.js";
20
+ import"./cli-w5990vr6.js";
21
+ import"./cli-e6rgwtpb.js";
22
+ import"./cli-9egg9azd.js";
23
+ import"./cli-gpnb45ck.js";
24
+ import"./cli-gtcd5c3f.js";
25
+ import"./cli-g5h24ny8.js";
26
+ import"./cli-8rxa073f.js";
27
+ export {
28
+ WhiteboxAttackSurfaceAgent,
29
+ WHITEBOX_DISCOVERY_SYSTEM_PROMPT,
30
+ WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT,
31
+ RiskScoreSchema,
32
+ RiskScoreBreakdownSchema,
33
+ EndpointSchema,
34
+ DiscoverySummarySchema,
35
+ AppsDiscoveryResultSchema
36
+ };
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  get,
3
3
  init,
4
+ init_config,
4
5
  update
5
- } from "./cli-nr1cjfr9.js";
6
- import"./cli-dj1dgw2n.js";
6
+ } from "./cli-gtcd5c3f.js";
7
+ import"./cli-g5h24ny8.js";
7
8
  import"./cli-8rxa073f.js";
8
9
 
9
10
  // src/core/config/index.ts
11
+ init_config();
10
12
  var config = {
11
13
  get,
12
14
  init,
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  disconnect,
3
+ ensureValidToken,
3
4
  fetchWorkspaces,
5
+ init_auth,
4
6
  isConnected,
7
+ isTokenExpired,
5
8
  pollForWorkspaceCreation,
6
9
  pollLegacyToken,
7
10
  pollWorkOSToken,
@@ -9,29 +12,24 @@ import {
9
12
  signGatewayRequest,
10
13
  startDeviceFlow,
11
14
  validateGateway
12
- } from "./cli-dqt80sw3.js";
13
- import {
14
- ensureValidToken,
15
- fetchWorkOSClientId,
16
- isTokenExpired,
17
- refreshAccessToken
18
- } from "./cli-asyas1xb.js";
19
- import"./cli-nr1cjfr9.js";
20
- import"./cli-dj1dgw2n.js";
15
+ } from "./cli-w5990vr6.js";
16
+ import"./cli-9egg9azd.js";
17
+ import"./cli-gtcd5c3f.js";
18
+ import"./cli-g5h24ny8.js";
21
19
  import"./cli-8rxa073f.js";
20
+ init_auth();
21
+
22
22
  export {
23
23
  validateGateway,
24
24
  startDeviceFlow,
25
25
  signGatewayRequest,
26
26
  selectWorkspace,
27
- refreshAccessToken,
28
27
  pollWorkOSToken,
29
28
  pollLegacyToken,
30
29
  pollForWorkspaceCreation,
31
30
  isTokenExpired,
32
31
  isConnected,
33
32
  fetchWorkspaces,
34
- fetchWorkOSClientId,
35
33
  ensureValidToken,
36
34
  disconnect
37
35
  };