@pensar/apex 0.0.48 → 0.0.49-canary.3f292d14

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 (237) hide show
  1. package/README.md +10 -156
  2. package/build/index.js +41551 -54211
  3. package/package.json +8 -19
  4. package/build/performance-client.linux-x64-gnu-g5psc0d8.node +0 -0
  5. package/build/performance-client.linux-x64-musl-d27ppy6x.node +0 -0
  6. package/src/api/index.ts +0 -63
  7. package/src/api/pentest.ts +0 -761
  8. package/src/api/types.ts +0 -213
  9. package/src/cli.ts +0 -44
  10. package/src/core/agent/attackSurfaceAgent/agent.ts +0 -1485
  11. package/src/core/agent/attackSurfaceAgent/index.ts +0 -14
  12. package/src/core/agent/attackSurfaceAgent/jsExtraction.ts +0 -134
  13. package/src/core/agent/attackSurfaceAgent/prompts.ts +0 -1861
  14. package/src/core/agent/attackSurfaceAgent/schemas.ts +0 -170
  15. package/src/core/agent/attackSurfaceAgent/types.ts +0 -100
  16. package/src/core/agent/authenticationSubagent/agent.ts +0 -740
  17. package/src/core/agent/authenticationSubagent/authStateManager.ts +0 -656
  18. package/src/core/agent/authenticationSubagent/delegateTool.ts +0 -420
  19. package/src/core/agent/authenticationSubagent/index.ts +0 -143
  20. package/src/core/agent/authenticationSubagent/integration.ts +0 -234
  21. package/src/core/agent/authenticationSubagent/prompts.ts +0 -675
  22. package/src/core/agent/authenticationSubagent/strategies/index.ts +0 -16
  23. package/src/core/agent/authenticationSubagent/strategies/providedCredentials.ts +0 -470
  24. package/src/core/agent/authenticationSubagent/tools.ts +0 -2016
  25. package/src/core/agent/authenticationSubagent/types.ts +0 -733
  26. package/src/core/agent/benchmark/comparisonAgent.ts +0 -359
  27. package/src/core/agent/benchmark/docker-utils.ts +0 -217
  28. package/src/core/agent/benchmark/flag-detector.ts +0 -579
  29. package/src/core/agent/benchmark/index.ts +0 -3
  30. package/src/core/agent/benchmark/prompts.ts +0 -257
  31. package/src/core/agent/benchmark/remote/circuit-breaker.ts +0 -100
  32. package/src/core/agent/benchmark/remote/daytona-benchmark.ts +0 -1807
  33. package/src/core/agent/benchmark/remote/daytona-wrapper.ts +0 -624
  34. package/src/core/agent/benchmark/remote/index.ts +0 -11
  35. package/src/core/agent/benchmark/types.ts +0 -98
  36. package/src/core/agent/browserTools/index.ts +0 -23
  37. package/src/core/agent/browserTools/playwrightMcp.ts +0 -865
  38. package/src/core/agent/cvssScorer/index.ts +0 -350
  39. package/src/core/agent/logger/index.ts +0 -91
  40. package/src/core/agent/operatorAgent/index.ts +0 -1383
  41. package/src/core/agent/operatorAgent/suggestActions.ts +0 -291
  42. package/src/core/agent/orchestrator/index.ts +0 -4
  43. package/src/core/agent/orchestrator/orchestrator.ts +0 -471
  44. package/src/core/agent/orchestrator/pipeline.ts +0 -268
  45. package/src/core/agent/orchestrator/prompts/base.ts +0 -184
  46. package/src/core/agent/orchestrator/prompts/command-injection.ts +0 -141
  47. package/src/core/agent/orchestrator/prompts/crypto.ts +0 -286
  48. package/src/core/agent/orchestrator/prompts/cve.ts +0 -326
  49. package/src/core/agent/orchestrator/prompts/generic.ts +0 -298
  50. package/src/core/agent/orchestrator/prompts/idor.ts +0 -309
  51. package/src/core/agent/orchestrator/prompts/index.ts +0 -240
  52. package/src/core/agent/orchestrator/prompts/lfi.ts +0 -282
  53. package/src/core/agent/orchestrator/prompts/sqli.ts +0 -186
  54. package/src/core/agent/orchestrator/prompts/ssrf.ts +0 -322
  55. package/src/core/agent/orchestrator/prompts/xss.ts +0 -162
  56. package/src/core/agent/orchestrator/types.ts +0 -32
  57. package/src/core/agent/pocTools.ts +0 -687
  58. package/src/core/agent/reportGeneratorAgent/agent.ts +0 -548
  59. package/src/core/agent/reportGeneratorAgent/index.ts +0 -14
  60. package/src/core/agent/reportGeneratorAgent/types.ts +0 -91
  61. package/src/core/agent/scope.ts +0 -98
  62. package/src/core/agent/sessions/index.ts +0 -123
  63. package/src/core/agent/subagent/attackAgent.ts +0 -436
  64. package/src/core/agent/subagent/guidance/authentication-bypass.md +0 -453
  65. package/src/core/agent/subagent/guidance/business-logic.md +0 -415
  66. package/src/core/agent/subagent/guidance/cache-poisoning.md +0 -390
  67. package/src/core/agent/subagent/guidance/clickjacking.md +0 -382
  68. package/src/core/agent/subagent/guidance/command-injection.md +0 -438
  69. package/src/core/agent/subagent/guidance/cors.md +0 -346
  70. package/src/core/agent/subagent/guidance/csp-bypass.md +0 -344
  71. package/src/core/agent/subagent/guidance/csrf.md +0 -366
  72. package/src/core/agent/subagent/guidance/deserialization.md +0 -387
  73. package/src/core/agent/subagent/guidance/file-upload.md +0 -435
  74. package/src/core/agent/subagent/guidance/idor.md +0 -434
  75. package/src/core/agent/subagent/guidance/index.ts +0 -66
  76. package/src/core/agent/subagent/guidance/open-redirect.md +0 -369
  77. package/src/core/agent/subagent/guidance/path-traversal.md +0 -443
  78. package/src/core/agent/subagent/guidance/request-smuggling.md +0 -430
  79. package/src/core/agent/subagent/guidance/sql-injection.md +0 -556
  80. package/src/core/agent/subagent/guidance/ssrf.md +0 -403
  81. package/src/core/agent/subagent/guidance/ssti.md +0 -438
  82. package/src/core/agent/subagent/guidance/xss.md +0 -431
  83. package/src/core/agent/subagent/guidance/xxe.md +0 -449
  84. package/src/core/agent/subagent/index.ts +0 -391
  85. package/src/core/agent/subagent/initAgent.ts +0 -296
  86. package/src/core/agent/subagent/repl.ts +0 -146
  87. package/src/core/agent/subagent/tools.ts +0 -715
  88. package/src/core/agent/subagent/types.ts +0 -154
  89. package/src/core/agent/subagent/verificationAgent.ts +0 -178
  90. package/src/core/agent/subagent/verificationGuidance.ts +0 -447
  91. package/src/core/agent/taskManager.ts +0 -137
  92. package/src/core/agent/tools.ts +0 -5000
  93. package/src/core/agent/utils.ts +0 -125
  94. package/src/core/ai/ai.test.ts +0 -288
  95. package/src/core/ai/ai.ts +0 -357
  96. package/src/core/ai/index.ts +0 -1
  97. package/src/core/ai/models/anthropic.ts +0 -93
  98. package/src/core/ai/models/baseten.ts +0 -12
  99. package/src/core/ai/models/bedrock.ts +0 -428
  100. package/src/core/ai/models/index.ts +0 -24
  101. package/src/core/ai/models/openai.ts +0 -52
  102. package/src/core/ai/models/openrouter.ts +0 -202
  103. package/src/core/ai/utils.ts +0 -417
  104. package/src/core/config/config.ts +0 -82
  105. package/src/core/config/index.ts +0 -7
  106. package/src/core/id/id.ts +0 -72
  107. package/src/core/installation/index.ts +0 -17
  108. package/src/core/knowledge/cache.ts +0 -431
  109. package/src/core/memory/index.ts +0 -276
  110. package/src/core/memory/types.ts +0 -55
  111. package/src/core/messages/index.ts +0 -227
  112. package/src/core/messages/types.ts +0 -145
  113. package/src/core/operator/approvalGate.ts +0 -303
  114. package/src/core/operator/index.ts +0 -68
  115. package/src/core/operator/permissionPolicy.ts +0 -141
  116. package/src/core/operator/stageInference.ts +0 -64
  117. package/src/core/operator/stageManager.ts +0 -186
  118. package/src/core/operator/toolClassifier.ts +0 -268
  119. package/src/core/operator/types.ts +0 -230
  120. package/src/core/providers/index.ts +0 -2
  121. package/src/core/providers/types.ts +0 -41
  122. package/src/core/providers/utils.ts +0 -60
  123. package/src/core/sandbox/runtime-sandbox.ts +0 -162
  124. package/src/core/services/rateLimiter/index.ts +0 -100
  125. package/src/core/services/rateLimiter/types.ts +0 -10
  126. package/src/core/session/index.ts +0 -598
  127. package/src/core/session/loader.ts +0 -409
  128. package/src/core/storage/index.ts +0 -140
  129. package/src/core/toolset/index.ts +0 -489
  130. package/src/lib/cvss/calculator.ts +0 -533
  131. package/src/lib/cvss/index.ts +0 -68
  132. package/src/lib/cvss/macrovector-scores.ts +0 -390
  133. package/src/lib/cvss/types.ts +0 -238
  134. package/src/tui/command-input.tsx +0 -126
  135. package/src/tui/command-registry.ts +0 -335
  136. package/src/tui/command-router.ts +0 -71
  137. package/src/tui/components/agent-display.tsx +0 -397
  138. package/src/tui/components/alert-dialog.tsx +0 -86
  139. package/src/tui/components/ascii-art-component.tsx +0 -49
  140. package/src/tui/components/ascii-art.tsx +0 -224
  141. package/src/tui/components/ascii-header.tsx +0 -24
  142. package/src/tui/components/ascii-title.tsx +0 -72
  143. package/src/tui/components/autocomplete.tsx +0 -169
  144. package/src/tui/components/box-logo.tsx +0 -70
  145. package/src/tui/components/chat/approval-inline.tsx +0 -62
  146. package/src/tui/components/chat/config-view.tsx +0 -258
  147. package/src/tui/components/chat/header.tsx +0 -142
  148. package/src/tui/components/chat/home-view.tsx +0 -126
  149. package/src/tui/components/chat/index.tsx +0 -177
  150. package/src/tui/components/chat/input-area.tsx +0 -316
  151. package/src/tui/components/chat/lib/petri-simulation.ts +0 -201
  152. package/src/tui/components/chat/lib/play-core/index.ts +0 -9
  153. package/src/tui/components/chat/lib/play-core/num.ts +0 -102
  154. package/src/tui/components/chat/lib/play-core/sdf.ts +0 -69
  155. package/src/tui/components/chat/lib/play-core/vec2.ts +0 -99
  156. package/src/tui/components/chat/lib/wave-simulation.ts +0 -120
  157. package/src/tui/components/chat/loading-indicator.tsx +0 -100
  158. package/src/tui/components/chat/message-list.tsx +0 -189
  159. package/src/tui/components/chat/petri-animation.tsx +0 -148
  160. package/src/tui/components/chat/sidebar.tsx +0 -363
  161. package/src/tui/components/chat/tool-message.tsx +0 -183
  162. package/src/tui/components/commands/api-key-input.tsx +0 -115
  163. package/src/tui/components/commands/config-dialog.tsx +0 -69
  164. package/src/tui/components/commands/create-session-dialog.tsx +0 -112
  165. package/src/tui/components/commands/help-dialog.tsx +0 -335
  166. package/src/tui/components/commands/init-wizard.tsx +0 -517
  167. package/src/tui/components/commands/models-display-old.tsx +0 -218
  168. package/src/tui/components/commands/models-display.tsx +0 -90
  169. package/src/tui/components/commands/operator-wizard.tsx +0 -545
  170. package/src/tui/components/commands/provider-manager.tsx +0 -91
  171. package/src/tui/components/commands/provider-selection.tsx +0 -165
  172. package/src/tui/components/commands/resume-wizard.tsx +0 -217
  173. package/src/tui/components/commands/sessions-display.tsx +0 -387
  174. package/src/tui/components/commands/shortcuts-dialog.tsx +0 -57
  175. package/src/tui/components/commands/web-wizard.tsx +0 -800
  176. package/src/tui/components/footer.tsx +0 -116
  177. package/src/tui/components/header.tsx +0 -23
  178. package/src/tui/components/input.tsx +0 -39
  179. package/src/tui/components/model-picker/ModelPicker.tsx +0 -218
  180. package/src/tui/components/model-picker/index.ts +0 -2
  181. package/src/tui/components/operator-dashboard/chat-view.tsx +0 -119
  182. package/src/tui/components/operator-dashboard/index.tsx +0 -31
  183. package/src/tui/components/operator-dashboard/sidebar/AttackSurfacePanel.tsx +0 -120
  184. package/src/tui/components/operator-dashboard/sidebar/CredentialsPanel.tsx +0 -75
  185. package/src/tui/components/operator-dashboard/sidebar/SuggestionsPanel.tsx +0 -43
  186. package/src/tui/components/operator-dashboard/sidebar/TargetStatePanel.tsx +0 -35
  187. package/src/tui/components/operator-dashboard/sidebar/VerifiedVulnsPanel.tsx +0 -69
  188. package/src/tui/components/operator-dashboard/sidebar/index.ts +0 -4
  189. package/src/tui/components/operator-dashboard/types.ts +0 -146
  190. package/src/tui/components/question/index.tsx +0 -669
  191. package/src/tui/components/question/types.ts +0 -247
  192. package/src/tui/components/responsible-use-disclosure.tsx +0 -51
  193. package/src/tui/components/session-view/index.tsx +0 -781
  194. package/src/tui/components/shared/approval-prompt.tsx +0 -173
  195. package/src/tui/components/shared/ascii-spinner.tsx +0 -37
  196. package/src/tui/components/shared/index.ts +0 -41
  197. package/src/tui/components/shared/markdown.ts +0 -160
  198. package/src/tui/components/shared/message-reducer.ts +0 -213
  199. package/src/tui/components/shared/message-renderer.tsx +0 -125
  200. package/src/tui/components/shared/message-utils.ts +0 -81
  201. package/src/tui/components/shared/prompt-input.tsx +0 -296
  202. package/src/tui/components/shared/result-registry.ts +0 -358
  203. package/src/tui/components/shared/tool-registry.ts +0 -151
  204. package/src/tui/components/shared/tool-renderer.tsx +0 -126
  205. package/src/tui/components/shared/type-guards.ts +0 -58
  206. package/src/tui/components/sprites.tsx +0 -242
  207. package/src/tui/components/swarm-dashboard/index.tsx +0 -725
  208. package/src/tui/components/switch.tsx +0 -78
  209. package/src/tui/components/tools-panel/index.tsx +0 -429
  210. package/src/tui/context/agent.tsx +0 -148
  211. package/src/tui/context/command.tsx +0 -111
  212. package/src/tui/context/config.tsx +0 -46
  213. package/src/tui/context/dialog.tsx +0 -150
  214. package/src/tui/context/focus.tsx +0 -61
  215. package/src/tui/context/input.tsx +0 -39
  216. package/src/tui/context/keybinding.tsx +0 -76
  217. package/src/tui/context/route.tsx +0 -91
  218. package/src/tui/context/session.tsx +0 -48
  219. package/src/tui/generated-ascii-art.json +0 -1
  220. package/src/tui/generated-ascii-art.json.d.ts +0 -3
  221. package/src/tui/index.tsx +0 -335
  222. package/src/tui/keybindings/actions.ts +0 -318
  223. package/src/tui/keybindings/index.ts +0 -163
  224. package/src/tui/keybindings/input-buffer.ts +0 -377
  225. package/src/tui/keybindings/keybind.tsx +0 -403
  226. package/src/tui/keybindings/registry.ts +0 -135
  227. package/src/tui/keybindings-registry.ts +0 -43
  228. package/src/tui/session/index.tsx +0 -831
  229. package/src/tui/session/session.tsx +0 -52
  230. package/src/tui/theme/colors.ts +0 -39
  231. package/src/tui/theme/index.ts +0 -35
  232. package/src/tui/types/driver-dashboard.ts +0 -95
  233. package/src/tui/utils/command-flags.ts +0 -371
  234. package/src/util/errors.ts +0 -54
  235. package/src/util/lazy.ts +0 -11
  236. package/src/util/lock.ts +0 -98
  237. package/src/util/name.ts +0 -20
package/README.md CHANGED
@@ -19,34 +19,31 @@
19
19
 
20
20
  ### Prerequisites
21
21
 
22
+ - **nmap** (required for network scanning)
22
23
  - **API Key** for your chosen AI provider
23
24
 
24
- #### Optional: Install nmap (recommended)
25
+ #### Install nmap
25
26
 
26
- The AI agent uses nmap for network reconnaissance. Install it for full scanning capabilities:
27
+ macOS:
27
28
 
28
- <details>
29
- <summary>Installation instructions</summary>
30
-
31
- **macOS:**
32
29
  ```bash
33
30
  brew install nmap
34
31
  ```
35
32
 
36
- **Debian/Ubuntu:**
33
+ Debian/Ubuntu:
34
+
37
35
  ```bash
38
36
  sudo apt-get update && sudo apt-get install -y nmap
39
37
  ```
40
38
 
41
- **Fedora/RHEL:**
39
+ Fedora/RHEL:
40
+
42
41
  ```bash
43
42
  sudo dnf install -y nmap
44
43
  ```
45
44
 
46
- **Windows:**
47
- Download installer from https://nmap.org/download.html and ensure `nmap` is on your PATH.
48
-
49
- </details>
45
+ Windows:
46
+ Download installer from `https://nmap.org/download.html` and ensure `nmap` is on your PATH.
50
47
 
51
48
  ### Install Apex
52
49
 
@@ -88,155 +85,12 @@ export ANTHROPIC_API_KEY="your-api-key-here"
88
85
 
89
86
  ## Usage
90
87
 
91
- ### Interactive Mode
92
-
93
- Run Apex interactively:
88
+ Run Apex:
94
89
 
95
90
  ```bash
96
91
  pensar
97
92
  ```
98
93
 
99
- ### Programmatic API
100
-
101
- Apex provides a programmatic API for integration into your security testing workflows.
102
-
103
- #### Blackbox Pentest
104
-
105
- Test a target without source code access. The AI performs full attack surface mapping, endpoint enumeration, and vulnerability testing:
106
-
107
- ```typescript
108
- import { runBlackboxPentest } from '@pensar/apex/api';
109
-
110
- const result = await runBlackboxPentest({
111
- target: 'https://example.com',
112
- model: 'claude-sonnet-4-5',
113
- concurrency: 10,
114
- callbacks: {
115
- onPhaseChange: (phase) => console.log('Phase:', phase),
116
- onSubagentStart: (id, endpoint, vulnClass) =>
117
- console.log(`Testing ${vulnClass} on ${endpoint}`),
118
- onFindingDiscovered: (finding) =>
119
- console.log(`Found: [${finding.severity}] ${finding.title}`),
120
- },
121
- });
122
-
123
- console.log(`Findings: ${result.findings.length}`);
124
- ```
125
-
126
- **How Blackbox Mode Works:**
127
-
128
- 1. **Enumeration Phase** (optional): Runs katana + feroxagent to discover endpoints
129
- 2. **Attack Surface Mapping**: AI agent explores the target, documents endpoints, parameters, and authentication
130
- 3. **Orchestrator Phase**: Analyzes attack surface and spawns targeted sub-agents
131
- 4. **Testing Phase**: Sub-agents test for vulnerabilities across all discovered endpoints
132
-
133
- **Input Options:**
134
-
135
- | Field | Type | Description |
136
- |-------|------|-------------|
137
- | `target` | `string` | Target URL or domain |
138
- | `model` | `AIModel` | AI model (default: `claude-sonnet-4-5`) |
139
- | `concurrency` | `number` | Max parallel sub-agents (default: 10) |
140
- | `skipEnumeration` | `boolean` | Skip katana+feroxagent enumeration |
141
- | `callbacks` | `PentestCallbacks` | Event callbacks |
142
- | `authCredentials` | `AuthCredentials?` | Authentication credentials |
143
- | `scopeConstraints` | `ScopeConstraints?` | Limit testing scope |
144
- | `blockedPaths` | `string[]?` | Paths to block from agent access |
145
- | `blockDocker` | `boolean?` | Block Docker commands |
146
- | `sessionId` | `string?` | Resume existing session |
147
- | `sessionName` | `string?` | Custom session name |
148
- | `timeout` | `number?` | Sub-agent timeout in ms (default: 20 min) |
149
-
150
- **Phases:**
151
-
152
- | Phase | Description |
153
- |-------|-------------|
154
- | `enumeration` | Running katana + feroxagent endpoint discovery |
155
- | `attack-surface` | AI mapping endpoints, parameters, auth flows |
156
- | `orchestrator` | Analyzing attack surface, planning sub-agents |
157
- | `testing` | Sub-agents actively testing for vulnerabilities |
158
-
159
- **Resume a Session:**
160
-
161
- ```typescript
162
- import { resumePentest } from '@pensar/apex/api';
163
-
164
- const result = await resumePentest({
165
- sessionId: 'pentest-abc123',
166
- model: 'claude-sonnet-4-5',
167
- callbacks: { /* ... */ },
168
- });
169
- ```
170
-
171
- #### Whitebox Pentest
172
-
173
- Test a specific endpoint with source code access. The AI orchestrator analyzes your source code to intelligently determine which vulnerability classes to test:
174
-
175
- ```typescript
176
- import { runWhiteboxPentest } from '@pensar/apex/api';
177
-
178
- const result = await runWhiteboxPentest({
179
- endpoint: 'http://localhost:3000/api/users/:id',
180
- sourceCodePath: '/path/to/your/source',
181
- model: 'claude-sonnet-4-5',
182
- callbacks: {
183
- onPhaseChange: (phase) => console.log('Phase:', phase),
184
- onSubagentStart: (id, endpoint, vulnClass) =>
185
- console.log(`Testing ${vulnClass} on ${endpoint}`),
186
- onFindingDiscovered: (finding) =>
187
- console.log(`Found: [${finding.severity}] ${finding.title}`),
188
- },
189
- });
190
-
191
- console.log(`Findings: ${result.findings.length}`);
192
- ```
193
-
194
- **How Whitebox Mode Works:**
195
-
196
- 1. The AI orchestrator analyzes your source code using pattern matching and code search
197
- 2. It locates route handlers, controllers, and related files for your target endpoint
198
- 3. It identifies vulnerability patterns in the code (SQL queries, exec calls, file operations, etc.)
199
- 4. It spawns targeted sub-agents only for vulnerabilities with evidence in the code
200
- 5. Each sub-agent tests for its assigned vulnerability class with full source code context
201
-
202
- ### CLI Script
203
-
204
- For direct command-line usage:
205
-
206
- ```bash
207
- # Blackbox pentest
208
- bun run scripts/pentest.ts https://example.com
209
-
210
- # Whitebox pentest (single endpoint with source code)
211
- bun run scripts/pentest.ts http://localhost:3000/api/users \
212
- --whitebox \
213
- --source-path /path/to/source \
214
- --focus /api/users/:id
215
-
216
- # With options
217
- bun run scripts/pentest.ts https://example.com \
218
- --model claude-sonnet-4-5 \
219
- --concurrency 10 \
220
- --verbose
221
- ```
222
-
223
- **CLI Options:**
224
-
225
- | Option | Description |
226
- |--------|-------------|
227
- | `--model <model>` | AI model to use (default: claude-sonnet-4-5) |
228
- | `--whitebox` | Enable whitebox mode with source code access |
229
- | `--source-path <path>` | Path to source code (required with --whitebox) |
230
- | `--workspace <name>` | Workspace name for memory |
231
- | `--focus <endpoint>` | Focus testing on a specific endpoint |
232
- | `--concurrency <n>` | Max parallel sub-agents (default: 10) |
233
- | `--skip-attack-surface` | Skip attack surface mapping phase |
234
- | `--skip-enum` | Skip katana+feroxagent enumeration |
235
- | `--verbose` | Show detailed output |
236
- | `--quiet` | Minimal output |
237
- | `--block-source <path>` | Block access to path (for sandboxing) |
238
- | `--block-docker` | Block Docker commands |
239
-
240
94
  ## AI Provider Support
241
95
 
242
96
  Apex supports **OpenAI**, **Anthropic**, **AWS Bedrock**, and **vLLM** (local models). **Anthropic models provide the best performance** and are recommended for optimal results.