""" Security Edge Case Test Configuration Shared fixtures and utilities for testing security vulnerabilities and attack patterns. Tests simulate malicious inputs to verify Atom platform security controls prevent exploitation. Security categories tested: - SQL injection attempts (OWASP A03:2021) - XSS attacks (OWASP A03:2021) - Prompt injection and jailbreaks (OWASP LLM Top 10) - Governance bypass attempts (OWASP A01:2021) - DoS protection (OWASP A04:2021) """ import pytest import logging from typing import Any, Dict, List from unittest.mock import patch, MagicMock, AsyncMock from sqlalchemy.orm import Session import time logger = logging.getLogger(__name__) # ============================================================================ # SQL Injection Payloads (OWASP Top 10) # ============================================================================ @pytest.fixture def sql_injection_payloads(): """ SQL injection payloads for testing input validation. Source: OWASP Top 10 2021 - A03: Injection """ return [ "'; DROP TABLE agents; --", "' OR '1'='1", "1' UNION SELECT * FROM users --", "'; INSERT INTO agents VALUES ('hacked', 'admin'); --", "1'; DELETE FROM episodes WHERE '1'='1' --", "' OR '1'='1' --", "admin'--", "admin'/*", "' OR 1=1#", "' UNION SELECT NULL,NULL,NULL--", "1' ORDER BY 1--", "'; EXEC xp_cmdshell('dir'); --", "1' AND 1=1--", "1' AND 1=2--", "' OR 'x'='x", ] @pytest.fixture def sql_injection_agent_ids(): """SQL injection payloads specifically for agent_id parameter.""" return [ "'; DROP TABLE agents; --", "' OR '1'='1", "1' UNION SELECT * FROM users --", "'; INSERT INTO agents VALUES ('hacked', 'admin'); --", "1'; DELETE FROM episodes WHERE '1'='1' --", ] @pytest.fixture def sql_injection_names(): """SQL injection payloads specifically for name parameter.""" return [ "'; DROP TABLE users; --", "' OR '1'='1", "", "$(whoami)", "`cat /etc/passwd`", ] # ============================================================================ # XSS Payloads (OWASP Top 10) # ============================================================================ @pytest.fixture def xss_payloads(): """ XSS (Cross-Site Scripting) payloads for testing output sanitization. Source: OWASP Top 10 2021 - A03: Injection """ return [ "", "", "javascript:alert('xss')", "", "'\">", "", "", "", "