tasq/node_modules/@claude-flow/aidefence/dist/domain/services/threat-detection-service.d.ts

81 lines
2.0 KiB
TypeScript

/**
* Threat Detection Service
*
* Core detection logic for AI manipulation attempts.
* Embedded implementation based on AIMDS patterns.
*
* Performance targets:
* - Detection: <10ms
* - Pattern matching: <5ms
* - PII scan: <3ms
*/
import { ThreatType, ThreatSeverity, ThreatDetectionResult } from '../entities/threat.js';
/**
* Threat pattern definition
*/
interface ThreatPattern {
readonly pattern: RegExp;
readonly type: ThreatType;
readonly severity: ThreatSeverity;
readonly description: string;
readonly baseConfidence: number;
}
/**
* Threat Detection Service
*/
export declare class ThreatDetectionService {
private readonly patterns;
private detectionCount;
private totalDetectionTimeMs;
constructor(customPatterns?: ThreatPattern[]);
/**
* Detect threats in input text
* Target: <10ms latency
*/
detect(input: string): ThreatDetectionResult;
/**
* Quick scan - pattern matching only
* Target: <5ms latency
*/
quickScan(input: string): {
threat: boolean;
confidence: number;
};
/**
* Detect PII in text
*/
detectPII(input: string): boolean;
/**
* Get detection statistics
*/
getStats(): {
detectionCount: number;
avgDetectionTimeMs: number;
};
/**
* Normalize input for consistent detection
*/
private normalizeInput;
/**
* Calculate confidence with contextual factors
*/
private calculateConfidence;
/**
* Adjust severity based on confidence
*/
private adjustSeverity;
/**
* Deduplicate threats by type
*/
private deduplicateThreats;
/**
* Hash input for caching/deduplication
*/
private hashInput;
}
/**
* Create a new ThreatDetectionService instance
*/
export declare function createThreatDetectionService(customPatterns?: ThreatPattern[]): ThreatDetectionService;
export {};
//# sourceMappingURL=threat-detection-service.d.ts.map