/** * Security Payload Tester * Executes security tests with payloads against MCP tools * * Extracted from SecurityAssessor.ts for maintainability. * Handles test execution, batching, and progress tracking. */ import { SecurityTestResult, ToolAnnotationsContext } from "../../../../lib/assessmentTypes.js"; import { ProgressCallback } from "../../../../lib/assessment/progressTypes.js"; import { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js"; import { SecurityPayload } from "../../../../lib/securityPatterns.js"; /** * Re-export ProgressCallback for external use */ export type TestProgressCallback = ProgressCallback; /** * Configuration for payload testing */ export interface PayloadTestConfig { enableDomainTesting?: boolean; maxParallelTests?: number; securityTestTimeout?: number; selectedToolsForTesting?: string[]; /** * Maximum retry attempts for transient errors (Issue #157) * Uses PerformanceConfig.securityRetryMaxAttempts if not specified */ securityRetryMaxAttempts?: number; /** * Initial backoff delay in ms for retries (Issue #157) * Uses PerformanceConfig.securityRetryBackoffMs if not specified */ securityRetryBackoffMs?: number; /** * Tool annotations context for severity adjustment (Issue #170) * When provided, enables annotation-aware false positive reduction */ toolAnnotationsContext?: ToolAnnotationsContext; /** * Transport type for context-aware test skipping * When "http" or "sse", skip filesystem-only tests (e.g., Path Traversal) */ transportType?: "stdio" | "http" | "sse"; } /** * Logger interface for test execution */ export interface TestLogger { log: (message: string) => void; logError: (message: string, error: unknown) => void; } /** * Executes security tests with payloads against MCP tools */ export declare class SecurityPayloadTester { private config; private logger; private executeWithTimeout; private responseAnalyzer; private payloadGenerator; private sanitizationDetector; private testCount; constructor(config: PayloadTestConfig, logger: TestLogger, executeWithTimeout: (promise: Promise, timeout: number) => Promise); /** * Set tool annotations context for severity adjustment (Issue #170) * Call before running tests to enable annotation-aware false positive reduction */ setToolAnnotationsContext(context: ToolAnnotationsContext | undefined): void; /** * Set transport type for context-aware test skipping (FP reduction) * Call before running tests to skip irrelevant patterns */ setTransportType(transportType: "stdio" | "http" | "sse" | undefined): void; /** * Check if an attack pattern should be skipped for a given tool. * Reduces false positives by skipping irrelevant test categories. */ private shouldSkipPattern; /** * Run comprehensive security tests (advanced mode) * Tests selected tools with ALL 23 security patterns using diverse payloads */ runUniversalSecurityTests(tools: Tool[], callTool: (name: string, params: Record) => Promise, onProgress?: TestProgressCallback): Promise; /** * Run basic security tests (fast mode) * Tests only 5 critical injection patterns with 1 generic payload each */ runBasicSecurityTests(tools: Tool[], callTool: (name: string, params: Record) => Promise, onProgress?: TestProgressCallback): Promise; /** * Test tool with a specific payload */ testPayload(tool: Tool, attackName: string, payload: SecurityPayload, callTool: (name: string, params: Record) => Promise): Promise; /** * Test payload with retry logic for transient errors. * Implements exponential backoff: 100ms → 200ms → 400ms * * Issue #157: Connection retry logic for reliability * * @param tool - Tool to test * @param attackName - Name of attack pattern * @param payload - Security payload to test * @param callTool - Function to call the tool * @returns SecurityTestResult with retry metadata if applicable */ testPayloadWithRetry(tool: Tool, attackName: string, payload: SecurityPayload, callTool: (name: string, params: Record) => Promise): Promise; /** * Add retry metadata to result. * Issue #157: Track retry attempts for reliability metrics */ private addRetryMetadata; /** * Extract error message from caught exception */ private extractErrorMessage; /** * Sleep for specified milliseconds */ private sleep; } //# sourceMappingURL=SecurityPayloadTester.d.ts.map