Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
291 lines (258 loc) · 9.55 KB
/
Copy pathtypes.ts
File metadata and controls
291 lines (258 loc) · 9.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
// @author: Albert C | @yz9yt | github.com/yz9yt
// types.ts
// version 0.1 Beta
export enum View {
URL_ANALYSIS = 'URL_ANALYSIS',
CODE_ANALYSIS = 'CODE_ANALYSIS',
PAYLOAD_TOOLS = 'PAYLOAD_TOOLS',
DISCOVERY_TOOLS = 'DISCOVERY_TOOLS',
JWT_ANALYZER = 'JWT_ANALYZER',
EXPLOIT_TOOLS = 'EXPLOIT_TOOLS',
FILE_UPLOAD_AUDITOR = 'FILE_UPLOAD_AUDITOR',
WEB_SEC_AGENT = 'WEB_SEC_AGENT',
XSS_EXPLOIT_ASSISTANT = 'XSS_EXPLOIT_ASSISTANT', // This is a special view, not in the main navigator
SQL_EXPLOIT_ASSISTANT = 'SQL_EXPLOIT_ASSISTANT', // Special view for SQLi
FINISHER = 'FINISHER', // AI Repeater / "The Finisher" — resume exploiting unconfirmed findings
CLI_FRAMEWORK = 'CLI_FRAMEWORK',
MODEL_LAB = 'MODEL_LAB', // Standalone sidebar module (route /modellab) — OpenRouter benchmark
HISTORY = 'HISTORY',
}
export enum Tool {
SAST = 'SAST',
DAST = 'DAST',
SECURITY_HEADERS_ANALYZER = 'SECURITY_HEADERS_ANALYZER',
JS_RECON = 'JS_RECON',
DOM_XSS_PATHFINDER = 'DOM_XSS_PATHFINDER',
PAYLOAD_FORGE = 'PAYLOAD_FORGE',
SSTI_FORGE = 'SSTI_FORGE',
PRIVESC_PATHFINDER = 'PRIVESC_PATHFINDER',
OOB_INTERACTION_HELPER = 'OOB_INTERACTION_HELPER',
URL_LIST_FINDER = 'URL_LIST_FINDER',
SUBDOMAIN_FINDER = 'SUBDOMAIN_FINDER',
API_DISCOVERY = 'API_DISCOVERY',
}
export type AgentType = 'web' | 'kali' | 'recon' | 'bugtrace';
export enum Severity {
CRITICAL = 'Critical',
HIGH = 'High',
MEDIUM = 'Medium',
LOW = 'Low',
INFO = 'Info',
UNKNOWN = 'Unknown'
}
export type DastScanType = 'recon' | 'active' | 'greybox';
export interface InjectionPoint {
type: 'URL_PARAM' | 'POST_PARAM' | 'PATH';
parameter: string; // e.g., 'q', 'name', 'id'
method?: 'GET' | 'POST';
}
export interface Vulnerability {
vulnerability: string;
severity: Severity;
description: string;
impact: string;
recommendation: string;
vulnerableCode: string; // The vulnerable pattern or example payload
injectionPoint?: InjectionPoint; // Where the injection occurs
}
export interface VulnerabilityReport {
id?: string;
analyzedTarget: string;
vulnerabilities: Vulnerability[];
}
export interface XssPayload {
payload: string;
description: string;
mechanism: string;
encoding: string;
}
export interface XssPayloadResult {
payloads: XssPayload[];
explanation: string;
}
export interface SqlmapCommandResult {
command: string;
explanation: string;
}
export interface ForgedPayload {
technique: string;
description: string;
payload: string;
}
export interface ForgedPayloadResult {
payloads: ForgedPayload[];
}
export interface FormInput {
name: string;
type: string;
value?: string;
isVulnerable: boolean;
}
export interface ExploitPath {
exploitUrl: string;
formMethod: 'GET' | 'POST';
formInputs: FormInput[];
reproductionGuide: string;
}
export interface ChatMessage {
role: 'user' | 'model' | 'system';
content: string;
isLoading?: boolean;
}
export interface ExploitContext {
vulnerability: Vulnerability;
targetUrl?: string;
}
/**
* ExploitSeed — everything the scanner already learned about an UNCONFIRMED finding,
* used to seed "The Finisher" (AI Repeater) so the agent resumes where the scan stopped
* instead of starting cold. All fields optional except url; built from CLI raw_findings.json
* (parseRawFindingToSeed) or from the manual form in FinisherAssistant.
*/
/** A captured HTTP request (from the CLI `repro` envelope) the repeater can replay verbatim. */
export interface RepeaterRequestDict {
method: string;
url: string;
headers?: Record<string, string>;
body?: string | null;
bodyContentType?: string | null;
}
export interface ExploitSeed {
scanId?: number; // scan id this finding belongs to
findingId?: number; // finding id from the scan's findings list
vulnType: string; // 'XSS' | 'SQLi' | 'CSTI' | ...
url: string; // the target URL the scanner tested
parameter?: string; // the injection parameter (e.g. 'searchTerm')
method?: 'GET' | 'POST';
reflectingPayloads?: string[]; // payloads that reflected but did NOT confirm
reflectionContext?: string; // e.g. 'js_string_single', 'html_attribute', 'script_block'
survivingChars?: string; // characters that survived filtering, e.g. "<>\"'"
serverEscaping?: string; // observed escaping behavior, free text
baselineRequest?: string; // closest-miss raw request, if available
baselineResponse?: string; // closest-miss response snippet, if available
whyStalled?: string; // human-readable reason the scanner couldn't confirm
confidence?: number; // 0..1 scanner confidence, if available
needsCdp?: boolean; // flagged NEEDS_CDP_VALIDATION (DOM execution required)
status?: string; // scanner status: 'Confirmed' | 'PENDING_VALIDATION' | ... (drives the agent framing)
// Seed enrichment — the REAL request the scanner used to confirm (CLI `repro` envelope).
confirmingRequest?: RepeaterRequestDict; // replay this verbatim (auth masked)
confirmingResponse?: { status?: number; excerpt?: string };
readbackRequest?: RepeaterRequestDict; // stored vulns: the GET that proved persistence
authUsed?: boolean;
authScheme?: string; // 'Bearer' | 'Cookie' | ...
jwtSecret?: string; // HS256 secret cracked by the scan (from a "Weak JWT Secret" finding) — lets the Repeater forge admin tokens
reproduction?: string; // curl command or reproduction string from specialist
curlCommand?: string; // alternative curl command field
}
export interface HeaderFinding {
name: string;
value: string | null;
status: 'Present - Good' | 'Present - Misconfigured' | 'Missing';
recommendation: string;
severity: 'High' | 'Medium' | 'Low' | 'Info';
}
export interface HeadersReport {
analyzedUrl: string;
overallScore: 'A+' | 'A' | 'B' | 'C' | 'D' | 'F';
summary: string;
findings: HeaderFinding[];
}
// Types for DOM XSS Pathfinder
export interface DomXssConnectedPath {
source: string;
sink: string;
code_snippet: string;
explanation: string;
}
export interface DomXssUnconnectedFinding {
type: 'source' | 'sink';
value: string;
}
export interface DomXssAnalysisResult {
connected_paths: DomXssConnectedPath[];
unconnected_findings: DomXssUnconnectedFinding[];
}
export interface FileUploadAnalysisResult {
found: boolean;
description: string;
manualTestingGuide: string;
}
export interface ApiKeys {
openrouter: string;
[key: string]: string; // Support any provider key (e.g. 'zai')
}
export type ApiOptions = {
apiKey: string;
model: string;
};
// New interface for vulnerability validation result
export interface ValidationResult {
is_valid: boolean;
reasoning: string;
}
// ============================================================================
// Report provenance (HANDOFF B.1 / E)
// ============================================================================
/**
* Executing engine. Discriminates the client/route/viewer/capabilities.
* Never infer engine from the badge text: both "web-cli" and "cli" are the CLI
* engine, both "web-api" and "api" are the API engine.
*/
export type ScanEngine = 'cli' | 'api';
/**
* Canonical launch origin — how the scan was started. Independent of engine.
* Exact four values for every NEW report; "legacy-unknown" is a read-only
* migration fallback for unverifiable legacy metadata, NOT a fifth origin.
*/
export type LaunchOrigin = 'web-cli' | 'web-api' | 'cli' | 'api' | 'legacy-unknown';
/**
* Human-readable badge for a launch origin.
*
* web-cli => "WEB → CLI" (BugTraceAI-WEB → CLI REST)
* web-api => "WEB → API" (BugTraceAI-WEB → API REST)
* cli => "CLI" (direct terminal/native CLI)
* api => "API" (direct API REST / automation / MCP)
* else => "Legacy / origin unknown"
*/
export function getBadge(origin: string | null | undefined): string {
switch (origin) {
case 'web-cli': return 'WEB → CLI';
case 'web-api': return 'WEB → API';
case 'cli': return 'CLI';
case 'api': return 'API';
default: return 'Legacy / origin unknown';
}
}
/**
* Normalize a legacy CLI `origin` value (or a fresh `launch_origin`) into the
* canonical LaunchOrigin. Pure function — safe to unit test without a DOM.
*
* "web" → "web-cli" (WEB launched the CLI scan)
* "cli" → "cli" (terminal/native CLI)
* canonical values pass through unchanged
* missing / anything else → "legacy-unknown" (migration fallback, NOT a 5th origin)
*/
export function normalizeLaunchOrigin(value: string | null | undefined): LaunchOrigin {
if (!value) return 'legacy-unknown';
switch (value) {
case 'web': return 'web-cli';
case 'cli': return 'cli';
case 'web-cli':
case 'web-api':
case 'api': return value as LaunchOrigin;
default: return 'legacy-unknown';
}
}
/**
* Return the engine implied by an engine-qualified report key (`cli:12` → 'cli',
* `api:a1b2c3d4-e5f` → 'api'). Unqualified / malformed keys return null.
* Never coerces API ids into numbers.
*/
export function getReportSource(key: string): ScanEngine | null {
if (!key) return null;
const firstColon = key.indexOf(':');
if (firstColon <= 0) return null;
const engine = key.slice(0, firstColon);
if (engine === 'cli' || engine === 'api') return engine as ScanEngine;
return null;
}