pub fn is_valid_namespaced_name(name: &str) -> boolExpand description
Whether name is a well-formed <plugin>:<local> namespaced dispatch
name — the ONE shape every plugin-aware caller (agents::resolve_agent,
plugins::agents::find_plugin_agent_config,
plugins::skills::resolve_plugin_skill_body,
skills::FsSkillResolver::resolve, tools::delegate::DelegateToAgentTool,
the CLI’s run-task validation, runner::agent_config_exists) accepts
(code-critic PR #3547 review, CRITICAL 2 / HIGH 3 / HIGH 4).
Why: a namespaced name’s local segment is joined onto a plugin’s
agents_dir/skills_dir — e.g. plugins::skills::resolve_plugin_skill_body
builds skills_dir.join(skill_name).join("SKILL.md") directly from the
caller-supplied (and, via use_skill, LLM-supplied) segment. Restricting
BOTH segments to agents::protocol::validate_agent_name’s existing safe
charset ([a-z0-9-]+, 1-64 chars — reused, not re-derived, so the two
concepts of “a safe catalog name” never drift apart) makes a traversal
payload like foo:../../../../x or foo:/etc/passwd syntactically
impossible to construct: the charset contains no / and no . at all,
so no join built from a validated segment can ever leave the directory
it was joined onto, regardless of what the discovered catalog happens to
list (closes the residual gap where a plugin’s own frontmatter could
declare a spoofed name: that would otherwise appear “known”).
What: true only for EXACTLY two :-separated segments, each accepted
by agents::protocol::validate_agent_name. Zero or one segment (a plain
name), more than two (multiple colons), or either segment failing the
charset/length check all return false.
Test: tests::is_valid_namespaced_name_accepts_two_safe_segments,
tests::is_valid_namespaced_name_rejects_traversal_segment,
tests::is_valid_namespaced_name_rejects_absolute_segment,
tests::is_valid_namespaced_name_rejects_plain_name,
tests::is_valid_namespaced_name_rejects_extra_colon.