litellm/ui/litellm-dashboard
Krish Dholakia ff8e01d20b
feat: Add Canadian PII protection (PIPEDA) (#22951)
* feat: Add Canadian PII protection patterns and PIPEDA-compliant policy template

Adds 6 new Canadian PII regex pattern detectors to patterns.json:
- ca_sin: Social Insurance Number (PIPEDA Privacy Act, Income Tax Act)
- ca_ohip: Ontario Health Insurance Plan Number (PHIPA)
- ca_on_drivers_licence: Ontario driver's licence (HTA, PIPEDA)
- ca_immigration_doc: IRCC immigration docs (UCI, work/study permits, IMM refs)
- ca_bank_account: Canadian bank account routing (transit-institution-account)
- ca_postal_code: Canadian postal code (Canada Post spec)

Adds comprehensive policy template 'canadian-pii-protection' (id: canadian-pii-protection)
with 5 sub-guardrails grouping patterns by data type. All patterns include contextual
keyword matching (English + French keywords where applicable) to reduce false positives.
Complements existing passport_canada pattern.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat: Add Canadian PII compliance dataset and tests (57 tests)

Adds:
- test_ca_patterns.py: 30 unit tests for regex pattern matching (SIN, OHIP,
  driver's licence, immigration docs, bank account, postal code)
- test_ca_policy_e2e.py: 27 end-to-end tests running the full
  ContentFilterGuardrail pipeline with MASK action — validates detection
  of real PII and pass-through of clean prompts
- canadianPiiCompliancePrompts.ts: 21-prompt compliance dataset for UI
  evaluation, wired into the main compliancePrompts framework

Fixes keyword_pattern alternation ordering in patterns.json — longer
alternatives (e.g. "social insurance number") now precede shorter ones
("social insurance") to avoid excessive gap-word count when the regex
engine selects the shorter match first.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat: Add University of Toronto FIPPA identifier patterns and tests (36 tests)

Add 3 UofT institutional identifiers (student/employee number, UTORid, TCard)
covered under Ontario FIPPA. Includes pattern definitions, policy template
sub-guardrail, compliance prompts, unit tests, and e2e tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Correct test assertion bug and inaccurate docstring

Fix test_utorid_masked checking `result` (dict) instead of `output` (string).
Update test_ca_policy_e2e.py docstring to clarify scope vs UofT tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Address Greptile review feedback

- Tighten ca_postal_code keyword_pattern: replace broad "address" with
  specific compound terms (mailing/street/shipping/home address)
- Add missing "PIPEDA" tag to policy_templates.json for discoverability
- Add us_phone pattern to test_ca_policy_e2e.py setup to match deployed template
- Add phone number e2e test for complete coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Tighten patterns to reduce false positives and add missing test coverage

- ca_sin: reject leading-zero SINs ([1-9]\d{2}), set allow_word_numbers to false
- ca_immigration_doc: require separators in UCI pattern (prevent bare \d{10} match)
- uoft_utorid: qualify generic keywords (acorn -> acorn login, quercus -> quercus login)
- uoft_tcard: remove generic keywords (student card, id card, library card) that
  overlap with credit card contexts; keep only UofT-specific terms (tcard, campus card)
- Add visa/mastercard/amex/iban patterns to test_ca_policy_e2e.py setup to match
  deployed template; add Visa card masking test
- Add test verifying "student card" no longer triggers TCard redaction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-06 18:27:31 -08:00
..
e2e_tests injecting localstorage values to hide usageIndicator, prompts, and new badges 2026-02-14 15:49:27 -08:00
public [UI QA] - Add all provider models + providers on ui (#22461) 2026-02-28 17:35:08 -08:00
scripts feat: add insults content filter + topic blocking compliance UI (#21729) 2026-02-20 19:10:31 -08:00
src feat: Add Canadian PII protection (PIPEDA) (#22951) 2026-03-06 18:27:31 -08:00
tests Merge remote-tracking branch 'origin' into feature/vkey-modal-squashed 2026-03-06 16:51:21 -08:00
.env.development hidden dashboard routing, dev and build env files 2025-10-06 19:21:34 -07:00
.env.production hidden dashboard routing, dev and build env files 2025-10-06 19:21:34 -07:00
.eslintrc.json removed unused imports 2025-10-10 10:25:00 -07:00
.prettierignore added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
.prettierrc added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
.trivyignore fix pkg lock 2025-11-14 18:59:49 -08:00
build_release_ui.sh build release ui script 2026-01-17 18:16:14 -08:00
build_ui_custom_path.sh
build_ui.sh upgraded build script to node 20 2025-09-18 18:01:47 -07:00
knip.json add knip as a dev dependency, remove some unused files 2026-02-07 15:51:21 -08:00
next.config.mjs react 19 2026-01-31 18:33:03 -08:00
package-lock.json fix(chat): fix /ui/chat routing, Suspense boundary, serverRootPath support (#22945) 2026-03-05 20:00:25 -08:00
package.json feat(ui): add Chat UI — ChatGPT-like interface with MCP tools and streaming (#22937) 2026-03-05 18:13:04 -08:00
postcss.config.js
README.md
tailwind.config.js added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
tailwind.config.ts added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
tsconfig.json Fix MCP server search in playground (#22824) 2026-03-04 17:14:18 -08:00
tsconfig.tsbuildinfo [Feature] UI - Paginated Key Alias Select 2026-02-25 22:21:32 -08:00
ui_colors.json added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
vitest.config.ts Fixing tests 2026-01-22 15:01:06 -08:00

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.