summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMohamed Hegazy <mhegazy@anthropic.com>2026-11-09 19:39:42 +0000
committerClaude <noreply@anthropic.com>2026-11-09 23:02:54 +0000
commit9ea2fbca5b6c62113e011a8f183bb336a26f9883 (patch)
tree91c7dda10972ab95c257c66e313c224aee5dfb9f /plugins
parent252ccd72713b8967f4bdd213665ee1122ca9ac77 (diff)
security-guidance: keep the user's own rules out of the commit count testsmhegazy/sg-custom-rule-counts
Co-authored-by: mhegazy <mhegazy@anthropic.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/security-guidance/tests/test_turn_commits_metric.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/security-guidance/tests/test_turn_commits_metric.py b/plugins/security-guidance/tests/test_turn_commits_metric.py
index fd74b082..cf3dc99a 100644
--- a/plugins/security-guidance/tests/test_turn_commits_metric.py
+++ b/plugins/security-guidance/tests/test_turn_commits_metric.py
@@ -25,6 +25,16 @@ def _session_id_from_the_payload(monkeypatch):
monkeypatch.delenv("CLAUDE_CODE_REMOTE_SESSION_ID", raising=False)
+@pytest.fixture(autouse=True)
+def _home_without_user_rules(tmp_path, monkeypatch):
+ """A home directory without the user's own rules, whose keys could fill the row."""
+ home = tmp_path / "home"
+ home.mkdir()
+ monkeypatch.setenv("HOME", str(home))
+ monkeypatch.setenv("USERPROFILE", str(home))
+ monkeypatch.delenv("CLAUDE_CONFIG_DIR", raising=False)
+
+
def session_state_file(hook_env):
[path] = [p for p in Path(hook_env["SECURITY_WARNINGS_STATE_DIR"]).glob("security_warnings_state_*.json")]
return path
@@ -358,7 +368,6 @@ def test_parts_are_capped(tmp_path, monkeypatch):
def test_old_commit_records_are_removed(tmp_path, monkeypatch):
monkeypatch.setenv("SECURITY_WARNINGS_STATE_DIR", str(tmp_path))
- monkeypatch.setenv("HOME", str(tmp_path))
diffstate.note_seen_commits("s1", ["abc1234"])
diffstate.note_seen_commits("s2", ["abc1234"])
os.utime(session_state.get_commit_log_file("s1"), (1, 1))