@vulcn/engine 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.d.ts CHANGED
@@ -1,5 +1,86 @@
1
- import { Page, Dialog, ConsoleMessage, Request, Response, Browser } from 'playwright';
2
1
  import { z } from 'zod';
2
+ import { Page, Dialog, ConsoleMessage, Request, Response, Browser } from 'playwright';
3
+
4
+ /**
5
+ * Payload Types for Vulcn
6
+ * Core types used by the engine and plugins
7
+ */
8
+ /**
9
+ * Valid payload categories
10
+ */
11
+ type PayloadCategory = "xss" | "sqli" | "ssrf" | "xxe" | "command-injection" | "path-traversal" | "open-redirect" | "reflection" | "custom";
12
+ /**
13
+ * Payload source types
14
+ */
15
+ type PayloadSource = "builtin" | "custom" | "payloadbox" | "plugin";
16
+ /**
17
+ * Runtime payload structure - used by plugins and the runner
18
+ */
19
+ interface RuntimePayload {
20
+ /** Unique payload name */
21
+ name: string;
22
+ /** Vulnerability category */
23
+ category: PayloadCategory;
24
+ /** Human-readable description */
25
+ description: string;
26
+ /** Array of payload strings to inject */
27
+ payloads: string[];
28
+ /** Patterns to detect vulnerability (as RegExp) */
29
+ detectPatterns: RegExp[];
30
+ /** Where this payload came from */
31
+ source: PayloadSource;
32
+ }
33
+ /**
34
+ * Custom payload schema for YAML/JSON files (used by loader plugins)
35
+ */
36
+ interface CustomPayload {
37
+ name: string;
38
+ category: PayloadCategory;
39
+ description?: string;
40
+ payloads: string[];
41
+ detectPatterns?: string[];
42
+ }
43
+ /**
44
+ * Custom payload file schema
45
+ */
46
+ interface CustomPayloadFile {
47
+ version?: string;
48
+ payloads: CustomPayload[];
49
+ }
50
+
51
+ type BrowserType = "chromium" | "firefox" | "webkit";
52
+ interface RecorderOptions {
53
+ browser?: BrowserType;
54
+ viewport?: {
55
+ width: number;
56
+ height: number;
57
+ };
58
+ headless?: boolean;
59
+ }
60
+ interface RunnerOptions {
61
+ browser?: BrowserType;
62
+ headless?: boolean;
63
+ onFinding?: (finding: Finding) => void;
64
+ }
65
+ interface Finding {
66
+ type: PayloadCategory;
67
+ severity: "critical" | "high" | "medium" | "low" | "info";
68
+ title: string;
69
+ description: string;
70
+ stepId: string;
71
+ payload: string;
72
+ url: string;
73
+ evidence?: string;
74
+ /** Plugin-specific metadata */
75
+ metadata?: Record<string, unknown>;
76
+ }
77
+ interface RunResult$1 {
78
+ findings: Finding[];
79
+ stepsExecuted: number;
80
+ payloadsTested: number;
81
+ duration: number;
82
+ errors: string[];
83
+ }
3
84
 
4
85
  declare const StepSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
5
86
  id: z.ZodString;
@@ -137,7 +218,7 @@ declare const StepSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
137
218
  timestamp: number;
138
219
  duration: number;
139
220
  }>]>;
140
- type Step = z.infer<typeof StepSchema>;
221
+ type Step$1 = z.infer<typeof StepSchema>;
141
222
  declare const SessionSchema: z.ZodObject<{
142
223
  version: z.ZodDefault<z.ZodString>;
143
224
  name: z.ZodString;
@@ -395,7 +476,7 @@ declare const SessionSchema: z.ZodObject<{
395
476
  version?: string | undefined;
396
477
  browser?: "chromium" | "firefox" | "webkit" | undefined;
397
478
  }>;
398
- type Session = z.infer<typeof SessionSchema>;
479
+ type Session$1 = z.infer<typeof SessionSchema>;
399
480
  /**
400
481
  * Create a new session object
401
482
  */
@@ -407,96 +488,15 @@ declare function createSession(options: {
407
488
  width: number;
408
489
  height: number;
409
490
  };
410
- }): Session;
491
+ }): Session$1;
411
492
  /**
412
493
  * Parse a session from YAML string
413
494
  */
414
- declare function parseSession(yaml: string): Session;
495
+ declare function parseSession(yaml: string): Session$1;
415
496
  /**
416
497
  * Serialize a session to YAML string
417
498
  */
418
- declare function serializeSession(session: Session): string;
419
-
420
- /**
421
- * Payload Types for Vulcn
422
- * Core types used by the engine and plugins
423
- */
424
- /**
425
- * Valid payload categories
426
- */
427
- type PayloadCategory = "xss" | "sqli" | "ssrf" | "xxe" | "command-injection" | "path-traversal" | "open-redirect" | "reflection" | "custom";
428
- /**
429
- * Payload source types
430
- */
431
- type PayloadSource = "builtin" | "custom" | "payloadbox" | "plugin";
432
- /**
433
- * Runtime payload structure - used by plugins and the runner
434
- */
435
- interface RuntimePayload {
436
- /** Unique payload name */
437
- name: string;
438
- /** Vulnerability category */
439
- category: PayloadCategory;
440
- /** Human-readable description */
441
- description: string;
442
- /** Array of payload strings to inject */
443
- payloads: string[];
444
- /** Patterns to detect vulnerability (as RegExp) */
445
- detectPatterns: RegExp[];
446
- /** Where this payload came from */
447
- source: PayloadSource;
448
- }
449
- /**
450
- * Custom payload schema for YAML/JSON files (used by loader plugins)
451
- */
452
- interface CustomPayload {
453
- name: string;
454
- category: PayloadCategory;
455
- description?: string;
456
- payloads: string[];
457
- detectPatterns?: string[];
458
- }
459
- /**
460
- * Custom payload file schema
461
- */
462
- interface CustomPayloadFile {
463
- version?: string;
464
- payloads: CustomPayload[];
465
- }
466
-
467
- type BrowserType = "chromium" | "firefox" | "webkit";
468
- interface RecorderOptions {
469
- browser?: BrowserType;
470
- viewport?: {
471
- width: number;
472
- height: number;
473
- };
474
- headless?: boolean;
475
- }
476
- interface RunnerOptions {
477
- browser?: BrowserType;
478
- headless?: boolean;
479
- onFinding?: (finding: Finding) => void;
480
- }
481
- interface Finding {
482
- type: PayloadCategory;
483
- severity: "critical" | "high" | "medium" | "low" | "info";
484
- title: string;
485
- description: string;
486
- stepId: string;
487
- payload: string;
488
- url: string;
489
- evidence?: string;
490
- /** Plugin-specific metadata */
491
- metadata?: Record<string, unknown>;
492
- }
493
- interface RunResult {
494
- findings: Finding[];
495
- stepsExecuted: number;
496
- payloadsTested: number;
497
- duration: number;
498
- errors: string[];
499
- }
499
+ declare function serializeSession(session: Session$1): string;
500
500
 
501
501
  /**
502
502
  * Vulcn Plugin System Types
@@ -551,17 +551,17 @@ interface PluginHooks {
551
551
  /** Called when recording starts */
552
552
  onRecordStart?: (ctx: RecordContext) => Promise<void>;
553
553
  /** Called for each recorded step, can transform */
554
- onRecordStep?: (step: Step, ctx: RecordContext) => Promise<Step>;
554
+ onRecordStep?: (step: Step$1, ctx: RecordContext) => Promise<Step$1>;
555
555
  /** Called when recording ends, can transform session */
556
- onRecordEnd?: (session: Session, ctx: RecordContext) => Promise<Session>;
556
+ onRecordEnd?: (session: Session$1, ctx: RecordContext) => Promise<Session$1>;
557
557
  /** Called when run starts */
558
- onRunStart?: (ctx: RunContext) => Promise<void>;
558
+ onRunStart?: (ctx: RunContext$1) => Promise<void>;
559
559
  /** Called before each payload is injected, can transform payload */
560
- onBeforePayload?: (payload: string, step: Step, ctx: RunContext) => Promise<string>;
560
+ onBeforePayload?: (payload: string, step: Step$1, ctx: RunContext$1) => Promise<string>;
561
561
  /** Called after payload injection, for detection */
562
562
  onAfterPayload?: (ctx: DetectContext) => Promise<Finding[]>;
563
563
  /** Called when run ends, can transform results */
564
- onRunEnd?: (result: RunResult, ctx: RunContext) => Promise<RunResult>;
564
+ onRunEnd?: (result: RunResult$1, ctx: RunContext$1) => Promise<RunResult$1>;
565
565
  /** Called on page load/navigation */
566
566
  onPageLoad?: (page: Page, ctx: DetectContext) => Promise<Finding[]>;
567
567
  /** Called when JavaScript alert/confirm/prompt appears */
@@ -620,9 +620,9 @@ interface RecordContext extends PluginContext {
620
620
  /**
621
621
  * Context for running phase hooks
622
622
  */
623
- interface RunContext extends PluginContext {
623
+ interface RunContext$1 extends PluginContext {
624
624
  /** Session being executed */
625
- session: Session;
625
+ session: Session$1;
626
626
  /** Playwright page instance */
627
627
  page: Page;
628
628
  /** Browser type being used */
@@ -633,9 +633,9 @@ interface RunContext extends PluginContext {
633
633
  /**
634
634
  * Context for detection hooks
635
635
  */
636
- interface DetectContext extends RunContext {
636
+ interface DetectContext extends RunContext$1 {
637
637
  /** Current step being tested */
638
- step: Step;
638
+ step: Step$1;
639
639
  /** Current payload set being tested */
640
640
  payloadSet: RuntimePayload;
641
641
  /** Actual payload value injected */
@@ -782,6 +782,247 @@ declare class PluginManager {
782
782
  */
783
783
  declare const pluginManager: PluginManager;
784
784
 
785
+ /**
786
+ * Vulcn Driver System
787
+ *
788
+ * Drivers handle recording and running sessions for different targets:
789
+ * - browser: Web applications (Playwright)
790
+ * - api: REST/HTTP APIs
791
+ * - cli: Command-line tools
792
+ *
793
+ * Each driver implements RecorderDriver and RunnerDriver interfaces.
794
+ */
795
+
796
+ /**
797
+ * Current driver API version
798
+ */
799
+ declare const DRIVER_API_VERSION = 1;
800
+ /**
801
+ * Generic step - drivers define their own step types
802
+ */
803
+ interface Step {
804
+ /** Unique step ID */
805
+ id: string;
806
+ /** Step type (namespaced, e.g., "browser.click", "api.request") */
807
+ type: string;
808
+ /** Timestamp when step was recorded */
809
+ timestamp: number;
810
+ /** Step-specific data */
811
+ [key: string]: unknown;
812
+ }
813
+ /**
814
+ * Generic session format
815
+ */
816
+ interface Session {
817
+ /** Session name */
818
+ name: string;
819
+ /** Driver that recorded this session */
820
+ driver: string;
821
+ /** Driver-specific configuration */
822
+ driverConfig: Record<string, unknown>;
823
+ /** Recorded steps */
824
+ steps: Step[];
825
+ /** Session metadata */
826
+ metadata?: {
827
+ recordedAt?: string;
828
+ version?: string;
829
+ [key: string]: unknown;
830
+ };
831
+ }
832
+ /**
833
+ * Running context passed to drivers
834
+ */
835
+ interface RunContext {
836
+ /** Session being executed */
837
+ session: Session;
838
+ /** Plugin manager for calling hooks */
839
+ pluginManager: PluginManager;
840
+ /** Available payloads */
841
+ payloads: RuntimePayload[];
842
+ /** Collected findings */
843
+ findings: Finding[];
844
+ /** Add a finding */
845
+ addFinding(finding: Finding): void;
846
+ /** Logger */
847
+ logger: DriverLogger;
848
+ /** Running options */
849
+ options: RunOptions;
850
+ }
851
+ /**
852
+ * Options for recording
853
+ */
854
+ interface RecordOptions {
855
+ /** Driver-specific options */
856
+ [key: string]: unknown;
857
+ }
858
+ /**
859
+ * Options for running
860
+ */
861
+ interface RunOptions {
862
+ /** Run headless (for visual drivers) */
863
+ headless?: boolean;
864
+ /** Callback for findings */
865
+ onFinding?: (finding: Finding) => void;
866
+ /** Callback for step completion */
867
+ onStepComplete?: (stepId: string, payloadCount: number) => void;
868
+ /** Driver-specific options */
869
+ [key: string]: unknown;
870
+ }
871
+ /**
872
+ * Run result
873
+ */
874
+ interface RunResult {
875
+ /** All findings */
876
+ findings: Finding[];
877
+ /** Steps executed */
878
+ stepsExecuted: number;
879
+ /** Payloads tested */
880
+ payloadsTested: number;
881
+ /** Duration in milliseconds */
882
+ duration: number;
883
+ /** Errors encountered */
884
+ errors: string[];
885
+ }
886
+ /**
887
+ * Driver logger
888
+ */
889
+ interface DriverLogger {
890
+ debug(msg: string, ...args: unknown[]): void;
891
+ info(msg: string, ...args: unknown[]): void;
892
+ warn(msg: string, ...args: unknown[]): void;
893
+ error(msg: string, ...args: unknown[]): void;
894
+ }
895
+ /**
896
+ * Recorder Driver Interface
897
+ *
898
+ * Implement this to add recording support for a target type.
899
+ */
900
+ interface RecorderDriver {
901
+ /** Start recording and return control handle */
902
+ start(config: Record<string, unknown>, options: RecordOptions): Promise<RecordingHandle>;
903
+ }
904
+ /**
905
+ * Handle returned by RecorderDriver.start()
906
+ */
907
+ interface RecordingHandle {
908
+ /** Stop recording and return the session */
909
+ stop(): Promise<Session>;
910
+ /** Abort recording without saving */
911
+ abort(): Promise<void>;
912
+ /** Get current steps (during recording) */
913
+ getSteps(): Step[];
914
+ /** Manually add a step */
915
+ addStep(step: Omit<Step, "id" | "timestamp">): void;
916
+ }
917
+ /**
918
+ * Runner Driver Interface
919
+ *
920
+ * Implement this to add running/replay support for a target type.
921
+ */
922
+ interface RunnerDriver {
923
+ /** Execute a session with payloads */
924
+ execute(session: Session, ctx: RunContext): Promise<RunResult>;
925
+ }
926
+ /**
927
+ * Complete driver definition
928
+ */
929
+ interface VulcnDriver {
930
+ /** Unique driver name (e.g., "browser", "api", "cli") */
931
+ name: string;
932
+ /** Driver version */
933
+ version: string;
934
+ /** Driver API version */
935
+ apiVersion?: number;
936
+ /** Human-readable description */
937
+ description?: string;
938
+ /** Configuration schema (Zod) */
939
+ configSchema?: z.ZodSchema;
940
+ /** Step types this driver handles */
941
+ stepTypes: string[];
942
+ /** Recorder implementation */
943
+ recorder: RecorderDriver;
944
+ /** Runner implementation */
945
+ runner: RunnerDriver;
946
+ }
947
+ /**
948
+ * Driver source for loading
949
+ */
950
+ type DriverSource = "npm" | "local" | "builtin";
951
+ /**
952
+ * Loaded driver with metadata
953
+ */
954
+ interface LoadedDriver {
955
+ driver: VulcnDriver;
956
+ source: DriverSource;
957
+ }
958
+
959
+ /**
960
+ * Vulcn Driver Manager
961
+ *
962
+ * Handles driver loading, registration, and lifecycle.
963
+ * Drivers are loaded from npm packages or local files.
964
+ */
965
+
966
+ /**
967
+ * Driver Manager - loads and manages recording/running drivers
968
+ */
969
+ declare class DriverManager {
970
+ private drivers;
971
+ private defaultDriver;
972
+ /**
973
+ * Register a driver
974
+ */
975
+ register(driver: VulcnDriver, source?: DriverSource): void;
976
+ /**
977
+ * Load a driver from npm or local path
978
+ */
979
+ load(nameOrPath: string): Promise<void>;
980
+ /**
981
+ * Get a loaded driver by name
982
+ */
983
+ get(name: string): VulcnDriver | undefined;
984
+ /**
985
+ * Get the default driver
986
+ */
987
+ getDefault(): VulcnDriver | undefined;
988
+ /**
989
+ * Set the default driver
990
+ */
991
+ setDefault(name: string): void;
992
+ /**
993
+ * Check if a driver is registered
994
+ */
995
+ has(name: string): boolean;
996
+ /**
997
+ * Get all registered drivers
998
+ */
999
+ list(): LoadedDriver[];
1000
+ /**
1001
+ * Get driver for a session
1002
+ */
1003
+ getForSession(session: Session): VulcnDriver;
1004
+ /**
1005
+ * Start recording with a driver
1006
+ */
1007
+ startRecording(driverName: string, config: Record<string, unknown>, options?: RecordOptions): Promise<RecordingHandle>;
1008
+ /**
1009
+ * Execute a session
1010
+ */
1011
+ execute(session: Session, pluginManager: PluginManager, options?: RunOptions): Promise<RunResult>;
1012
+ /**
1013
+ * Validate driver structure
1014
+ */
1015
+ private validateDriver;
1016
+ /**
1017
+ * Create a scoped logger for a driver
1018
+ */
1019
+ private createLogger;
1020
+ }
1021
+ /**
1022
+ * Default driver manager instance
1023
+ */
1024
+ declare const driverManager: DriverManager;
1025
+
785
1026
  /**
786
1027
  * Recorder - captures browser interactions as a replayable session
787
1028
  * v0.2.0: Plugin hooks for recording customization
@@ -799,9 +1040,9 @@ interface RecorderConfig {
799
1040
  */
800
1041
  interface RecordingSession {
801
1042
  /** Stop recording and return the session */
802
- stop(): Promise<Session>;
1043
+ stop(): Promise<Session$1>;
803
1044
  /** Get current recorded steps */
804
- getSteps(): Step[];
1045
+ getSteps(): Step$1[];
805
1046
  /** Get the Playwright page (for advanced use) */
806
1047
  getPage(): Page;
807
1048
  }
@@ -854,11 +1095,11 @@ declare class Runner {
854
1095
  * @param options - Runner configuration
855
1096
  * @param config - Plugin manager configuration
856
1097
  */
857
- static execute(session: Session, options?: RunnerOptions, config?: RunnerConfig): Promise<RunResult>;
1098
+ static execute(session: Session$1, options?: RunnerOptions, config?: RunnerConfig): Promise<RunResult$1>;
858
1099
  /**
859
1100
  * Execute with explicit payloads (legacy API, for backwards compatibility)
860
1101
  */
861
- static executeWithPayloads(session: Session, payloads: RuntimePayload[], options?: RunnerOptions): Promise<RunResult>;
1102
+ static executeWithPayloads(session: Session$1, payloads: RuntimePayload[], options?: RunnerOptions): Promise<RunResult$1>;
862
1103
  /**
863
1104
  * Replay session steps with payload injected at target step
864
1105
  */
@@ -905,4 +1146,4 @@ declare function checkBrowsers(): Promise<{
905
1146
  playwrightWebkit: boolean;
906
1147
  }>;
907
1148
 
908
- export { type BrowserLaunchResult, BrowserNotFoundError, type BrowserType, type CustomPayload, type CustomPayloadFile, type DetectContext, type EngineInfo, type Finding, type LaunchOptions, type LoadedPlugin, PLUGIN_API_VERSION, type PayloadCategory, type PayloadSource, type PluginConfig, type PluginContext, type PluginHooks, type PluginLogger, PluginManager, type PluginSource, type RecordContext, Recorder, type RecorderOptions, type RecordingSession, type RunContext, type RunResult, Runner, type RunnerOptions, type RuntimePayload, type Session, SessionSchema, type Step, StepSchema, type VulcnConfig, type VulcnPlugin, checkBrowsers, createSession, installBrowsers, launchBrowser, parseSession, pluginManager, serializeSession };
1149
+ export { type BrowserLaunchResult, BrowserNotFoundError, type BrowserType, type CustomPayload, type CustomPayloadFile, DRIVER_API_VERSION, type DetectContext, type DriverLogger, DriverManager, type DriverSource, type EngineInfo, type Finding, type LaunchOptions, type Session$1 as LegacySession, type Step$1 as LegacyStep, type LoadedDriver, type LoadedPlugin as LoadedPluginInfo, PLUGIN_API_VERSION, type PayloadCategory, type PayloadSource, type PluginConfig, type PluginContext, type PluginHooks, type PluginLogger, PluginManager, type PluginSource, type RecordContext, type RecordOptions, Recorder, type RecorderDriver, type RecorderOptions, type RecordingHandle, type RecordingSession, type RunContext, type RunOptions, type RunResult, Runner, type RunnerDriver, type RunnerOptions, type RuntimePayload, type Session, SessionSchema, type Step, StepSchema, type VulcnConfig, type VulcnDriver, type VulcnPlugin, checkBrowsers, createSession, driverManager, installBrowsers, launchBrowser, parseSession, pluginManager, serializeSession };