litellm/.semgrep/rules/python
ryan-crabbe-berri 509ef61103 refactor(proxy): ban raw datetime.fromisoformat via parse_utc_datetime helper
Extract parse_utc_datetime into litellm_core_utils/datetime_utils.py as the
single ISO-8601 parse entrypoint for the proxy: it accepts str or datetime,
handles the Z suffix on Python 3.10, and assumes naive values are UTC so
results always compare safely against datetime.now(timezone.utc).

Convert all 27 raw fromisoformat sites under litellm/proxy/ to the helper,
collapsing the hand-rolled tzinfo guards they each carried. This also fixes a
real bug in get_mcp_oauth_user_credential_status: a tz-naive expires_at raised
TypeError against the aware now(), the bare except swallowed it, and the
credential never read as expired.

Two semgrep rules enforce the pattern in CI: raw fromisoformat is banned under
litellm/proxy/, and a repo-wide taint rule flags comparing or subtracting an
unnormalized fromisoformat result.
2026-07-21 11:26:49 -07:00
..
reliability refactor(proxy): ban raw datetime.fromisoformat via parse_utc_datetime helper 2026-07-21 11:26:49 -07:00
unbounded-memory.yml chore: improve Semgrep rules documentation and organization (#20978) 2026-02-11 09:39:44 -08:00