litellm/tests/guardrails_tests
Ron Zhong 73fd5a41e4
feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948)
* feat: Singapore PDPA PII protection guardrail policy template

Add Singapore Personal Data Protection Act (PDPA) guardrail support:

Regex patterns (patterns.json):
- sg_nric: NRIC/FIN detection ([STFGM] + 7 digits + checksum letter)
- sg_phone: Singapore phone numbers (+65/0065/65 prefix)
- sg_postal_code: 6-digit postal codes (contextual)
- passport_singapore: Passport numbers (E/K + 7 digits, contextual)
- sg_uen: Unique Entity Numbers (3 formats)
- sg_bank_account: Bank account numbers (dash format, contextual)

YAML policy templates (5 sub-guardrails):
- sg_pdpa_personal_identifiers: s.13 Consent
- sg_pdpa_sensitive_data: Advisory Guidelines
- sg_pdpa_do_not_call: Part IX DNC Registry
- sg_pdpa_data_transfer: s.26 overseas transfers
- sg_pdpa_profiling_automated_decisions: Model AI Governance Framework

Policy template entry in policy_templates.json with 9 guardrail definitions
(4 regex-based + 5 YAML conditional keyword matching).

Tests:
- test_sg_patterns.py: regex pattern unit tests
- test_sg_pdpa_guardrails.py: conditional keyword matching tests (100+ cases)

* feat: MAS AI Risk Management Guidelines guardrail policy template

Add Monetary Authority of Singapore (MAS) AI Risk Management Guidelines
guardrail support for financial institutions:

YAML policy templates (5 sub-guardrails):
- sg_mas_fairness_bias: Blocks discriminatory financial AI (credit/loans/insurance by protected attributes)
- sg_mas_transparency_explainability: Blocks opaque/unexplainable AI for consequential financial decisions
- sg_mas_human_oversight: Blocks fully automated financial decisions without human-in-the-loop
- sg_mas_data_governance: Blocks unauthorized sharing/mishandling of financial customer data
- sg_mas_model_security: Blocks adversarial attacks, model poisoning, inversion on financial AI

Policy template entry in policy_templates.json with 5 guardrail definitions.
Aligned with MAS FEAT Principles, Project MindForge, and NIST AI RMF.

Tests:
- test_sg_mas_ai_guardrails.py: conditional keyword matching tests (100+ cases)

* fix: address SG pattern review feedback

- Update NRIC lowercase test for IGNORECASE runtime behavior
- Add keyword context guard to sg_uen pattern to reduce false positives

* docs: clarify MAS AIRM timeline references

- Explicitly mark MAS AIRM as Nov 2025 consultation draft
- Add 2018 qualifier for FEAT principles in MAS policy descriptions
- Update MAS guardrail wording to avoid release-year ambiguity

* chore: commit resolved MAS policy conflicts

* test:

* chore:
2026-02-23 12:08:22 -08:00
..
conftest.py [Feat] Guardrails - add logging for important status fields (#15090) 2025-09-30 18:38:07 -07:00
test_bedrock_guardrails.py fix: test_convert_to_bedrock_format_post_call_streaming_hook 2026-01-20 18:27:36 +05:30
test_custom_guardrail.py [Feat] Presidio Improvements - Allow adding presidio api base on UI, Test presidio on Test Key, fixes for running presidio hook (#10840) 2025-05-14 17:41:33 -07:00
test_dynamoai_guardrails.py [Fix] CI/CD #1 - mypy | check_code_and_doc_quality | guardrails_testing (#18195) 2025-12-18 06:31:01 -08:00
test_eu_ai_act_article5.py feat: EU AI Act Article 5 policy template for prohibited practices detection (#21342) 2026-02-16 15:33:07 -08:00
test_eu_ai_act_french_3_scenarios.py Add French language support for EU AI Act Article 5 guardrail (#21427) 2026-02-17 16:07:54 -08:00
test_guardrail_load_balancing.py [Feat] Guardrails Load Balancing - Allow Platform admins to load balance between guardrails (#18181) 2025-12-19 00:08:03 +05:30
test_guardrails_config.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
test_javelin_guardrails.py fix: reject status code and tests. 2025-09-28 16:56:28 +05:30
test_lakera_v2.py [Release Day] - Fixed CI/CD issues & changed processes (#19902) 2026-01-28 17:57:24 -08:00
test_lasso_guardrails.py [Feat] New Guardrail - Dynamo AI Guardrail (#15920) 2025-10-24 17:11:04 -07:00
test_presidio_pii.py Fix Presidio guardrail test TypeError and license base64 decoding error (#17538) 2025-12-05 08:45:02 -08:00
test_semantic_guard.py feat: prompt injection guardrail policy template (#21520) 2026-02-19 15:06:06 -08:00
test_sg_mas_ai_guardrails.py feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948) 2026-02-23 12:08:22 -08:00
test_sg_pdpa_guardrails.py feat: Singapore guardrail policies (PDPA + MAS AI Risk Management) (#21948) 2026-02-23 12:08:22 -08:00
test_tracing_guardrails.py fix: test_standard_logging_payload_includes_guardrail_information 2026-01-20 18:21:32 +05:30
test_zscaler_ai_guard.py fix(guardrails): Zscaler AI Guard bug fixes and support during post-call (#20801) 2026-02-13 11:28:14 -08:00