Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ program
.option("-l, --level <level>", "Pentest level: priority or full", "full")
.option("--quick", "Run a quick pentest (highest-risk endpoints only, ~15 mins). Shorthand for --level priority")
.option("--no-wait", "Don't wait for pentest to complete")
.option("-u, --url <url>", "Deploy preview URL to pentest against")
.option("-e, --environment <env>", "Environment: dev, staging, or production")
.option(
"-c, --commit <sha>",
Expand All @@ -45,6 +46,15 @@ program
process.exit(1);
}

if (options.url) {
try {
new URL(options.url);
} catch {
console.error(`Invalid URL: "${options.url}"`);
process.exit(1);
}
}

const scanLevel: "priority" | "full" = options.quick
? "priority"
: (options.level as "priority" | "full");
Expand All @@ -58,6 +68,7 @@ program
environment: options.environment as Environment | undefined,
errorSeverityThreshold: severityThreshold,
commitSha: options.commit,
targetUrl: options.url,
});

if (result.status === "completed") {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export interface DispatchScanParams {
scanLevel?: "priority" | "full";
environment?: Environment;
commitSha?: string;
targetUrl?: string;
}

export async function dispatchScan(
Expand All @@ -166,6 +167,7 @@ export async function dispatchScan(
branch: params.branch,
scanLevel: params.scanLevel,
commitSha: params.commitSha,
...(params.targetUrl && { targetUrl: params.targetUrl }),
}),
});

Expand Down Expand Up @@ -296,6 +298,7 @@ export interface RunScanParams {
pollIntervalMs?: number;
errorSeverityThreshold?: SeverityLevel;
commitSha?: string;
targetUrl?: string;
}

export async function runScan(params: RunScanParams = {}): Promise<ScanStatus> {
Expand Down Expand Up @@ -323,6 +326,7 @@ export async function runScan(params: RunScanParams = {}): Promise<ScanStatus> {
scanLevel: params.scanLevel,
environment,
commitSha,
targetUrl: params.targetUrl,
});

console.log(`Pentest ${label} dispatched (ID: ${scanId})`);
Expand Down
Loading