Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-15 - [Assert Removal in Python]
**Vulnerability:** Use of `assert` in application logic (`assert best is not None` in `python/fast_mlsirm/fit.py`).
**Learning:** Python `assert` statements are stripped when the interpreter is run with optimization (`-O`). This can cause application logic to silently skip checks and lead to undefined behaviors or security issues.
**Prevention:** Replace `assert` with explicit `if` conditions that raise exceptions like `RuntimeError` or `ValueError` to ensure checks are enforced regardless of interpreter optimization flags.
3 changes: 2 additions & 1 deletion python/fast_mlsirm/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def fit(
if best is None or candidate.objective < best.objective:
best = candidate

assert best is not None
if best is None:
raise RuntimeError("Fit failed to produce a valid result")
return best


Expand Down
Loading