Skip to content

Commit 7a0a13f

Browse files
committed
Adding Korean RRN
1 parent d934a65 commit 7a0a13f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ site/
101101
__pycache__/
102102
*.pyc
103103
.pytest_cache/
104+
105+
# internal examples
106+
internal_examples/

src/__tests__/unit/checks/pii.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,31 @@ describe('pii guardrail', () => {
4242

4343
await expect(pii({}, '', config)).rejects.toThrow('Text cannot be empty or null');
4444
});
45+
46+
it('detects Korean Resident Registration Number (KR_RRN)', async () => {
47+
const config = PIIConfig.parse({
48+
entities: [PIIEntity.KR_RRN],
49+
block: false,
50+
});
51+
const text = 'Korean RRN: 123456-1234567';
52+
53+
const result = await pii({}, text, config);
54+
55+
expect(result.tripwireTriggered).toBe(false);
56+
expect((result.info?.detected_entities as Record<string, string[]>)?.KR_RRN).toEqual(['123456-1234567']);
57+
expect(result.info?.checked_text).toBe('Korean RRN: <KR_RRN>');
58+
});
59+
60+
it('triggers tripwire for KR_RRN when block=true', async () => {
61+
const config = PIIConfig.parse({
62+
entities: [PIIEntity.KR_RRN],
63+
block: true,
64+
});
65+
const text = 'Korean RRN: 123456-1234567';
66+
67+
const result = await pii({}, text, config);
68+
69+
expect(result.tripwireTriggered).toBe(true);
70+
expect((result.info?.detected_entities as Record<string, string[]>)?.KR_RRN).toEqual(['123456-1234567']);
71+
});
4572
});

src/checks/pii.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ export enum PIIEntity {
125125

126126
// Finland
127127
FI_PERSONAL_IDENTITY_CODE = 'FI_PERSONAL_IDENTITY_CODE',
128+
129+
// Korea
130+
KR_RRN = 'KR_RRN',
128131
}
129132

130133
/**
@@ -236,6 +239,9 @@ const DEFAULT_PII_PATTERNS: Record<PIIEntity, RegExp> = {
236239

237240
// Finland
238241
[PIIEntity.FI_PERSONAL_IDENTITY_CODE]: /\b\d{6}[+-A]\d{3}[A-Z0-9]\b/g,
242+
243+
// Korea
244+
[PIIEntity.KR_RRN]: /\b\d{6}-\d{7}\b/g,
239245
};
240246

241247
/**

0 commit comments

Comments
 (0)