plugin_guard.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. #!/usr/bin/env python3
  2. """Plugin Guard — ``skills_guard`` engine applied to ``hermes plugins install``/``update``.
  3. Plugins run in-process but are *expected* to read their own env keys, call provider APIs
  4. and spawn subprocesses, so: full pattern set on docs/config files (where prompt-injection
  5. lives); the "reads own secret"/"HTTP call with key" family exempt on *code* files;
  6. plugin-sized structural limits; VCS/venv noise skipped. ``safe`` installs, ``caution``
  7. needs confirmation, ``dangerous`` is blocked and ``--force`` does NOT override.
  8. """
  9. from __future__ import annotations
  10. import ast
  11. import os
  12. import subprocess
  13. from datetime import datetime, timezone, UTC
  14. from pathlib import Path
  15. from typing import Iterator, List, Optional, Tuple
  16. from tools.plugin_guard_context import (
  17. STEP_DOWN, catalog_cap, is_agent_facing, is_authorized_keys_prose, is_base64_archive_roundtrip,
  18. is_base64_media, is_benign_lazy_os_import, is_ci_workflow, is_coin_name_only,
  19. is_disclosed_config_note, is_doc_prose, is_env_dump_in_safety_clause, is_hex_in_char_class,
  20. is_inert_fixture_line, is_json_prose_value, is_locale_catalog, is_loopback_continuation,
  21. is_loopback_only, is_own_proc_read, is_pip_install_in_prose_literal, is_public_client_key,
  22. is_quoted_injection_phrase, is_regex_alternation_token, is_repo_root_traversal,
  23. is_self_uninstall_doc, is_sudo_inert, is_test_tree, is_trusted_installer_pipe, logical_line, prose_cap)
  24. from tools.skills_guard import (
  25. Finding, ScanResult, SUSPICIOUS_BINARY_EXTENSIONS, _determine_verdict, format_scan_report,
  26. scan_file)
  27. PLUGIN_SCANNER_VERSION = "plugin-guard-v12"
  28. # Never scanned: VCS internals, caches, vendored envs.
  29. EXCLUDED_DIRS = {
  30. ".git", "__pycache__", "node_modules", ".venv", "venv",
  31. ".mypy_cache", ".pytest_cache", ".ruff_cache", ".tox"}
  32. # Test trees ARE scanned (``plugins_loader`` sets ``submodule_search_locations`` to the
  33. # plugin root, so ``from .tests import evil`` runs whatever lives there), but findings under
  34. # them step down one severity (``plugin_guard_context.is_test_tree``): fixtures deliberately
  35. # hold hostile strings to prove the plugin rejects them, and an un-overridable ``dangerous``
  36. # made such plugins uninstallable and taught authors to obfuscate their own tests (#89610).
  37. # Code files, where "reads an env secret" / "HTTP call with a key" is normal (requires_env).
  38. CODE_FILE_EXTENSIONS = {".py", ".js", ".ts", ".sh", ".bash", ".rb", ".pl", ".php"}
  39. # Line-comment marker per code extension. Whole-line comments explain intent; hardening
  40. # notes like "# a symlink could point at /etc/passwd" are prose *about* a defense.
  41. COMMENT_PREFIXES_BY_EXTENSION = {
  42. ".py": "#", ".sh": "#", ".bash": "#", ".rb": "#", ".pl": "#", ".r": "#", ".jl": "#",
  43. ".js": "//", ".ts": "//", ".php": "//"}
  44. # One severity step down from the pattern's default.
  45. _COMMENT_SEVERITY_CAP = {"critical": "high", "high": "medium"}
  46. # History, not an agent-facing instruction surface: a hardening entry mentioning the threat
  47. # it fixed ("A symlink could point at /etc/passwd, so ...") is documentation, not the attack.
  48. CHANGELOG_FILENAMES = {"changelog.md"}
  49. # Pattern ids exempt on code files (every legitimate provider plugin trips them); still
  50. # applied in full to docs/config files.
  51. CODE_EXEMPT_PATTERN_IDS = {
  52. "python_environ_get_secret", "python_getenv_secret", "python_os_environ", "node_process_env",
  53. "ruby_env_secret", "env_exfil_httpx", "env_exfil_requests", "env_exfil_fetch",
  54. "env_exfil_curl", "env_exfil_wget",
  55. # Agent-facing instruction patterns are meaningless inside code (prompt docstrings trip them).
  56. "context_exfil", "send_to_url", "fake_policy",
  57. # Plugins legitimately write config.yaml in post_setup and base64 credentials (Basic auth).
  58. "agent_config_mod", "agent_config_contract", "encoded_exfil"}
  59. # Severity remaps: a bundled binary is warn-tier (repos occasionally vendor one); a mere
  60. # ``~/.hermes/.env`` mention is how READMEs say where keys go (READING it still trips
  61. # ``read_secrets_file``, critical); ``curl | sh`` in READMEs is caution, not a hard block.
  62. SEVERITY_REMAP = {
  63. "binary_file": "high", "hermes_env_access": "medium", "curl_pipe_shell": "high"}
  64. # In JS/TS, these text matches cannot distinguish a UI label or DNS lookup
  65. # template from a write or exfiltration operation. Keep them visible and require
  66. # confirmation; do not silently allow them. Shell commands and instructions keep
  67. # their critical severity, as do separate credential-read/exfiltration findings.
  68. JS_CAPABILITY_REMAP = {"dns_exfil": "high", "ssh_backdoor": "high"}
  69. # Plugin scans gate a HOST install: what matters is what executes on the host. Two critical
  70. # families describe the author's own dev workflow when they appear in documentation files, so
  71. # they land at high (caution) there instead of hard-blocking an otherwise auditable plugin; the
  72. # same content in runtime code keeps its critical severity. The generic one-step prose cap for
  73. # command/path-shaped findings lives in ``plugin_guard_context`` (``DOC_PROSE_EXTENSIONS``).
  74. DOC_PROSE_DEMOTIONS = {
  75. # Prose modification bullets ("- Modify: `CLAUDE.md`") in plan/design docs describe the
  76. # repo's own files; only executable intent (shell writes, code) stays critical.
  77. "agent_config_mod": "high",
  78. # Example/demo credentials quoted in docs (placeholder hex, test tokens). Real token-shaped
  79. # literals (sk-, ghp_, AKIA, glpat-, private keys) keep their own critical patterns.
  80. "hardcoded_secret": "high",
  81. }
  82. # A root-level ``if __name__ == "__main__":`` block is the module's own self-test harness:
  83. # ``plugins_loader`` imports plugins and never runs them as scripts, so a sample credential
  84. # quoted there is a fixture, not a shipped secret — the test-tree reasoning applied where a
  85. # root-level runtime file has no ``tests/`` to hold it (#112139). Narrower than the
  86. # test-tree cap because the block is still directly executable code: only the generic
  87. # sample-token pattern is demoted; destructive/persistence/exfil findings and the
  88. # provider-signature patterns (``sk-``, ``AKIA``, ``ghp_`` ...) keep full severity there.
  89. MAIN_GUARD_DEMOTIONS = {"hardcoded_secret": "high"}
  90. # Structural limits — plugins are real codebases, far larger than skills.
  91. MAX_PLUGIN_FILE_COUNT = 400
  92. MAX_PLUGIN_TOTAL_SIZE_KB = 10 * 1024 # 10MB of scannable tree
  93. MAX_PLUGIN_SINGLE_FILE_KB = 1024 # 1MB single file
  94. # Committed bytecode (catalog rule 17): an unchecked-hash or sourceless ``.pyc`` is imported in
  95. # place of the ``.py`` this scanner read, so it is the same reviewable-but-unscannable tier as a
  96. # bundled binary (``SEVERITY_REMAP["binary_file"]``).
  97. _BYTECODE_SUFFIXES = (".pyc", ".pyo")
  98. def _walk(plugin_dir: Path) -> Iterator[tuple[Path, str]]:
  99. """Yield (path, "a/b/c" relative path) for every non-excluded entry under plugin_dir."""
  100. for f in plugin_dir.rglob("*"):
  101. try:
  102. rel_parts = f.relative_to(plugin_dir).parts
  103. except ValueError:
  104. continue
  105. if not any(part in EXCLUDED_DIRS for part in rel_parts):
  106. yield f, "/".join(rel_parts)
  107. def _finding(pattern_id: str, severity: str, category: str, file: str, match: str, description: str) -> Finding:
  108. return Finding(pattern_id, severity, category, file, 0, match, description)
  109. def _is_main_guard(node: ast.If) -> bool:
  110. """Return whether an ``if`` node is the conventional module self-test guard."""
  111. test = node.test
  112. if not isinstance(test, ast.Compare) or len(test.ops) != 1 or not isinstance(test.ops[0], ast.Eq):
  113. return False
  114. if len(test.comparators) != 1:
  115. return False
  116. left, right = test.left, test.comparators[0]
  117. return (
  118. isinstance(left, ast.Name) and left.id == "__name__"
  119. and isinstance(right, ast.Constant) and right.value == "__main__"
  120. ) or (
  121. isinstance(right, ast.Name) and right.id == "__name__"
  122. and isinstance(left, ast.Constant) and left.value == "__main__"
  123. )
  124. def _main_guard_body_lines(file_path: Path) -> set[int]:
  125. """Return lines executed only by ``if __name__ == '__main__'`` blocks.
  126. Invalid Python deliberately returns no lines so its findings retain the
  127. conservative severity.
  128. """
  129. try:
  130. tree = ast.parse(file_path.read_text(encoding="utf-8-sig"))
  131. except (OSError, SyntaxError, ValueError): # ValueError: UnicodeDecodeError, NUL bytes
  132. return set()
  133. lines: set[int] = set()
  134. for node in ast.walk(tree):
  135. if not isinstance(node, ast.If) or not _is_main_guard(node):
  136. continue
  137. for statement in node.body:
  138. lines.update(range(statement.lineno, getattr(statement, "end_lineno", statement.lineno) + 1))
  139. return lines
  140. def _filter_findings(findings: list[Finding], rel_path: str, file_path: Path) -> list[Finding]:
  141. """Apply plugin-specific exemptions and severity remaps to raw findings."""
  142. is_code = Path(rel_path).suffix.lower() in CODE_FILE_EXTENSIONS
  143. main_guard_lines = _main_guard_body_lines(file_path) if file_path.suffix.lower() == ".py" else set()
  144. is_js = Path(rel_path).suffix.lower() in {".js", ".ts"}
  145. # A CI workflow definition runs on the forge's runner, not the host: same cap as a README.
  146. is_ci = is_ci_workflow(rel_path)
  147. doc_prose = is_doc_prose(rel_path) or is_ci
  148. locale_catalog = is_locale_catalog(rel_path)
  149. lines = _file_lines(file_path) if findings else []
  150. out: list[Finding] = []
  151. for f in findings:
  152. if is_code and f.pattern_id in CODE_EXEMPT_PATTERN_IDS:
  153. continue
  154. f.severity = (
  155. (JS_CAPABILITY_REMAP.get(f.pattern_id) if is_js else None)
  156. or SEVERITY_REMAP.get(f.pattern_id) or f.severity
  157. )
  158. if doc_prose and f.pattern_id in DOC_PROSE_DEMOTIONS:
  159. f.severity = DOC_PROSE_DEMOTIONS[f.pattern_id]
  160. line = lines[f.line - 1] if 0 < f.line <= len(lines) else f.match
  161. joined = logical_line(lines, f.line - 1) if 0 < f.line <= len(lines) else line
  162. f.severity = _context_severity(f, rel_path, line, joined, doc_prose or locale_catalog, is_code,
  163. locale_catalog)
  164. if _is_defensive_documentation(f, rel_path):
  165. f.severity = _comment_severity(f)
  166. # A quoted injection phrase in a defensive doc (``"ignore previous instructions"`` in a
  167. # CHANGELOG / code comment describing the filter that refuses it) is a note, not caution.
  168. if is_quoted_injection_phrase(f, line):
  169. f.severity = _at_most(f.severity, "medium")
  170. # Last and critical-only: a one-step cap that can never re-raise a finding an
  171. # earlier remap already lowered.
  172. if (
  173. f.pattern_id in MAIN_GUARD_DEMOTIONS
  174. and f.severity == "critical"
  175. and f.line in main_guard_lines
  176. ):
  177. f.severity = MAIN_GUARD_DEMOTIONS[f.pattern_id]
  178. out.append(f)
  179. return out
  180. _SEVERITY_RANK = {"low": 0, "medium": 1, "high": 2, "critical": 3}
  181. def _at_most(severity: str, cap: str) -> str:
  182. """Lower *severity* to *cap*; never raise it."""
  183. return cap if _SEVERITY_RANK.get(severity, 0) > _SEVERITY_RANK[cap] else severity
  184. def _comment_severity(f: Finding) -> str:
  185. """A whole-line comment / changelog entry cannot execute: one step down for every finding,
  186. a second for command/path shapes (a comment is prose); agent-facing shapes keep one step."""
  187. sev = _COMMENT_SEVERITY_CAP.get(f.severity, f.severity)
  188. return sev if is_agent_facing(f) else STEP_DOWN.get(sev, sev)
  189. def _file_lines(file_path: Path) -> list[str]:
  190. """Full source lines (``Finding.match`` is truncated to 120 chars); unreadable → []."""
  191. try:
  192. return file_path.read_text(encoding="utf-8-sig").split("\n")
  193. except (OSError, UnicodeDecodeError):
  194. return []
  195. def _context_severity(f: Finding, rel_path: str, line: str, joined: str, doc_prose: bool, is_code: bool,
  196. locale_catalog: bool = False) -> str:
  197. """Severity after the inert-context demotions (``plugin_guard_context``). Each rule only
  198. ever lowers, and every finding stays in the report; the order runs from the broadest
  199. context (where the text lives) to the narrowest (what the token sits inside). *joined* is
  200. the logical shell line (``line`` plus its ``\\\\``-continuations)."""
  201. sev = f.severity
  202. if doc_prose:
  203. sev = (catalog_cap(f) if locale_catalog else prose_cap(f)) or sev
  204. if is_self_uninstall_doc(f, line):
  205. sev = _at_most(sev, "medium")
  206. elif is_json_prose_value(f, rel_path, line):
  207. sev = prose_cap(f) or sev # `"en": "Bare sudo commands are …"` in a tips/translation table
  208. if is_test_tree(rel_path):
  209. # A key-shaped literal or quoted-only hostile string in a fixture is the corpus the
  210. # plugin's own tests reject (#89610): a note. Executable test code steps down once.
  211. inert = f.category == "credential_exposure" or is_inert_fixture_line(f, line, is_code, rel_path)
  212. sev = _at_most(sev, "medium") if inert else STEP_DOWN.get(sev, sev)
  213. if is_code and is_regex_alternation_token(f, line):
  214. sev = STEP_DOWN.get(sev, sev)
  215. return _inert_context_cap(f, rel_path, line, joined, is_code, doc_prose, sev)
  216. # Narrow inert-context demotions, each a ``(predicate, target severity)`` that only ever lowers. See
  217. # ``plugin_guard_context`` for the shape each recognises and the attack twin that keeps full severity.
  218. def _inert_context_cap(f: Finding, rel_path: str, line: str, joined: str, is_code: bool,
  219. doc_prose: bool, sev: str) -> str:
  220. if f.pattern_id == "encoded_exfil" and is_base64_media(line):
  221. return "low"
  222. to_low = (
  223. is_loopback_only(f, line) # 127.0.0.0/8 is a local service, not egress
  224. or is_loopback_continuation(f, line, joined) # loopback health check over a `\`-continuation
  225. or is_hex_in_char_class(f, line) # `[\x00-\x1F]`: a control-char filter, not a payload
  226. or (is_code and is_pip_install_in_prose_literal(f, line)) # "no pip install is needed" message
  227. or is_own_proc_read(f, joined) # `/proc/self/cgroup`: container placement, read only
  228. )
  229. if to_low:
  230. return "low"
  231. # Each predicate recognises a disclosed/inert shape that lands at a note (medium), never a block.
  232. to_medium = (
  233. is_base64_archive_roundtrip(f, line) # `tar c… | base64 | base64 -d | tar x`: transport
  234. or is_coin_name_only(f, line) # "monero gateway" in a connector index, no miner
  235. or is_trusted_installer_pipe(f, line) # `curl … hermes/ollama/bun install.sh | sh`
  236. or is_sudo_inert(f, line, rel_path) # advisory `sudo apt install` hint / "never … sudo"
  237. or is_env_dump_in_safety_clause(f, line) # `env`/`printenv` in a "never inspect env" rule
  238. or is_repo_root_traversal(f, line) # `../../..` to the repo root, no sensitive leaf
  239. or is_benign_lazy_os_import(f, line) # `__import__("os").environ.get(...)` one member
  240. or is_disclosed_config_note(f, rel_path) # disclosed scoped config-write in install docs
  241. or is_authorized_keys_prose(f, line, doc_prose) # `authorized_keys` in a UI string, no write
  242. )
  243. if to_medium:
  244. return _at_most(sev, "medium")
  245. if is_public_client_key(f, line):
  246. return _at_most(sev, "high") # public-by-design client key (GOCSPX-, phc_), reviewable caution
  247. return sev
  248. def _is_defensive_documentation(finding: Finding, rel_path: str) -> bool:
  249. """A whole-line code comment or a changelog entry *describes* threats (the attack a
  250. defense rejects, the hardening a release shipped) instead of executing them, so its
  251. findings cap one severity step lower — visible and reviewable, never un-overridable
  252. ``dangerous`` from prose alone. Runtime code and agent-facing docs keep full severity.
  253. """
  254. if Path(rel_path).name.lower() in CHANGELOG_FILENAMES:
  255. return True
  256. prefix = COMMENT_PREFIXES_BY_EXTENSION.get(Path(rel_path).suffix.lower())
  257. if prefix is None or not finding.match:
  258. return False
  259. stripped = finding.match.lstrip()
  260. if not stripped.startswith(prefix):
  261. return False
  262. if prefix == "#" and stripped.startswith(("#!", "#:")):
  263. return False
  264. return True
  265. def _dangerous_findings_summary(findings: list[Finding]) -> str:
  266. """Describe the critical findings that made a plugin install dangerous."""
  267. critical = [finding for finding in findings if finding.severity == "critical"]
  268. pattern_ids = sorted({finding.pattern_id for finding in critical})
  269. names = f" ({', '.join(pattern_ids)})" if pattern_ids else ""
  270. return f"{len(critical)} critical of {len(findings)} findings{names}"
  271. def _tracked_bytecode(plugin_dir: Path) -> set[str]:
  272. """``.pyc``/``.pyo`` the checkout tracks. ``hermes plugins validate`` imports the plugin before
  273. it scans, so an untracked ``__pycache__`` that run wrote is not shipped content; only the index
  274. says what the pinned commit carries. Not a checkout (or no git) → empty."""
  275. try:
  276. out = subprocess.run(
  277. ["git", "-c", "core.fsmonitor=false", "-C", str(plugin_dir), "ls-files", "-z", "--", "*.pyc", "*.pyo"],
  278. capture_output=True, check=True, timeout=60, stdin=subprocess.DEVNULL).stdout
  279. except (OSError, subprocess.SubprocessError):
  280. return set()
  281. return {os.fsdecode(p) for p in out.split(b"\0") if p}
  282. def _bytecode_findings(plugin_dir: Path) -> list[Finding]:
  283. """Tracked bytecode anywhere, plus bytecode outside ``__pycache__`` (CPython 3 never writes it
  284. there, so it was shipped even when the tree is not a checkout)."""
  285. loose = {rel for f, rel in _walk(plugin_dir) if rel.endswith(_BYTECODE_SUFFIXES) and f.is_file()}
  286. return [_finding("bytecode_file", SEVERITY_REMAP["binary_file"], "structural", rel, "committed bytecode",
  287. "committed Python bytecode runs in place of the scanned source (catalog rule 17)")
  288. for rel in sorted(loose | _tracked_bytecode(plugin_dir))]
  289. def _check_plugin_structure(plugin_dir: Path) -> list[Finding]:
  290. """Structural checks sized for plugin repositories."""
  291. findings: list[Finding] = _bytecode_findings(plugin_dir)
  292. file_count = 0
  293. total_size = 0
  294. resolved_root = plugin_dir.resolve()
  295. for f, rel in _walk(plugin_dir):
  296. if f.is_symlink():
  297. file_count += 1
  298. try:
  299. resolved = f.resolve()
  300. except OSError:
  301. findings.append(_finding("broken_symlink", "medium", "traversal", rel,
  302. "broken symlink", "broken or circular symlink"))
  303. continue
  304. if not resolved.is_relative_to(resolved_root):
  305. findings.append(_finding("symlink_escape", "critical", "traversal", rel,
  306. f"symlink -> {resolved}", "symlink points outside the plugin directory"))
  307. continue
  308. if not f.is_file():
  309. continue
  310. file_count += 1
  311. try:
  312. size = f.stat().st_size
  313. except OSError:
  314. continue
  315. total_size += size
  316. if size > MAX_PLUGIN_SINGLE_FILE_KB * 1024:
  317. findings.append(_finding("oversized_file", "medium", "structural", rel, f"{size // 1024}KB",
  318. f"file is {size // 1024}KB (limit: {MAX_PLUGIN_SINGLE_FILE_KB}KB)"))
  319. ext = f.suffix.lower()
  320. if ext in SUSPICIOUS_BINARY_EXTENSIONS:
  321. findings.append(_finding("binary_file", SEVERITY_REMAP["binary_file"], "structural", rel,
  322. f"binary: {ext}", f"binary/executable file ({ext}) bundled in plugin (cannot be scanned)"))
  323. if file_count > MAX_PLUGIN_FILE_COUNT:
  324. findings.append(_finding("too_many_files", "medium", "structural", "(directory)", f"{file_count} files",
  325. f"plugin has {file_count} files (limit: {MAX_PLUGIN_FILE_COUNT})"))
  326. if total_size > MAX_PLUGIN_TOTAL_SIZE_KB * 1024:
  327. findings.append(_finding("oversized_bundle", "medium", "structural", "(directory)", f"{total_size // 1024}KB",
  328. f"plugin is {total_size // 1024}KB total (limit: {MAX_PLUGIN_TOTAL_SIZE_KB}KB)"))
  329. return findings
  330. def scan_plugin(plugin_dir: Path, source: str = "") -> ScanResult:
  331. """Scan a plugin directory (typically the temp clone); every external plugin is ``community`` trust."""
  332. all_findings: list[Finding] = []
  333. if plugin_dir.is_dir():
  334. all_findings.extend(_check_plugin_structure(plugin_dir))
  335. for f, rel in sorted(_walk(plugin_dir)):
  336. if f.is_file() and not f.is_symlink():
  337. all_findings.extend(_filter_findings(scan_file(f, rel_path=rel), rel, f))
  338. verdict = _determine_verdict(all_findings)
  339. if all_findings:
  340. categories = sorted({f.category for f in all_findings})
  341. summary = f"{plugin_dir.name}: {verdict} — {len(all_findings)} finding(s) in {', '.join(categories)}"
  342. else:
  343. summary = f"{plugin_dir.name}: clean scan, no threats detected"
  344. result = ScanResult(
  345. skill_name=plugin_dir.name, source=source or plugin_dir.name, trust_level="community",
  346. verdict=verdict, findings=all_findings, scanned_at=datetime.now(UTC).isoformat(),
  347. summary=summary)
  348. result.scan_provenance = {
  349. "scanner_version": PLUGIN_SCANNER_VERSION, "verdict": verdict, "source": result.source}
  350. return result
  351. def should_allow_plugin_install(
  352. result: ScanResult, force: bool = False) -> tuple[Optional[bool], str]:
  353. """Map a verdict to ``(allowed, reason)``: True installs, None asks to confirm, False blocks."""
  354. n = len(result.findings)
  355. if result.verdict == "safe":
  356. return True, "Allowed (clean scan)"
  357. if result.verdict == "caution":
  358. if force:
  359. return True, f"Force-installed despite caution verdict ({n} findings)"
  360. return None, f"Requires confirmation (caution verdict, {n} findings)"
  361. return False, (
  362. f"Blocked (dangerous verdict, {_dangerous_findings_summary(result.findings)}). "
  363. f"--force does not override a dangerous verdict.")
  364. __all__ = [
  365. "PLUGIN_SCANNER_VERSION",
  366. "format_scan_report",
  367. "scan_plugin",
  368. "should_allow_plugin_install",
  369. ]