Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func Names(values []string) ([]string, error) {
return slices.Compact(ordered), nil
}

// Hidden reports whether a skills directory entry belongs to tooling rather
// than to a skill. Plugin packagers such as Codex keep a manifest directory
// like .codex-plugin next to the skills; skill names never start with a dot, so
// these entries are left in place instead of being imported or rejected.
func Hidden(name string) bool { return strings.HasPrefix(name, ".") }

// CheckSkills rejects symlinks before the importer can write through them or
// import escapes. A symlink inside a skill directory would let a later write
// land anywhere on the caller's filesystem.
Expand All @@ -80,6 +86,9 @@ func CheckSkills(path string) error {
return err
}
for _, entry := range entries {
if Hidden(entry.Name()) {
continue
}
if _, err := Names([]string{entry.Name()}); err != nil {
return err
}
Expand Down Expand Up @@ -263,10 +272,16 @@ func Import(repo, target, upstreamLock string) error {
}
names := map[string]bool{}
for _, entry := range before {
if Hidden(entry.Name()) {
continue
}
names[entry.Name()] = true
}
afterSet := map[string]bool{}
for _, entry := range after {
if Hidden(entry.Name()) {
continue
}
afterSet[entry.Name()] = true
names[entry.Name()] = true
}
Expand Down
16 changes: 16 additions & 0 deletions internal/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ func TestNamesRejectsEscapes(t *testing.T) {
}
}

// TestCheckSkillsIgnoresHiddenEntries covers plugin manifests such as
// .codex-plugin that packagers keep beside the skills.
func TestCheckSkillsIgnoresHiddenEntries(t *testing.T) {
dir := newRepo(t)
manifest := filepath.Join(dir, ".agents/skills/.codex-plugin")
if err := os.MkdirAll(manifest, 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(manifest, "plugin.json"), []byte("{}"), 0o644); err != nil {
t.Fatal(err)
}
if err := install.CheckSkills(filepath.Join(dir, ".agents/skills")); err != nil {
t.Fatalf("a hidden manifest directory was refused: %v", err)
}
}

// TestCheckSkillsRefusesSymlinks covers the isolation requirement: a symlink
// inside a skill directory would let a later write land anywhere on disk.
func TestCheckSkillsRefusesSymlinks(t *testing.T) {
Expand Down
Loading