Fix(findrive): resolve missing negative-limit guard in search_files#449
Open
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Open
Fix(findrive): resolve missing negative-limit guard in search_files#449Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Conversation
Root cause: search_files forwarded unvalidated limit to repo.search_files(), allowing negative values to reach the DB layer with undefined LIMIT behavior. Solution: Add early return with error dict when limit < 0, matching the validation pattern used in upload_file. Impact: Deterministic error response for invalid input; zero change to valid path. Signed-off-by: JEAN REGIS <240509606@firat.edu.tr>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #353
search_filesaccepted negativelimitvalues and forwarded them directly to the database layer, triggering undefined SQLLIMITbehavior.Root Cause
No lower-bound validation existed on the
limitparameter insearch_files. The raw value was passed unchecked intorepo.search_files(query, limit=limit).Solution
Added a two-line early-return guard at the top of
search_files, before thedb_sessionblock, that returns a structured error response whenlimit < 0. Matches the existing error-return pattern used inupload_file.Impact
Testing
Tasks
limitforwarded to DB without validation)db_sessionblock insearch_filesupload_filetest_fd_int_006_search_files_negative_limit_raises)test_fd_srch_001_returns_matching_files_by_filename)