summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-11-10 18:06:29 +0000
committerClaude <noreply@anthropic.com>2026-11-10 18:06:29 +0000
commit3882490d47e95095aed7ecd0ecfda7b4080bd0e7 (patch)
tree012be8433b156bd4216d310dbb7e67f04d9d2e66 /plugins
parentc5b331fc98841f8050ec498393ef210b0eb10f13 (diff)
Keep the regex limit reset apart from the rest of session load
Co-authored-by: mhegazy <mhegazy@anthropic.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/security-guidance/hooks/extensibility.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/security-guidance/hooks/extensibility.py b/plugins/security-guidance/hooks/extensibility.py
index 79d4c43e..ad3c7e61 100644
--- a/plugins/security-guidance/hooks/extensibility.py
+++ b/plugins/security-guidance/hooks/extensibility.py
@@ -78,10 +78,8 @@ def load_for_session(cwd: Optional[str]) -> None:
Called from the hook's main() before dispatching. Failures are non-fatal —
a malformed config file produces a debug_log entry, never a crash.
"""
- global _guidance_block, _user_patterns, _refused_regexes, _regex_seconds_left
+ global _guidance_block, _user_patterns, _refused_regexes
_refused_regexes = 0
- _regex_seconds_left = REGEX_TIME_LIMIT_S
- _stopped_regexes.clear()
try:
_guidance_block = _wrap_guidance(_load_guidance(cwd))
except Exception as e:
@@ -92,6 +90,7 @@ def load_for_session(cwd: Optional[str]) -> None:
except Exception as e:
debug_log(f"extensibility: failed to load security-patterns: {e}")
_user_patterns = []
+ _reset_regex_limit()
def guidance_block() -> str:
@@ -605,6 +604,12 @@ for regex in job["regexes"]:
"""
+def _reset_regex_limit() -> None:
+ global _regex_seconds_left
+ _regex_seconds_left = REGEX_TIME_LIMIT_S
+ _stopped_regexes.clear()
+
+
def search_custom_regexes(regexes: List[str], content: str) -> List[bool]:
"""Whether each regex is found in content. A regex that does not finish in
time counts as not found and is left out for the rest of this hook run;