/** * @name security/unsafe-action-guard * @description Detects potentially dangerous Solana operations before execution. * * Validates actions against a program whitelist, unsafe pattern blacklist, * value thresholds, privilege escalation attempts, and reentrancy risks. * Returns a structured safety verdict with risk level classification. * * @flow * 1. Tool handlers call `unsafeActionGuard` before executing on-chain actions. * 2. If the guard returns `safe: false`, the tool blocks execution. * 3. `getRiskScore` provides a numeric risk score (0–100) for logging/metrics. * * @module security/unsafe-action-guard */ import type { SapMcpContext } from '../../core/src/types.js'; /** * @name unsafeActionGuard * @description Evaluates whether an action is safe to execute on-chain. * * Checks (in order): unsafe pattern matching, program whitelist, value thresholds, * privilege escalation attempts, and reentrancy risks. * * @param context — SAP MCP runtime context with config thresholds. * @param action — Action name string to evaluate. * @param metadata — Optional metadata including `programId`, `valueSol`, and `accounts`. * @returns Safety verdict with `safe` boolean, optional `reason`, and `riskLevel` (`low`, `medium`, `high`, `critical`). * * @usedBy Tool handlers across the SAP MCP runtime. */ export declare function unsafeActionGuard(context: SapMcpContext, action: string, metadata?: { programId?: string; valueSol?: number; accounts?: string[]; }): { safe: boolean; reason?: string; riskLevel?: 'low' | 'medium' | 'high' | 'critical'; }; /** * @name getRiskScore * @description Computes a numeric risk score (0–100) for an action based on the guard verdict * and action characteristics. * * @param context — SAP MCP runtime context with config thresholds. * @param action — Action name string to evaluate. * @param metadata — Optional metadata including `programId`, `valueSol`, and `accounts`. * @returns Risk score from 0 (safe) to 100 (critical). Blocked actions return 25–100 based on * risk level; safe actions return 10–60 based on write operations and value. * * @usedBy Tool handlers and metrics collection in the SAP MCP runtime. */ export declare function getRiskScore(context: SapMcpContext, action: string, metadata?: Parameters[2]): number; //# sourceMappingURL=unsafe-action-guard.d.ts.map