secure-scan-js
Version:
A JavaScript implementation of Yelp's detect-secrets tool - no Python required
155 lines (154 loc) • 3.19 kB
TypeScript
/**
* Options for scanning a directory for secrets
*/
export interface ScanOptions {
/**
* Directory to scan (default: current directory)
*/
directory?: string;
/**
* Scan from project root
*/
root?: boolean;
/**
* File patterns to exclude
*/
excludeFiles?: string[];
/**
* Directory patterns to exclude
*/
excludeDirs?: string[];
/**
* Check for potentially missed secrets
*/
checkMissed?: boolean;
/**
* Include additional information
*/
verbose?: boolean;
/**
* Output file path
*/
output?: string;
/**
* Enable file size limits (default: false)
*/
limitFileSize?: boolean;
/**
* Maximum file size to scan in bytes (default: 0, no limit)
*/
maxFileSize?: number;
/**
* Scan git history (default: false)
*/
scanGitHistory?: boolean;
/**
* Starting commit for git history scan
*/
fromCommit?: string;
/**
* Ending commit for git history scan
*/
toCommit?: string;
/**
* Enrich scan results with git blame information (default: true)
*/
enrichWithGitInfo?: boolean;
/**
* Git repository path for external scans
*/
gitRepoPath?: string;
/**
* Whether to include node_modules in the scan (not recommended)
*/
includeNodeModules?: boolean;
}
/**
* Secret details returned from scanning
*/
export interface Secret {
/**
* File path where the secret was found
*/
file: string;
/**
* Line number where the secret was found
*/
line: number;
/**
* Secret type (e.g. 'AWS Access Key', 'API Key', etc.)
*/
types: string[];
/**
* Whether this is likely a false positive
*/
is_false_positive: boolean;
/**
* A hash of the secret for reporting without exposing the value
*/
hashed_secret: string;
/**
* Git commit hash where the secret was found
*/
commit: string;
/**
* Author who committed the secret
*/
author: string;
/**
* Email of the author who committed the secret
*/
email: string;
/**
* Date when the secret was committed
*/
date: string;
/**
* Commit message when the secret was added
*/
message: string;
/**
* Detected by which scanner
*/
detectedBy: string;
/**
* Enhanced fields
*/
entropy?: number;
confidence?: number;
severity?: "low" | "medium" | "high" | "critical";
}
/**
* A potentially missed secret
*/
export interface MissedSecret {
/**
* File path where the secret was found
*/
file: string;
/**
* Line number where the secret was found
*/
line: number;
/**
* Type of secret
*/
type: string;
}
/**
* Results from a secret scan
*/
export interface ScanResults {
/**
* List of secrets found
*/
secrets: Secret[];
/**
* List of potentially missed secrets
*/
missed_secrets: MissedSecret[];
/**
* Whether any files were truncated due to size
*/
truncated?: boolean;
}