Lightweight coding agent that runs in your terminal
Rust
[codex] Validate plugin skill base names (#25782)
xl-openai67b805fc1117
diff --git a/codex-rs/core-skills/src/loader.rs b/codex-rs/core-skills/src/loader.rsindex d8b05c604f..7dac256010 100644--- a/codex-rs/core-skills/src/loader.rs+++ b/codex-rs/core-skills/src/loader.rs@@ -110,6 +110,7 @@ const SKILLS_METADATA_DIR: &str = "agents";const SKILLS_METADATA_FILENAME: &str = "openai.yaml";const SKILLS_DIR_NAME: &str = "skills";const MAX_NAME_LEN: usize = 64;+const MAX_QUALIFIED_NAME_LEN: usize = 128;const MAX_DESCRIPTION_LEN: usize = 1024;const MAX_SHORT_DESCRIPTION_LEN: usize = MAX_DESCRIPTION_LEN;const MAX_DEFAULT_PROMPT_LEN: usize = MAX_DESCRIPTION_LEN;@@ -660,7 +661,8 @@ async fn parse_skill_file(policy,} = load_skill_metadata(fs, path, plugin_root).await;- validate_len(&name, MAX_NAME_LEN, "name")?;+ validate_len(&base_name, MAX_NAME_LEN, "name")?;+ validate_len(&name, MAX_QUALIFIED_NAME_LEN, "qualified name")?;validate_len(&description, MAX_DESCRIPTION_LEN, "description")?;if let Some(short_description) = short_description.as_deref() {validate_len(diff --git a/codex-rs/core-skills/src/loader_tests.rs b/codex-rs/core-skills/src/loader_tests.rsindex 69e357d93d..f6c71b2be5 100644--- a/codex-rs/core-skills/src/loader_tests.rs+++ b/codex-rs/core-skills/src/loader_tests.rs@@ -1301,6 +1301,84 @@ async fn namespaces_plugin_skills_using_plugin_name() {);}+#[tokio::test]+async fn plugin_skill_name_length_limit_allows_max_qualified_name() {+ let root = tempfile::tempdir().expect("tempdir");+ let plugin_name = "p".repeat(MAX_NAME_LEN - 1);+ let skill_name = "s".repeat(MAX_NAME_LEN);+ let plugin_root = root.path().join("plugins").join(&plugin_name);+ let frontmatter = format!("name: {skill_name}\ndescription: search sample data");+ let skill_path = write_raw_skill_at(&plugin_root.join("skills"), "sample-search", &frontmatter);+ fs::create_dir_all(plugin_root.join(".codex-plugin")).unwrap();+ fs::write(+ plugin_root.join(".codex-plugin/plugin.json"),+ format!(r#"{{"name":"{plugin_name}"}}"#),+ )+ .unwrap();++ let outcome = load_skills_from_roots([SkillRoot {+ path: plugin_root.join("skills").abs(),+ scope: SkillScope::User,+ file_system: Arc::clone(&LOCAL_FS),+ plugin_id: Some("sample@test".to_string()),+ plugin_root: Some(plugin_root.abs()),+ }])+ .await;++ assert!(+ outcome.errors.is_empty(),+ "unexpected errors: {:?}",+ outcome.errors+ );+ assert_eq!(+ outcome.skills,+ vec![SkillMetadata {+ name: format!("{plugin_name}:{skill_name}"),+ description: "search sample data".to_string(),+ short_description: None,+ interface: None,+ dependencies: None,+ policy: None,+ path_to_skills_md: normalized(&skill_path),+ scope: SkillScope::User,+ plugin_id: Some("sample@test".to_string()),+ }]+ );+}++#[tokio::test]+async fn plugin_skill_name_length_limit_rejects_overlong_qualified_name() {+ let root = tempfile::tempdir().expect("tempdir");+ let plugin_name = "p".repeat(MAX_NAME_LEN);+ let skill_name = "s".repeat(MAX_NAME_LEN);+ let plugin_root = root.path().join("plugins").join(&plugin_name);+ let frontmatter = format!("name: {skill_name}\ndescription: search sample data");+ write_raw_skill_at(&plugin_root.join("skills"), "sample-search", &frontmatter);+ fs::create_dir_all(plugin_root.join(".codex-plugin")).unwrap();+ fs::write(+ plugin_root.join(".codex-plugin/plugin.json"),+ format!(r#"{{"name":"{plugin_name}"}}"#),+ )+ .unwrap();++ let outcome = load_skills_from_roots([SkillRoot {+ path: plugin_root.join("skills").abs(),+ scope: SkillScope::User,+ file_system: Arc::clone(&LOCAL_FS),+ plugin_id: Some("sample@test".to_string()),+ plugin_root: Some(plugin_root.abs()),+ }])+ .await;++ assert_eq!(outcome.skills, Vec::new());+ assert_eq!(outcome.errors.len(), 1);+ assert!(+ outcome.errors[0].message.contains("invalid qualified name"),+ "expected qualified name length error, got: {:?}",+ outcome.errors+ );+}+#[tokio::test]async fn loads_short_description_from_metadata() {let codex_home = tempfile::tempdir().expect("tempdir");