@vulcn/driver-browser 0.2.0 → 0.3.0
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.
- package/dist/index.cjs +487 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -21
- package/dist/index.d.ts +90 -21
- package/dist/index.js +483 -191
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { RecordOptions, RecordingHandle, Session, RunContext, RunResult, CrawlOptions, VulcnDriver } from '@vulcn/engine';
|
|
3
|
-
import { Browser } from 'playwright';
|
|
2
|
+
import { RecordOptions, RecordingHandle, Session, RunContext, RunResult, CrawlOptions, FormCredentials, VulcnDriver } from '@vulcn/engine';
|
|
3
|
+
import { Browser, Page, BrowserContext } from 'playwright';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Browser Recorder Implementation
|
|
@@ -32,33 +32,31 @@ declare class BrowserRecorder {
|
|
|
32
32
|
*
|
|
33
33
|
* Replays browser sessions with security payloads.
|
|
34
34
|
* Uses plugin hooks for detection.
|
|
35
|
+
*
|
|
36
|
+
* v2: Persistent browser with in-page payload cycling.
|
|
37
|
+
* - ONE browser for the entire scan (not per-session)
|
|
38
|
+
* - Uses page.goBack() between payloads instead of full page.goto()
|
|
39
|
+
* - Falls back to full navigation when goBack() fails
|
|
40
|
+
* - 5-10x faster on SPAs, same speed on simple sites
|
|
35
41
|
*/
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Browser Runner - replays sessions with payloads
|
|
45
|
+
*
|
|
46
|
+
* Supports two modes:
|
|
47
|
+
* 1. Self-managed browser: launches its own browser (backward compat)
|
|
48
|
+
* 2. Shared browser: receives a browser instance via RunOptions
|
|
49
|
+
*
|
|
50
|
+
* In both modes, payload cycling uses goBack() for speed.
|
|
39
51
|
*/
|
|
40
52
|
declare class BrowserRunner {
|
|
41
53
|
/**
|
|
42
|
-
* Execute a session with security payloads
|
|
43
|
-
*/
|
|
44
|
-
static execute(session: Session, ctx: RunContext): Promise<RunResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Replay session steps with payload injected at target step
|
|
54
|
+
* Execute a session with security payloads.
|
|
47
55
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* clicking submit) must still execute so the payload reaches the server
|
|
51
|
-
* and gets reflected back in the response.
|
|
52
|
-
*/
|
|
53
|
-
private static replayWithPayload;
|
|
54
|
-
/**
|
|
55
|
-
* Check for payload reflection in page content
|
|
56
|
+
* If ctx.options.browser is provided, reuses that browser (persistent mode).
|
|
57
|
+
* Otherwise, launches and closes its own browser (standalone mode).
|
|
56
58
|
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Determine severity based on vulnerability category
|
|
60
|
-
*/
|
|
61
|
-
private static getSeverity;
|
|
59
|
+
static execute(session: Session, ctx: RunContext): Promise<RunResult>;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
/**
|
|
@@ -130,6 +128,77 @@ interface BrowserCrawlConfig {
|
|
|
130
128
|
*/
|
|
131
129
|
declare function crawlAndBuildSessions(config: BrowserCrawlConfig, options?: CrawlOptions): Promise<Session[]>;
|
|
132
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Login Form Auto-Detection & Auth Replay
|
|
133
|
+
*
|
|
134
|
+
* Detects login forms on a page and fills them with credentials.
|
|
135
|
+
* After login, captures the browser storage state (cookies + localStorage)
|
|
136
|
+
* for re-use in subsequent scans.
|
|
137
|
+
*
|
|
138
|
+
* Detection strategy:
|
|
139
|
+
* 1. Find forms with a password input (strongest signal)
|
|
140
|
+
* 2. Find username field via heuristics (name, id, autocomplete, type)
|
|
141
|
+
* 3. Find submit button
|
|
142
|
+
* 4. Fall back to custom selectors from credentials
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
interface LoginForm {
|
|
146
|
+
/** Username input selector */
|
|
147
|
+
usernameSelector: string;
|
|
148
|
+
/** Password input selector */
|
|
149
|
+
passwordSelector: string;
|
|
150
|
+
/** Submit button selector (may be null if not found) */
|
|
151
|
+
submitSelector: string | null;
|
|
152
|
+
/** Whether the form was detected automatically */
|
|
153
|
+
autoDetected: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface LoginResult {
|
|
156
|
+
/** Whether login succeeded */
|
|
157
|
+
success: boolean;
|
|
158
|
+
/** Message for logging */
|
|
159
|
+
message: string;
|
|
160
|
+
/** Playwright storage state JSON (cookies + localStorage) */
|
|
161
|
+
storageState?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Auto-detect a login form on the current page.
|
|
165
|
+
*
|
|
166
|
+
* Strategy:
|
|
167
|
+
* 1. Find `<form>` elements containing an `input[type="password"]`
|
|
168
|
+
* 2. Within that form, find the username field using heuristics
|
|
169
|
+
* 3. Find the submit button
|
|
170
|
+
*
|
|
171
|
+
* Falls back to page-wide search if no enclosing <form> is found.
|
|
172
|
+
*/
|
|
173
|
+
declare function detectLoginForm(page: Page): Promise<LoginForm | null>;
|
|
174
|
+
/**
|
|
175
|
+
* Perform login using detected form or custom selectors.
|
|
176
|
+
*
|
|
177
|
+
* Flow:
|
|
178
|
+
* 1. Navigate to login URL (or target URL)
|
|
179
|
+
* 2. Detect login form (or use custom selectors from credentials)
|
|
180
|
+
* 3. Fill username + password
|
|
181
|
+
* 4. Submit form
|
|
182
|
+
* 5. Wait for navigation
|
|
183
|
+
* 6. Check for logged-in indicator
|
|
184
|
+
* 7. Capture storage state
|
|
185
|
+
*/
|
|
186
|
+
declare function performLogin(page: Page, context: BrowserContext, credentials: FormCredentials, options: {
|
|
187
|
+
targetUrl: string;
|
|
188
|
+
loggedInIndicator?: string;
|
|
189
|
+
loggedOutIndicator?: string;
|
|
190
|
+
}): Promise<LoginResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Check if the current session is still alive.
|
|
193
|
+
*
|
|
194
|
+
* Used during long-running scans to detect session expiry
|
|
195
|
+
* and trigger re-authentication.
|
|
196
|
+
*/
|
|
197
|
+
declare function checkSessionAlive(page: Page, config: {
|
|
198
|
+
loggedInIndicator?: string;
|
|
199
|
+
loggedOutIndicator?: string;
|
|
200
|
+
}): Promise<boolean>;
|
|
201
|
+
|
|
133
202
|
/**
|
|
134
203
|
* @vulcn/driver-browser
|
|
135
204
|
*
|
|
@@ -334,4 +403,4 @@ type BrowserStep = z.infer<typeof BrowserStepSchema>;
|
|
|
334
403
|
*/
|
|
335
404
|
declare const browserDriver: VulcnDriver;
|
|
336
405
|
|
|
337
|
-
export { BROWSER_STEP_TYPES, type BrowserConfig, BrowserRecorder, BrowserRunner, type BrowserStep, BrowserStepSchema, type BrowserStepType, checkBrowsers, configSchema, crawlAndBuildSessions, browserDriver as default, installBrowsers, launchBrowser };
|
|
406
|
+
export { BROWSER_STEP_TYPES, type BrowserConfig, BrowserRecorder, BrowserRunner, type BrowserStep, BrowserStepSchema, type BrowserStepType, type LoginForm, type LoginResult, checkBrowsers, checkSessionAlive, configSchema, crawlAndBuildSessions, browserDriver as default, detectLoginForm, installBrowsers, launchBrowser, performLogin };
|