fix: reject symlinked agents directory

This commit is contained in:
Yoilun
2026-05-25 18:05:35 +08:00
parent 425e11c444
commit 37e3d77110
4 changed files with 51 additions and 0 deletions

View File

@@ -18,6 +18,16 @@ type Store struct {
}
func (s Store) List() ([]AgentDefinition, error) {
agentsPath := filepath.Join(s.CodexHome, "agents")
if info, err := os.Lstat(agentsPath); err != nil {
if os.IsNotExist(err) {
return []AgentDefinition{}, nil
}
return nil, err
} else if info.Mode()&os.ModeSymlink != 0 {
return nil, codexhome.ErrForbiddenPath
}
agentsDir, err := codexhome.ResolveInside(s.CodexHome, "agents")
if err != nil {
return nil, err