Fix(invoice): reject trailing spaces and invalid status values in update_invoice_status#257
Open
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Open
Fix(invoice): reject trailing spaces and invalid status values in update_invoice_status#257Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Conversation
…es in update_invoice_status status Root cause: No validation was performed on the status argument, allowing strings like "approved " to be stored in the database. This bypasses exact-match checks downstream (e.g., status == "approved"). Solution: - Define VALID_INVOICE_STATUSES set with the allowed values. - Before updating, check if status is in that set and raise ValueError if not, with a clear error message. Impact: - Only invalid status values are rejected; valid calls unchanged. - Prevents silent data corruption and ensures downstream logic works. - Minimal, isolated change – easy to review and merge. 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 #179 –
update_invoice_statusnow rejects status strings with trailing spaces (or any value not in the allowed set).Problem
The function
update_invoice_statusaccepts any string as thestatusargument and stores it directly in the database. This allows inputs like"approved "(with a trailing space) to be persisted, which then break all exact‑match comparisons (e.g.,status == "approved"). The issue was discovered by testtest_inv_upd_011.Root Cause
No validation of the
statusargument against the domain‑allowed statuses. The code directly passed the user‑supplied string to the repository update call.Solution
VALID_INVOICE_STATUSEScontaining the exact allowed status strings.ValueErroris raised with a descriptive message.Code Changes
File:
finbot/tools/data/invoice.py1. Define valid statuses (inserted after logger definition):