Skip to content

Enhance FindTextTool with recursive search option and improve json_schema #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025

Conversation

whoisarpit
Copy link
Contributor

…hema specification.

PR Checklist

  • The commit message follows our guidelines: Code of conduct
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Does this PR introduce a breaking change?
  • Include PR in release notes?

PR Type

  • Bugfix
  • Feature
  • Refactoring
  • Build /CI
  • Documentation
  • Others

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

@whoisarpit whoisarpit requested a review from CTY-git April 11, 2025 09:08
@patched-admin
Copy link
Contributor

File Changed: patchwork/common/tools/grep_tool.py

Rule 1: Do not ignore potential bugs in the code

Details: A potential bug exists in the error handling where exceptions are silently caught and ignored without logging or proper error handling.

Affected Code Snippet:

            try:
                with path.open("r") as f:
                    for i, line in enumerate(f):
                        if fnmatch.fnmatch(line.rstrip("\n"), pattern):
                            content = f"Line {i + 1}: {line}"
                            if len(content) > self.__CHAR_LIMIT:
                                content = f"Line {i + 1}: {self.__CHAR_LIMIT_TEXT}"

                        file_matches[str(path)].append(content)
            except Exception:
                pass

Start Line: 198
End Line: 214


Rule 2: Do not overlook possible security vulnerabilities

Details: The code introduces a potential security vulnerability by using Path.rglob("*") without file type validation, which could expose sensitive files or lead to directory traversal issues.

Affected Code Snippet:

        elif recursive:
            paths = list(set(p for p in path.rglob("*") if p.is_file()))

Start Line: 193
End Line: 194

@whoisarpit whoisarpit merged commit 584a853 into main Apr 11, 2025
3 of 4 checks passed
@whoisarpit whoisarpit deleted the fix/find-text-tool branch April 11, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants