@pensar/apex 2.2.0 → 2.3.0-canary.3f6d2a2b

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 (55) hide show
  1. package/build/{agent-yayy5x2a.js → agent-2h0w8eta.js} +7 -7
  2. package/build/agent-95qsypnq.js +19 -0
  3. package/build/{agent-q5hwjdtb.js → agent-rktf0v3c.js} +9 -9
  4. package/build/{apps-0es69e2s.js → apps-rehs72t3.js} +17 -17
  5. package/build/{auth-q73k9bh9.js → auth-h5bjv1dp.js} +51 -40
  6. package/build/authentication-zqkagnvm.js +19 -0
  7. package/build/blackboxAgent-b799jbpa.js +19 -0
  8. package/build/{blackboxPentest-h28nykk5.js → blackboxPentest-gszetqnq.js} +14 -14
  9. package/build/{cli-s43t5ay0.js → cli-06fq5zym.js} +1 -1
  10. package/build/{cli-51dkmt5p.js → cli-0qybv29g.js} +1 -1
  11. package/build/{cli-1cf5vy5m.js → cli-2m8y1rkp.js} +60 -162
  12. package/build/{cli-6kx46ck0.js → cli-2q3kvbwv.js} +228 -39
  13. package/build/{cli-1f636vzd.js → cli-3e0jb8k6.js} +1 -1
  14. package/build/{cli-ptzy9ak5.js → cli-3r7xgtqj.js} +1 -1
  15. package/build/{cli-xpn9tsw0.js → cli-41h8gh1v.js} +34 -9
  16. package/build/{cli-1re2kv5v.js → cli-5asc7364.js} +3 -3
  17. package/build/{cli-knqx15w6.js → cli-7d3h16fw.js} +2 -2
  18. package/build/{cli-tz9yg4ew.js → cli-abm5bgap.js} +24 -8
  19. package/build/{cli-4tc6888c.js → cli-dth5et2y.js} +51 -2
  20. package/build/{cli-7n43wz82.js → cli-khyery65.js} +5 -2
  21. package/build/{cli-xbdn034b.js → cli-mb680jb3.js} +4517 -120
  22. package/build/{cli-vgg6h2ax.js → cli-pvf8tyr2.js} +1 -1
  23. package/build/{cli-7e5ad5js.js → cli-qs2mveb2.js} +2 -2
  24. package/build/{cli-n114n8mk.js → cli-s8z1mkv5.js} +2 -2
  25. package/build/{cli-2jn8104w.js → cli-xkv494x1.js} +2 -2
  26. package/build/{cli-yz80qkzn.js → cli-ycj65kyw.js} +6 -0
  27. package/build/cli.js +42 -36
  28. package/build/{config-xcf7rc6x.js → config-hawgse8e.js} +3 -3
  29. package/build/{doctor-98zperf9.js → doctor-t305mq12.js} +7 -6
  30. package/build/{fastStrike-9tm6bedh.js → fastStrike-mk0gxtkm.js} +34 -14
  31. package/build/{fixes-1dry8j61.js → fixes-gxn4cmte.js} +16 -16
  32. package/build/{index-4hqbyzf5.js → index-98bpwjq9.js} +16 -8
  33. package/build/{index-pxwwcefn.js → index-a2qb45hc.js} +9 -9
  34. package/build/{index-f6ttv7np.js → index-cpbhz85w.js} +9 -5
  35. package/build/{index-6dbym5jy.js → index-fa4xk0fq.js} +29 -12
  36. package/build/{index-31rwrakh.js → index-qqp08dtj.js} +2 -2
  37. package/build/{index-0j880wqc.js → index-ra8jmwb2.js} +1154 -909
  38. package/build/{index-34h2nb6x.js → index-yggyem63.js} +3 -3
  39. package/build/{issues-wjakj8yy.js → issues-mtbp80dr.js} +44 -16
  40. package/build/{logs-ewyzcspy.js → logs-0wpqqb3z.js} +16 -16
  41. package/build/{offesecAgent-7m9smy0t.js → offesecAgent-d5ceedmg.js} +8 -8
  42. package/build/pentest-2znknvqd.js +29 -0
  43. package/build/{pentests-1hcqjyk2.js → pentests-gnwwdmac.js} +16 -16
  44. package/build/{targetedPentest-3x13kqvc.js → targetedPentest-ap7p8j6q.js} +9 -9
  45. package/build/{targets-nqz8w37e.js → targets-be3c736k.js} +16 -16
  46. package/build/threatModel-bypv7mjx.js +27 -0
  47. package/build/{uninstall-p1q5pkx2.js → uninstall-71xttcr0.js} +1 -1
  48. package/build/{upload-x7etpfp4.js → upload-c7e0bdcn.js} +6 -6
  49. package/build/{utils-kw6yh5yn.js → utils-ef23ac3j.js} +11 -7
  50. package/package.json +1 -1
  51. package/build/agent-3cdfwxcd.js +0 -19
  52. package/build/authentication-tqx2brcv.js +0 -19
  53. package/build/blackboxAgent-d0smgqt7.js +0 -19
  54. package/build/pentest-1cb5t0dt.js +0 -29
  55. package/build/threatModel-7f02av7y.js +0 -27
@@ -3,28 +3,22 @@ import {
3
3
  ASK_USER_QUESTIONS_TOOL_NAME,
4
4
  OffensiveSecurityAgent,
5
5
  SKILL_TOOL_NAMES,
6
+ apiRequest,
6
7
  buildBaseSystemPrompt
7
- } from "./cli-xbdn034b.js";
8
+ } from "./cli-mb680jb3.js";
8
9
  import {
9
10
  init_dist,
10
11
  init_session,
11
12
  sessions,
12
13
  stepCountIs
13
- } from "./cli-6kx46ck0.js";
14
+ } from "./cli-2q3kvbwv.js";
14
15
  import {
15
- ensureValidToken,
16
- getPensarApiUrl,
17
- init_auth,
18
16
  init_constants
19
- } from "./cli-4tc6888c.js";
17
+ } from "./cli-dth5et2y.js";
20
18
  import {
21
19
  exports_external,
22
20
  init_zod
23
21
  } from "./cli-3k1x5rn3.js";
24
- import {
25
- config,
26
- init_config
27
- } from "./cli-51dkmt5p.js";
28
22
  import {
29
23
  __commonJS,
30
24
  __require
@@ -6971,134 +6965,6 @@ var require_public_api = __commonJS((exports) => {
6971
6965
  exports.stringify = stringify;
6972
6966
  });
6973
6967
 
6974
- // src/core/api/apiClient.ts
6975
- init_auth();
6976
- init_config();
6977
- init_constants();
6978
- async function getAuthHeaders() {
6979
- const cfg = await config.get();
6980
- const validToken = await ensureValidToken({
6981
- accessToken: cfg.accessToken,
6982
- refreshToken: cfg.refreshToken,
6983
- pensarAPIKey: cfg.pensarAPIKey
6984
- });
6985
- if (!validToken) {
6986
- throw new Error("Not authenticated. Run `pensar login` to connect to Pensar Console.");
6987
- }
6988
- const headers = {
6989
- "Content-Type": "application/json",
6990
- Authorization: `Bearer ${validToken.token}`
6991
- };
6992
- if (cfg.workspaceId) {
6993
- headers["X-Workspace-Id"] = cfg.workspaceId;
6994
- }
6995
- return headers;
6996
- }
6997
- async function apiRequest(method, path, body) {
6998
- const baseUrl = getPensarApiUrl();
6999
- const headers = await getAuthHeaders();
7000
- const url = `${baseUrl}${path}`;
7001
- const init = { method, headers };
7002
- if (body !== undefined) {
7003
- init.body = JSON.stringify(body);
7004
- }
7005
- const response = await fetch(url, init);
7006
- if (!response.ok) {
7007
- const text2 = await response.text();
7008
- let message;
7009
- try {
7010
- const err = JSON.parse(text2);
7011
- message = err.error ?? text2;
7012
- } catch {
7013
- message = text2;
7014
- }
7015
- throw new Error(`API error (${response.status}): ${message}`);
7016
- }
7017
- const text = await response.text();
7018
- if (!text)
7019
- return;
7020
- return JSON.parse(text);
7021
- }
7022
-
7023
- // src/core/api/apps.ts
7024
- async function listApps(opts) {
7025
- const params = new URLSearchParams;
7026
- if (opts?.limit !== undefined)
7027
- params.set("limit", String(opts.limit));
7028
- if (opts?.offset !== undefined)
7029
- params.set("offset", String(opts.offset));
7030
- const qs = params.toString();
7031
- return apiRequest("GET", `/apps${qs ? `?${qs}` : ""}`);
7032
- }
7033
- async function getApp(appId) {
7034
- return apiRequest("GET", `/apps/${appId}`);
7035
- }
7036
- async function createApp(data) {
7037
- return apiRequest("POST", "/apps", data);
7038
- }
7039
- async function updateApp(appId, data) {
7040
- return apiRequest("PATCH", `/apps/${appId}`, data);
7041
- }
7042
- async function deleteApp(appId) {
7043
- return apiRequest("DELETE", `/apps/${appId}`);
7044
- }
7045
- async function listEndpoints(appId, filters) {
7046
- const params = new URLSearchParams;
7047
- if (filters?.type)
7048
- params.set("type", filters.type);
7049
- if (filters?.minRiskScore !== undefined) {
7050
- params.set("minRiskScore", String(filters.minRiskScore));
7051
- }
7052
- if (filters?.limit !== undefined)
7053
- params.set("limit", String(filters.limit));
7054
- if (filters?.offset !== undefined) {
7055
- params.set("offset", String(filters.offset));
7056
- }
7057
- const qs = params.toString();
7058
- const path = `/apps/${appId}/endpoints${qs ? `?${qs}` : ""}`;
7059
- return apiRequest("GET", path);
7060
- }
7061
- async function getEndpoint(endpointId) {
7062
- return apiRequest("GET", `/endpoints/${endpointId}`);
7063
- }
7064
- async function createEndpoint(appId, data) {
7065
- return apiRequest("POST", `/apps/${appId}/endpoints`, data);
7066
- }
7067
- async function updateEndpoint(endpointId, data) {
7068
- return apiRequest("PATCH", `/endpoints/${endpointId}`, data);
7069
- }
7070
- async function deleteEndpoint(endpointId) {
7071
- return apiRequest("DELETE", `/endpoints/${endpointId}`);
7072
- }
7073
- async function searchApps(query, opts) {
7074
- const params = new URLSearchParams({ q: query });
7075
- if (opts?.type)
7076
- params.set("type", opts.type);
7077
- if (opts?.limit !== undefined)
7078
- params.set("limit", String(opts.limit));
7079
- if (opts?.offset !== undefined)
7080
- params.set("offset", String(opts.offset));
7081
- return apiRequest("GET", `/search/apps?${params.toString()}`);
7082
- }
7083
- async function searchEndpoints(query, opts) {
7084
- const params = new URLSearchParams({ q: query });
7085
- if (opts?.applicationId)
7086
- params.set("applicationId", opts.applicationId);
7087
- if (opts?.type)
7088
- params.set("type", opts.type);
7089
- if (opts?.minRiskScore !== undefined) {
7090
- params.set("minRiskScore", String(opts.minRiskScore));
7091
- }
7092
- if (opts?.authRequired !== undefined) {
7093
- params.set("authRequired", opts.authRequired ? "true" : "false");
7094
- }
7095
- if (opts?.limit !== undefined)
7096
- params.set("limit", String(opts.limit));
7097
- if (opts?.offset !== undefined)
7098
- params.set("offset", String(opts.offset));
7099
- return apiRequest("GET", `/search/endpoints?${params.toString()}`);
7100
- }
7101
-
7102
6968
  // src/core/api/issues.ts
7103
6969
  async function listScans() {
7104
6970
  return apiRequest("GET", "/pentests");
@@ -7135,6 +7001,12 @@ async function updateIssue(issueId, data) {
7135
7001
  async function retestIssue(issueId) {
7136
7002
  return apiRequest("POST", `/issues/${issueId}/retest`);
7137
7003
  }
7004
+ async function linkPullRequest(issueId, url) {
7005
+ return apiRequest("POST", `/issues/${issueId}/pull-requests`, { url });
7006
+ }
7007
+ async function listIssuePullRequests(issueId) {
7008
+ return apiRequest("GET", `/issues/${issueId}/pull-requests`);
7009
+ }
7138
7010
  async function listFixes(issueId) {
7139
7011
  return apiRequest("GET", `/issues/${issueId}/fixes`);
7140
7012
  }
@@ -7322,46 +7194,60 @@ async function runOffensiveSecurityAgent(input) {
7322
7194
  return { streamResult: agent.streamResult, session: agent.session };
7323
7195
  }
7324
7196
  // src/core/agents/specialized/patching/prompts.ts
7325
- var PREAMBLE2 = `You are an expert security vulnerability patching agent. Your goal is to analyze security vulnerabilities, provide high-quality fixes, and verify the fixes don't break existing functionality.`;
7197
+ var PREAMBLE2 = `You are an expert security vulnerability patching agent — an autonomous coding agent specialized in fixing security issues. Your goal is to analyze security vulnerabilities, apply high-quality fixes, verify they don't break existing functionality, and return structured PR metadata.`;
7326
7198
  var ORIENT_STEP = `1. **Orient Yourself**:
7327
- - Review the AGENTS.md / project documentation provided in your prompt for build, lint, and test commands
7328
- - Use list_files to explore the repository structure
7199
+ - Read the project instructions (AGENTS.md / CLAUDE.md) provided in your prompt in full. They are authoritative for this repository: coding conventions, architectural rules, error-handling policy, forbidden patterns, AND the exact build/lint/test commands
7200
+ - Use glob / list_files to explore the repository structure (prefer glob for pattern searches like "**/*.ts")
7329
7201
  - Read package.json, Makefile, or equivalent to understand the project's toolchain
7330
- - Identify the lint command, test command, type-check command, and any other verification scripts`;
7331
- var UNDERSTAND_STEP = `2. **Understand the Vulnerability**:
7202
+ - Identify the lint command, test command, type-check command, and any other verification scripts
7203
+ - Optionally call profile_codebase for a high-level map of the repo`;
7204
+ var TASK_STEP = `2. **Track Work with Tasks**:
7205
+ - Use create_task early to decompose the job into concrete steps (orient, understand, edit, verify, finalize)
7206
+ - Update tasks with update_task as you progress (in_progress → completed / failed)
7207
+ - Use list_tasks when you need to recall what's left
7208
+ - Keep tasks atomic — one clear outcome per task`;
7209
+ var UNDERSTAND_STEP = `3. **Understand the Vulnerability**:
7332
7210
  - Carefully read the vulnerability description, CWE mappings, and any dataflow analysis provided
7333
7211
  - Understand the root cause: What makes this code vulnerable?
7334
7212
  - Identify the attack vector: How would an attacker exploit this?
7335
- - Consider the context: What is the application trying to do?`;
7336
- var REVIEW_STEP = `3. **Review the Code**:
7213
+ - Consider the context: What is the application trying to do?
7214
+ - Use web_search / get_page when you need framework-specific security guidance or CVE details`;
7215
+ var REVIEW_STEP = `4. **Review the Code**:
7337
7216
  - Use read_file to read the vulnerable file(s) mentioned in the issue
7338
- - Use grep to search for related code patterns, similar vulnerabilities, or existing security controls
7217
+ - Use grep or run_code_query for structural searches (rg / ast-grep) across related patterns
7339
7218
  - Review related files: imports, dependencies, configuration files
7340
7219
  - Understand the data flow: Where does user input come from? Where does it go?`;
7341
- var PLAN_STEP = `4. **Plan Your Fix**:
7220
+ var PLAN_STEP = `5. **Plan Your Fix**:
7342
7221
  - Identify the exact code that needs to change
7343
7222
  - Determine the appropriate security control (input validation, parameterized queries, access control, etc.)
7344
7223
  - Consider side effects: Will this break existing functionality?
7345
7224
  - Think about edge cases: What other inputs or scenarios need to be handled?
7346
7225
  - Look for framework-specific or language-specific best practices
7347
- - State your complete plan clearly before making changes`;
7348
- var APPLY_STEP = `5. **Apply the Patch**:
7349
- - Use update_file to modify existing files with your security fixes
7226
+ - State your complete plan clearly before making changes, and reflect it in your task list`;
7227
+ var APPLY_STEP = `6. **Apply the Patch**:
7228
+ - Prefer update_file for small, exact string replacements
7229
+ - Prefer apply_patch (unified diff) for multi-hunk or multi-file edits
7350
7230
  - Use create_file if you need to add new security utilities or middleware
7231
+ - Use delete_file only when removing obsolete insecure code that is truly unused
7351
7232
  - Make minimal, targeted changes — don't refactor unrelated code
7352
- - Follow the existing code style and conventions
7233
+ - Follow the existing code style and conventions, and any rules stated in the project instructions
7353
7234
  - Ensure your changes integrate cleanly with the existing codebase`;
7354
- var RESTART_STEP = `6. **Restart Dev Environment** (if applicable):
7235
+ var GIT_STEP = `7. **Self-Check with Git**:
7236
+ - Use git_status to see which files changed
7237
+ - Use git_diff to review the exact patch before verification
7238
+ - Do NOT commit, push, or open a PR — the host handles that after you finalize`;
7239
+ var RESTART_STEP = `8. **Restart Dev Environment** (if applicable):
7355
7240
  - Use execute_command to restart any dev servers or services so your changes are loaded
7356
7241
  - Wait for the services to become healthy`;
7357
- var VERIFY_STEP = `7. **Verify the Patch**:
7242
+ var VERIFY_STEP = `9. **Verify the Patch**:
7358
7243
  - Use execute_command to run the project's lint command (e.g. \`npm run lint\`, \`ruff check\`, \`cargo clippy\`)
7359
7244
  - Use execute_command to run the project's type-check command if applicable (e.g. \`npx tsc --noEmit\`, \`mypy\`)
7360
7245
  - Use execute_command to run the project's test suite (e.g. \`npm test\`, \`pytest\`, \`cargo test\`)
7361
7246
  - If a Proof of Concept (POC) is provided, run it to verify the vulnerability is fixed — the POC should FAIL (non-zero exit code) after a successful patch
7362
7247
  - If any check fails, read the error output carefully, fix the issues, and re-run until all checks pass
7363
7248
  - If the project has no clear lint/test commands, at minimum verify the changed files parse correctly (e.g. \`node -c file.js\`, \`python -m py_compile file.py\`)`;
7364
- var FINALIZE_STEP = `8. **Finalize**:
7249
+ var FINALIZE_STEP = `10. **Finalize**:
7250
+ - Mark remaining tasks completed
7365
7251
  - Use the response tool to complete the patching process
7366
7252
  - Provide a clear, detailed summary of:
7367
7253
  * Each file you changed and why
@@ -7428,12 +7314,18 @@ var SECURITY_BEST_PRACTICES = `# Security Best Practices by Vulnerability Type
7428
7314
  - Remove sensitive data from client-side code`;
7429
7315
  var TOOL_USAGE2 = `# Tool Usage
7430
7316
 
7431
- - **list_files**: Explore directory structure and find relevant files
7317
+ - **glob**: Find files by pattern (e.g. "**/*.ts", "**/package.json")
7318
+ - **list_files**: Explore directory structure
7432
7319
  - **read_file**: Read file contents to understand code
7433
- - **grep**: Search for patterns across the codebase
7434
- - **update_file**: Modify existing files with security fixes
7435
- - **create_file**: Create new files if needed (utilities, middleware, etc.)
7436
- - **execute_command**: Run shell commands use for linting, type-checking, running tests, restarting services, running POCs, installing dependencies, and verifying your changes
7320
+ - **grep** / **run_code_query**: Search for patterns (run_code_query supports rg / ast-grep / comby)
7321
+ - **profile_codebase**: High-level codebase map when orientation is hard
7322
+ - **web_search** / **get_page**: Look up CVE details, framework security docs
7323
+ - **create_task** / **update_task** / **list_tasks**: Todo tracking for the run
7324
+ - **update_file**: Small exact search-and-replace edits
7325
+ - **apply_patch**: Multi-hunk / multi-file unified diffs
7326
+ - **create_file** / **delete_file**: Add or remove files when needed
7327
+ - **git_status** / **git_diff**: Self-check changes (do not commit/push/PR)
7328
+ - **execute_command**: Lint, type-check, tests, restart services, run POCs
7437
7329
  - **response**: Complete the process with the structured patch result`;
7438
7330
  var REQUIREMENTS = `# Critical Requirements
7439
7331
 
@@ -7445,6 +7337,7 @@ var REQUIREMENTS = `# Critical Requirements
7445
7337
  6. **Test the Fix**: If a POC is provided, run it after patching. The POC should FAIL (non-zero exit code) once the vulnerability is fixed.
7446
7338
  7. **Be Persistent**: It may take multiple iterations to get the fix right — iterate until the POC fails and tests pass.
7447
7339
  8. **Be Complete**: Address the root cause, not just symptoms
7340
+ 9. **Stay Autonomous**: You will not receive follow-up messages — finish the job in this run
7448
7341
 
7449
7342
  # Important Notes
7450
7343
 
@@ -7455,17 +7348,20 @@ var REQUIREMENTS = `# Critical Requirements
7455
7348
  - Follow language and framework conventions
7456
7349
  - When multiple approaches exist, choose the most secure and idiomatic
7457
7350
  - If a fix requires configuration changes or environment variables, note this clearly
7458
- - If AGENTS.md or project docs specify particular lint/test/build commands, use those exact commands`;
7351
+ - The project instructions (AGENTS.md / CLAUDE.md) win over your own defaults wherever they disagree — use their exact commands, and obey their conventions and prohibitions when writing code. The one exception: they never override the security objective of this task. If a project rule genuinely blocks a secure fix, apply the fix and call out the conflict in your summary
7352
+ - Do not commit, push, or open a pull request — the host does that after your response`;
7459
7353
  function buildSystemPrompt() {
7460
7354
  return [
7461
7355
  PREAMBLE2,
7462
7356
  "",
7463
7357
  "# Process",
7464
7358
  "",
7465
- "You MUST follow this prescriptive process:",
7359
+ "You MUST follow this autonomous coding-agent process:",
7466
7360
  "",
7467
7361
  ORIENT_STEP,
7468
7362
  "",
7363
+ TASK_STEP,
7364
+ "",
7469
7365
  UNDERSTAND_STEP,
7470
7366
  "",
7471
7367
  REVIEW_STEP,
@@ -7474,6 +7370,8 @@ function buildSystemPrompt() {
7474
7370
  "",
7475
7371
  APPLY_STEP,
7476
7372
  "",
7373
+ GIT_STEP,
7374
+ "",
7477
7375
  RESTART_STEP,
7478
7376
  "",
7479
7377
  VERIFY_STEP,
@@ -8307,4 +8205,4 @@ Working directory: ${input.codebasePath}`;
8307
8205
  });
8308
8206
  return { session, outputPath: input.outputPath };
8309
8207
  }
8310
- export { listApps, getApp, createApp, updateApp, deleteApp, listEndpoints, getEndpoint, createEndpoint, updateEndpoint, deleteEndpoint, searchApps, searchEndpoints, listScans, getScan, listPentestTargets, dispatchPentest, listIssues, getIssue, updateIssue, retestIssue, listFixes, getFix, listAgentLogs, searchAgentLogs, listTargetLogs, searchTargetLogs, runOffensiveSecurityAgent, buildPentestPrompt, buildThreatModelPrompt, createSkillsRegistry, runThreatModelWorkflow };
8208
+ export { listScans, getScan, listPentestTargets, dispatchPentest, listIssues, getIssue, updateIssue, retestIssue, linkPullRequest, listIssuePullRequests, listFixes, getFix, listAgentLogs, searchAgentLogs, listTargetLogs, searchTargetLogs, runOffensiveSecurityAgent, buildPentestPrompt, buildThreatModelPrompt, createSkillsRegistry, runThreatModelWorkflow };