Answer security round 1: 0 🔴, 1 🟡 (0 misread); keep the hooks in settings.json on their full path, so a session started outside the loop still runs them
CI / tests (pull_request) Successful in 4m36s
CI / tests (pull_request) Successful in 4m36s
This commit is contained in:
@@ -10,6 +10,8 @@ BY_ITS_FOLDER = re.compile(r"(?:~|\$HOME)/\.claude/bin/[\w.<>-]+(?![\w.<>/-])")
|
||||
HISTORY = ("CHANGELOG.md", "todo.md", "docs/")
|
||||
# README.md → Install links loop-claude and compress-archives from a shell and a crontab, which lack the tools, and says how to run any other tool there.
|
||||
INSTALL = {"~/.claude/bin/loop-claude", "$HOME/.claude/bin/compress-archives", "~/.claude/bin/<tool>"}
|
||||
# settings.json names its hooks and its status line by their folder, and the test of the reviewer hook quotes it. Claude Code reads the file in every session, also one the human starts without the tools on PATH. A hook it cannot find doesn't refuse anything, so a bare name there would switch rule-hook off in that session.
|
||||
SETTINGS = ("settings.json", "bin/review_rules/test_reviewer_context.py")
|
||||
|
||||
|
||||
class ToolsNamedBare(unittest.TestCase):
|
||||
@@ -19,7 +21,7 @@ class ToolsNamedBare(unittest.TestCase):
|
||||
found = []
|
||||
for name in str(tracked).splitlines():
|
||||
path = ROOT / name
|
||||
if name.startswith(HISTORY) or name == "bin/repo_checks/test_tools_named_bare.py" or not path.is_file():
|
||||
if name.startswith(HISTORY) or name in SETTINGS or name == "bin/repo_checks/test_tools_named_bare.py" or not path.is_file():
|
||||
continue
|
||||
for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1):
|
||||
found += [f"{name}:{number}: {spelled}" for spelled in BY_ITS_FOLDER.findall(line) if not (name == "README.md" and spelled in INSTALL)]
|
||||
|
||||
@@ -97,7 +97,7 @@ class Reviewers(unittest.TestCase):
|
||||
|
||||
def test_settings_run_the_hook_as_each_subagent_starts(self):
|
||||
hooks = json.loads((REPO / "settings.json").read_text())["hooks"]["SubagentStart"]
|
||||
self.assertEqual(hooks, [{"hooks": [{"command": "larv-review reviewer-context", "timeout": 30, "type": "command"}]}])
|
||||
self.assertEqual(hooks, [{"hooks": [{"command": "~/.claude/bin/larv-review reviewer-context", "timeout": 30, "type": "command"}]}])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user