Skip to content

fix(ctf): reject None for numeric detector config keys - #605

Open
Prasad-desh wants to merge 3 commits into
GenAI-Security-Project:mainfrom
Prasad-desh:fix/detector-none-numeric-config
Open

Prasad-desh wants to merge 3 commits into
GenAI-Security-Project:mainfrom
Prasad-desh:fix/detector-none-numeric-config

Conversation

@Prasad-desh

Copy link
Copy Markdown

Follow-up to the note at the end of #594, which flagged these two but left them out of that PR.

_validate_config guards the range check with if <value> is not None, so a config that carries the key with an empty YAML value passes construction. check_event then reads the key back with .get(key, DEFAULT), which returns None rather than the default once the key is present, and the first comparison raises TypeError. The detector is down for the rest of the process after that.

Confirmed on main before the change:

InvoiceThresholdBypassDetector: config.get("max_invoice_amount", DEFAULT) -> None
   '<' not supported between instances of 'int' and 'NoneType'
InvoiceTrustOverrideDetector:   config.get("min_amount", DEFAULT) -> None
   '<' not supported between instances of 'int' and 'NoneType'

Checking for the key's presence instead, same as #594 did for the list-typed keys.

The two None tests fail on main and pass with the fix. tests/unit/ctf is 39 passed, 1 skipped before and after. Tests are in their own file so they don't collide with #136, which adds test_detectors.py.

Independent of #594, so either can go in first.

Signed-off-by: Prasad Deshpande <officiallyprasad@gmail.com>
Signed-off-by: Prasad Deshpande <officiallyprasad@gmail.com>
Signed-off-by: Prasad Deshpande <officiallyprasad@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants