pastoralist
Version:
A tool to watch over node module resolutions and overrides
64 lines (63 loc) • 3.14 kB
TypeScript
import type { PastoralistJSON, SecurityAlert, SecurityOverride, SecurityProviderType } from "../../types";
import { execFile } from "child_process";
import * as readline from "readline/promises";
import type { CLIInstallOptions, PromptFunctions, PromptChoice } from "./types";
declare const execFileAsync: typeof execFile.__promisify__;
type ExecFileAsync = typeof execFileAsync;
export declare const getSeverityScore: (severity: string) => number;
export declare const deduplicateAlerts: (alerts: SecurityAlert[]) => SecurityAlert[];
export declare const computeConfidence: (sources: SecurityProviderType[]) => "confirmed" | "possible";
export declare const sortAlertsByPriority: (alerts: SecurityAlert[]) => SecurityAlert[];
export declare const extractPackages: (config: PastoralistJSON, excludePackages?: string[]) => Array<{
name: string;
version: string;
}>;
export declare const isVersionVulnerable: (currentVersion: string, vulnerableRange: string) => boolean;
export declare const computeVulnerabilityReduction: (packageName: string, currentVersion: string, targetVersion: string, allAlerts: SecurityAlert[]) => {
skip: boolean;
targetStillVulnerable: boolean;
};
export declare const findVulnerablePackages: (config: PastoralistJSON, alerts: SecurityAlert[]) => SecurityAlert[];
export declare class CLIInstaller {
private log;
private execFileAsync;
constructor(options?: {
debug?: boolean;
execFileAsync?: ExecFileAsync;
});
isInstalled(command: string): Promise<boolean>;
isInstalledGlobally(packageName: string): Promise<boolean>;
installGlobally(packageName: string): Promise<void>;
ensureInstalled(options: CLIInstallOptions): Promise<boolean>;
private hasAvailableCommand;
private hasGlobalPackage;
private installMissingCommand;
private verifyInstalledCommand;
getVersion(command: string): Promise<string | undefined>;
}
export declare const createPromptInterface: () => readline.Interface;
export declare const promptConfirm: (message: string, defaultValue?: boolean) => Promise<boolean>;
export declare const promptSelect: (message: string, choices: PromptChoice[]) => Promise<string>;
export declare const promptInput: (message: string, defaultValue?: string) => Promise<string>;
export declare const promptSecret: (message: string, defaultValue?: string) => Promise<string>;
export declare class InteractiveSecurityManager {
private prompts;
constructor(prompts?: PromptFunctions);
promptForSecurityActions(vulnerablePackages: SecurityAlert[], suggestedOverrides: SecurityOverride[]): Promise<SecurityOverride[]>;
private printSecurityReview;
private confirmSecurityReview;
private collectSelectedOverrides;
private selectOverride;
private findVulnerability;
private printOverrideReview;
private getActionChoices;
private createSelectedOverride;
private confirmSelectedOverrides;
private printSelectedOverrides;
private generateSummary;
private countBySeverity;
private formatSeveritySummary;
private getSeverityLabel;
private getSeverityEmoji;
}
export {};