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

Function test_pattern_matching

test_security_integration.py:207–237  ·  view source on GitHub ↗

Test that wildcard patterns work correctly.

()

Source from the content-addressed store, hash-verified

205
206
207def test_pattern_matching():
208 """Test that wildcard patterns work correctly."""
209 print("\n" + "=" * 70)
210 print("TEST 5: Pattern matching (swift*)")
211 print("=" * 70)
212
213 with tempfile.TemporaryDirectory() as tmpdir:
214 project_dir = Path(tmpdir)
215
216 # Create project config with swift* pattern
217 autoforge_dir = project_dir / ".autoforge"
218 autoforge_dir.mkdir()
219 (autoforge_dir / "allowed_commands.yaml").write_text("""version: 1
220commands:
221 - name: swift*
222 description: All Swift tools
223""")
224
225 # Try to run swiftlint (should match swift* pattern)
226 input_data = {"tool_name": "Bash", "tool_input": {"command": "swiftlint"}}
227 context = {"project_dir": str(project_dir)}
228
229 result = asyncio.run(bash_security_hook(input_data, context=context))
230
231 if result.get("decision") != "block":
232 print("✅ PASS: swiftlint matched swift* pattern")
233 return True
234 else:
235 print("❌ FAIL: swiftlint should have matched swift*")
236 print(f" Reason: {result.get('reason', 'N/A')}")
237 return False
238
239
240def test_org_blocklist_enforcement():

Callers

nothing calls this directly

Calls 1

bash_security_hookFunction · 0.90

Tested by

no test coverage detected