mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
d692cc0cc6
* Add Find Skills and Install Skills * Improvements * fix file name * Update pkg/skills/clawhub_registry.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix * Comments addressed * Resolve comments * fix tests * fixes * Comments resolved * Update pkg/skills/search_cache_repro_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * minor fix * fix test * fixes --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
20 lines
623 B
Go
20 lines
623 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// ValidateSkillIdentifier validates that the given skill identifier (slug or registry name) is non-empty
|
|
// and does not contain path separators ("/", "\\") or ".." for security.
|
|
func ValidateSkillIdentifier(identifier string) error {
|
|
trimmed := strings.TrimSpace(identifier)
|
|
if trimmed == "" {
|
|
return fmt.Errorf("identifier is required and must be a non-empty string")
|
|
}
|
|
if strings.ContainsAny(trimmed, "/\\") || strings.Contains(trimmed, "..") {
|
|
return fmt.Errorf("identifier must not contain path separators or '..' to prevent directory traversal")
|
|
}
|
|
return nil
|
|
}
|