/** * @fileoverview Report Aggregator for Multiple Scan Results * @module @nahisaho/musubix-security/integrations/report-aggregator * * Aggregates multiple security scan results into unified reports * with trend analysis and comparison capabilities. */ import type { ScanResult, Severity, Vulnerability } from '../types/index.js'; /** * Aggregated scan entry */ export interface AggregatedScanEntry { /** Scan identifier */ id: string; /** Scan timestamp */ timestamp: Date; /** Scan target/source */ source: string; /** Scan type */ type: ScanType; /** Original scan result */ result: ScanResult; /** Metadata */ metadata?: Record; } /** * Scan type classification */ export type ScanType = 'vulnerability' | 'secret' | 'dependency' | 'compliance' | 'container' | 'iac' | 'api' | 'full'; /** * Report aggregator options */ export interface ReportAggregatorOptions { /** Deduplicate similar findings */ deduplicate?: boolean; /** Similarity threshold for deduplication (0-1) */ similarityThreshold?: number; /** Group by file/rule/severity */ groupBy?: 'file' | 'rule' | 'severity' | 'category'; /** Include historical comparison */ includeHistory?: boolean; /** Maximum history entries to keep */ maxHistoryEntries?: number; } /** * Aggregated report */ export interface AggregatedReport { /** Report generation timestamp */ generatedAt: Date; /** Report ID */ reportId: string; /** Summary statistics */ summary: AggregatedSummary; /** All findings (deduplicated if enabled) */ findings: AggregatedFinding[]; /** Grouped findings */ groupedFindings: GroupedFindings; /** Scan sources */ sources: ScanSource[]; /** Trend data */ trends: TrendData; /** Comparison with previous */ comparison?: ReportComparison; } /** * Aggregated summary */ export interface AggregatedSummary { /** Total scans aggregated */ totalScans: number; /** Total unique findings */ totalFindings: number; /** Findings by severity */ bySeverity: Record; /** Findings by type */ byType: Record; /** Files affected */ filesAffected: number; /** Rules triggered */ rulesTriggered: number; /** Overall security score */ securityScore: number; /** Risk level */ riskLevel: 'critical' | 'high' | 'medium' | 'low' | 'minimal'; } /** * Aggregated finding */ export interface AggregatedFinding { /** Finding ID */ id: string; /** Original vulnerability */ vulnerability: Vulnerability; /** Sources where this finding was detected */ sources: string[]; /** Occurrence count */ occurrences: number; /** First seen timestamp */ firstSeen: Date; /** Last seen timestamp */ lastSeen: Date; /** Is new (not in previous report) */ isNew: boolean; /** Is fixed (was in previous, not in current) */ isFixed: boolean; /** Fingerprint for deduplication */ fingerprint: string; } /** * Grouped findings by category */ export interface GroupedFindings { /** Findings grouped by file */ byFile: Map; /** Findings grouped by rule */ byRule: Map; /** Findings grouped by severity */ bySeverity: Map; /** Findings grouped by OWASP category */ byCategory: Map; } /** * Scan source metadata */ export interface ScanSource { /** Source identifier */ id: string; /** Scan type */ type: ScanType; /** Timestamp */ timestamp: Date; /** Target scanned */ target: string; /** Finding count from this source */ findingCount: number; } /** * Trend data over time */ export interface TrendData { /** Data points */ dataPoints: TrendDataPoint[]; /** Trend direction */ direction: 'improving' | 'stable' | 'degrading'; /** Change percentage */ changePercent: number; /** Projected risk (if trend continues) */ projectedRisk: string; } /** * Single trend data point */ export interface TrendDataPoint { /** Timestamp */ timestamp: Date; /** Total findings */ totalFindings: number; /** Critical findings */ criticalFindings: number; /** Security score */ securityScore: number; } /** * Comparison with previous report */ export interface ReportComparison { /** New findings */ newFindings: AggregatedFinding[]; /** Fixed findings */ fixedFindings: AggregatedFinding[]; /** Unchanged findings */ unchangedFindings: AggregatedFinding[]; /** Finding count change */ findingDelta: number; /** Security score change */ scoreDelta: number; /** Summary text */ summaryText: string; } /** * Aggregates multiple security scan results * * @example * ```typescript * const aggregator = createReportAggregator({ * deduplicate: true, * groupBy: 'severity', * }); * * aggregator.addScan('vuln-scan', scanResult1, 'vulnerability'); * aggregator.addScan('secret-scan', scanResult2, 'secret'); * * const report = aggregator.generateReport(); * ``` */ export declare class ReportAggregator { private options; private scans; private history; private scanCounter; constructor(options?: ReportAggregatorOptions); /** * Add a scan result to the aggregator */ addScan(source: string, result: ScanResult, type?: ScanType, metadata?: Record): string; /** * Remove a scan by ID */ removeScan(id: string): boolean; /** * Clear all scans */ clear(): void; /** * Generate aggregated report */ generateReport(): AggregatedReport; /** * Get scan count */ getScanCount(): number; /** * Get history */ getHistory(): AggregatedReport[]; /** * Export report as JSON */ exportJSON(report: AggregatedReport): string; /** * Export report as Markdown */ exportMarkdown(report: AggregatedReport): string; private aggregateFindings; private deduplicateFindings; private groupFindings; private generateSummary; private generateSources; private generateTrends; private compareWithPrevious; private generateFingerprint; private calculateSimilarity; private calculateSecurityScore; } /** * Create a report aggregator */ export declare function createReportAggregator(options?: ReportAggregatorOptions): ReportAggregator; //# sourceMappingURL=report-aggregator.d.ts.map