Refuse a security-review or claude-security Skill call from the worker's own context below the project's rung

This commit is contained in:
2026-10-30 13:10:56 +01:00
parent 0bb6f54a3c
commit a212b4ef91
9 changed files with 63 additions and 13 deletions
+25
View File
@@ -315,6 +315,31 @@ class ReviewerRung(unittest.TestCase):
def test_a_claude_loop_claude_did_not_start_is_not_checked(self):
self.assertEqual(self.refused({"subagent_type": "stability-reviewer", "model": "haiku", "effort": "low"}, {}), [])
def test_a_security_skill_in_the_sessions_own_context_runs_on_the_workers_rung(self):
for skill in ("security-review", "claude-security", "claude-security:claude-security"):
with self.subTest(skill=skill):
breaches = reviewer_breaches(Call("Skill", {"skill": skill}, "/r"), self.ENVIRON)
self.assertEqual(rules(breaches), ["reviewer-rung"])
self.assertIn("claude-sonnet-5-5 at high effort", breaches[0].detail)
self.assertIn("model opus, effort medium", breaches[0].detail)
self.assertIn("You are the security pass for this chunk.", breaches[0].detail)
self.assertEqual(rules(reviewer_breaches(Call("Skill", {"skill": skill}, "/r"), self.ABOVE)), [])
def test_a_security_skill_inside_a_subagent_runs_on_the_rung_its_launch_was_held_to(self):
self.assertEqual(rules(reviewer_breaches(Call("Skill", {"skill": "security-review"}, "/r", "general-purpose"), self.ENVIRON)), [])
def test_any_other_skill_is_not_checked(self):
self.assertEqual(rules(reviewer_breaches(Call("Skill", {"skill": "simplify"}, "/r"), self.ENVIRON)), [])
def test_a_skill_calls_args_are_the_text_scanned_for_a_marker(self):
found = breaches_of(Call("Skill", {"skill": "security-review", "args": "the branch # rule-override reviewer-rung: trust me"}, "/r"), "/h", {})
self.assertEqual(found[:2], ("the branch # rule-override reviewer-rung: trust me", "security-review"))
def test_settings_run_the_hook_before_each_skill_call(self):
settings = json.loads(pathlib.Path(__file__).resolve().parents[2].joinpath("settings.json").read_text())
matchers = [entry["matcher"].split("|") for entry in settings["hooks"]["PreToolUse"]]
self.assertTrue(any("Skill" in tools for tools in matchers))
class ReviewerReport(unittest.TestCase):
def breached(self, tool: str, path: str, agent: str = "prose-reviewer", cwd: str = "/r") -> list[str]: