/** * False Positive Filter * * Context-aware filtering to reduce false positives from scanners. * Analyzes code context, semantic patterns, and historical data. * * @module scanners/fp-filter */ import type { DeterministicFinding } from "./types.js"; /** * Context information for filtering decisions */ export interface FPFilterContext { /** File-level context */ codeContext: { isTestFile: boolean; isGeneratedCode: boolean; isThirdPartyVendored: boolean; isMockFile: boolean; isFixtureFile: boolean; isExampleFile: boolean; }; /** Semantic context from code analysis */ semanticContext: { hasValidation: boolean; hasEncoding: boolean; isSanitized: boolean; isConstant: boolean; isEnvironmentVariable: boolean; }; /** Historical FP data */ historicalContext: { previousFPs: string[]; ruleAccuracy: number; suppressions: string[]; }; } /** * Result of filtering decision */ export interface FilterResult { /** Whether to filter out this finding */ filter: boolean; /** Reason for filtering (if filtered) */ reason?: string; /** Confidence in the filtering decision (0-100) */ confidence: number; /** Suggested action */ suggestion?: "suppress" | "review" | "confirm"; } /** * Directories excluded by default from code scanners (Bandit, Gosec, Brakeman). * These contain test fixtures, generated artefacts, and vendored code that * routinely trigger FPs (e.g. B101 assert_used in tests/). * * NOT applied to the secrets scanner — secrets in test dirs can be real leaks. */ export declare const DEFAULT_EXCLUDED_DIRS: readonly string[]; /** * Analyze file path to determine code context */ export declare function analyzeFilePath(filePath: string): FPFilterContext["codeContext"]; /** * Analyze code content for semantic context */ export declare function analyzeCodeContext(projectPath: string, finding: DeterministicFinding): Promise; /** * Determine if a finding should be filtered as a false positive */ export declare function shouldFilter(finding: DeterministicFinding, context: FPFilterContext): FilterResult; /** * Filter findings and return filtered results with reasons */ export declare function filterFindings(projectPath: string, findings: DeterministicFinding[], options?: { historicalData?: Map; minConfidence?: number; }): Promise<{ filtered: DeterministicFinding[]; removed: Array<{ finding: DeterministicFinding; reason: string; confidence: number; }>; stats: { total: number; kept: number; filtered: number; byReason: Record; }; }>; /** * Get suggested suppressions for a finding */ export declare function getSuppressSuggestion(finding: DeterministicFinding, context: FPFilterContext): { suppressionComment: string; inlineSuppress: string; fileSuppress: string; }; //# sourceMappingURL=fp-filter.d.ts.map