(ctx context.Context, files map[string]string, root string, absPath string, info os.FileInfo)
| 524 | } |
| 525 | |
| 526 | func appendSkillFile(ctx context.Context, files map[string]string, root string, absPath string, info os.FileInfo) error { |
| 527 | if info.Size() > 10*1024*1024 { |
| 528 | logger.Warnf(ctx, "Skipping large file %s (%d bytes)", absPath, info.Size()) |
| 529 | return nil |
| 530 | } |
| 531 | relPath, err := filepath.Rel(root, absPath) |
| 532 | if err != nil { |
| 533 | return err |
| 534 | } |
| 535 | relPath = filepath.Clean(relPath) |
| 536 | if strings.HasPrefix(relPath, "..") || filepath.IsAbs(relPath) { |
| 537 | return fmt.Errorf("path traversal detected: %s", relPath) |
| 538 | } |
| 539 | content, err := os.ReadFile(absPath) |
| 540 | if err != nil { |
| 541 | return err |
| 542 | } |
| 543 | files[filepath.ToSlash(relPath)] = string(content) |
| 544 | return nil |
| 545 | } |
| 546 | |
| 547 | func ensureSkillResourcesSeeded(ctx context.Context, sessionID string, cwd string) error { |
| 548 | if strings.TrimSpace(sessionID) == "" { |
no test coverage detected