Repository navigation
fix(platform): mask two-digit-year dates of birth after a keyword - #5083
Closed
tale-code-bot wants to merge 1 commit into
Closed
tale-code-bot wants to merge 1 commit into
tale-code-bot wants to merge 1 commit into
Conversation
Since #1710 the numeric date-of-birth validator needs a four-digit year (yearLooksPlausible looks for /\d{4}/), so every two-digit-year match of the pattern knob was dropped: "DOB: 15/03/87", "Geburtsdatum: 15.03.87" and "date de naissance : 15/03/87" reached the model unmasked. A bare two-digit year stays unmasked, since on its own 15.03.87 reads as well as a version or a section number. A new composed pass masks it right after a date-of-birth context keyword of an enabled locale. The keyword sits in a lookbehind, so the mask keeps it ("DOB: [DATE_OF_BIRTH]", as with a four-digit year). The day and month must form a date in DMY, MDY or YMD order. The pattern description and the guardrails guide (EN, DE, FR) state the rule. Closes #4776
Contributor
|
The autonomous cycle now lands each task through the merge train instead of its own pull request ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PII protection never masked a date of birth written with a two-digit year, such as
DOB: 15/03/87,Geburtsdatum: 15.03.87ordate de naissance : 15/03/87. Since #1710 the numeric validator requires a four-digit year (yearLooksPlausiblelooks for/\d{4}/), so it dropped every\d{2}-year match of thedateOfBirth.ymlknob.Closes #4776 (Tale task TALE-154; the plan was posted on the task before the first edit).
Fix. A two-digit year on its own still passes:
15.03.87could just as well be a version or a section number, which is what #1710 stopped masking. A new pass composed inservices/platform/lib/pii/patterns/date-of-birth.tsmasks it only right after a date-of-birth keyword of an enabled locale. The keywords come fromdateOfBirth.contextKeywords(DOB,Geburtsdatum,date de naissance, …), which the locale data already has.composeKeywordAlternationand are word-bounded and case-insensitive, like the phone and national-ID keyword gates. The pass is cached in the existingDOB_REGEX_CACHE.DOB: 15/03/87becomesDOB: [DATE_OF_BIRTH], the same result asDOB: 15/03/1987.생년월일: 87.03.15).:or:,.,,,=or dashes. The date must not run on into more digits or letters, so15.03.87.12and15/03/87abcare not masked.The knob regex and the four-digit validator are unchanged. The pattern description and the guardrails guide (EN, DE, FR) state the rule; the guide's sentence sits next to the existing one on keyword-gated identifiers.
Known limits:
s., plur., cs/sk/uknar., idTTL. For example,s. 3.2.10would be masked. That is still narrower than the four-digit pass, which masks any plausible date anywhere.Checklist
bun run check: not run in full on this worker (lint, typecheck, test and test:ui of every workspace). The gates this change touches ran instead; see the test plan. CI runs the rest.bun run lint:sast: not run. The pinned opengrep binary is not cached on this worker, and fetching it is outside the lock files; the pre-commit opengrep step skipped for the same reason. CI's SAST job runs it.docs/{en,de,fr}/platform/admin/governance/guardrails.md.Test plan
Before the fix. At
main9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2with only the new tests added, fromservices/platform:Result: 4 failed, 54 passed. Exactly the four keyword cases failed, each with
expected 'pass' to be 'modified'.After the fix. At head
bdefd7f8cd04c4ecbdc33d0a631a179cd5362809, fromservices/platformunless noted:bunx vitest --run --project piibunx vitest --run --project server lib/chat/guardrails.test.ts backend/domains/model_api/guardrails.test.ts backend/core/knowledge/pii_gate.test.tsNODE_OPTIONS=--max-old-space-size=6144 bunx tsc --noEmit(CI's heap budget)bunx oxlint --type-awarebunx vitest --runinservices/docsbun run lint:links(repo root)oxfmt --checkon the touched filesNew smoke tests:
DOB: 15/03/87,Geburtsdatum: 15.03.87,date de naissance : 15/03/87and생년월일: 87.03.15become<keyword>: [DATE_OF_BIRTH], withdateOfBirthas the only category.15.03.87passes.DOB: 45/13/87passes.DOB: [DATE_OF_BIRTH].Not tested: the chat, model-API and knowledge paths end to end on a running platform, and the guide rendered in a browser.