flare-redact 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +3 -3
- package/SECURITY.md +1 -1
- package/dist/detectors.d.ts +1 -2
- package/dist/detectors.d.ts.map +1 -1
- package/dist/detectors.js +8 -4
- package/dist/detectors.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +24 -6
- package/dist/engine.js.map +1 -1
- package/dist/extra.d.ts.map +1 -1
- package/dist/extra.js +3 -1
- package/dist/extra.js.map +1 -1
- package/dist/fold.d.ts +22 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/fold.js +140 -0
- package/dist/fold.js.map +1 -0
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +13 -9
- package/dist/help.js.map +1 -1
- package/dist/i18n.d.ts +10 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +18 -1
- package/dist/i18n.js.map +1 -1
- package/dist/pack.d.ts +2 -2
- package/dist/pack.d.ts.map +1 -1
- package/dist/pack.js +9 -7
- package/dist/pack.js.map +1 -1
- package/dist/terms.d.ts +4 -4
- package/dist/terms.d.ts.map +1 -1
- package/dist/terms.js +22 -13
- package/dist/terms.js.map +1 -1
- package/docs/guide.md +33 -15
- package/package.json +1 -1
- package/spec/SPEC.md +142 -51
- package/spec/conformance/README.md +7 -4
- package/spec/conformance/cases.json +22 -0
- package/spec/conformance/expected.json +378 -0
- package/spec/detectors.json +4 -4
- package/spec/detectors.schema.json +1 -1
package/spec/SPEC.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
**Status:** stable · **Revision:** FRS-1 · **Reference pack:** [`detectors.json`](./detectors.json) · **Schema:** [`detectors.schema.json`](./detectors.schema.json)
|
|
4
4
|
|
|
5
5
|
FRS-1 defines how a *detector pack* is written and how an engine must execute it,
|
|
6
|
-
in enough detail that
|
|
7
|
-
Python, Go and
|
|
8
|
-
options and pack. The [conformance corpus](./conformance/) is the executable form
|
|
6
|
+
in enough detail that six independent implementations (JavaScript/TypeScript,
|
|
7
|
+
Python, Go, Rust, Java and C#/.NET) produce **byte-identical output** for the
|
|
8
|
+
same input, options and pack. The [conformance corpus](./conformance/) is the executable form
|
|
9
9
|
of this document; a change that breaks it breaks the spec.
|
|
10
10
|
|
|
11
|
-
The reason for a spec rather than
|
|
12
|
-
in
|
|
11
|
+
The reason for a spec rather than six ports is drift. Detection logic that lives
|
|
12
|
+
in six hand-maintained copies diverges within a release or two, and a redactor
|
|
13
13
|
that behaves differently per language is worse than no redactor, because the team
|
|
14
14
|
stops being able to reason about what leaves the process.
|
|
15
15
|
|
|
@@ -34,19 +34,20 @@ stops being able to reason about what leaves the process.
|
|
|
34
34
|
|
|
35
35
|
## 1. Why a restricted regular-expression subset
|
|
36
36
|
|
|
37
|
-
The
|
|
37
|
+
The target engines do not agree on the syntax or the semantics of a "normal"
|
|
38
38
|
regular expression:
|
|
39
39
|
|
|
40
|
-
| Construct | JavaScript | Python `re` | Go `regexp` (RE2) | Rust `regex` |
|
|
41
|
-
|
|
42
|
-
| Lookahead / lookbehind | yes | yes | **no** | **no** |
|
|
43
|
-
| Backreferences | yes | yes | **no** | **no** |
|
|
44
|
-
| `\b` | ASCII | **Unicode** | ASCII | **Unicode** |
|
|
45
|
-
| `\d`, `\w` | ASCII | **Unicode** | ASCII | **Unicode** |
|
|
46
|
-
| `\s` | +Unicode spaces | Unicode | **ASCII, no `\v`** | Unicode |
|
|
47
|
-
| `\p{L}` | with `u` flag | **unsupported** | yes | yes |
|
|
48
|
-
| `(?s:…)` scoped flags | **no** | yes | yes | yes |
|
|
49
|
-
|
|
|
40
|
+
| Construct | JavaScript | Python `re` | Go `regexp` (RE2) | Rust `regex` | Java `java.util.regex` | .NET `Regex` |
|
|
41
|
+
|---|---|---|---|---|---|---|
|
|
42
|
+
| Lookahead / lookbehind | yes | yes | **no** | **no** | yes | yes |
|
|
43
|
+
| Backreferences | yes | yes | **no** | **no** | yes | yes |
|
|
44
|
+
| `\b` | ASCII | **Unicode** | ASCII | **Unicode** | ASCII | **Unicode** |
|
|
45
|
+
| `\d`, `\w` | ASCII | **Unicode** | ASCII | **Unicode** | ASCII | **Unicode** |
|
|
46
|
+
| `\s` | +Unicode spaces | Unicode | **ASCII, no `\v`** | Unicode | **ASCII** | Unicode |
|
|
47
|
+
| `\p{L}` | with `u` flag | **unsupported** | yes | yes | yes | **BMP only** |
|
|
48
|
+
| `(?s:…)` scoped flags | **no** | yes | yes | yes | yes | yes |
|
|
49
|
+
| `.` | not `\n \r U+2028 U+2029` | not `\n` | not `\n` | not `\n` | **also not U+0085** | not `\n`, **one UTF-16 unit** |
|
|
50
|
+
| `$` without multiline | end of input | **also before a final newline** | end of input | end of input | **also before a final line break** | **also before a final newline** |
|
|
50
51
|
|
|
51
52
|
Every one of those rows is a silent behaviour difference — the kind that makes a
|
|
52
53
|
secret redacted on the Node service and passed through on the Python worker. FRS-1
|
|
@@ -60,7 +61,9 @@ catastrophic backtracking, so a pack cannot introduce a ReDoS into a host proces
|
|
|
60
61
|
|
|
61
62
|
A pattern **may** use:
|
|
62
63
|
|
|
63
|
-
- literals, and
|
|
64
|
+
- literals, and `.`, which matches any character except the four JavaScript line
|
|
65
|
+
terminators `\n`, `\r`, U+2028 and U+2029 (an engine whose `.` differs spells
|
|
66
|
+
the set out, for example `[^\n\r\x{2028}\x{2029}]`)
|
|
64
67
|
- character classes `[…]`, `[^…]`, ranges, and the escapes `\t \n \r \f \x0B \xHH \\ \. \* \+ \? \( \) \[ \] \{ \} \| \^ \$ \/ \-`
|
|
65
68
|
- groups `(…)` (capturing) and `(?:…)` (non-capturing)
|
|
66
69
|
- alternation `|`
|
|
@@ -82,26 +85,57 @@ A pattern **must not** use:
|
|
|
82
85
|
Engines textually replace these **before** compiling, so the compiled automaton is
|
|
83
86
|
native and fast:
|
|
84
87
|
|
|
85
|
-
| Token | Meaning | JavaScript | Python | Go | Rust |
|
|
86
|
-
|
|
87
|
-
| `{{ANY}}` | any single character, including line terminators | `[\s\S]` | `[\s\S]` | `(?s:.)` | `(?s:.)` |
|
|
88
|
-
| `{{L}}` | any single Unicode letter | `\p{L}` | `[^\W\d_]` | `\p{L}` | `\p{L}` |
|
|
88
|
+
| Token | Meaning | JavaScript | Python | Go | Rust | Java | .NET |
|
|
89
|
+
|---|---|---|---|---|---|---|---|
|
|
90
|
+
| `{{ANY}}` | any single character, including line terminators | `[\s\S]` | `[\s\S]` | `(?s:.)` | `(?s:.)` | `(?s:.)` | a surrogate pair, or one unit that does not start a pair |
|
|
91
|
+
| `{{L}}` | any single Unicode letter | `\p{L}` | `[^\W\d_]` | `\p{L}` | `\p{L}` | `\p{L}` | `\p{L}`, or a surrogate pair from the astral letters |
|
|
89
92
|
|
|
90
93
|
`{{L}}` must not appear inside a character class — write `(?:{{L}}|[0-9.-])`
|
|
91
94
|
instead of `[{{L}}0-9.-]`. This is what lets the Python engine expand it to the
|
|
92
95
|
`[^\W\d_]` idiom, which is a complete class and cannot be nested.
|
|
93
96
|
|
|
97
|
+
.NET regular expressions match UTF-16 code units, where every other engine
|
|
98
|
+
matches code points. The .NET engine therefore translates the whole pattern:
|
|
99
|
+
an astral literal becomes its surrogate pair as one group, a class that holds
|
|
100
|
+
astral code points gains pair alternatives, and `.`, `{{ANY}}` and a negated
|
|
101
|
+
class consume a whole pair or none of it, so no match can start or end inside a
|
|
102
|
+
character.
|
|
103
|
+
|
|
94
104
|
### Flags
|
|
95
105
|
|
|
96
|
-
`flags` is `""` or `"i"`. Case-insensitive matching is Unicode simple case folding
|
|
97
|
-
|
|
106
|
+
`flags` is `""` or `"i"`. Case-insensitive matching is Unicode simple case folding
|
|
107
|
+
(`CaseFolding.txt`, statuses C and S) with one addition: **i, I, İ (U+0130) and
|
|
108
|
+
ı (U+0131) are one class.** Simple folding keeps the two Turkish letters apart
|
|
109
|
+
from i, which would let `ŞİFRE`, `GİZLİ`, `MƏXFİ` and identifiers upper-cased
|
|
110
|
+
under a Turkish locale (`APİ_KEY`) past every keyword.
|
|
98
111
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
An engine whose regular expressions fold exactly rewrites a case-insensitive
|
|
113
|
+
pattern before compiling it: a literal i, I, İ or ı (also when written `\x49` or
|
|
114
|
+
`\x69`) becomes `[iIİı]`, and a character class that holds any of the four,
|
|
115
|
+
directly or inside a range, gains the other three, which for a negated class
|
|
116
|
+
keeps all four out. Python's `re.IGNORECASE` already treats the four as one class
|
|
117
|
+
and compiles the pattern unchanged.
|
|
118
|
+
|
|
119
|
+
| | case-sensitive | case-insensitive |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| JavaScript | `new RegExp(pattern, "gu")` | `new RegExp(rewritten, "giu")` |
|
|
122
|
+
| Python | `re.compile(pattern)` | `re.compile(pattern, re.IGNORECASE)` (never `re.ASCII`) |
|
|
123
|
+
| Go | `regexp.MustCompile(pattern)` | `regexp.MustCompile("(?i)" + rewritten)` |
|
|
124
|
+
| Rust | `RegexBuilder::new(pattern)` | `RegexBuilder::new(rewritten).case_insensitive(true)` |
|
|
125
|
+
| Java | `Pattern.compile(translated)` | `Pattern.compile(translated)`, the pattern spelled out with whole case classes |
|
|
126
|
+
| .NET | `new Regex(translated)` | `new Regex(translated)`, the pattern spelled out with whole case classes |
|
|
127
|
+
|
|
128
|
+
Java and .NET do not use their own case-insensitive flag, whose folding differs
|
|
129
|
+
from the spec's and changes with the runtime's Unicode version. Each ships the
|
|
130
|
+
closure of simple case folding (Unicode 17, plus the i class above) as a table
|
|
131
|
+
and translates a case-insensitive pattern into a case-sensitive one: every
|
|
132
|
+
literal becomes the class of characters that fold together with it, and every
|
|
133
|
+
class gains the members that fold into it.
|
|
134
|
+
|
|
135
|
+
These rules hold everywhere this document says *case-insensitive*: the pattern
|
|
136
|
+
and `reject` patterns of an `"i"` detector, a mask pattern with its own
|
|
137
|
+
`"flags": "i"`, `context` words, the `prefilter` test and `terms`. Validator
|
|
138
|
+
patterns are always case-sensitive.
|
|
105
139
|
|
|
106
140
|
### Anchored sub-patterns
|
|
107
141
|
|
|
@@ -117,6 +151,8 @@ Implementations wrap these themselves (`^(?:…)` and `^(?:…)$`, or `re.match`
|
|
|
117
151
|
`re.fullmatch`). Because the wrapping is applied by the engine and never by the
|
|
118
152
|
pack author, Python's "`$` also matches before a trailing newline" behaviour is
|
|
119
153
|
avoided: Python engines use `re.match` / `re.fullmatch`, which do not have it.
|
|
154
|
+
Java and .NET have the same `$` behaviour as Python and write the full-match
|
|
155
|
+
anchor as `\z`, which is the end of input only.
|
|
120
156
|
|
|
121
157
|
## 3. Detector fields
|
|
122
158
|
|
|
@@ -140,8 +176,9 @@ the input always satisfy a boundary.
|
|
|
140
176
|
| `base64url` | `[A-Za-z0-9_+/=-]` |
|
|
141
177
|
| `word_dash` | `[A-Za-z0-9_-]` |
|
|
142
178
|
|
|
143
|
-
Membership is tested on UTF-16 code units in JavaScript,
|
|
144
|
-
|
|
179
|
+
Membership is tested on UTF-16 code units in JavaScript, Java and .NET, and on
|
|
180
|
+
Unicode scalar values in Python, Go and Rust; every class is ASCII-only, so the
|
|
181
|
+
two agree.
|
|
145
182
|
|
|
146
183
|
`{"before": "word", "after": "word"}` is the portable spelling of `\b…\b` for a
|
|
147
184
|
pattern that starts and ends with a word character.
|
|
@@ -222,7 +259,9 @@ For a subject string *S* and a resolved, ordered detector list *D*:
|
|
|
222
259
|
`p a ss w o r d` is caught and the original characters are what get
|
|
223
260
|
replaced.
|
|
224
261
|
2. For each detector *d* in *D*, **in pack order**:
|
|
225
|
-
1. If `prefilter` is set and
|
|
262
|
+
1. If `prefilter` is set and none of its literals occurs in *S′*, compared
|
|
263
|
+
case-insensitively ([§2](#flags)), skip *d*. A prefilter only saves work: it
|
|
264
|
+
must never skip a detector whose pattern would match.
|
|
226
265
|
2. Scan *S′* left to right for successive non-overlapping matches of `pattern`.
|
|
227
266
|
3. For each match:
|
|
228
267
|
1. Take the span of capture group `capture` (0 = whole match). If the group
|
|
@@ -267,9 +306,9 @@ The algorithm:
|
|
|
267
306
|
4. Walk back from the end, taking *i* when `weight(i) + best[p[i]+1] > best[i−1]`.
|
|
268
307
|
|
|
269
308
|
Every step is integer/IEEE-754 double arithmetic with a fixed evaluation order, so
|
|
270
|
-
all
|
|
271
|
-
|
|
272
|
-
`slice::sort_by`).
|
|
309
|
+
all six engines compute the same sums. Sort stability is guaranteed by the
|
|
310
|
+
library in all six cases (`Array.prototype.sort`, `sorted`, `sort.SliceStable`,
|
|
311
|
+
`slice::sort_by`, `List.sort`, LINQ `OrderBy`).
|
|
273
312
|
|
|
274
313
|
A single candidate short-circuits: with fewer than two candidates the list is
|
|
275
314
|
returned unchanged.
|
|
@@ -285,19 +324,35 @@ score = clamp(score, 0, 1)
|
|
|
285
324
|
```
|
|
286
325
|
|
|
287
326
|
`P(secret)` comes from the logistic model carried in the pack's `confidenceModel`.
|
|
288
|
-
Its 14 features are computed over the captured value plus a
|
|
327
|
+
Its 14 features are computed over the captured value plus a window of 64
|
|
328
|
+
characters on each side of it:
|
|
289
329
|
|
|
290
330
|
`log2Len`, `entropy`, `fracLower`, `fracUpper`, `fracDigit`, `fracSymbol`,
|
|
291
331
|
`fracHex`, `vowelFrac`, `classTransitionRate`, `hasMixedClasses`, `maxRunFrac`,
|
|
292
332
|
`structuredHexId`, `ctxSecret`, `ctxBenign`.
|
|
293
333
|
|
|
294
|
-
Feature extraction is defined over UTF-16 code units in JavaScript and
|
|
295
|
-
Unicode scalar values
|
|
334
|
+
Feature extraction is defined over UTF-16 code units in JavaScript, Java and
|
|
335
|
+
.NET, and over Unicode scalar values in Python, Go and Rust; the features are ASCII-classifying, and `entropy`
|
|
296
336
|
is defined over code points in every engine, so the vectors agree for any input.
|
|
297
337
|
The model only ever moves a score that a detector opted into with `refine: true`,
|
|
298
338
|
and only when the host passes `refineConfidence`. Checksum-validated detectors
|
|
299
339
|
never opt in — they are already certain.
|
|
300
340
|
|
|
341
|
+
The value and the windows are taken from the input *S* around the reported span
|
|
342
|
+
(so a zero-width character inside them counts), measured in the unit of offsets
|
|
343
|
+
(UTF-16 code units in JavaScript, Java and .NET, characters in Python, Go and
|
|
344
|
+
Rust) and clipped at the ends of
|
|
345
|
+
the input; a detector's `context.window` (80 when absent) is measured the same
|
|
346
|
+
way.
|
|
347
|
+
`ctxSecret` and `ctxBenign` are 1 when the window contains one of these words
|
|
348
|
+
with neither neighbour in `[A-Za-z0-9_]`, compared with ASCII-only case folding
|
|
349
|
+
(A-Z against a-z and nothing else, so `ſecret` does not count):
|
|
350
|
+
|
|
351
|
+
| Feature | Words |
|
|
352
|
+
|---|---|
|
|
353
|
+
| `ctxSecret` | `secret`, `api[_-]?key`, `apikey`, `token`, `password`, `passwd`, `pwd`, `auth`, `authorization`, `bearer`, `access[_-]?key`, `private[_-]?key`, `client[_-]?secret`, `credential`, `signing[_-]?key` |
|
|
354
|
+
| `ctxBenign` | `uuid`, `guid`, `sha1`, `sha256`, `sha512`, `md5`, `hash`, `digest`, `etag`, `checksum`, `commit`, `revision`, `request[_-]?id`, `trace[_-]?id`, `correlation[_-]?id`, `span[_-]?id`, `object[_-]?id`, `content[_-]?id`, `version`, `colou?r`, `slug`, `filename` |
|
|
355
|
+
|
|
301
356
|
## 7. Replacement modes
|
|
302
357
|
|
|
303
358
|
| Mode | Replacement |
|
|
@@ -351,35 +406,56 @@ deriveBytes(secret, context, n):
|
|
|
351
406
|
`<number> <street> Street`; anything else falls back to `pseudonym`.
|
|
352
407
|
|
|
353
408
|
Indexing is by **Unicode scalar value** in Python, Go and Rust, and by UTF-16 code
|
|
354
|
-
unit in JavaScript. Because the alphabets are ASCII and non-ASCII characters are
|
|
409
|
+
unit in JavaScript, Java and .NET. Because the alphabets are ASCII and non-ASCII characters are
|
|
355
410
|
passed through unchanged, the outputs agree for all inputs. The `deriveBytes`
|
|
356
411
|
length is the length in the engine's own unit; a pack that needs cross-language
|
|
357
412
|
identical pseudonyms for astral-plane input should mask those detectors instead.
|
|
358
413
|
|
|
359
414
|
## 9. Sensitive keys, allowlists and terms
|
|
360
415
|
|
|
361
|
-
- **`redactKeys
|
|
362
|
-
sensitive by name, the value is replaced without pattern matching.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
416
|
+
- **`redactKeys`**: when a structured input has a string value under a key that is
|
|
417
|
+
sensitive by name, the value is replaced without pattern matching. Keys are
|
|
418
|
+
compared in a **normalised form**: İ and ı become i, every character takes its
|
|
419
|
+
simple lowercase mapping (`UnicodeData.txt`), then ς becomes σ and ſ becomes s.
|
|
420
|
+
A locale-free full lowercase (`toLowerCase`, `str.lower`) differs from simple
|
|
421
|
+
lowercasing only in İ and the final-sigma rule, both of which this form erases,
|
|
422
|
+
so `ŞİFRE`, `GİZLİ`, `ΚΩΔΙΚΌΣ` and `APİ_KEY` are recognised by every engine.
|
|
423
|
+
The default test is that the normalised key fully matches `SENSITIVE_KEY_RE`
|
|
424
|
+
(`password`, `secret`, `token`, `api_key`, `authorization`, `cookie`,
|
|
425
|
+
`session_id`, `credit_card`, `cvv`, `ssn`, …) or equals a multilingual keyword
|
|
426
|
+
in normalised form. A host-supplied list of key names is compared the same way.
|
|
427
|
+
The finding is reported as detector `sensitive_key`, risk `critical`,
|
|
428
|
+
confidence `0.98`.
|
|
367
429
|
- **`allow`** — exact values (or a host regular expression) that are never
|
|
368
430
|
redacted. Tested against the raw slice *and* against the zero-width-normalised
|
|
369
431
|
slice, so ``-padded look-alikes cannot slip past an allowlist entry.
|
|
370
|
-
- **`terms
|
|
371
|
-
|
|
372
|
-
|
|
432
|
+
- **`terms`**: host-supplied literals, reported as detector `custom_term` and
|
|
433
|
+
prepended to the detector list, so they take part in overlap resolution like any
|
|
434
|
+
other candidate. They are ordered longest first by character count, equal
|
|
435
|
+
lengths keeping the caller's order. Scanning *S′* left to right, at each
|
|
436
|
+
position the first term in that order that matches there (case-insensitively
|
|
437
|
+
per [§2](#flags) unless `termsCaseSensitive` is set) and whose neighbours are
|
|
438
|
+
not a letter, a combining mark, a number (general categories L, M and N) or `_`
|
|
439
|
+
is taken, and the scan resumes after it; when none is, the scan moves on one
|
|
440
|
+
character. That is what a backtracking engine does with
|
|
441
|
+
`(?<![\p{L}\p{M}\p{N}_])(?:t1|t2|…)(?![\p{L}\p{M}\p{N}_])`. An engine without
|
|
442
|
+
lookaround checks the neighbours itself and, when they fail, tries the
|
|
443
|
+
remaining terms at the same position before moving on. Marks belong to the
|
|
444
|
+
word, so `राज` does not match inside `राजा`. A match is replaced by its own
|
|
445
|
+
term's `replace` text, or `***`.
|
|
373
446
|
|
|
374
447
|
## 10. Structured data
|
|
375
448
|
|
|
376
449
|
Redacting a structure is defined as redacting every string reachable from it:
|
|
377
450
|
|
|
378
|
-
-
|
|
451
|
+
- values of objects, dicts and maps, array/list elements, set members
|
|
452
|
+
- the keys of a host map type other than the JSON object model (a JavaScript `Map`)
|
|
379
453
|
- error/exception messages
|
|
380
454
|
- the string form of URLs and query strings
|
|
381
455
|
|
|
382
|
-
|
|
456
|
+
The member names of a JSON object are field names and are never redacted, in
|
|
457
|
+
whatever type an engine uses for one: a JavaScript object, a Python `dict`, a Go
|
|
458
|
+
`map[string]any`, a `serde_json::Map`. Cycles are visited once. Non-string leaves (numbers, booleans, null, binary
|
|
383
459
|
buffers, dates) are returned as-is; a redactor that stringifies numbers changes
|
|
384
460
|
meaning, and a redactor that walks binary blobs wastes the caller's CPU.
|
|
385
461
|
|
|
@@ -402,7 +478,8 @@ mapping, so the same secret gets the same placeholder everywhere in a session an
|
|
|
402
478
|
`restore` puts the originals back — the round trip that makes "send a prompt to a
|
|
403
479
|
model without sending the data" work.
|
|
404
480
|
|
|
405
|
-
- Default placeholders are **opaque**: `[FR_<DETECTOR_ID>_<12 random bytes, hex>]
|
|
481
|
+
- Default placeholders are **opaque**: `[FR_<DETECTOR_ID>_<12 random bytes, hex>]`,
|
|
482
|
+
the bytes drawn from a cryptographically secure generator.
|
|
406
483
|
They carry no counter, so an observer cannot tell how many distinct values a
|
|
407
484
|
session has seen or which appeared first.
|
|
408
485
|
- `readable` placeholders (`[EMAIL_1]`) are predictable and are for local
|
|
@@ -458,6 +535,10 @@ partial tool input, and output the request asked to be JSON.
|
|
|
458
535
|
| `maxInputLength` | 16 MiB per scanned string | error |
|
|
459
536
|
| `maxFindings` | 50 000 per scanned string | error |
|
|
460
537
|
|
|
538
|
+
`maxInputLength` counts UTF-16 code units, the unit JavaScript measures strings
|
|
539
|
+
in; the other engines compute the same count (a character above U+FFFF counts
|
|
540
|
+
twice), so an input is accepted or refused identically everywhere.
|
|
541
|
+
|
|
461
542
|
Both fail **closed** — an error, never a truncated or partially-redacted result.
|
|
462
543
|
A caller who receives a partially-redacted string has no way to know it, which is
|
|
463
544
|
exactly the failure mode a redactor must not have.
|
|
@@ -478,6 +559,8 @@ output for each. Every implementation ships a test that runs the whole corpus:
|
|
|
478
559
|
| Python | `python -m unittest discover sdk/python/tests` |
|
|
479
560
|
| Go | `go test ./...` in `sdk/go` |
|
|
480
561
|
| Rust | `cargo test` in `sdk/rust` |
|
|
562
|
+
| Java | `mvn verify` in `sdk/java` |
|
|
563
|
+
| .NET | `dotnet test sdk/dotnet/FlareRedact.sln` |
|
|
481
564
|
|
|
482
565
|
The corpus covers each detector's positive and negative cases, overlap resolution,
|
|
483
566
|
zero-width evasion, every replacement mode, keyed transform vectors, structured
|
|
@@ -517,6 +600,14 @@ purpose and listed here.
|
|
|
517
600
|
cue lists, name lists and context, not a set of patterns, so it does not fit a
|
|
518
601
|
detector pack. Node runs it; other runtimes reach it through the gateway with
|
|
519
602
|
`enable: ["entities"]`.
|
|
603
|
+
8. **Detector `context` words match anywhere in the window.** Node's built-in
|
|
604
|
+
`phone` detector wraps its words in `\b`, so `xcall me at` raises a phone
|
|
605
|
+
number's confidence by 0.06 under the pack and not in Node.
|
|
606
|
+
9. **A `boundary` checks the neighbours of a span; it never moves the span.**
|
|
607
|
+
JavaScript's `\b` in front of a pattern that may start with `-`, `.` or `/`
|
|
608
|
+
moves the start past those characters (`-ada@example.com` reports
|
|
609
|
+
`ada@example.com`); FRS-1 keeps them. The difference is punctuation at the edge
|
|
610
|
+
of a match that is redacted either way.
|
|
520
611
|
|
|
521
612
|
---
|
|
522
613
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The conformance corpus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Six engines, one answer. `cases.json` holds inputs and options; `expected.json`
|
|
4
4
|
holds the output every FRS-1 implementation must produce for them.
|
|
5
5
|
|
|
6
6
|
| File | What it is |
|
|
@@ -16,6 +16,8 @@ holds the output every FRS-1 implementation must produce for them.
|
|
|
16
16
|
| Python | `python -m unittest discover -s sdk/python/tests -t sdk/python` |
|
|
17
17
|
| Go | `cd sdk/go && go test ./...` |
|
|
18
18
|
| Rust | `cd sdk/rust && cargo test` |
|
|
19
|
+
| Java | `cd sdk/java && mvn verify` |
|
|
20
|
+
| .NET | `dotnet test sdk/dotnet/FlareRedact.sln` |
|
|
19
21
|
|
|
20
22
|
## Regenerating expectations
|
|
21
23
|
|
|
@@ -36,7 +38,7 @@ formatting change.
|
|
|
36
38
|
- `name` is unique and reads as `area/behaviour`.
|
|
37
39
|
- `input` is any JSON value. Objects must have their keys in sorted order — see
|
|
38
40
|
[SPEC.md §10](../SPEC.md#10-structured-data) for why traversal order is
|
|
39
|
-
observable and how the corpus keeps the
|
|
41
|
+
observable and how the corpus keeps the engines in agreement.
|
|
40
42
|
- `options` uses the JSON wire names (camelCase), the same ones the gateway
|
|
41
43
|
accepts.
|
|
42
44
|
- `checks` defaults to `["redact", "scan"]`; add `"vault"` for a round trip, and
|
|
@@ -54,7 +56,8 @@ gets turned off.
|
|
|
54
56
|
## Ground rules
|
|
55
57
|
|
|
56
58
|
- **No astral-plane characters.** Offsets are reported in the host language's
|
|
57
|
-
natural string unit: UTF-16 code units in JavaScript,
|
|
59
|
+
natural string unit: UTF-16 code units in JavaScript, Java and .NET, scalar
|
|
60
|
+
values in Python, Go and Rust.
|
|
58
61
|
These coincide for everything below U+10000, and the corpus stays there.
|
|
59
62
|
- **No complete credential in the raw file.** A case that holds a whole token
|
|
60
63
|
writes one character of its prefix as a `\uXXXX` escape (`glpat\u002d…`).
|
|
@@ -63,5 +66,5 @@ gets turned off.
|
|
|
63
66
|
- **No wall-clock or randomness.** Vault cases use readable placeholders; keyed
|
|
64
67
|
transforms use a fixed `transformSecret`.
|
|
65
68
|
- **Confidence is compared at six decimal places**, which is finer than any
|
|
66
|
-
decision the library makes with the value and coarse enough that
|
|
69
|
+
decision the library makes with the value and coarse enough that six
|
|
67
70
|
languages' floating-point formatting cannot disagree about the text.
|
|
@@ -95,6 +95,13 @@
|
|
|
95
95
|
{ "name": "assignment/russian", "input": "пароль: ochen-sekretno" },
|
|
96
96
|
{ "name": "assignment/turkish", "input": "parola=gizli-anahtar-2026" },
|
|
97
97
|
{ "name": "assignment/too-short", "input": "pwd=abc" },
|
|
98
|
+
{ "name": "assignment/value-holding-separators", "input": "secret=key:value:more pwd=abc=defghij" },
|
|
99
|
+
{ "name": "assignment/turkish-uppercase", "input": "ŞİFRE: hunter2hunter2 MƏXFİ=zzTop12345" },
|
|
100
|
+
{ "name": "assignment/turkish-locale-identifier", "input": "APİ_KEY=abcdefgh12345678" },
|
|
101
|
+
{ "name": "assignment/dotless-i", "input": "şıfre: hunter2hunter2" },
|
|
102
|
+
{ "name": "assignment/long-s", "input": "PAſſWORD=hunter2hunter2" },
|
|
103
|
+
{ "name": "assignment/kelvin-sign", "input": "API_KEY=abcdefgh12345678" },
|
|
104
|
+
{ "name": "assignment/greek-final-sigma", "input": "ΚΩΔΙΚΌΣ: Abc123456789" },
|
|
98
105
|
|
|
99
106
|
{ "name": "card/visa", "input": "card 4111 1111 1111 1111 charged" },
|
|
100
107
|
{ "name": "card/negative-luhn", "input": "card 4111 1111 1111 1112 declined" },
|
|
@@ -105,6 +112,7 @@
|
|
|
105
112
|
{ "name": "iban/printed-trailing-word", "input": "IBAN: BE68 5390 0754 7034 EUR, BIC: GKCCBEBB" },
|
|
106
113
|
{ "name": "iban/printed-no-break-space", "input": "NO93\u00a08601\u00a01117\u00a0947 and FR76\u202f3000\u202f6000\u202f0112\u202f3456\u202f7890\u202f189" },
|
|
107
114
|
{ "name": "iban/printed-negative", "input": "GB82 WEST 1234 5698 7654 33 is a typo" },
|
|
115
|
+
{ "name": "iban/bic-needs-a-country", "input": "PASSWORD QWERTY12345 DEUTDEFF NWBKGB2L", "options": { "enable": ["finance"] } },
|
|
108
116
|
|
|
109
117
|
{ "name": "obfuscated-email/brackets", "input": "reach me at ada [at] example [dot] com" },
|
|
110
118
|
{ "name": "obfuscated-email/parens", "input": "grace (at) example (dot) org" },
|
|
@@ -113,15 +121,25 @@
|
|
|
113
121
|
{ "name": "keys/multilingual-object", "input": { "wachtwoord": "geheim", "şifrə": "gizli", "密码": "mimi" } },
|
|
114
122
|
{ "name": "keys/nested-structure", "input": { "db": { "token": "t0ken", "url": "postgres://u:p@h/d" }, "list": ["ada@example.com", 42, true, null] } },
|
|
115
123
|
{ "name": "keys/disabled", "input": { "password": "hunter2" }, "options": { "redactKeys": false } },
|
|
124
|
+
{ "name": "keys/turkish-uppercase", "input": { "GİZLİ": "abc123", "note": "ok", "ŞİFRE": "hunter2" } },
|
|
125
|
+
{ "name": "keys/greek-final-sigma", "input": { "ΚΩΔΙΚΌΣ": "Abc123456789" } },
|
|
126
|
+
{ "name": "keys/redact-keys-normalised", "input": { "other": "z", "Şifre": "x", "ŞİFRE": "y" }, "options": { "redactKeys": ["şifre"] } },
|
|
127
|
+
{ "name": "keys/names-are-not-redacted", "input": { "ada@example.com": "grace@example.org" } },
|
|
116
128
|
|
|
117
129
|
{ "name": "evasion/zero-width-assignment", "input": "password=hunter2000" },
|
|
118
130
|
{ "name": "evasion/zero-width-email", "input": "mail ada@example.com now" },
|
|
131
|
+
{ "name": "evasion/prefilter-folds-case", "input": "aws_ſecret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" },
|
|
119
132
|
|
|
120
133
|
{ "name": "allow/exact-value", "input": "support@example.com and ada@example.com", "options": { "allow": ["support@example.com"] } },
|
|
121
134
|
{ "name": "terms/plain", "input": "project Bluebird ships in Q3", "options": { "terms": ["Bluebird"] } },
|
|
122
135
|
{ "name": "terms/replacement", "input": "project Bluebird ships in Q3", "options": { "terms": { "Bluebird": "[PROJECT]" } } },
|
|
123
136
|
{ "name": "terms/word-boundary", "input": "Bluebirds are not Bluebird", "options": { "terms": ["Bluebird"] } },
|
|
124
137
|
{ "name": "terms/case-sensitive", "input": "bluebird and Bluebird", "options": { "terms": ["Bluebird"], "termsCaseSensitive": true } },
|
|
138
|
+
{ "name": "terms/combining-mark-boundary", "input": "राजा राज राजकुमार", "options": { "terms": ["राज"] } },
|
|
139
|
+
{ "name": "terms/shorter-term-at-same-position", "input": "abc defx and abc", "options": { "terms": ["abc def", "abc"] } },
|
|
140
|
+
{ "name": "terms/boundary-failure-moves-one-character", "input": "say 76 451 089 now", "options": { "terms": ["76 45", "451 089"] } },
|
|
141
|
+
{ "name": "terms/dotted-i", "input": "GİZLİ and gizli", "options": { "terms": [{ "term": "gizli", "replace": "<G>" }] } },
|
|
142
|
+
{ "name": "terms/equal-length-keeps-order", "input": "sam and ſam", "options": { "terms": [{ "term": "sam", "replace": "<1>" }, { "term": "ſam", "replace": "<2>" }] } },
|
|
125
143
|
|
|
126
144
|
{ "name": "mode/label", "input": "ada@example.com", "options": { "mode": "label" } },
|
|
127
145
|
{ "name": "mode/hash", "input": "ada@example.com", "options": { "mode": "hash", "transformSecret": "conformance-key" } },
|
|
@@ -133,6 +151,7 @@
|
|
|
133
151
|
{ "name": "phone/e164", "input": "call me on +90 532 123 45 67 tomorrow", "options": { "enable": ["phone"] } },
|
|
134
152
|
{ "name": "phone/parenthesised", "input": "phone (555) 123-4567", "options": { "enable": ["phone"] } },
|
|
135
153
|
{ "name": "phone/negative-date", "input": "released on 07.24.2026 exactly", "options": { "enable": ["phone"] } },
|
|
154
|
+
{ "name": "phone/context-window-in-characters", "input": "call яяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяя +994 50 123 45 67", "options": { "enable": ["pii"] } },
|
|
136
155
|
{ "name": "network/ipv4", "input": "peer 192.168.1.10 connected", "options": { "enable": ["ipv4"] } },
|
|
137
156
|
{ "name": "network/ipv6", "input": "peer 2001:0db8:85a3:0000:0000:8a2e:0370:7334", "options": { "enable": ["ipv6"] } },
|
|
138
157
|
{ "name": "network/ipv6-compressed", "input": "peer 2001:db8::8a2e:370:7334 and fe80::1 and ::ffff:192.168.1.10", "options": { "enable": ["ipv6"] } },
|
|
@@ -145,6 +164,9 @@
|
|
|
145
164
|
{ "name": "entropy/enabled", "input": "value Zm9vYmFyYmF6cXV4MTIzNDU2Nzg5 stored", "options": { "enable": ["high_entropy"] } },
|
|
146
165
|
{ "name": "entropy/refined-uuid", "input": "commit 9f8b7a6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f00", "options": { "enable": ["high_entropy"], "refineConfidence": true, "minConfidence": 0.5 } },
|
|
147
166
|
{ "name": "entropy/refined-secret", "input": "api_key GkL3nQ7pRt2vXz9WbYc4Hs6MdF8jA1eU", "options": { "enable": ["high_entropy"], "refineConfidence": true, "minConfidence": 0.5 } },
|
|
167
|
+
{ "name": "entropy/refine-window-in-characters", "input": "token яяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяя GkL3nQ7pRt2vXz9WbYc4Hs6MdF8jA1eU", "options": { "enable": ["high_entropy"], "refineConfidence": true } },
|
|
168
|
+
{ "name": "entropy/refine-context-ascii-boundary", "input": "çtoken GkL3nQ7pRt2vXz9WbYc4Hs6MdF8jA1eU", "options": { "enable": ["high_entropy"], "refineConfidence": true } },
|
|
169
|
+
{ "name": "entropy/refine-context-ascii-case", "input": "ſecret GkL3nQ7pRt2vXz9WbYc4Hs6MdF8jA1eU", "options": { "enable": ["high_entropy"], "refineConfidence": true } },
|
|
148
170
|
|
|
149
171
|
{ "name": "id/us-ssn", "input": "SSN 123-45-6789 on file", "options": { "enable": ["us_ssn"] } },
|
|
150
172
|
{ "name": "id/us-ssn-spaced", "input": "SSN 123 45 6789 on file", "options": { "enable": ["us_ssn"] } },
|