Skip to content

The agent that grows with you

fix(plugin-guard): reconcile current scanner rules and test install confirmation

Adolanium30d78cd85eef
diff --cc tests/tools/test_plugin_guard.py
index fb1282c1305,6378366fb99..065ef236e64
--- a/tests/tools/test_plugin_guard.py
+++ b/tests/tools/test_plugin_guard.py
@@@ -254,22 -249,22 +277,27 @@@ class TestInstallIntegration
# Nothing got installed.
assert not (plugins_dir / "test-plugin").exists()
-- def test_caution_plugin_accepted_via_callback(self, tmp_path, monkeypatch):
++ @pytest.mark.parametrize("filename,content", [
++ ("helper.py", "eval('1 + 1')\n"),
++ ("desktop/plugin.js", 'const lookup = `dig +short +time=3 A ${hostname}`;\n'),
++ ("desktop/plugin.js", 'const help = "Add this public key to authorized_keys on the server.";\n'),
++ ])
++ def test_caution_plugin_accepted_via_callback(self, tmp_path, monkeypatch, filename, content):
from hermes_cli import plugins_cmd as pc
files = dict(BASE_FILES)
-- files["helper.py"] = "eval('1 + 1')\n"
++ files[filename] = content
repo = tmp_path / "repo"
self._make_git_repo(repo, files)
-- plugins_dir = tmp_path / "installed"
-- plugins_dir.mkdir()
-- monkeypatch.setattr(pc, "_plugins_dir", lambda: plugins_dir)
++ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "home"))
++ plugins_dir = pc._plugins_dir()
# Declined → blocked
with pytest.raises(pc.PluginScanBlocked):
pc._install_plugin_core(
f"file://{repo}", force=False, scan_decision_cb=lambda r: False,
)
++ assert not (plugins_dir / "test-plugin").exists()
# Accepted → installs
target, _, name = pc._install_plugin_core(
f"file://{repo}", force=False, scan_decision_cb=lambda r: True,
diff --cc tools/plugin_guard.py
index 4d8e0b3e9cc,48d84d7594e..d34adca0807
--- a/tools/plugin_guard.py
+++ b/tools/plugin_guard.py
@@@ -78,14 -75,15 +84,18 @@@ def _finding(pattern_id: str, severity
def _filter_findings(findings: List[Finding], rel_path: str) -> List[Finding]:
"""Apply plugin-specific exemptions and severity remaps to raw findings."""
is_code = Path(rel_path).suffix.lower() in CODE_FILE_EXTENSIONS
+ in_test_tree = Path(rel_path).parts[0] in TEST_TREE_DIRS
+ is_js = Path(rel_path).suffix.lower() in {".js", ".ts"}
out: List[Finding] = []
for f in findings:
if is_code and f.pattern_id in CODE_EXEMPT_PATTERN_IDS:
continue
- f.severity = SEVERITY_REMAP.get(f.pattern_id) or f.severity
+ f.severity = (
+ (JS_CAPABILITY_REMAP.get(f.pattern_id) if is_js else None)
+ or SEVERITY_REMAP.get(f.pattern_id) or f.severity
+ )
+ if in_test_tree and f.severity == "critical":
+ f.severity = "high"
out.append(f)
return out