(ctx context.Context, args map[string]any)
| 38 | } |
| 39 | |
| 40 | func (p *CodeSearchProvider) execute(ctx context.Context, args map[string]any) (string, error) { |
| 41 | searchText, _ := args["search_text"].(string) |
| 42 | caseSensitive, _ := args["case_sensitive"].(bool) |
| 43 | usePerlRegexp, _ := args["use_perl_regexp"].(bool) |
| 44 | |
| 45 | filePatternsIface, _ := args["file_patterns"].([]any) |
| 46 | var patterns []string |
| 47 | for _, item := range filePatternsIface { |
| 48 | if s, ok := item.(string); ok && s != "" { |
| 49 | if hasTraversalPathComponent(s) { |
| 50 | return "Error: file_patterns must not contain ..", nil |
| 51 | } |
| 52 | // Treat backslashes as separators so Windows pathspecs match. |
| 53 | patterns = append(patterns, strings.ReplaceAll(s, "\\", "/")) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if strings.TrimSpace(searchText) == "" { |
| 58 | return "Error: search_text is blank", nil |
| 59 | } |
| 60 | |
| 61 | result, err := p.gitGrep(ctx, searchText, caseSensitive, usePerlRegexp, patterns) |
| 62 | if err != nil { |
| 63 | return "", err |
| 64 | } |
| 65 | return result, nil |
| 66 | } |
| 67 | |
| 68 | func (p *CodeSearchProvider) buildGrepArgs(searchText string, caseSensitive bool, usePerlRegexp bool, noIndex bool, pathspec []string) []string { |
| 69 | // core.quotepath=false reports non-ASCII paths literally instead of as |
no test coverage detected