mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-05 01:59:27 +00:00
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. |
||
|---|---|---|
| .. | ||
| python | ||
| security | ||
| README.md | ||
Custom Semgrep rules for LiteLLM
Add custom rule YAML files here. Semgrep loads all .yml/.yaml files under this directory.
Run only custom rules (CI / fail on findings):
semgrep scan --config .semgrep/rules . --error
Run with registry + custom rules:
semgrep scan --config auto --config .semgrep/rules .
Layout:
python/– Python-specific rules (security, patterns)- Add more subdirs as needed (e.g.
generic/for language-agnostic rules)
See Semgrep rule syntax.