MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / validateLocalSkillPackagePath

Function validateLocalSkillPackagePath

agent/app/service/agents_skills.go:325–352  ·  view source on GitHub ↗
(packagePath string)

Source from the content-addressed store, hash-verified

323}
324
325func validateLocalSkillPackagePath(packagePath string) (string, error) {
326 packagePath = strings.TrimSpace(packagePath)
327 if packagePath == "" {
328 return "", fmt.Errorf("skill package path is required")
329 }
330 if _, err := localSkillPackageFormat(packagePath); err != nil {
331 return "", err
332 }
333 absPath, err := filepath.Abs(packagePath)
334 if err != nil {
335 return "", err
336 }
337 resolvedPath, err := filepath.EvalSymlinks(absPath)
338 if err != nil {
339 return "", err
340 }
341 if !isLocalSkillPackageAllowedPath(resolvedPath) {
342 return "", fmt.Errorf("invalid local skill package path")
343 }
344 info, err := os.Stat(resolvedPath)
345 if err != nil {
346 return "", err
347 }
348 if info.IsDir() {
349 return "", fmt.Errorf("skill package must be a file")
350 }
351 return resolvedPath, nil
352}
353
354func isLocalSkillPackageAllowedPath(resolvedPath string) bool {
355 roots := []string{

Callers 2

BatchInstallSkillMethod · 0.85
resolveLocalSkillPackageFunction · 0.85

Calls 4

localSkillPackageFormatFunction · 0.85
IsDirMethod · 0.80
StatMethod · 0.45

Tested by

no test coverage detected