Skip to content

Fix runtime validation bypass by removing asserts in metrics#13

Open
victor-nb wants to merge 1 commit intomainfrom
boost-advisor/fix-0cc4SUvj
Open

Fix runtime validation bypass by removing asserts in metrics#13
victor-nb wants to merge 1 commit intomainfrom
boost-advisor/fix-0cc4SUvj

Conversation

@victor-nb
Copy link
Copy Markdown

Summary

This PR fixes 1 security vulnerability identified by BoostSecurity.


Replace runtime asserts with explicit exceptions in metrics in twml/twml/contrib/metrics/metrics.py (Line: 58)

Risk: assert statements were used for runtime input validation in metrics.py. Python can strip asserts under -O/-OO, allowing invalid indices/parameters to bypass checks and potentially break metric computation in production.

Fix: Replaced the asserts with explicit ValueError/TypeError exceptions so validation is always enforced regardless of optimization flags.

Review notes: Behavior changes from AssertionError to ValueError/TypeError for invalid inputs.


Generated by BoostSecurity Advisor

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.

1 participant