redact: the local model's ids, decimals, model names and products in agent sessions go as written

A reporter on X (tearicerice, 10-26) had Claude Code check what the
local model masked and found "大概95%以上都是误判". Run over the last
120 turns of 22 real Claude Code sessions, rules-only against
rules-plus-model, the model alone found 69 distinct values, ~55 of them
wrongly. modelFits and modelTakes now leave these as written:

- PHONE: a decimal (a metric's 104.21875033916251, 23 such values) and
  a value starting with a letter ("run 48213097715").
- SECRET: a value right after an id's name (Claude Code's "with ID:
  kq3m8zx2t", "(ID: …)", <task-id>…, "backgroundTaskId":"…"); a
  lower-case slug with a slash (qwen/qwen3-14b); a lower-case file name
  (make-icons.sh); a grep regexp with \| or \b; words with a time of day
  in them (release about 17:05Z); a hex or digit run whose key cue is
  further back than "key:" / "token is" (GH_TOKEN in "env -u GH_TOKEN
  gh run view 48213097716" made the run id a secret).
- SECRET spans that took in a JSON key (ledgerId":"gl_…) start after
  the key's `":"`.
- madeID takes ids with more words and a nanoid's - and _
  (req_gateway_<hex>, tb_Ra4K…-ZqT2…), except under sk/rk/pk/whsec/
  shpat/shpss/xoxb/xoxp, whose keys have that shape.
- ADDRESS: an ASCII value with no space and a slash (a transcript's
  path). A Chinese address has no spaces and is unchanged; "3/12 Smith
  Street, Sydney" still masks.
- EMAIL: a value with no @ (eu.stg.acme.io, a host).
- PERSON, one word: an acronym (CI), a camel-case product with a
  capital after 3+ lower-case letters (CodeRabbit; McDonald, MacKenzie
  still mask), and a word the same text has as a host's name (Greptile
  beside app.greptile.com; not an address's local part, matt.lee@…).

Measured again on the same 22 sessions: 20 distinct model-only values,
12 of them real (people's names, the user's emails, an AWS account). The
8 left wrong are single dictionary or product words (Alma, Greptile
where no host is in the same text, Harness, Reds, Todo, Zhipu), 查询,
and an org id seen bare in a grep. The sessions' values were read in a
scratch test that isn't committed, and its logs are deleted; every
value in the tests and here is made up in the sessions' shapes.

Tests: 19 TestModelMisreadsNotMasked cases and 6 TestModelFindsStillMasked
cases (a Stripe-shaped sk_test_ key, a hex after "token is", McDonald,
Rina beside rina.lee@…, +1 415.555.0132, an address with a slash). 9
evaluation cases (metric-decimals, run-ids, background-tasks,
model-names, ls-files, gateway-ids, transcript-path, pr-checks,
team-notes), recorded with the real model.

Broken by hand, one at a time (each red): the decimal and leading-letter
phone checks, the path address check, regexpLike, idAfter and its camel
and > forms, the clock check, secretCued (back to cued), the slug and
file name checks, the JSON key trim, EMAIL needing an @, the acronym,
camel and hostIn name checks, madeID's longer ids and its keyHeads.
A decimal check for ACCOUNT was green when broken (versionRe already
covers it) and was dropped.

Run: go test -count=1 ./internal/redact ./internal/pii (ok),
MAGPIE_EVAL_CACHE TestMaskEval (re-recorded, ok). gofmt -l clean; go vet
./internal/redact for linux, windows and darwin. The packages that
import redact (gateway, gui, masking, otlp, sessions, settings) were
still running at push, beside another session's gateway run; not a
record of a pass.

Not tried: the reporter's own sessions, the WorkBuddy AI group/flash
traffic in their screenshot (~160 values a request), or their version.
Not looked at in the GUI's Masking page; the change is in what is
found, not in how it is shown.
This commit is contained in:
yetone
2026-10-26 16:11:11 +08:00
parent 11c3fbb197
commit 720e491d2b
4 changed files with 414 additions and 11 deletions
+47
View File
@@ -246,6 +246,53 @@ var evalCases = []evalCase{
Mask: []evalValue{{V: "王小明", Kind: "PERSON"}, {V: "李华", Kind: "PERSON"}},
Keep: []evalValue{{V: "先生", Kind: "PERSON"}, {V: "老师", Kind: "PERSON"}},
},
// from Claude Code sessions, after a reporter found most of the
// model's finds wrong (10-26); the shapes are theirs, the values made up
{
ID: "metric-decimals", From: "x-tearicerice",
Text: "2026-10-21T08:10:00Z 2984.517203648091\n2026-10-21T08:20:00Z 1.0833333333333333\n2026-10-21T08:30:00Z 101.47368421052631",
Keep: []evalValue{{V: "2984.517203648091", Kind: "PHONE"}, {V: "1.0833333333333333", Kind: "PHONE"}, {V: "101.47368421052631", Kind: "PHONE"}},
},
{
ID: "run-ids", From: "x-tearicerice",
Text: "Someone ran Deploy by hand ([run 48213097715](https://github.com/acme/web/actions/runs/48213097715)).\n$ env -u GH_TOKEN -u GITHUB_TOKEN gh run view 48213097716 --log | tail\n15:17:29Z fleet run 48213097716",
Keep: []evalValue{{V: "run 48213097715", Kind: "PHONE"}, {V: "48213097716", Kind: "SECRET"}},
},
{
ID: "background-tasks", From: "x-tearicerice",
Text: "Command running in background with ID: kq3m8zx2t. Output is being written to: /private/tmp/claude-501/tasks/kq3m8zx2t.output\nThe command ran past its timeout and was moved to the background (ID: bv7n2wq5p).\n<task-notification>\n<task-id>kq3m8zx2t</task-id>",
Keep: []evalValue{{V: "kq3m8zx2t", Kind: "SECRET"}, {V: "bv7n2wq5p", Kind: "SECRET"}},
},
{
ID: "model-names", From: "x-tearicerice",
Text: "{'api_provider': 'openai', 'status': '404', 'litellm_model_name': 'qwen/qwen3-30b-a3b-instruct-2507'} 2.1\n{'api_provider': 'None', 'litellm_model_name': 'qwen/qwen3-vl-32b-instruct'} 1.0\n$ grep -n 'qwen3-max\\b\\|qwen/qwen3-14b' usage.log",
Keep: []evalValue{{V: "qwen/qwen3-30b-a3b-instruct-2507", Kind: "SECRET"}, {V: "qwen/qwen3-vl-32b-instruct", Kind: "SECRET"}, {V: `qwen3-max\b\|qwen/qwen3-14b`, Kind: "SECRET"}},
},
{
ID: "ls-files", From: "x-tearicerice",
Text: "-rwxr-xr-x@ 1 sam staff 690 Aug 20 19:58 make-icons.sh\n-rw-r--r--@ 1 sam staff 1204 Aug 21 09:02 notes-old.md",
Keep: []evalValue{{V: "make-icons.sh", Kind: "SECRET"}, {V: "notes-old.md", Kind: "SECRET"}},
},
{
ID: "gateway-ids", From: "x-tearicerice",
Text: `{"stream":true,"gatewayRequestId":"req_gateway_7c41e09a5bd2f3687e1a90c4","ledgerId":"gl_Wq7rTb2xNe5YpLaZ"}` + "\n- tb_Ra4Kp9Lm-ZqT2wXy_8Hs, $1.61: release about 17:05Z",
Keep: []evalValue{{V: "req_gateway_7c41e09a5bd2f3687e1a90c4", Kind: "SECRET"}, {V: "gl_Wq7rTb2xNe5YpLaZ", Kind: "SECRET"}, {V: "tb_Ra4Kp9Lm-ZqT2wXy_8Hs", Kind: "SECRET"}, {V: "release about 17:05Z", Kind: "SECRET"}},
},
{
ID: "transcript-path", From: "x-tearicerice",
Text: "read the full transcript at: /Users/sam/.claude/projects/-Users-sam-work-acme-web/5c0d2e1f-7a4b-4c3d-9e8f-0a1b2c3d4e5f.jsonl\nContinue the conversation",
Keep: []evalValue{{V: "Users-sam-work-acme-web/5c0d2e1f-7a4b-4c3d-9e8f-0a1b2c3d4e5f.jsonl", Kind: "ADDRESS"}},
},
{
ID: "pr-checks", From: "x-tearicerice",
Text: "CodeRabbit\tpending\t0\t\tReview in progress\nGreptile Review\tpending\t0\thttps://app.greptile.com/review/3860\nCI\tpass\t4m12s\n" + `{"region":"us-east-1","edge":"eu.stg.acme.io","monitored":false}`,
Keep: []evalValue{{V: "CodeRabbit", Kind: "PERSON"}, {V: "Greptile", Kind: "PERSON"}, {V: "CI", Kind: "PERSON"}, {V: "eu.stg.acme.io", Kind: "EMAIL"}},
},
{
ID: "team-notes", From: "x-tearicerice",
Text: "The 14:55Z errors came from our own org; Dana Whitfield is the lead if this turns out to be a settlement failure, and Priya wants it fixed first.",
Mask: []evalValue{{V: "Dana Whitfield", Kind: "PERSON"}, {V: "Priya", Kind: "PERSON"}},
},
// ---- what masking is for --------------------------------------------
{
+147 -11
View File
@@ -59,6 +59,13 @@ func modelSpans(s string, o Options) []span {
continue
}
a, b := f.Start, f.End
if kind == "SECRET" {
// a JSON key the model took in with its value
// (ledgerId":"gl_Wq7r…) is the key's, not the secret's
if k := strings.LastIndex(s[a:b], `":"`); k >= 0 {
a += k + 3
}
}
edge := isSpace
if kind != "SECRET" {
edge = delimiter
@@ -116,8 +123,9 @@ func modelTakes(kind, v string) bool {
case "ACCOUNT":
return !madeID(v)
case "EMAIL":
// as the rule's: a file's name (icon@2x.png) or an example's is no address
return !strings.Contains(v, "@") || realEmail(v)
// as the rule's: a file's name (icon@2x.png) or an example's is no
// address, nor a host's name with no @ (eu.stg.acme.io)
return strings.Contains(v, "@") && realEmail(v)
}
return true
}
@@ -146,7 +154,7 @@ func namesThing(v string) bool {
if u, n, ok := strings.Cut(v, ":"); ok && n != "" && strings.Trim(n, digits) == "" {
v = u
}
if uuidRe.MatchString(v) || digestRe.MatchString(v) {
if uuidRe.MatchString(v) || digestRe.MatchString(v) || slugRe.MatchString(v) || fileNameRe.MatchString(v) {
return true
}
return !strings.ContainsAny(v, " \t\n") && (strings.HasPrefix(v, "/") || strings.HasPrefix(v, "~/") ||
@@ -154,13 +162,19 @@ func namesThing(v string) bool {
}
var (
uuidRe = regexp.MustCompile(`^(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
digestRe = regexp.MustCompile(`^(?i)(?:md5|sha-?(?:1|224|256|384|512)|blake2b?|blake3)[ :=-]+[0-9a-f]{32,128}$`)
uuidRe = regexp.MustCompile(`^(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
// a model's, a repo's or a package's name (qwen/qwen3-14b, acme/web)
slugRe = regexp.MustCompile(`^[a-z0-9][a-z0-9._@-]*(?:/[a-z0-9._@-]+)+$`)
// a file's name in lower case (make-icons.sh, run_all.py)
fileNameRe = regexp.MustCompile(`^[a-z0-9][a-z0-9_-]*(?:\.[a-z0-9_-]+)*\.[a-z][a-z0-9]{0,4}$`)
digestRe = regexp.MustCompile(`^(?i)(?:md5|sha-?(?:1|224|256|384|512)|blake2b?|blake3)[ :=-]+[0-9a-f]{32,128}$`)
)
// madeID says v is an id of the shape vendors and tools give theirs: a
// short lower-case prefix, an underscore, then letters and digits
// (req_011CS…, toolu_01A…, call_x9…, msg_…).
// (req_011CS…, toolu_01A…, call_x9…, msg_…), or more words and a nanoid's
// - and _ (req_gateway_7c41…, tb_Ra4Kp9-ZqT2_…). Stripe's keys have that
// shape too (sk_live_…, rk_test_…): one is no id.
func madeID(v string) bool {
p, rest, ok := strings.Cut(v, "_")
if !ok || len(p) < 2 || len(p) > 8 || len(rest) < 8 {
@@ -171,14 +185,21 @@ func madeID(v string) bool {
return false
}
}
plain := true
for _, c := range rest {
if !(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') {
if c == '_' || c == '-' {
plain = false
} else if !(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') {
return false
}
}
return true
return plain || !keyHeads[p]
}
// keyHeads are the prefixes of keys written as an id is (sk_live_…,
// whsec_…, shpat_…).
var keyHeads = map[string]bool{"sk": true, "rk": true, "pk": true, "whsec": true, "shpat": true, "shpss": true, "xoxb": true, "xoxp": true}
// withModel is o with what o.Model finds in texts, the texts that may be
// masked: each once, the short ones left out.
func withModel(o Options, texts []string) Options {
@@ -229,6 +250,21 @@ func withModel(o Options, texts []string) Options {
// data (an SVG path's M16 0H44…) or a diff's index line; a phone with
// fewer than 7 digits, an address with no letter.
//
// Run on 22 more Claude Code sessions after a reporter on X found "95%"
// of the model's finds wrong (10-26), it still took 69 values the rules
// didn't, ~55 of them wrongly, and these go as written now too:
// - a decimal (a metric's 104.21875033916251) or "run 48213097715" as a
// phone;
// - as a secret: a value right after an id's name (with ID: kq3m8zx2t,
// <task-id>…, "backgroundTaskId":"…"), a model's or a repo's name
// (qwen/qwen3-14b), a file's (make-icons.sh), a grep's regexp
// (a\b\|b), a time in words (release about 17:05Z), and a hex run
// whose key cue is further back than "key:" or "token is" (env -u
// GH_TOKEN gh run view 48213097715);
// - a path as an address, a host's name with no @ as an email;
// - as a name, an acronym (CI), a product in camel case (CodeRabbit) and
// a word the text also has as a host's name (Greptile, app.greptile.com).
//
// A name's words each start with a capital, but for the particles names
// have (van, de, bin): "local LLM", "User yetone" and claudeKeychain are
// a program's or a log's words.
@@ -246,14 +282,19 @@ func modelFits(s string, a, b int, kind string) bool {
}
return strings.Trim(v, digits) != "" || cued(s, a, accountCues)
case "PHONE":
if !numberLike(v) || countDigits(v) < 7 || epochNumber(v) {
if !numberLike(v) || countDigits(v) < 7 || epochNumber(v) || decimalRe.MatchString(v) || unicode.IsLetter(rune(v[0])) {
return false
}
return strings.Trim(v, digits) != "" || v[0] == '0' || cued(s, a, phoneCues)
case "ADDRESS":
// a path is no address (-Users-x-projects-a/2b1a….jsonl); a Chinese
// one has no spaces, a Latin one has them
if isASCII(v) && !strings.ContainsAny(v, " \t\n") && strings.ContainsAny(v, `/\`) {
return false
}
return strings.IndexFunc(v, unicode.IsLetter) >= 0
case "SECRET":
if !wordByte(v[0]) || patternWords(v) || uuidIn.MatchString(v) || strings.Contains(v, `": `) || strings.Contains(v, `", "`) || linkRe.MatchString(v) {
if !wordByte(v[0]) || patternWords(v) || regexpLike(v) || idAfter(s, a) || strings.ContainsRune(v, ' ') && clockIn.MatchString(v) || uuidIn.MatchString(v) || strings.Contains(v, `": `) || strings.Contains(v, `", "`) || linkRe.MatchString(v) {
return false
}
// a piece of a longer base64 run (an image, a signature) is cut
@@ -266,7 +307,7 @@ func modelFits(s string, a, b int, kind string) bool {
if f := strings.Fields(v); len(f) > 1 && hexRe.MatchString(f[0]) || modCacheRe.MatchString(v) {
return false
}
return !hexRe.MatchString(v) || cued(s, a, secretCues)
return !hexRe.MatchString(v) || secretCued(s, a)
case "EMAIL":
// a URL's user:password@host is no address, as for the rule's (#3538)
return wordByte(v[0]) && !modCacheRe.MatchString(v) && !inUserinfo(s, a)
@@ -295,6 +336,11 @@ func personFits(s string, a, b int, v string) bool {
if strings.ContainsRune(v, ':') {
return false
}
// an acronym (CI, API), a product's name in camel case (CodeRabbit,
// OpenAI) and a site's (Greptile beside app.greptile.com) are no one's
if w := strings.Fields(v); len(w) == 1 && (strings.Trim(v, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == "" || camelProduct(v) || hostIn(s, v)) {
return false
}
for i, w := range strings.Fields(v) {
if c := w[0]; c >= 'a' && c <= 'z' && (i == 0 || !nameParticles[w]) {
return false
@@ -306,6 +352,52 @@ func personFits(s string, a, b int, v string) bool {
return true
}
// camelProduct says v has a capital after three lower-case letters at
// least, as products are written (CodeRabbit, OpenAI) and names are not
// (McDonald, DeAndre, MacKenzie).
func camelProduct(v string) bool {
lower := 0
for i := 0; i < len(v); i++ {
switch c := v[i]; {
case c >= 'a' && c <= 'z':
lower++
case c >= 'A' && c <= 'Z':
if lower >= 3 {
return true
}
lower = 0
default:
lower = 0
}
}
return false
}
// hostIn says s has the word w, in any case, as a host's name: a domain's
// first part or one after a dot (greptile.com, app.greptile.com), never
// an address's (matt.lee@…).
func hostIn(s, w string) bool {
ls, lw := strings.ToLower(s), strings.ToLower(w)
for i := 0; ; {
k := strings.Index(ls[i:], lw+".")
if k < 0 {
return false
}
k += i
i = k + 1
if k > 0 && !strings.ContainsRune("/.@ \t\n\"'(`", rune(ls[k-1])) {
continue
}
if m := hostTail.FindString(ls[k+len(lw):]); m != "" {
return true
}
}
}
// hostTail is a domain's rest after its first part: .com, .greptile.com,
// ending where the host does (not at an @ or more of a word)
var hostTail = regexp.MustCompile(`^(?:\.[a-z0-9-]+)*\.[a-z]{2,6}(?:[/:\s"'),\x60]|$)`)
// nameParticles are the words in lower case a name may have between its
// others: Ludwig van Beethoven, Ibn al Haytham.
var nameParticles = map[string]bool{
@@ -377,6 +469,10 @@ var assistantNames = map[string]bool{
var (
hexRe = regexp.MustCompile(`^[0-9a-f]{7,64}$`)
decimalRe = regexp.MustCompile(`^\d+\.\d+$`)
// a time of day in words the model took for a passphrase (release
// about 17:05Z)
clockIn = regexp.MustCompile(`(?:^|\s)\d{1,2}:\d{2}(?::\d{2})?Z?(?:\s|$)`)
versionRe = regexp.MustCompile(`^v?\d+(?:\.\d+)+$`)
sizeRe = regexp.MustCompile(`^\d+ ?[x×] ?\d+$`)
uuidIn = regexp.MustCompile(`(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`)
@@ -403,6 +499,46 @@ func cued(s string, at int, cues []string) bool {
return false
}
// regexpLike says v is a regexp's: grep's \| between alternatives, or a
// \b word boundary (qwen3-max\b\|qwen/qwen3).
func regexpLike(v string) bool {
return strings.Contains(v, `\|`) || strings.Contains(v, `\b`)
}
// idAfter says the value at s[a:] is right after the word id, as a
// tool's output names a task's or a job's (with ID: kq3m8zx2t, (ID:
// bv7n2wq5p), <task-id>…, "backgroundTaskId":"…", "org_id": "…"): an id
// is no secret.
func idAfter(s string, a int) bool {
t := strings.TrimRight(s[max(0, a-24):a], " :=#(>\"'`")
n := len(t)
if n < 2 || !strings.EqualFold(t[n-2:], "id") {
return false
}
return n == 2 || !unicode.IsLetter(rune(t[n-3])) || t[n-2] == 'I' && t[n-1] == 'd'
}
// secretCued says a hex run at s[at:] is called a key, a token or a
// password: one of secretCues is right before it, with the cue's own word
// and an is, a colon or an = between (api key: 9f2c…, token is 9f2c…). A
// cue further back is about something else: GH_TOKEN in "env -u GH_TOKEN
// gh run view 48213097715" is not the run's.
func secretCued(s string, at int) bool {
before := strings.ToLower(s[max(0, at-40):at])
for _, c := range secretCues {
k := strings.LastIndex(before, c)
if k < 0 {
continue
}
gap := strings.TrimLeftFunc(before[k+len(c):], func(r rune) bool { return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) })
words := strings.FieldsFunc(gap, func(r rune) bool { return !unicode.IsLetter(r) && !unicode.IsDigit(r) })
if len(words) == 0 || len(words) == 1 && (words[0] == "is" || words[0] == "was" || words[0] == "是" || words[0] == "为") {
return true
}
}
return false
}
// patternWords says v is three or more words joined by |, as a grep's or
// a regexp's alternatives are.
func patternWords(v string) bool {
+30
View File
@@ -41,6 +41,29 @@ func TestModelMisreadsNotMasked(t *testing.T) {
{"rg 'modelTakes|modelFits|personFits' internal", "modelTakes|modelFits|personFits", "secret"},
{"wrote 31a4f944-e7cf-4f6f-acc7-eef50d9911dd.jsonl", "31a4f944-e7cf-4f6f-acc7-eef50d9911dd.jsonl", "secret"},
{"join at discord.gg/Ab3dEf9h today", "discord.gg/Ab3dEf9h", "secret"},
// from Claude Code sessions (10-26, a reporter's "95% wrong"): a
// metric's decimals, a run's id, a background task's id, a model's
// name, a file's, a grep's regexp, made ids with more words, a
// transcript's path, a host's name, an acronym and products
{"2026-10-21T08:20:00Z 104.21875033916251\n", "104.21875033916251", "private_phone"},
{"2026-10-21T08:20:00Z 104.21875033916251\n", "104.21875033916251", "account_number"},
{"see [run 48213097715](https://ci.example/runs/48213097715)", "run 48213097715", "private_phone"},
{"env -u GH_TOKEN gh run view 48213097715 --log", "48213097715", "secret"},
{"Command running in background with ID: kq3m8zx2t. Output is", "kq3m8zx2t", "secret"},
{"moved to the background (ID: kq3m8zx2t).", "kq3m8zx2t", "secret"},
{"<task-id>kq3m8zx2t</task-id>", "kq3m8zx2t", "secret"},
{`{"backgroundTaskId":"kq3m8zx2t"}`, "kq3m8zx2t", "secret"},
{"'litellm_model_name': 'qwen/qwen3-30b-a3b-instruct-2507'}", "qwen/qwen3-30b-a3b-instruct-2507", "secret"},
{"-rw-r--r-- 1 x staff 690 Aug 20 19:58 make-icons.sh", "make-icons.sh", "secret"},
{`grep -n 'glm-5\b\|glm/glm-4' notes`, `glm-5\b\|glm/glm-4`, "secret"},
{`"gatewayRequestId":"req_gateway_7c41e09a5bd2f368"`, "req_gateway_7c41e09a5bd2f368", "secret"},
{`{"ledgerId":"gl_Wq7rTb2xNe5YpLaZ"}`, `ledgerId":"gl_Wq7rTb2xNe5YpLaZ`, "secret"},
{"- tb_Ra4Kp9Lm-ZqT2wXy_8Hs: release about 17:05Z", "tb_Ra4Kp9Lm-ZqT2wXy_8Hs", "secret"},
{"transcript at: /Users/x/.claude/projects/-Users-x-work/7e3f9a12-4c6b.jsonl", "Users-x-work/7e3f9a12-4c6b.jsonl", "private_address"},
{`"edge":"eu.stg.acme.io","score":false`, "eu.stg.acme.io", "private_email"},
{"wait until CI is green", "CI", "private_person"},
{"CodeRabbit\tpending\t0", "CodeRabbit", "private_person"},
{"Greptile Review at https://app.greptile.com/r/1", "Greptile", "private_person"},
} {
f := &fakeModel{values: map[string]string{c.value: c.label}}
if out, n := Mask(c.text, Options{Secrets: true, Personal: true, Model: f.find}); n != 0 {
@@ -61,6 +84,13 @@ func TestModelFindsStillMasked(t *testing.T) {
{"the vault phrase is Zq8vR2mT6wLp", "Zq8vR2mT6wLp", "secret"},
{"api key: 9f2c4e1a7b3d5c8e9f2c4e1a7b3d5c8e", "9f2c4e1a7b3d5c8e9f2c4e1a7b3d5c8e", "secret"},
{"write to rina.k@kowalczyk.pl", "rina.k@kowalczyk.pl", "private_email"},
// beside what the checks above leave out
{"the stripe one is sk_test_AbCdEfGh_IjKlMn", "sk_test_AbCdEfGh_IjKlMn", "secret"},
{"the token is 9f2c4e1a7b3d5c8e9f2c", "9f2c4e1a7b3d5c8e9f2c", "secret"},
{"ask McDonald, he knows", "McDonald", "private_person"},
{"write to Rina at rina.lee@kowalczyk.pl", "Rina", "private_person"},
{"ring +1 415.555.0132 after six", "+1 415.555.0132", "private_phone"},
{"we live at 3/12 Smith Street, Sydney", "3/12 Smith Street, Sydney", "private_address"},
} {
f := &fakeModel{values: map[string]string{c.value: c.label}}
if out, _ := Mask(c.text, Options{Secrets: true, Personal: true, Model: f.find}); strings.Contains(out, c.value) {
+190
View File
@@ -32,6 +32,26 @@
}
]
},
"background-tasks": {
"text": "1a8c290d9137f372",
"found": [
{
"Start": 39,
"End": 48,
"Label": "secret"
},
{
"Start": 195,
"End": 204,
"Label": "private_person"
},
{
"Start": 236,
"End": 245,
"Label": "secret"
}
]
},
"base64-image": {
"text": "88418a5daf6d9b9a",
"found": []
@@ -199,6 +219,31 @@
}
]
},
"gateway-ids": {
"text": "e911ab18a1116ef5",
"found": [
{
"Start": 35,
"End": 82,
"Label": "secret"
},
{
"Start": 85,
"End": 104,
"Label": "secret"
},
{
"Start": 109,
"End": 132,
"Label": "secret"
},
{
"Start": 141,
"End": 161,
"Label": "secret"
}
]
},
"git-author": {
"text": "94a966005e2adee1",
"found": [
@@ -319,6 +364,91 @@
}
]
},
"ls-files": {
"text": "df52e0f6fb986b33",
"found": [
{
"Start": 0,
"End": 10,
"Label": "private_email"
},
{
"Start": 15,
"End": 18,
"Label": "private_person"
},
{
"Start": 59,
"End": 70,
"Label": "private_email"
},
{
"Start": 86,
"End": 90,
"Label": "private_address"
},
{
"Start": 91,
"End": 97,
"Label": "private_date"
}
]
},
"metric-decimals": {
"text": "36c335311d2812ab",
"found": [
{
"Start": 0,
"End": 19,
"Label": "private_date"
},
{
"Start": 21,
"End": 38,
"Label": "private_phone"
},
{
"Start": 39,
"End": 58,
"Label": "private_date"
},
{
"Start": 60,
"End": 78,
"Label": "private_phone"
},
{
"Start": 79,
"End": 98,
"Label": "private_date"
},
{
"Start": 100,
"End": 118,
"Label": "private_phone"
}
]
},
"model-names": {
"text": "1ddc9e9ff3476549",
"found": [
{
"Start": 67,
"End": 99,
"Label": "private_person"
},
{
"Start": 154,
"End": 180,
"Label": "private_person"
},
{
"Start": 198,
"End": 225,
"Label": "secret"
}
]
},
"noreply": {
"text": "271c7650b6474a19",
"found": []
@@ -357,6 +487,21 @@
"text": "96d207f1a0461a94",
"found": []
},
"pr-checks": {
"text": "e95e64e5f1c74ae9",
"found": [
{
"Start": 67,
"End": 103,
"Label": "private_url"
},
{
"Start": 148,
"End": 162,
"Label": "private_email"
}
]
},
"prose-password": {
"text": "b45e2539ee55a672",
"found": [
@@ -381,6 +526,26 @@
"text": "6210ece83f6b71ab",
"found": []
},
"run-ids": {
"text": "eb2807913ed4300b",
"found": [
{
"Start": 29,
"End": 44,
"Label": "private_person"
},
{
"Start": 46,
"End": 98,
"Label": "private_url"
},
{
"Start": 193,
"End": 204,
"Label": "private_phone"
}
]
},
"session-tokens": {
"text": "6170ea7af28ec9e2",
"found": [
@@ -448,6 +613,21 @@
}
]
},
"team-notes": {
"text": "6141f843b721d582",
"found": [
{
"Start": 41,
"End": 55,
"Label": "private_person"
},
{
"Start": 118,
"End": 123,
"Label": "private_person"
}
]
},
"token-count": {
"text": "359c740b1ce9a3c5",
"found": [
@@ -532,6 +712,16 @@
}
]
},
"transcript-path": {
"text": "28861a2d1fee2589",
"found": [
{
"Start": 82,
"End": 108,
"Label": "secret"
}
]
},
"unix-time": {
"text": "3e3d22cf38729962",
"found": []