Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

fix(security): redact credentials in declared component paths (#301)

Narendran Raghavanc8e26ceb6806
diff --git a/src/skillevaluator/plugin_discovery.py b/src/skillevaluator/plugin_discovery.py
index 08708bf0..48ea0e28 100644
--- a/src/skillevaluator/plugin_discovery.py
+++ b/src/skillevaluator/plugin_discovery.py
@@ -64,6 +64,7 @@ from skillevaluator.plugin_paths import (
_unscanned_packaged_finding,
_unscanned_path_finding,
normalize_declared_path,
+ reported_ref,
)
from skillevaluator.plugin_refs import normalize_ref
from skillevaluator.utils.secure_fs import SecurePathError
@@ -252,8 +253,8 @@ class _MemberCollector:
return component
def _broken(self, component_type: str, declared: DeclaredPath | None, raw: Any, problem: str) -> None:
- path = declared.rel.as_posix() if declared is not None and declared.rel is not None else None
- name = raw if isinstance(raw, str) else repr(raw)
+ path = reported_ref(declared.rel.as_posix()) if declared is not None and declared.rel is not None else None
+ name = reported_ref(raw if isinstance(raw, str) else repr(raw))
self._add(PluginMember(component_type, name, "declared", path, _TYPE_SUPPORT[component_type], problem=problem))
def _declared_field(self, field_name: str) -> Any:
@@ -329,12 +330,12 @@ class _MemberCollector:
_plugin_finding(
Severity.MEDIUM,
"plugin_component_path_invalid",
- f"'{field_name}' entry {report_text(repr(raw), 80)} is not a path; Codex ignores the value, "
+ f"'{field_name}' entry {report_text(reported_ref(repr(raw)), 80)} is not a path; Codex ignores the value, "
"loads the default location, and still installs the plugin",
self.reader.display(self.manifest_rel),
f"Write '{field_name}' as a './'-relative path (or a list of them), or remove it to use the "
"default location.",
- metadata={"plugin_component_ref": repr(raw)},
+ metadata={"plugin_component_ref": reported_ref(repr(raw))},
)
)
return None, "dropped"
@@ -377,12 +378,12 @@ class _MemberCollector:
_plugin_finding(
Severity.HIGH,
"plugin_component_path_invalid",
- f"'{field_name}' entry {raw!r} must name a {wrong_kind} file; "
+ f"'{field_name}' entry {reported_ref(raw)!r} must name a {wrong_kind} file; "
f"{profile.label.removesuffix(' plugin')} rejects the whole manifest otherwise and does not "
"load the plugin",
self.reader.display(self.manifest_rel),
f"List each {wrong_kind} file by its own './'-relative path, as the {profile.reference} requires.",
- metadata={"plugin_component_ref": raw},
+ metadata={"plugin_component_ref": reported_ref(raw)},
)
)
return declared, "invalid"
@@ -983,7 +984,7 @@ class _MemberCollector:
_plugin_finding(
Severity.MEDIUM,
"plugin_command_folder_empty",
- f"commands[{command_name!r}].source {declared.raw!r} is a folder with no Markdown (.md) file "
+ f"commands[{command_name!r}].source {reported_ref(declared.raw)!r} is a folder with no Markdown (.md) file "
"directly in it, so Claude Code loads no command from it",
self.manifest_display,
"Point the source at the command's .md file, or put the command files directly in the folder.",
diff --git a/src/skillevaluator/plugin_mcp.py b/src/skillevaluator/plugin_mcp.py
index 1dd42dae..1a7eca24 100644
--- a/src/skillevaluator/plugin_mcp.py
+++ b/src/skillevaluator/plugin_mcp.py
@@ -47,6 +47,7 @@ from skillevaluator.plugin_paths import (
_unscanned_folder,
_unscanned_path_finding,
normalize_declared_path,
+ reported_ref,
)
from skillevaluator.utils.secure_fs import SecurePathError
from skillevaluator.utils.structured_data import StructuredDataError, StructuredDataLimitError, load_bounded_json
@@ -61,10 +62,7 @@ from skillevaluator.validators.mcp_static import (
)
from skillevaluator.validators.url_policy import (
looks_like_inline_secret,
- redact_secrets,
- report_text,
safe_url,
- url_scheme,
)
McpSource = Literal["inline", "mcp_json", "path_ref", "agent_plugin_yaml"]
@@ -721,14 +719,14 @@ def _collect_path_ref(
dropped = contained and profile.codex_path_rules and not codex_accepts_path(raw)
declared = normalize_declared_path(raw, profile.manifest_path_prefixes)
# Findings and the inventory name the reference without the credentials it may carry.
- shown = _reported_ref(raw)
+ shown = reported_ref(raw)
reported = (
declared
if shown == raw
else replace(
declared,
raw=shown,
- rel=None if declared.rel is None else PurePosixPath(_reported_ref(declared.rel.as_posix())),
+ rel=None if declared.rel is None else PurePosixPath(reported_ref(declared.rel.as_posix())),
)
)
if declared.problem is not None or declared.rel is None:
@@ -798,22 +796,6 @@ def _collect_path_ref(
_load_mcp_file(reader, collection, rel, "path_ref", shown)
-def _reported_ref(raw: str) -> str:
- """A declared ``mcpServers`` reference as findings and the inventory show it, without its credentials.
-
- A reference with a URL scheme (``ws://user:token@host/srv.mcpb``, the
- one-slash ``https:/user:pw@host/...``) is shown as :func:`safe_url` shows
- it: no userinfo, query, or fragment. Any other (``//user:pw@host/...``,
- ``./servers.json?token=...``) has its credentials redacted. A reference
- that carries none is returned as written.
- """
- scheme = url_scheme(raw.strip())
- if scheme is not None and len(scheme) > 1: # one letter is a Windows drive ('C:\\...')
- return safe_url(raw)
- redacted = redact_secrets(raw)
- return raw if redacted == raw else report_text(redacted)
-
-
def _collect_url_ref(reader: PluginRootReader, collection: McpCollection, raw: str, manifest_rel: str) -> None:
"""Collect one remote ``mcpServers`` reference; only an ``.mcpb``/``.dxt`` bundle may be named by URL.
diff --git a/src/skillevaluator/plugin_paths.py b/src/skillevaluator/plugin_paths.py
index 4dfa416c..c43fd8a1 100644
--- a/src/skillevaluator/plugin_paths.py
+++ b/src/skillevaluator/plugin_paths.py
@@ -46,6 +46,7 @@ from skillevaluator.utils.secure_fs import (
lstat_walk,
stat_is_link_or_reparse,
)
+from skillevaluator.validators.url_policy import redact_secrets, report_text, safe_url, url_scheme
# The category of every plugin schema and component finding; a policy overlay changes a severity with
# PLUGIN_SCHEMA.<check>.
@@ -262,6 +263,22 @@ def _plugin_finding(
)
+def reported_ref(raw: str) -> str:
+ """A declared component reference as findings and the inventory show it, without its credentials.
+
+ A reference with a URL scheme (``ws://user:token@host/srv.mcpb``, the
+ one-slash ``https:/user:pw@host/...``) is shown as :func:`safe_url` shows
+ it: no userinfo, query, or fragment. Any other (``//user:pw@host/...``,
+ ``./servers.json?token=...``) has its credentials redacted. A reference
+ that carries none is returned as written.
+ """
+ scheme = url_scheme(raw.strip())
+ if scheme is not None and len(scheme) > 1: # one letter is a Windows drive ('C:\\...')
+ return safe_url(raw)
+ redacted = redact_secrets(raw)
+ return raw if redacted == raw else report_text(redacted)
+
+
def _path_problem_finding(
reader: PluginRootReader,
field_name: str,
@@ -273,7 +290,7 @@ def _path_problem_finding(
reference: str = CLAUDE_PROFILE.reference,
) -> Finding:
"""HIGH finding for a declared component path that is missing, escapes, or is unsafe."""
- raw = declared.raw
+ raw = reported_ref(declared.raw)
# Lets the inventory attribute the finding to the (broken) component it names.
metadata = {"plugin_component_ref": raw}
if problem == "escape":
@@ -300,7 +317,7 @@ def _path_problem_finding(
"plugin_component_path_unsafe",
f"'{field_name}' path {raw!r} is (or passes through) a symlink, hard link, or special file; "
"it was not followed",
- reader.display(rel if rel is not None else manifest_rel),
+ reader.display(PurePosixPath(reported_ref(rel.as_posix())) if rel is not None else manifest_rel),
"Replace links with regular files and directories contained in the plugin root.",
metadata=metadata,
)
@@ -394,14 +411,15 @@ def _unscanned_path_finding(
folder = _unscanned_folder(rel, reader.root) if rel is not None else None
if folder is None:
return None
+ shown = reported_ref(declared.raw)
return _plugin_finding(
Severity.HIGH,
"plugin_component_path_unscanned",
- f"'{field_name}' path {declared.raw!r} is inside '{folder}/', a folder that Tier 1 whole-tree scans skip "
+ f"'{field_name}' path {shown!r} is inside '{folder}/', a folder that Tier 1 whole-tree scans skip "
f"({_UNSCANNED_FOLDERS_TEXT}), so the client loads files that are never security-scanned",
reader.display(manifest_rel),
_UNSCANNED_SUGGESTION,
- metadata={"plugin_component_ref": declared.raw},
+ metadata={"plugin_component_ref": shown},
)
@@ -447,12 +465,13 @@ def _style_finding(
(HIGH, the plugin does not load); Codex drops the value and loads the
format's default location instead (MEDIUM).
"""
+ shown = reported_ref(declared.raw)
if declared.rel is not None and str(declared.rel) == "." and declared.dot_relative:
problem = "names the plugin root itself"
fix = "Name the component folder or file, for example './skills/'."
else:
problem = "does not start with './'"
- fix = f"Write the path as './{declared.rel.as_posix() if declared.rel else declared.raw}'."
+ fix = f"Write the path as './{reported_ref(declared.rel.as_posix()) if declared.rel else shown}'."
if profile.rejects_undotted_paths:
severity = Severity.HIGH
outcome = f"{profile.label.removesuffix(' plugin')} rejects the whole manifest and does not load the plugin"
@@ -462,10 +481,10 @@ def _style_finding(
return _plugin_finding(
severity,
"plugin_component_path_style",
- f"'{field_name}' path {declared.raw!r} {problem}; {outcome}",
+ f"'{field_name}' path {shown!r} {problem}; {outcome}",
reader.display(manifest_rel),
fix,
- metadata={"plugin_component_ref": declared.raw},
+ metadata={"plugin_component_ref": shown},
)
@@ -473,16 +492,17 @@ def _root_variable_finding(
reader: PluginRootReader, field_name: str, declared: DeclaredPath, manifest_rel: str, profile: FormatProfile
) -> Finding:
"""MEDIUM for a component path that starts with a root variable the client documents only elsewhere (Cursor)."""
+ shown = reported_ref(declared.raw)
return _plugin_finding(
Severity.MEDIUM,
"plugin_component_path_root_variable",
- f"'{field_name}' path {declared.raw!r} starts with {declared.root_variable}. The {profile.label} reference "
+ f"'{field_name}' path {shown!r} starts with {declared.root_variable}. The {profile.label} reference "
"documents root variables for hook commands and MCP server fields, not for manifest component paths, so "
"the client may not expand it there and may not load this component. SkillEvaluator still checks the files "
"it names",
reader.display(manifest_rel),
- f"Write the path relative to the plugin root, for example './{declared.rel.as_posix() if declared.rel else ''}'.",
- metadata={"plugin_component_ref": declared.raw},
+ f"Write the path relative to the plugin root, for example './{reported_ref(declared.rel.as_posix()) if declared.rel else ''}'.",
+ metadata={"plugin_component_ref": shown},
)
diff --git a/tests/test_plugin_discovery.py b/tests/test_plugin_discovery.py
index 43a8dde8..748bf561 100644
--- a/tests/test_plugin_discovery.py
+++ b/tests/test_plugin_discovery.py
@@ -19,7 +19,7 @@ from skillevaluator.plugin_discovery import discover_plugin_members
from skillevaluator.plugin_formats import AGENT_PLUGINS_V1_PROFILE, CLAUDE_PROFILE, CODEX_PROFILE, CURSOR_PROFILE
from skillevaluator.plugin_manifest import PluginManifestPathError, locate_plugin_manifest
from skillevaluator.plugin_mcp import collect_mcp_declarations
-from skillevaluator.plugin_paths import PluginRootReader
+from skillevaluator.plugin_paths import DeclaredPath, PluginRootReader, _path_problem_finding
from skillevaluator.utils.secure_fs import SecurePathError, SecureRoot
from skillevaluator.validators.mcp_static import validate_mcp_server_declaration
@@ -556,3 +556,52 @@ def test_codex_drops_a_commands_map_and_loads_the_default_folder(tmp_path):
result = found(tmp_path)
assert [(m.name, m.origin) for m in result.components if m.type == "command"] == [("default", "packaged")]
assert [(f.check_name, f.severity) for f in result.findings] == [("plugin_component_path_invalid", Severity.MEDIUM)]
+
+
+def _credential() -> str:
+ return "pw-" + "test-value"
+
+
+ ("manifest_rel", "fields"),
+ [
+ (
+ ".claude-plugin/plugin.json",
+ {
+ "skills": "https://user:{pw}@host.example/skills",
+ "commands": ["ws://user:{pw}@host.example/x"],
+ "agents": ["//user:{pw}@host.example/a.md"],
+ "hooks": "./hooks.json?token={pw}",
+ "outputStyles": "styles?token={pw}",
+ },
+ ),
+ (".codex-plugin/plugin.json", {"skills": {"url": "https://user:{pw}@host.example/skills"}}),
+ ],
+)
+def test_declared_component_references_never_show_their_credentials(
+ tmp_path: Path, manifest_rel: str, fields: dict
+) -> None:
+ """Regression: component-path findings and inventory rows quoted the declared value as written, so a
+ reference carrying userinfo or a query credential copied it into reports (only mcpServers was redacted)."""
+ pw = _credential()
+ declared = json.loads(json.dumps(fields).replace("{pw}", pw))
+ write_tree(tmp_path, {manifest_rel: {"name": "demo", **declared}})
+ result = found(tmp_path)
+ assert {name for name in fields if any(f"'{name}'" in finding.message for finding in result.findings)} == set(
+ fields
+ )
+ # The manifest record keeps the source as written; findings and inventory rows are what reports show.
+ assert pw not in repr((result.findings, result.components))
+
+
+def test_unsafe_declared_path_location_never_shows_its_credentials(tmp_path: Path) -> None:
+ """Regression: an unreadable declared path (Windows rejects '?' in file names) named the declared value,
+ credential included, as the finding's location."""
+ pw = _credential()
+ reader = PluginRootReader(tmp_path)
+ declared = DeclaredPath(f"styles?token={pw}", PurePosixPath(f"styles?token={pw}"))
+ finding = _path_problem_finding(
+ reader, "outputStyles", declared, ".claude-plugin/plugin.json", "unsafe", declared.rel
+ )
+ assert finding.check_name == "plugin_component_path_unsafe"
+ assert pw not in repr(finding)