Skip to content

fix: return 400 when text param is missing in text_search#867

Open
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
shiwani42:fix-text-search-none-param
Open

fix: return 400 when text param is missing in text_search#867
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
shiwani42:fix-text-search-none-param

Conversation

@shiwani42
Copy link
Copy Markdown

Closes #862

Problem

GET /rest/v1/text_search without a text query parameter causes an
unhandled TypeError deep in re.search() because
request.args.get('text') returns None.

Fix

Return a 400 with a descriptive error message before reaching the
database call. Also handles the empty string case (?text=).

Tests

Added two cases to test_test_search:

  • missing param: 400
  • empty string: 400

Closes OWASP#862

request.args.get('text') returns None if the query param is absent.
Passing None into db.text_search() causes re.search() to raise
TypeError: expected string or bytes-like object.
Return a 400 before reaching the database call.
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.

GET /rest/v1/text_search without text param causes unhandled TypeError

1 participant