mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
* feat(guardrails): add prebuilt credential patterns for JWT, and OpenAI, Anthropic, Gemini API keys * fix(guardrails): prevent quadratic backtracking in jwt_token pattern * test(guardrails): move credential pattern tests into test_patterns.py * feat(guardrails): remove jwt_token to keep credential patterns strictly bounded * fix(guardrails): mask whole provider keys and keep openai_api_key to OpenAI's key shapes End each pattern so a key ending in "-" is masked in full, require OpenAI's T3BlbkFJ marker on bare sk- keys so other vendors' sk- keys and LiteLLM virtual keys are left alone, add sk-None- user keys, and replace the registration-only tests with whole-match, length-boundary, and negative cases * fix(guardrails): require the T3BlbkFJ marker on every OpenAI key form and match keys after escaped separators openai_api_key now needs the marker on the sk-proj-, sk-svcacct-, sk-admin- and sk-None- forms too, as gitleaks and TruffleHog do. anthropic_api_key and gemini_api_key also start a match right after a literal \n or \t or a percent-encoded byte, so keys in pasted JSON strings and URL-encoded logs are masked. * fix(guardrails): bound the OpenAI key regex, match Gemini prefixes case-sensitively, and hold back long keys in streamed replies * fix(guardrails): size the streaming holdback per pattern, stop OpenAI key tails before the next key, and allow non-ASCII text after a key * fix(guardrails): mask content filter pattern matches found in the original text so overlapping patterns cannot split a key * fix(guardrails): let a block pattern see the text after earlier masking patterns, as before Masking patterns still match the original text and merge overlapping matches into one tag, but a BLOCK pattern checks the text with the masking patterns listed before it applied, so a request main masked and passed is not blocked now. Detections name only the patterns whose tag was written. * fix(guardrails): keep content filter masks in order and hold back the longest OpenAI key Masking patterns run in configured order on the masked text as on main, so a contextual pattern still matches next to an earlier tag, and each also matches the original text so an earlier tag cannot split a key. Detections follow the configured pattern, not its name, and the OpenAI streaming holdback covers the pattern's 419-character longest match. --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| akto | ||
| aporia_ai | ||
| azure | ||
| content_filter | ||
| dynamoai | ||
| guardrails_ai | ||
| ibm_guardrails | ||
| javelin | ||
| litellm_content_filter | ||
| noma | ||
| openai | ||
| semantic_guard | ||
| unified_guardrails | ||
| zscaler_ai_guard | ||
| __init__.py | ||
| _cisco_ai_defense_test_utils.py | ||
| code_execution_compliance_dataset.json | ||
| test_agent_365.py | ||
| test_aim.py | ||
| test_airia.py | ||
| test_alice.py | ||
| test_bedrock_guardrails.py | ||
| test_bedrock_invoke_guardrail_checks.py | ||
| test_block_code_execution.py | ||
| test_block_code_execution_compliance.py | ||
| test_cato_networks.py | ||
| test_cisco_ai_defense_chat.py | ||
| test_cisco_ai_defense_mcp.py | ||
| test_compresr.py | ||
| test_conduct.py | ||
| test_crowdstrike_aidr.py | ||
| test_custom_code_bounded_execution.py | ||
| test_decision_model.py | ||
| test_deepkeep.py | ||
| test_dynamoai.py | ||
| test_enkryptai.py | ||
| test_generic_guardrail_api.py | ||
| test_grayswan.py | ||
| test_headroom.py | ||
| test_hiddenlayer.py | ||
| test_javelin.py | ||
| test_lakera_ai.py | ||
| test_lakera_ai_v2.py | ||
| test_lasso.py | ||
| test_llm_shield_proxy.py | ||
| test_mcp_end_user_permission.py | ||
| test_mcp_security.py | ||
| test_microsoft_purview.py | ||
| test_model_armor.py | ||
| test_noma.py | ||
| test_noma_v2.py | ||
| test_onyx.py | ||
| test_ovalix.py | ||
| test_ovalix_extraction.py | ||
| test_pangea.py | ||
| test_panw_prisma_airs.py | ||
| test_presidio.py | ||
| test_presidio_union_fix.py | ||
| test_promptguard.py | ||
| test_qualifire.py | ||
| test_reco.py | ||
| test_repelloai.py | ||
| test_response_rejection_guardrail_code.py | ||
| test_singulr.py | ||
| test_straiker.py | ||
| test_structured_messages_writeback.py | ||
| test_tool_permission.py | ||
| test_tool_policy_guardrail.py | ||
| test_typesafe.py | ||
| test_vigil_guard.py | ||
| test_wingback.py | ||
| test_xecguard.py | ||