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

Function test_blocklist_enforcement

test_security.py:382–399  ·  view source on GitHub ↗

Test blocklist enforcement in security hook.

()

Source from the content-addressed store, hash-verified

380
381
382def test_blocklist_enforcement():
383 """Test blocklist enforcement in security hook."""
384 print("\nTesting blocklist enforcement:\n")
385 passed = 0
386 failed = 0
387
388 # All blocklisted commands should be rejected
389 for cmd in ["sudo apt install", "shutdown now", "dd if=/dev/zero", "aws s3 ls"]:
390 input_data = {"tool_name": "Bash", "tool_input": {"command": cmd}}
391 result = asyncio.run(bash_security_hook(input_data))
392 if result.get("decision") == "block":
393 print(f" PASS: Blocked {cmd.split()[0]}")
394 passed += 1
395 else:
396 print(f" FAIL: Should block {cmd.split()[0]}")
397 failed += 1
398
399 return passed, failed
400
401
402def test_project_commands():

Callers 1

mainFunction · 0.85

Calls 1

bash_security_hookFunction · 0.90

Tested by

no test coverage detected