Skip to main content

oxios_kernel/skill/
mod.rs

1//! Skill system: multi-format SKILL.md parsing with format detection,
2//! plus multi-registry marketplace sources (ClawHub, Skills.sh).
3
4pub mod archive;
5pub mod clawhub;
6pub mod format;
7pub mod frontmatter;
8pub mod manager;
9pub mod prompt;
10pub mod requirements;
11pub mod skills_sh;
12pub mod types;
13
14pub use format::SkillFormat;
15pub use manager::SkillManager;
16pub use prompt::{compact_path, escape_xml};
17pub use requirements::check_requirements;
18pub use types::{
19    ConfigCheck, InstallKind, Requirements, RequirementsCheck, Skill, SkillConfig, SkillEntry,
20    SkillInstallSpec, SkillInvocationPolicy, SkillMeta, SkillMetadata, SkillRef, SkillSnapshot,
21    SkillSource, SkillState, SkillStatus,
22};
23
24/// Returns true if `rel` is a safe relative path: no parent/root/prefix
25/// components that could escape a target directory (Zip Slip / path traversal).
26///
27/// Used by skill installers (ClawHub zip extraction, skills.sh file writes)
28/// to reject archive entries whose names contain `..`, absolute paths, or
29/// Windows drive prefixes.
30pub(crate) fn is_safe_relative_path(rel: &str) -> bool {
31    let p = std::path::Path::new(rel);
32    !p.components().any(|c| {
33        matches!(
34            c,
35            std::path::Component::ParentDir
36                | std::path::Component::RootDir
37                | std::path::Component::Prefix(_)
38        )
39    })
40}