/** * Scan Registry Module * * Maintains a persistent registry of all scans for analytics, * case study identification, and compliance auditing. * * @module telemetry/registry */ import type { Severity, CertificationLevel } from "../certification/types.js"; /** * A record of a completed scan */ export interface ScanRecord { /** Unique scan ID */ id: string; /** Certification ID if certified */ certificationId?: string; /** Project path (can be redacted) */ projectPath: string; /** SHA256 hash of project path for matching */ projectHash: string; /** Repository URL (if opted in) */ repoUrl?: string; /** Organization name (if opted in) */ orgName?: string; /** User email (if opted in) */ userEmail?: string; /** When the scan was performed */ scanDate: string; /** Certification level achieved */ level?: CertificationLevel; /** Overall score (0-100) */ score?: number; /** Scan duration in milliseconds */ duration: number; /** Findings by severity */ findingsSummary: Record; /** Total findings */ totalFindings: number; /** Scanners that were run */ scannersRun: string[]; /** Frameworks assessed */ frameworksAssessed: string[]; /** Whether the scan succeeded */ success: boolean; /** Error message if failed */ errorMessage?: string; /** Whether user consented to case study */ caseStudyConsent?: boolean; /** Tags for categorization */ tags?: string[]; } /** * Summary of findings for analytics */ export interface FindingSummary { /** Rule/check ID */ ruleId: string; /** Scanner that found it */ scanner: string; /** Category */ category: string; /** Severity */ severity: Severity; /** Number of occurrences across all scans */ occurrences: number; /** Number of unique projects affected */ projectsAffected: number; } /** * Analytics summary */ export interface RegistryAnalytics { /** Total scans recorded */ totalScans: number; /** Successful scans */ successfulScans: number; /** Failed scans */ failedScans: number; /** Scans by certification level */ byLevel: Record; /** Scans by framework */ byFramework: Record; /** Scans by scanner */ byScanner: Record; /** Scans by month (YYYY-MM format) */ byMonth: Record; /** Average score */ averageScore: number; /** Average scan duration in ms */ averageDuration: number; /** Top findings */ topFindings: FindingSummary[]; /** Case study candidates count */ caseStudyCandidates: number; } /** * Scan Registry for persistent tracking of all scans */ export declare class ScanRegistry { private records; private storagePath; private loaded; constructor(storagePath?: string); /** * Load registry from storage */ load(): Promise; /** * Save registry to storage */ save(): Promise; /** * Generate a unique scan ID */ private generateScanId; /** * Hash a project path for matching */ private hashProjectPath; /** * Record a new scan */ recordScan(record: Omit): Promise; /** * Get a scan by ID */ getScan(scanId: string): Promise; /** * Get scans for a project (by path or hash) */ getScansForProject(projectPathOrHash: string): Promise; /** * Get scans for an organization */ getScansForOrg(orgName: string): Promise; /** * Get recent scans */ getRecentScans(limit?: number): Promise; /** * Get successful scans with high scores (case study candidates) */ getCaseStudyCandidates(minScore?: number): Promise; /** * Get all unique organizations */ getOrganizations(): Promise; /** * Get analytics summary */ getAnalytics(): Promise; /** * Export registry to JSON */ exportToJson(): Promise; /** * Export analytics to JSON */ exportAnalyticsToJson(): Promise; /** * Get total scan count */ getCount(): Promise; /** * Clear all records (use with caution) */ clear(): Promise; } /** * Get the singleton registry instance */ export declare function getRegistry(storagePath?: string): ScanRegistry; /** * Reset the singleton (for testing) */ export declare function resetRegistry(): void; //# sourceMappingURL=registry.d.ts.map