summaryrefslogtreecommitdiff
path: root/plugins/claude-security/scripts/lib/plugin.py
diff options
context:
space:
mode:
authorBryan Thompson <238056179+bryan-anthropic@users.noreply.github.com>2026-08-20 14:50:15 -0500
committerGitHub <noreply@github.com>2026-08-20 14:50:15 -0500
commit240c4b2c17b19868e880f2bfdd909144d67224e1 (patch)
tree9deddb18cf7c137cd56c93b25763eba0946a7ad6 /plugins/claude-security/scripts/lib/plugin.py
parent81182783dc1c15ae70e8a489b1edee5450b1434d (diff)
parentcbe94d02bc8ea7375e13b39cc400e17eeabfcbee (diff)
Merge branch 'main' into add-unleashadd-unleash
Diffstat (limited to 'plugins/claude-security/scripts/lib/plugin.py')
-rw-r--r--plugins/claude-security/scripts/lib/plugin.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/claude-security/scripts/lib/plugin.py b/plugins/claude-security/scripts/lib/plugin.py
new file mode 100644
index 00000000..c5daa153
--- /dev/null
+++ b/plugins/claude-security/scripts/lib/plugin.py
@@ -0,0 +1,31 @@
+"""The plugin's fixed names, and its own manifest."""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+
+from . import strictjson
+from .strictjson import is_map, is_str
+
+NAME = "claude-security"
+ROOT = Path(__file__).resolve().parents[2]
+RUN_DIR_NAME = ".claude-security-run"
+MODES = ("scan", "changes", "commit")
+REPORT_DIR_PREFIX = "CLAUDE-SECURITY-"
+# \Z, not $: `$` also matches before a trailing newline, and this id names product files.
+SHA_RE = re.compile(r"^[0-9a-fA-F]{7,64}\Z")
+
+
+def version() -> str | None:
+ """The non-blank version string in the plugin's manifest, or None when there is not one."""
+ try:
+ manifest = strictjson.load(ROOT / ".claude-plugin" / "plugin.json")
+ except (OSError, ValueError):
+ return None
+ if not is_map(manifest):
+ return None
+ declared = manifest.get("version")
+ if not is_str(declared):
+ return None
+ return declared.strip() or None