MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / check_hook

Function check_hook

test_security.py:74–94  ·  view source on GitHub ↗

Check a single command against the security hook (helper function).

(command: str, should_block: bool)

Source from the content-addressed store, hash-verified

72
73
74def check_hook(command: str, should_block: bool) -> bool:
75 """Check a single command against the security hook (helper function)."""
76 input_data = {"tool_name": "Bash", "tool_input": {"command": command}}
77 result = asyncio.run(bash_security_hook(input_data))
78 was_blocked = result.get("decision") == "block"
79
80 if was_blocked == should_block:
81 status = "PASS"
82 else:
83 status = "FAIL"
84 expected = "blocked" if should_block else "allowed"
85 actual = "blocked" if was_blocked else "allowed"
86 reason = result.get("reason", "")
87 print(f" {status}: {command!r}")
88 print(f" Expected: {expected}, Got: {actual}")
89 if reason:
90 print(f" Reason: {reason}")
91 return False
92
93 print(f" {status}: {command!r}")
94 return True
95
96
97def test_extract_commands():

Callers 1

mainFunction · 0.85

Calls 1

bash_security_hookFunction · 0.90

Tested by

no test coverage detected