{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/tools\/ki-protokoll\/claude-hook\/quality\/pre_rules_security.py",
"limit": 50
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/tools\/ki-protokoll\/claude-hook\/quality\/pre_rules_security.py",
"content": "#!\/usr\/bin\/env python3\n\"\"\"\nPre-Hook Security Regeln (BLOCK) - MVC + Layer Violations + DIP.\n\nP2.x Regeln: MVC-Trennung, keine SQL in Controller\nP6.x Regeln: SOLID + DIP Layer-Violations\nH-Regeln: Legacy Architecture Guards\n\"\"\"\n\nimport re\nfrom typing import Optional\nfrom .rule_base import GLOBAL_ALLOWLIST, is_in_allowlist\n\n\n# =============================================================================\n# ALLOWLIST\n# =============================================================================\n\nFACTORY_ALLOWLIST = [\n \"\/Factory\/\",\n \"\/Bootstrap\/\",\n]\n\n\n# =============================================================================\n# HELPER FUNCTIONS\n# =============================================================================\n\ndef block(rule_id: str, message: str) -> dict:\n \"\"\"Erzeugt Block-Response.\"\"\"\n return {\n \"allowed\": False,\n \"message\": f\"QUALITY VIOLATION [{rule_id}]: {message}\"\n }\n\n\n# =============================================================================\n# PRÜFUNG 2: MVC + CRUD\n# =============================================================================\n\ndef p2_1_no_sql_in_controller(file_path: str, content: str) -> Optional[dict]:\n \"\"\"P2.1: Keine SQL-Statements in Controller.\"\"\"\n if \"\/Controller\/\" not in file_path:\n return None\n if is_in_allowlist(file_path, GLOBAL_ALLOWLIST):\n return None\n\n sql_patterns = [\n r\"\\bSELECT\\s+.+\\s+FROM\\b\",\n r\"\\bINSERT\\s+INTO\\b\",",
"numLines": 50,
"startLine": 1,
"totalLines": 233
}
}
}