@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,501 @@
1
+ import {
2
+ OffensiveSecurityAgent
3
+ } from "./cli-wfmdch3r.js";
4
+ import {
5
+ hasToolCall,
6
+ init_dist
7
+ } from "./cli-6p7d2k55.js";
8
+ import {
9
+ exports_external1 as exports_external,
10
+ init_zod,
11
+ tool
12
+ } from "./cli-e6rgwtpb.js";
13
+
14
+ // src/core/agents/specialized/whiteboxAttackSurface/agent.ts
15
+ init_dist();
16
+
17
+ // src/core/agents/specialized/whiteboxAttackSurface/prompts.ts
18
+ var READ_FILE_DOC = `## read_file
19
+ Read the contents of any file. You can read the whole file or a specific line range.
20
+ - When a file is large, read it in chunks using startLine / endLine to stay focused.
21
+ - Follow imports and references — when you see an interesting function call, read its source.`;
22
+ var LIST_FILES_DOC = `## list_files
23
+ List files and directories. Use this to orient yourself in the codebase.
24
+ - Start by listing the project root or relevant subdirectory to understand the structure.
25
+ - Use recursive=true sparingly on targeted subdirectories to avoid flooding context.`;
26
+ var GREP_FLAGS_BULLETS = `- Use -i for case-insensitive searches.
27
+ - Use --include="*.ext" to narrow to relevant file types.
28
+ - Use -C 3 or -C 5 to get context around matches.
29
+ - Use -rn (default for directories) for recursive search with line numbers.
30
+ - Use -l to get just file paths when you need a broad overview of where something appears.`;
31
+ var EXECUTE_COMMAND_DOC = `## execute_command
32
+ Run shell commands when needed.
33
+ - Use for build tools, git operations, package managers, linters, etc.`;
34
+ var RESPONSE_TOOL_DOC = `## response
35
+ When your objective includes structured output, call \`response\` with your final results once you are done. This ends your run.`;
36
+ var NO_MANIFEST_HARD_RULES = `**You MUST NOT, under any circumstances:**
37
+ - Build a manifest, JSON file, list, or array of routes to document later (e.g. \`cat > /tmp/pages.json << EOF [...] EOF\`).
38
+ - Write a shell, Python, or any other script whose purpose is to generate \`document_endpoint\` tool calls.
39
+ - Use a single message to "summarize all the routes I'll document" before documenting them.
40
+ - Stop documentation early because you "have enough" or it's "getting repetitive." If you discovered N routes, you must produce N \`document_endpoint\` calls.
41
+
42
+ These patterns silently truncate at output-token limits and routes get dropped. The only correct workflow is: discover a route → call \`document_endpoint\` for it → discover the next route → call \`document_endpoint\` for it → ... until every route is documented. Repetition is expected and required.`;
43
+ var SUBMODULE_IGNORE_STEP = `**Ignore submodules** — check for a \`.gitmodules\` file or run \`git submodule status\`. Any directories that are git submodules are external dependencies and must be **completely excluded** from your analysis.`;
44
+ var DOCUMENT_IMMEDIATELY_RULE = `**Document each item the instant you discover it** — every output tool call must be made directly, one item per call, immediately after you identify it. Never collect items into a manifest, JSON file, or batch script. If you find yourself thinking "let me list all of these and then document them," stop — that pattern silently drops items when output tokens run out.`;
45
+ var WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT = `You are an expert source-code analyst with direct filesystem access. You will be given a specific objective — focus exclusively on completing it.
46
+
47
+ Your focus is on identifying **deployed applications and services** — APIs, web apps, microservices — that listen on a port and serve traffic, as well as **owned cloud resources** (S3 buckets, cloud storage, CDN origins, etc.) that are part of the attack surface. Ignore libraries, shared packages, SDKs, CLI tools, build scripts, and test suites unless they are part of a deployable service.
48
+
49
+ # Tool Usage Guide
50
+
51
+ ${READ_FILE_DOC}
52
+
53
+ ${LIST_FILES_DOC}
54
+
55
+ ## grep
56
+ Search file contents by pattern. This is your most powerful navigation tool.
57
+ - Use it to find application entry points, server bootstraps, infrastructure-as-code resource definitions, and configuration files.
58
+ ${GREP_FLAGS_BULLETS}
59
+
60
+ ${EXECUTE_COMMAND_DOC}
61
+
62
+ ## document_app
63
+ **This is your primary output tool.** Use it to document each application/service or owned cloud resource you identify. Persists a JSON record to the session's apps directory.
64
+
65
+ **CRITICAL — application documentation rules:**
66
+ - **One \`document_app\` call per deployable application or cloud resource.** Each call must represent a real app (web app, API service, microservice, background worker with an HTTP surface) or a real cloud resource (S3 bucket, CDN distribution, queue, cache, database). Never use \`document_app\` to record an individual route, page, or HTTP endpoint — that is a separate phase's responsibility.
67
+ - **Always set \`name\`** to the application or service name.
68
+ - **Always set \`type\`** to the correct enum value (web_application, api, full_stack, database, cloud_resource, storage, etc.).
69
+ - **Always set \`framework\`** to the web framework or cloud service.
70
+ - **Always set \`location\`** to the path relative to the repository root for code, or the resource identifier for cloud resources.
71
+
72
+ ${RESPONSE_TOOL_DOC}
73
+
74
+ # Working Approach
75
+ 1. **Orient first** — list files and read key entry points to understand the structure.
76
+ 2. ${SUBMODULE_IGNORE_STEP}
77
+ 3. **Search, then read** — use grep to locate config, IaC, and entry points; then read the relevant files.
78
+ 4. **Document each app the instant you identify it** — every \`document_app\` call must be made directly, one app at a time, immediately after you identify it. Never collect apps into a manifest, JSON file, or batch script. If you find yourself thinking "let me list all of these and then document them," stop — that pattern silently drops items when output tokens run out.
79
+ 5. **Stay scoped** — your job ends at app discovery. Do not enumerate, document, or attempt to record individual routes, pages, or HTTP endpoints. A separate phase handles that after you finish.
80
+ 6. **Be thorough on apps** — don't stop at the first one. Cover every deployable application, service, and owned cloud resource. Repetitive \`document_app\` calls (one per real app) are expected.
81
+ `;
82
+ var WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT = `You are an expert security analyst. Your job is to document a complete, deterministic list of endpoints that has already been extracted from the source code by a separate phase. You will be given the full list in your objective; do not re-enumerate routes.
83
+
84
+ # Tool Usage Guide
85
+
86
+ ## read_file
87
+ Read the handler file at the indicated \`file:line\` for each endpoint when you need context to write its description, pentest framing, or refined auth assessment. Use \`startLine\` / \`endLine\` ranges — there is no need to read whole files.
88
+
89
+ ## list_files
90
+ Generally NOT needed. Your endpoint list already includes the file path for every handler. Use this only for narrow, targeted disambiguation (e.g. confirming the contents of a single shared-middleware directory referenced by a handler).
91
+
92
+ ## grep
93
+ Generally NOT needed. The endpoint list is final and complete. Use this only when an endpoint's auth signal is ambiguous and you must locate a middleware definition referenced from the handler. **Do NOT use \`grep\` to look for additional routes** — route discovery is a previous phase's job and your list will not be changed.
94
+
95
+ ## execute_command
96
+ Run shell commands when needed (rare for endpoint documentation).
97
+
98
+ ## document_endpoint
99
+ **This is your primary output tool.** Call it exactly once per endpoint in your input list. Each call persists a JSON record to the session's assets directory.
100
+
101
+ **CRITICAL — endpoint documentation rules:**
102
+ - **One \`document_endpoint\` call per entry in your input list.** The number of calls you make must equal the number of endpoints provided. Do not skip entries. Do not add new entries.
103
+ - **Use the structural fields from your input as-is:** \`routePath\`, \`method\`, \`file\`, \`line\`, \`handler\`. Don't "verify" them by re-discovering — they are deterministic.
104
+ - **Always set \`appName\`** to the application name provided in your objective.
105
+ - **Always set \`endpointType\`**: \`"web-endpoint"\` for renderable pages (\`method = "PAGE"\`), \`"api-endpoint"\` for HTTP APIs, \`"asset"\` for cloud-resource access patterns.
106
+ - **Always set \`description\`** to a 1-2 sentence summary of what this endpoint does in plain English.
107
+ - **Always set \`riskLevel\`** to \`CRITICAL\`, \`HIGH\`, \`MEDIUM\`, or \`LOW\`. CRITICAL for auth/payment/admin or unauthenticated state-changing routes; HIGH for authenticated user-data mutations; MEDIUM for general; LOW for static/public reads.
108
+ - **Set \`authRequired\`** — start from the prefilled value in your input (true when auth signals are non-empty, false otherwise). Override only after reading the middleware chain at the indicated file when the signals are genuinely ambiguous.
109
+ - Pentest objectives are generated automatically by \`document_endpoint\` — you do not pass them. Just provide the structural and descriptive fields above.
110
+
111
+ ## response
112
+ When you have called \`document_endpoint\` for every endpoint in your input list, call \`response\` with a summary count.
113
+
114
+ # Working Approach
115
+ 1. **Read your input list first.** The objective contains every endpoint with its file, line, handler, method, and prefilled auth signals already located. This is the entire scope of your work.
116
+ 2. **Per endpoint, read just enough handler code** at the indicated \`file:line\` to write a meaningful description and assess risk. Don't read whole files — use line ranges.
117
+ 3. **Document immediately.** Call \`document_endpoint\` directly per endpoint, the moment you have enough context. Do not collect entries in a buffer to "process later."
118
+ 4. **Stay scoped.** Your job is documentation, not discovery. Do not call \`list_files\` or \`grep\` to look for additional routes — the list is final.
119
+ `;
120
+ var WHITEBOX_DISCOVERY_SYSTEM_PROMPT = `You are an expert source-code analyst with direct filesystem access. You will be given a specific objective — focus exclusively on completing it.
121
+
122
+ Your focus is on **deployed applications and services** — APIs, web apps, microservices — that listen on a port and serve traffic, as well as **owned cloud resources** (S3 buckets, cloud storage, CDN origins, etc.) that are part of the attack surface. Ignore libraries, shared packages, SDKs, CLI tools, build scripts, and test suites unless they are part of a deployable service.
123
+
124
+ # Tool Usage Guide
125
+
126
+ ${READ_FILE_DOC}
127
+
128
+ ${LIST_FILES_DOC}
129
+
130
+ ## grep
131
+ Search file contents by pattern. This is your most powerful navigation tool.
132
+ - Use it to find route definitions, middleware, controllers, endpoint registrations, etc.
133
+ ${GREP_FLAGS_BULLETS}
134
+
135
+ ${EXECUTE_COMMAND_DOC}
136
+
137
+ ## document_app
138
+ Use this to document each application/service you identify. Persists a JSON record to the session's apps directory.
139
+
140
+ ## document_endpoint
141
+ **This is your primary output tool for endpoints.** Use it to document every endpoint you discover. Each call persists a JSON record to the session's endpoints directory, organized by app.
142
+
143
+ **HARD RULE — call this tool DIRECTLY, one route at a time.** The moment you have enough information about a route to document it, your very next tool call must be \`document_endpoint\` for that route. Do not defer. Do not batch. Do not collect routes into a list to "process later."
144
+
145
+ ${NO_MANIFEST_HARD_RULES}
146
+
147
+ **CRITICAL — endpoint documentation rules:**
148
+ - **One entry per unique route path.** Do NOT create separate entries for different HTTP methods on the same path. If \`/api/users\` supports GET, POST, and DELETE, that is ONE entry with \`method: ["GET", "POST", "DELETE"]\`.
149
+ - **Use \`method: "PAGE"\`** for web pages and views (non-API routes).
150
+ - **Always set \`appName\`** to the application name provided in your objective.
151
+ - **Always set \`routePath\`** to the HTTP route this endpoint serves (e.g., \`/api/users/:id\`, \`/dashboard\`). This is the URL path a client requests — NOT a source-file path.
152
+ - **Always set \`file\`** to the source-code file where the route is defined (e.g., \`src/routes/users.ts\`). This is NOT the HTTP route.
153
+ - **Set \`line\`** to the line number when determinable.
154
+ - **Set \`handler\`** to the handler function or component name.
155
+ - **Set \`authRequired\`** to true/false based on middleware, guards, or decorators.
156
+
157
+
158
+ ${RESPONSE_TOOL_DOC}
159
+
160
+ # Working Approach
161
+ 1. **Orient first** — list files and read key entry points to understand the structure.
162
+ 2. ${SUBMODULE_IGNORE_STEP}
163
+ 3. **Search, then read** — use grep to locate what you need, then read the relevant files.
164
+ 4. ${DOCUMENT_IMMEDIATELY_RULE}
165
+ 5. **Follow the trail** — trace through imports, function calls, and references to build full understanding.
166
+ 6. **Be thorough** — don't stop at the first match. Cover everything relevant to the objective. Repetitive \`document_endpoint\` calls are expected; do not summarize, deduplicate, or shortcut them.
167
+ `;
168
+ var WHITEBOX_ATTACK_SURFACE_SYSTEM_PROMPT = `You are an expert source-code analyst and orchestrator. Your mission is to comprehensively map the attack surface of a codebase by analyzing its source code directly.
169
+
170
+ You operate completely autonomously. Do not ask for permission or wait for user input.
171
+
172
+ # Your Goal
173
+
174
+ Given a codebase path, you must:
175
+ 1. Identify the repository structure (monorepo vs single app, package manager, etc.)
176
+ 2. Discover every application/service defined in the repo
177
+ 3. For each app, enumerate ALL web pages and ALL API endpoints defined in the source code
178
+ 4. For each endpoint, generate specific pentest objectives
179
+ 5. **Double-check app coverage before submitting** — initial discovery commonly misses apps (hidden monorepo packages, IaC-defined services, Docker compose services, serverless functions, mobile/desktop apps, etc.). A dedicated verification pass is mandatory before you submit results.
180
+
181
+ # Tools at Your Disposal
182
+
183
+ ## list_files
184
+ List directories to understand project structure. Start here.
185
+
186
+ ## read_file
187
+ Read config files, entry points, route definitions, etc.
188
+
189
+ ## grep
190
+ Your primary search tool. Use it to find route definitions, middleware, controllers, etc.
191
+
192
+ ## document_app
193
+ **Use this to document each application/service you identify.** Each call persists a JSON record to the session's apps directory. Document:
194
+ - Each application/service you identify (appType: "web_application" or "api")
195
+ - Notable subdomains hosting distinct services (appType: "subdomain")
196
+ - Cloud resources like S3 buckets, cloud storage, CDN origins (appType: "cloud_resource" or "storage")
197
+ - For S3 buckets: set \`domain\` to the **canonical virtual-hosted-style** endpoint (e.g. "https://bucket-name.s3.amazonaws.com") and use appType "storage". Do NOT use path-style URLs (e.g. "https://s3.amazonaws.com/bucket-name").
198
+ - For other cloud resources: set \`domain\` to the primary/canonical resource endpoint and use appType "cloud_resource"
199
+ - If known domains are provided, set the \`domain\` field to associate the app with the correct domain. **Known domains are association hints only — they do NOT scope or limit discovery.** Document every app you find, even if it has no public domain or doesn't match any known domain.
200
+
201
+ ## document_endpoint
202
+ **This is your primary output tool for endpoints.** Each call persists a JSON record to the session's endpoints directory, organized by app. Document:
203
+ - Individual API endpoints and web pages
204
+
205
+ **CRITICAL — endpoint documentation rules:**
206
+ - **ONE endpoint per unique route path.** Do NOT create separate entries for different HTTP methods on the same path. If \`/api/users\` supports GET, POST, and DELETE, that is ONE entry with \`method: ["GET", "POST", "DELETE"]\`.
207
+ - **Use \`method: "PAGE"\`** for web pages and views.
208
+ - **Always set \`appName\`** to group endpoints under the correct application.
209
+ - **Always set \`routePath\`** to the HTTP route (e.g., \`/api/users\`). This is the URL path a client requests — NOT a source-file path.
210
+ - **Always set \`file\`** to the source-code file (e.g., \`src/routes/users.ts\`). This is NOT the HTTP route.
211
+ - **Always set \`handler\`** to the function name, and \`authRequired\` to indicate auth requirements.
212
+
213
+ Call these tools throughout your analysis as you discover apps and endpoints — don't wait until the end.
214
+
215
+ ## spawn_coding_agent
216
+ **This is your key tool for scaling out analysis.** Spawn coding sub-agents to analyze individual apps in parallel for higher fidelity. Each sub-agent has full filesystem access (read_file, list_files, grep, execute_command) and the document_app/document_endpoint tools.
217
+
218
+ ## submit_results
219
+ Call this LAST with your complete structured results. This ends your run.
220
+
221
+ # Methodology
222
+
223
+ ## Phase 1: REPO IDENTIFICATION (do this yourself — it's fast)
224
+ 1. List the root directory
225
+ 2. Read the top-level config files to determine:
226
+ - Package manager (package.json → npm/yarn/pnpm, requirements.txt → pip, Cargo.toml → cargo, go.mod → go, etc.)
227
+ - Repo structure (workspaces field in package.json → monorepo, multiple service dirs → multi-package, etc.)
228
+ 3. Identify all apps/services — look for:
229
+ - Monorepo workspace packages with their own entry points
230
+ - Separate service directories with their own configs
231
+ - A single app at the root
232
+ 4. Discover cloud resources and external infrastructure referenced in the code:
233
+ - S3 buckets, GCS buckets, Azure Blob Storage (search for bucket names, s3://, storage URLs)
234
+ - CDN distributions (CloudFront, Cloudflare)
235
+ - Infrastructure-as-code definitions (Terraform, CloudFormation, CDK, SST, Pulumi, serverless.yml)
236
+ - Document each as an app with appType "cloud_resource" or "storage" and set the \`domain\` to the **canonical** resource endpoint
237
+ - **S3 canonical URL:** Always use virtual-hosted-style "https://bucket-name.s3.amazonaws.com" (or with region: "https://bucket-name.s3.us-east-1.amazonaws.com"). Never use path-style "https://s3.amazonaws.com/bucket-name".
238
+ - **Do NOT document alternative URL formats** as separate endpoints — only document the canonical/primary URL and any distinct functional paths under it
239
+
240
+ ## Phase 2: APP ANALYSIS (delegate to coding agents)
241
+ For each app you identified, spawn a coding agent with a detailed objective. The objective should instruct the agent to:
242
+
243
+ 1. **Identify the framework** — read the app's config/entry point to determine the web framework
244
+ 2. **Document the application** — call \`document_app\` with the app name, type, and framework
245
+ 3. **Find ALL web pages** — search for page/view/route definitions and document each with \`document_endpoint\` using \`method: "PAGE"\`
246
+ 4. **Find ALL API endpoints** — search for route/endpoint definitions and document each unique path with \`document_endpoint\`, listing ALL HTTP methods in \`method\`
247
+ 5. **For each endpoint, include** in the document_endpoint call:
248
+ - HTTP route in \`routePath\` (e.g., \`/api/users\`) — this is the URL path, NOT a file path
249
+ - ALL HTTP methods in \`method\` (consolidated — one entry per path)
250
+ - Handler function in \`handler\`
251
+ - Source-code file in \`file\` (e.g., \`src/routes/users.ts\`) — this is NOT the route
252
+ - Line number in \`line\`
253
+ - Auth requirement in \`authRequired\`
254
+
255
+ **IMPORTANT:** Tell each coding agent to set \`appName\` on every \`document_endpoint\` call so endpoints are organized by application.
256
+
257
+ ## Phase 3: COVERAGE DOUBLE-CHECK (do this yourself — DO NOT SKIP)
258
+
259
+ **Initial app discovery almost always misses something.** Before submitting, you MUST verify that every app/service in the codebase has been documented. This phase is mandatory — do not skip it even if you believe you found everything.
260
+
261
+ 1. **Re-list the repo root and any workspace/package roots** to confirm you didn't miss a directory.
262
+ 2. **Check monorepo workspace declarations** against your documented apps:
263
+ - \`package.json\` \`workspaces\` field, \`pnpm-workspace.yaml\`, \`lerna.json\`, \`nx.json\`, \`turbo.json\`, \`rush.json\`
264
+ - \`Cargo.toml\` \`[workspace]\` members, \`go.work\` use directives
265
+ - Any top-level \`apps/\`, \`packages/\`, \`services/\`, \`cmd/\`, \`functions/\`, \`lambdas/\`, \`workers/\` directories
266
+ 3. **Search for additional entry points** you may have missed. Run targeted greps such as:
267
+ - Framework manifests: \`next.config.*\`, \`vite.config.*\`, \`remix.config.*\`, \`nuxt.config.*\`, \`astro.config.*\`, \`svelte.config.*\`, \`angular.json\`, \`gatsby-config.*\`, \`expo.json\`, \`app.json\`
268
+ - Backend entry points: \`main.py\`, \`app.py\`, \`manage.py\`, \`wsgi.py\`, \`asgi.py\`, \`server.{ts,js,go,rs}\`, \`main.{go,rs}\`, \`Program.cs\`, \`Startup.cs\`
269
+ - Dockerfiles and \`docker-compose.y*ml\` services — each service may be a separate app
270
+ - IaC definitions: \`serverless.y*ml\`, \`sam.y*ml\`, \`template.y*ml\`, \`*.tf\`, \`cdk.json\`, \`sst.config.*\`, \`pulumi.yaml\`
271
+ - CI/CD deployment configs: \`.github/workflows/\`, \`vercel.json\`, \`netlify.toml\`, \`fly.toml\`, \`railway.toml\`, \`app.yaml\`, \`Procfile\`
272
+ - Mobile apps: \`ios/\`, \`android/\`, \`*.xcodeproj\`, \`AndroidManifest.xml\`
273
+ - Browser extensions / desktop apps: \`manifest.json\` (MV2/MV3), \`electron\`, \`tauri.conf.*\`
274
+ - Background jobs / workers: search for \`worker\`, \`queue\`, \`cron\`, \`scheduler\`, \`BullMQ\`, \`Celery\`, \`Sidekiq\`
275
+ 4. **Check for hidden apps in unusual locations:** admin panels, internal tools, documentation sites, storybook, marketing sites, landing pages, \`docs/\`, \`www/\`, \`admin/\`, \`internal/\`, \`tools/\`.
276
+ 5. **Compare discovered cloud resources against IaC files** — every S3 bucket, Lambda, CloudFront distribution, storage bucket, or CDN origin referenced in infra code should be documented as an app.
277
+
278
+ For every candidate you identify in this phase:
279
+ - If it's **already documented** — good, move on.
280
+ - If it's **NOT documented** — spawn another coding agent to analyze it, or document it yourself with \`document_app\` / \`document_endpoint\`. Do not simply note it in the final summary; it must be in the apps list.
281
+
282
+ Only proceed to Phase 4 once you have explicitly walked through the checks above and confirmed coverage is complete.
283
+
284
+ ## Phase 4: COLLECT AND SUBMIT (do this yourself)
285
+
286
+ Before calling \`submit_results\`, verify the final coverage checklist:
287
+ - [ ] Every workspace package / service directory is represented by a documented app
288
+ - [ ] Every framework entry point discovered in Phase 3 maps to a documented app
289
+ - [ ] Every Dockerfile / compose service / IaC resource maps to a documented app or cloud resource
290
+ - [ ] Every known domain (if provided) that maps to an app in the repo has been associated via the \`domain\` field — but apps that don't map to a known domain are still documented (known domains are hints, not a scope filter)
291
+ - [ ] Each documented app has its endpoints/pages enumerated (or an explicit note in \`pentestObjectives\` if it is a non-HTTP service)
292
+
293
+ Then:
294
+ 1. Parse the output from all coding agents
295
+ 2. Assemble the complete structured result
296
+ 3. Call \`submit_results\` with the full data
297
+
298
+ # Guidelines
299
+ - Be thorough — every endpoint matters. Don't skip files or directories.
300
+ - Delegate aggressively — spawn coding agents for each app to get high-fidelity results.
301
+ - Give coding agents VERY detailed objectives — they work best with specific instructions about what to search for and how to report it.
302
+ - Don't duplicate work — let the coding agents do the deep file-by-file analysis.
303
+ - When in doubt about repo structure, read more config files before deciding.
304
+ - **Never skip the Phase 3 coverage double-check** — initial discovery routinely misses apps, and a second pass is the cheapest way to catch them.
305
+ - **Known domains are association hints, not a scope filter.** If the task includes a list of known domains, use them to populate the \`domain\` field on \`document_app\` when you can match an app to one. Do NOT use them to decide which apps, packages, services, endpoints, or cloud resources are worth documenting — document everything found in the codebase.
306
+ `;
307
+
308
+ // src/core/agents/specialized/whiteboxAttackSurface/types.ts
309
+ init_zod();
310
+ var RiskScoreBreakdownSchema = exports_external.object({
311
+ exposure: exports_external.number().min(0).max(3).describe("Exposure Level (0-3): 3=Public no auth, 2=Standard user login, 1=Privileged/admin access, 0=Private/internal-only"),
312
+ dataSensitivity: exports_external.number().min(0).max(3).describe("Data Sensitivity (0-3): 3=PII/PHI/financial/passwords/tokens, 2=Business operations/configs, 1=Low-value user data, 0=No meaningful data"),
313
+ functionCriticality: exports_external.number().min(0).max(2).describe("Function Criticality (0-2): 2=Auth flows/payments/state-changing mutations, 1=Core product functionality, 0=Non-critical content"),
314
+ securityIndicators: exports_external.number().min(0).max(2).describe("Security Indicators (0-2): 2=Critical vuln patterns (SQLi, command injection, hardcoded secrets), 1=Moderate concerns (missing validation, weak error handling), 0=No obvious issues")
315
+ });
316
+ var RiskScoreSchema = exports_external.object({
317
+ score: exports_external.number().min(0).max(10).describe("Total risk score (0-10)"),
318
+ explanation: exports_external.string().describe("Justification for the risk score"),
319
+ breakdown: RiskScoreBreakdownSchema
320
+ });
321
+ var EndpointSchema = exports_external.object({
322
+ method: exports_external.string().describe("HTTP method (GET, POST, PUT, DELETE, etc.) or 'PAGE' for web pages"),
323
+ path: exports_external.string().describe("Route path (e.g. /api/users/:id, /dashboard)"),
324
+ handler: exports_external.string().optional().describe("Handler function or component name, if identifiable"),
325
+ file: exports_external.string().describe("File where this endpoint is defined"),
326
+ line: exports_external.number().optional().describe("Line number in the file"),
327
+ authRequired: exports_external.boolean().optional().describe("Whether this endpoint appears to require authentication"),
328
+ description: exports_external.string().optional().describe("Brief description of what this endpoint does"),
329
+ pentestObjectives: exports_external.array(exports_external.string()).default([]).describe("Pentest objectives for this endpoint, derived from the threat model when available " + "(e.g. 'Test for IDOR by enumerating user IDs', 'Test for SQL injection in search parameter')"),
330
+ riskScore: RiskScoreSchema.optional().describe("AI-calculated risk score for prioritizing pentest efforts"),
331
+ threatModel: exports_external.string().optional().describe("Endpoint-specific threat model describing attack vectors, data sensitivity, and testing priorities")
332
+ });
333
+ var AppSchema = exports_external.object({
334
+ name: exports_external.string().describe("Application or service name"),
335
+ type: exports_external.enum([
336
+ "web_application",
337
+ "api",
338
+ "full_stack",
339
+ "domain",
340
+ "subdomain",
341
+ "database",
342
+ "cloud_resource",
343
+ "storage"
344
+ ]).default("web_application").describe("Type of application (web_application, api, full_stack, database, cloud_resource, storage, etc.)"),
345
+ framework: exports_external.string().describe("Framework in use (e.g. Express, Next.js, Django, FastAPI, Rails)"),
346
+ description: exports_external.string().describe("Brief description of what this app does"),
347
+ location: exports_external.string().describe("Path to the app root relative to the repository root"),
348
+ pages: exports_external.array(EndpointSchema).describe("Web pages / views defined in this app"),
349
+ apiEndpoints: exports_external.array(EndpointSchema).describe("API endpoints defined in this app")
350
+ });
351
+ var AppInfoSchema = exports_external.object({
352
+ name: exports_external.string().describe("Application or service name"),
353
+ framework: exports_external.string().describe("Framework or cloud service (e.g. Express, Next.js, Django, FastAPI, Rails, AWS S3, CloudFront)"),
354
+ description: exports_external.string().describe("Brief description of what this app does"),
355
+ location: exports_external.string().describe("Path to the app root relative to the repository root, or resource identifier for cloud resources"),
356
+ type: exports_external.enum([
357
+ "web_application",
358
+ "api",
359
+ "full_stack",
360
+ "domain",
361
+ "subdomain",
362
+ "database",
363
+ "cloud_resource",
364
+ "storage"
365
+ ]).default("web_application").describe("Application type — web_application for frontend apps, api for backend services, " + "full_stack for frameworks like Next.js/Remix that serve both, " + "database for databases, cloud_resource for owned cloud infra, storage for S3/GCS/blob storage")
366
+ });
367
+ var AppsDiscoveryResultSchema = exports_external.object({
368
+ repoType: exports_external.string().describe("e.g. monorepo, single-app, multi-package"),
369
+ packageManager: exports_external.string().describe("e.g. npm, yarn, pnpm, pip, cargo, go modules"),
370
+ apps: exports_external.array(AppInfoSchema).describe("All applications/services discovered in the repository")
371
+ });
372
+ var DiscoverySummarySchema = exports_external.object({
373
+ endpointsDocumented: exports_external.number().describe("Number of endpoints documented via document_endpoint"),
374
+ summary: exports_external.string().describe("Brief summary of what was found")
375
+ });
376
+ var WhiteboxAttackSurfaceResultSchema = exports_external.object({
377
+ repoType: exports_external.string().describe("Repository structure type (e.g. 'monorepo', 'single-app', 'multi-package')"),
378
+ packageManager: exports_external.string().describe("Package manager detected (e.g. npm, yarn, pnpm, pip, cargo, go modules)"),
379
+ apps: exports_external.array(AppSchema).describe("All applications discovered in the repository"),
380
+ summary: exports_external.object({
381
+ totalApps: exports_external.number(),
382
+ totalPages: exports_external.number(),
383
+ totalApiEndpoints: exports_external.number(),
384
+ totalPentestObjectives: exports_external.number()
385
+ })
386
+ });
387
+
388
+ // src/core/agents/specialized/whiteboxAttackSurface/agent.ts
389
+ class WhiteboxAttackSurfaceAgent extends OffensiveSecurityAgent {
390
+ constructor(opts) {
391
+ const {
392
+ model,
393
+ codebasePath,
394
+ session,
395
+ authConfig,
396
+ onStepFinish,
397
+ abortSignal,
398
+ eventBus,
399
+ subagentId,
400
+ attackSurfaceRegistry,
401
+ domains,
402
+ enableThinking,
403
+ openAIReasoningEffort
404
+ } = opts;
405
+ let capturedResult = null;
406
+ const submitResultsTool = tool({
407
+ description: `Submit the final whitebox attack surface analysis results.
408
+
409
+ Call this ONCE at the end with your complete structured findings.
410
+ This ends the agent run — make sure all data is included.`,
411
+ inputSchema: WhiteboxAttackSurfaceResultSchema,
412
+ execute: async (results) => {
413
+ capturedResult = results;
414
+ return { success: true, message: "Results submitted." };
415
+ }
416
+ });
417
+ super({
418
+ system: WHITEBOX_ATTACK_SURFACE_SYSTEM_PROMPT,
419
+ prompt: buildPrompt(codebasePath, domains, session.config?.prompt),
420
+ model,
421
+ session,
422
+ authConfig,
423
+ onStepFinish,
424
+ abortSignal,
425
+ eventBus,
426
+ subagentId,
427
+ attackSurfaceRegistry,
428
+ enableThinking,
429
+ openAIReasoningEffort,
430
+ activeTools: [
431
+ "read_file",
432
+ "list_files",
433
+ "grep",
434
+ "document_app",
435
+ "document_endpoint",
436
+ "spawn_coding_agent",
437
+ "submit_results"
438
+ ],
439
+ extraTools: {
440
+ submit_results: submitResultsTool
441
+ },
442
+ stopWhen: hasToolCall("submit_results"),
443
+ resolveResult: () => {
444
+ if (capturedResult) {
445
+ return capturedResult;
446
+ }
447
+ return {
448
+ repoType: "unknown",
449
+ packageManager: "unknown",
450
+ apps: [],
451
+ summary: {
452
+ totalApps: 0,
453
+ totalPages: 0,
454
+ totalApiEndpoints: 0,
455
+ totalPentestObjectives: 0
456
+ }
457
+ };
458
+ }
459
+ });
460
+ }
461
+ }
462
+ function buildPrompt(codebasePath, domains, operatorPrompt) {
463
+ const domainSection = domains?.length ? `
464
+ ## Known Domains
465
+ The following domains are **hints for association only** — they are known to be operated by the target and should be set on the \`domain\` field of \`document_app\` when you can determine which domain serves a given app.
466
+
467
+ **IMPORTANT — these domains DO NOT define the scope of discovery:**
468
+ - Discover and document **every** app/service/cloud resource defined in the codebase, regardless of whether it maps to one of these domains.
469
+ - Apps with no known public domain (internal services, background workers, staging-only apps, functions, admin tools, etc.) MUST still be documented. Leave \`domain\` unset or use the canonical resource URL for cloud resources.
470
+ - Do NOT filter out apps, endpoints, subdomains, or cloud resources because they don't appear to belong to one of these domains.
471
+ - Do NOT skip directories, packages, or services because they "look unrelated" to the listed domains.
472
+
473
+ Known domains:
474
+ ${domains.map((d) => `- ${d}`).join(`
475
+ `)}
476
+ ` : "";
477
+ const operatorGuidanceBlock = operatorPrompt ? `
478
+ ## Operator Guidance
479
+ ${operatorPrompt}
480
+ ` : "";
481
+ return `# Whitebox Attack Surface Analysis
482
+
483
+ ## Codebase
484
+ - **Path:** ${codebasePath}
485
+ ${domainSection}${operatorGuidanceBlock}
486
+ ## Task
487
+ Analyze this codebase and produce a complete attack surface map:
488
+ 1. Identify the repo type and package manager
489
+ 2. Discover all apps/services
490
+ 3. Discover cloud resources and external infrastructure referenced in the code (S3 buckets, cloud storage, CDN origins, etc.) — document these as apps with the appropriate type
491
+ 4. For each app, find all web pages and API endpoints
492
+ 5. For each endpoint, generate pentest objectives
493
+ 6. **Before submitting**, perform the Phase 3 coverage double-check from the system prompt — re-scan workspace roots, framework configs, Dockerfiles, IaC, and CI/deploy configs for apps you may have missed on the first pass, and document any that were missed.
494
+
495
+ Use \`spawn_coding_agent\` to delegate app-level analysis for higher fidelity.
496
+
497
+ When finished, call \`submit_results\` with the complete structured output. Do NOT call \`submit_results\` until you have explicitly completed the coverage double-check.
498
+
499
+ Begin now.`;
500
+ }
501
+ export { WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT, WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT, WHITEBOX_DISCOVERY_SYSTEM_PROMPT, RiskScoreBreakdownSchema, RiskScoreSchema, EndpointSchema, AppsDiscoveryResultSchema, DiscoverySummarySchema, WhiteboxAttackSurfaceAgent };
@@ -1,6 +1,6 @@
1
1
  // src/util/url.ts
2
2
  function parseTargetUrl(target) {
3
- if (!target || !target.trim()) {
3
+ if (!target?.trim()) {
4
4
  return null;
5
5
  }
6
6
  let urlString = target.trim();
@@ -35,7 +35,7 @@ function getAutoPopulatedHosts(target, initialHosts = []) {
35
35
  }
36
36
  function getAutoPopulatedPorts(target, initialPorts = []) {
37
37
  const parsed = parseTargetUrl(target);
38
- if (!parsed || !parsed.port) {
38
+ if (!parsed?.port) {
39
39
  return initialPorts;
40
40
  }
41
41
  const ports = [...initialPorts];
@@ -0,0 +1,24 @@
1
+ // src/core/http/types.ts
2
+ var SENSITIVE_PATTERNS = [
3
+ "authorization",
4
+ "cookie",
5
+ "token",
6
+ "key",
7
+ "secret",
8
+ "password"
9
+ ];
10
+ function isSensitiveHeaderName(name) {
11
+ const lower = name.toLowerCase();
12
+ return SENSITIVE_PATTERNS.some((p) => lower.includes(p));
13
+ }
14
+ function renderHeaderValue(name, value, showSecrets) {
15
+ if (showSecrets || !isSensitiveHeaderName(name)) {
16
+ return value;
17
+ }
18
+ if (value.length <= 4) {
19
+ return "****";
20
+ }
21
+ return `****${value.slice(-4)}`;
22
+ }
23
+
24
+ export { isSensitiveHeaderName, renderHeaderValue };