vulnzap-core
Version:
Secure AI-generated code by intercepting vulnerabilities in real-time
123 lines (122 loc) • 3.12 kB
TypeScript
interface GitHubAdvisory {
id: number;
ghsa_id: string;
cve_id: string | null;
url: string;
html_url: string;
repository_advisory_url: string | null;
summary: string;
description: string;
type: string;
severity: string;
source_code_location: string | null;
identifiers: Array<{
type: string;
value: string;
}>;
references: string[];
published_at: string;
updated_at: string;
github_reviewed_at: string | null;
nvd_published_at: string | null;
withdrawn_at: string | null;
vulnerabilities: Array<{
package: {
ecosystem: string;
name: string;
};
first_patched_version: string | null;
vulnerable_version_range: string;
vulnerable_functions: string[] | null;
}>;
cvss: {
vector_string: string;
score: number;
} | null;
cvss_severities: {
cvss_v3: {
vector_string: string;
score: number;
} | null;
cvss_v4: {
vector_string: string;
score: number;
} | null;
} | null;
cwes: Array<{
cwe_id: string;
name: string;
}> | null;
epss: Array<{
percentage: number;
percentile: string;
}> | null;
credits: Array<{
user: {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
};
type: string;
}> | null;
}
export interface VulnerabilityResult {
isVulnerable: boolean;
advisories?: Array<{
id: string;
title: string;
severity: string;
cve_id?: string;
description: string;
source?: string;
}>;
fixedVersions?: string[];
message?: string;
error?: string;
isUnknown?: boolean;
sources?: string[];
}
export default class GitHubAdvisorySource {
private readonly CACHE_TTL;
private isInitialized;
private cachePath;
constructor();
initialize(): Promise<boolean>;
/**
* Save data to cache file
* @private
*/
private _saveToCache;
/**
* Get data from cache
* @private
*/
private _getFromCache;
/**
* Clear cache for specific key or all cache
* @private
*/
private _clearCache;
private makeApiRequest;
getAllAdvisoriesForEcosystem(ecosystem: string): Promise<GitHubAdvisory[]>;
private processAdvisoryResults;
findVulnerabilities(packageName: string, version: string, ecosystem: string, options?: {
refresh?: boolean;
}): Promise<VulnerabilityResult>;
}
export {};