redact: a wallet address goes as written, and an IP as a documentation address the agent can use

0x0_air on X (10-28): with masking on, the agent stopped and asked again.
Their EVM address (0x89dfBD9b…, public) went as a secret placeholder and
the vendor's model told them to rotate it in case it was a private key;
the server IP they typed went as {{IP_…}} and the model refused to ssh
to it and asked for the real host.

- model.go: the local model's SECRET/ACCOUNT span on 0x and 40 hex
  digits (evmRe) is left as written; no rule matched it, the model's
  label did (the 0x prefix and mixed case got past hexRe). A 64-hex
  private key is masked still, and so is a 40-hex value called a key
  (secretCued).
- shape.go: an IP the IP rule masks goes as an address from the
  documentation ranges (192.0.2/198.51.100/203.0.113 .101-.254, IPv6
  2001:db8::/32), stable for the value, never shared by two values
  (falls back to {{IP_…}} past 462 IPv4 ones), and put back only as a
  whole address in replies and streamed tool calls (restoreAddr).
  Preview shows the same stand-in.
- docs: gateway-routing.md, and masking.html in en/zh/ja.

Run:
- Real models through the local gateway, the screenshot's ssh prompt
  with the placeholder vs a documentation address: with
  {{IP_k3v9x2mq}}, deepseek-v4-pro, glm-5.3, kimi-k3 and
  claude-sonnet-5-5 mostly searched ~/.ssh or asked for the real IP;
  with 203.0.113.147 or 192.0.2.183 all 20 runs over 5 models ran ssh
  at once.
- New tests (internal/redact/standin_ip_test.go): the screenshot's
  message, the tool call restored whole and streamed cut at every byte,
  boundary cases, IPv6, 472 addresses never sharing, the screenshot's
  address under labels secret and account_number with every category
  on, and a 64-hex key still masked. gateway TestRedactedKinds now
  wants a documentation address upstream.
- Broken by hand: without the evmRe check TestEVMAddressGoesAsWritten
  is red for every text and label; without restoreAddr the boundary
  cases are red; without the IP stand-in all three IP tests and
  gateway TestRedactedKinds are red.
- On mote at this head (rebased on 27bf14790): gofmt -l, go vet
  ./... for darwin, linux (-tags nogui) and windows, go test -count=1 -timeout 45m
  -tags nogui ./... (and go build for
  darwin, linux -tags nogui and windows): every package ok, exit 0.
  The run before at 56602426d had TestMoreKinds red, which wanted
  {{IP_…}}; it now wants the documentation address.
- Rebased again on 56d26f0bb (two gateway commits, #4004): go vet
  and go test -tags nogui of internal/redact, internal/gateway and
  internal/maskrec on mote at this head: ok.

Not tried:
- the real AstrLink model on an EVM address (the fake model gives it
  the labels it can give);
- a host name (user@host) still goes as {{HOSTNAME_…}};
- a documentation address the user writes themselves can match a
  stand-in in a reply and be put back as the real one;
- stand-ins are not kept across a restart or once their slot is
  evicted, like every placeholder.
This commit is contained in:
yetone
2026-10-28 20:23:38 +08:00
parent 04749d926d
commit c2aad3db02
10 changed files with 390 additions and 14 deletions
File diff suppressed because one or more lines are too long
+7 -2
View File
@@ -13,6 +13,9 @@ import (
"github.com/yetone/magpie/internal/settings"
)
// docIP is an IPv4 stand-in: an address in RFC 5737's ranges, .101 to .254
var docIP = regexp.MustCompile(`(?:192\.0\.2|198\.51\.100|203\.0\.113)\.(?:1\d\d|2[0-4]\d|25[0-4])`)
// The kinds of personal data the user turned on or off in settings
// (redactKinds) are what the vendor doesn't see, the others as their
// defaults say; what it answers with a placeholder comes back as the value.
@@ -21,7 +24,7 @@ func TestRedactedKinds(t *testing.T) {
var got []byte
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
got, _ = io.ReadAll(r.Body)
p := regexp.MustCompile(`\{\{IP_[a-z2-7]{8}\}\}`).FindString(string(got))
p := docIP.FindString(string(got))
chunk := func(s string) string {
b, _ := json.Marshal(map[string]any{"id": "c1", "model": "m1", "choices": []any{map[string]any{"index": 0, "delta": map[string]any{"content": s}}}})
return "data: " + string(b)
@@ -44,7 +47,9 @@ func TestRedactedKinds(t *testing.T) {
t.Fatalf("%d %s", code, body)
}
sent := string(got)
if strings.Contains(sent, ssn) || strings.Contains(sent, ip) || !strings.Contains(sent, "{{SSN_") || !strings.Contains(sent, "{{IP_") {
// an address goes as one from the documentation ranges, not a
// placeholder, so the model uses it rather than asking for the real one
if strings.Contains(sent, ssn) || strings.Contains(sent, ip) || !strings.Contains(sent, "{{SSN_") || !docIP.MatchString(sent) || strings.Contains(sent, "{{IP_") {
t.Fatalf("SSN (on by default) or IP (turned on) went out: %s", sent)
}
if !strings.Contains(sent, "s3://"+bucket+"/x") || !strings.Contains(sent, "/Users/"+user+"/src") {
+12 -1
View File
@@ -306,6 +306,14 @@ func modelFits(s string, a, b int, kind string) bool {
return false
}
v := s[a:b]
if evmRe.MatchString(v) {
// a wallet's or a contract's address (0x and 40 hex digits) is
// public, on its chain for anyone to read, and the vendor's model
// needs it as written: masked, it took the placeholder for a
// private key and told the user to rotate it (0x0_air on X,
// 10-28). A key is 64 hex digits; one called a key is masked still.
return kind == "SECRET" && secretCued(s, a)
}
switch kind {
case "PERSON":
return personFits(s, a, b, v)
@@ -501,7 +509,10 @@ var assistantNames = map[string]bool{
}
var (
hexRe = regexp.MustCompile(`^[0-9a-f]{7,64}$`)
hexRe = regexp.MustCompile(`^[0-9a-f]{7,64}$`)
// an EVM chain's address: 0x and 40 hex digits, in either case or
// mixed (EIP-55's checksum)
evmRe = regexp.MustCompile(`^0[xX][0-9a-fA-F]{40}$`)
decimalRe = regexp.MustCompile(`^\d+\.\d+$`)
// a time of day in words the model took for a passphrase (release
// about 17:05Z)
+10 -1
View File
@@ -16,7 +16,8 @@ func allKinds() Options {
return o
}
// Each category finds its values, as the placeholder of its kind, and puts
// Each category finds its values, as the placeholder of its kind (an IP as
// a documentation address, a user name as a made-up one), and puts
// them back; and leaves alone what only looks like one: versions,
// timestamps, hashes, UUIDs, ordinary dates, model ids, URLs in code.
func TestMoreKinds(t *testing.T) {
@@ -99,6 +100,14 @@ func TestMoreKinds(t *testing.T) {
if g.kind == "USERNAME" {
p = standInOf(g.value) // a made-up name (shape.go)
}
if at, n, ok := ipStandIns(g.value); g.kind == "IP" && ok {
for i := 0; i < n; i++ { // a documentation address (shape.go)
if strings.Contains(out, at(i)) {
p = at(i)
break
}
}
}
if !strings.Contains(out, p) {
t.Errorf("%q: no %s placeholder for %q in %q", c.in, g.kind, g.value, out)
}
+6 -1
View File
@@ -824,7 +824,7 @@ func Mask(s string, o Options) (string, int) {
// Preview is Mask with nothing remembered: each value goes as the
// placeholder, or with Options.Shape the made-up key, it would have (a
// user name its made-up name), which
// user name its made-up name, an IP address its documentation one), which
// isn't kept for Restore or as a value seen before (known.go).
func Preview(s string, o Options) string {
put := tag
@@ -842,6 +842,11 @@ func Preview(s string, o Options) string {
if kind == "USERNAME" {
return standInOf(v) // a user name's made-up name (shape.go)
}
if kind == "IP" {
if at, _, ok := ipStandIns(v); ok {
return at(0) // an address's documentation one (shape.go)
}
}
return tagOrShape(kind, v)
}
out, _ := mask(s, withModel(o, []string{s}), put, false)
+153 -5
View File
@@ -4,8 +4,10 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/binary"
"net/netip"
"regexp"
"slices"
"strconv"
"strings"
)
@@ -189,9 +191,15 @@ func shaped(kind, v string) string {
// restoreShapes puts back each made-up key in s, counting it in put
// where put isn't nil; called with mu held for reading. A made-up key
// needs no escaping, nor does the value it stands for.
// needs no escaping, nor does the value it stands for. A stand-in address
// is put back only where it is a whole address: 203.0.113.147 is no part
// of 203.0.113.1470 or 10.203.0.113.147.
func restoreShapes(s string, put map[string]int) string {
for f := range shapes {
for f, kind := range shapes {
if kind == "IP" {
s = restoreAddr(s, f, values[f], put)
continue
}
if n := strings.Count(s, f); n > 0 {
s = strings.ReplaceAll(s, f, values[f])
if put != nil {
@@ -202,6 +210,48 @@ func restoreShapes(s string, put map[string]int) string {
return s
}
// restoreAddr is s with each whole stand-in address f in it put back as
// v, counted in put where put isn't nil.
func restoreAddr(s, f, v string, put map[string]int) string {
if !strings.Contains(s, f) {
return s
}
v6 := strings.Contains(f, ":")
var b strings.Builder
last := 0
for i := 0; ; {
j := strings.Index(s[i:], f)
if j < 0 {
break
}
a, z := i+j, i+j+len(f)
i = a + 1
if a > 0 && addrByte(s[a-1], v6) || z < len(s) && addrByte(s[z], v6) && s[z] != '.' ||
z+1 < len(s) && s[z] == '.' && s[z+1] >= '0' && s[z+1] <= '9' {
continue
}
b.WriteString(s[last:a])
b.WriteString(v)
last, i = z, z
if put != nil {
put[f]++
}
}
if last == 0 {
return s
}
b.WriteString(s[last:])
return b.String()
}
// addrByte says c may be part of an address, so an address beside it is
// a piece of a longer one: a letter or digit, a dot, and beside an IPv6
// one a colon (an IPv4 one has its port after one, or a field's name
// before: ip:203.0.113.147:22).
func addrByte(c byte, v6 bool) bool {
return c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '.' || v6 && c == ':'
}
// shapeTail is how much of the end of s may be the start of a made-up
// key, which the next piece of a stream goes on with: the longest end of s
// that one of them starts with, after the last whole one in s. A key that
@@ -292,11 +342,109 @@ func standInOf(v string) string {
return string(out)
}
// standIn is put with a user name sent as its made-up name, which is
// kept to be put back as a made-up key is; put's own where that name is
// another value's already.
// A public IP address goes to the vendor as an address from the ranges
// set aside for documentation (RFC 5737's 192.0.2.0/24, 198.51.100.0/24
// and 203.0.113.0/24; RFC 3849's 2001:db8::/32), not a placeholder. Told
// "my server is {{IP_…}}, ssh in", models asked the user for the real
// address or searched ~/.ssh and the environment for it (0x0_air on X,
// 10-28: "你消息里的 IP 被脱敏成 …,我无法连接"); told 203.0.113.147, they
// ran ssh root@203.0.113.147, which comes back as the real address in the
// tool call, so the agent connects where the user asked. An address in
// those ranges is no one's, so a stand-in the vendor tries itself reaches
// nobody, and the IP rule never masks one (notIPs). The same address gets
// the same stand-in every turn while magpie runs; two addresses never
// share one. IPv4 stand-ins end in 101 to 254, so one is never the start
// of another, and come back only as whole addresses (restoreAddr).
// ipNets are the IPv4 documentation ranges stand-ins are made in, and
// ipHosts how many of each range's addresses are used: .101 to .254.
var ipNets = [...]string{"192.0.2.", "198.51.100.", "203.0.113."}
const ipHosts = 154
// ipStandIns are the stand-ins the address v may go as, in the order
// they are tried: n of them, the i-th made by at(i) (every IPv4 one from
// where v's hash starts, or a few IPv6 ones), with nothing locked, so it
// may be called with mu held. False where v is no address.
func ipStandIns(v string) (at func(i int) string, n int, ok bool) {
a, err := netip.ParseAddr(v)
if err != nil {
return nil, 0, false
}
k := key()
sum := func(i int) []byte {
h := hmac.New(sha256.New, k)
h.Write([]byte("ip\x00" + a.String()))
if i >= 0 {
var c [8]byte
binary.BigEndian.PutUint64(c[:], uint64(i))
h.Write(c[:])
}
return h.Sum(nil)
}
if a.Unmap().Is4() {
n := len(ipNets) * ipHosts
start := int(binary.BigEndian.Uint32(sum(-1)[:4]) % uint32(n))
return func(i int) string {
slot := (start + i) % n
return ipNets[slot/ipHosts] + strconv.Itoa(101+slot%ipHosts)
}, n, true
}
return func(i int) string {
s := sum(i)
g := []string{"2001", "db8"}
for k := 0; k < 6; k++ {
// each group of four digits with no 0 to start, so all are
// as long and none is the start of another
g = append(g, strconv.FormatUint(uint64(0x1000+binary.BigEndian.Uint16(s[2*k:])%0xf000), 16))
}
return strings.Join(g, ":")
}, 8, true
}
// ipStandIn is the stand-in the address v goes as, kept to be put back as
// a made-up key is: the one it went as before, or the first that is no
// other value's. False where v is no address or every one is taken.
func ipStandIn(v string) (string, bool) {
at, n, ok := ipStandIns(v)
if !ok {
return "", false
}
mu.Lock()
defer mu.Unlock()
free := ""
for i := 0; i < n; i++ {
f := at(i)
have, taken := values[f]
if taken && have == v {
return f, true
}
if !taken && free == "" {
free = f
}
}
if free == "" {
return "", false
}
makeRoom()
values[free] = v
kinds["IP"] = true
shapes[free] = "IP"
addKnown(free, v)
return free, true
}
// standIn is put with a user name sent as its made-up name and an IP
// address as a documentation one, each kept to be put back as a made-up
// key is; put's own where that name is another value's already.
func standIn(put func(kind, v string) string) func(kind, v string) string {
return func(kind, v string) string {
if kind == "IP" {
if f, ok := ipStandIn(v); ok {
return f
}
return put(kind, v)
}
if kind != "USERNAME" {
return put(kind, v)
}
+198
View File
@@ -0,0 +1,198 @@
package redact
import (
"encoding/json"
"fmt"
"net/http/httptest"
"net/netip"
"strings"
"testing"
)
// docAddr says f is an IPv4 stand-in: in RFC 5737's ranges, .101 to .254.
func docAddr(f string) bool {
a, err := netip.ParseAddr(f)
if err != nil || !a.Is4() {
return false
}
b := a.As4()
inNet := b[0] == 192 && b[1] == 0 && b[2] == 2 || b[0] == 198 && b[1] == 51 && b[2] == 100 || b[0] == 203 && b[1] == 0 && b[2] == 113
return inNet && b[3] >= 101 && b[3] <= 254
}
// A server's address the user gives goes as an address from the
// documentation ranges, not {{IP_…}}: told "my server is {{IP_…}}", models
// asked the user for the real one or searched ~/.ssh for it (0x0_air on X,
// 10-28: "你消息里的 IP 被脱敏成 …,我无法连接"). The model's ssh with the
// stand-in comes back with the real address, in a whole reply and a stream.
func TestIPGoesAsADocumentationAddress(t *testing.T) {
Forget()
t.Cleanup(Forget)
const ip = "47.96.123.45"
o := Options{Personal: true, Kinds: map[string]bool{"ip": true}}
msg := "我的服务器是 " + ip + ",用户 root,已经配好密钥登录。先 ssh 上去看看 uname -a 和磁盘空间。"
out, n := Mask(msg, o)
f := strings.TrimSuffix(strings.Fields(strings.TrimPrefix(out, "我的服务器是 "))[0], ",用户")
if n != 1 || strings.Contains(out, ip) || strings.Contains(out, "{{") || !docAddr(f) {
t.Fatalf("sent %q (address %q), want the address as a documentation one", out, f)
}
if again, _ := Mask(msg, o); again != out {
t.Errorf("not the same stand-in twice: %q, %q", out, again)
}
if p := Preview(msg, o); p != out {
t.Errorf("preview %q, sent %q", p, out)
}
if back := Restore(out, false); back != msg {
t.Errorf("put back as %q", back)
}
// the model's tool call, as the probe's models wrote it
call := `{"command":"ssh -o BatchMode=yes -o ConnectTimeout=10 root@` + f + ` 'uname -a; echo ---; df -h'"}`
if back := Restore(call, true); back != strings.Replace(call, f, ip, 1) {
t.Errorf("tool call put back as %s", back)
}
// only a whole address is put back
for _, c := range []struct{ s, want string }{
{f + ":22", ip + ":22"},
{"ssh to " + f + ".", "ssh to " + ip + "."},
{"[" + f + "]", "[" + ip + "]"},
{"ip:" + f, "ip:" + ip},
{f + "0", f + "0"},
{"1" + f, "1" + f},
{"10." + f, "10." + f},
{f + ".5", f + ".5"},
{f + "a", f + "a"},
} {
if got := Restore(c.s, false); got != c.want {
t.Errorf("Restore(%q) = %q, want %q", c.s, got, c.want)
}
}
// streamed: the tool call's arguments cut at every place in the address
whole := `{"command":"ssh root@` + f + ` 'uname -a'"}`
for cut := strings.Index(whole, f); cut <= strings.Index(whole, f)+len(f); cut++ {
ev := func(args string) string {
b, _ := json.Marshal(map[string]any{"choices": []any{map[string]any{"index": 0, "delta": map[string]any{
"tool_calls": []any{map[string]any{"index": 0, "function": map[string]any{"arguments": args}}}}}}})
return "data: " + string(b) + "\n\n"
}
rec := httptest.NewRecorder()
rec.Header().Set("Content-Type", "text/event-stream")
w := NewWriter(rec)
w.WriteHeader(200)
for _, e := range []string{ev(whole[:cut]), ev(whole[cut:]), "data: [DONE]\n\n"} {
w.Write([]byte(e))
}
w.Finish()
var args strings.Builder
for _, e := range strings.Split(rec.Body.String(), "\n\n") {
d, ok := strings.CutPrefix(e, "data: ")
if !ok || d == "[DONE]" {
continue
}
var x struct {
Choices []struct {
Delta struct {
ToolCalls []struct{ Function struct{ Arguments string } } `json:"tool_calls"`
}
}
}
if err := json.Unmarshal([]byte(d), &x); err != nil {
t.Fatalf("event %q: %v", d, err)
}
for _, c := range x.Choices[0].Delta.ToolCalls {
args.WriteString(c.Function.Arguments)
}
}
if want := strings.Replace(whole, f, ip, 1); args.String() != want {
t.Errorf("cut at %d: arguments %s, want %s", cut, args.String(), want)
}
}
}
// An IPv6 address goes as one in 2001:db8::/32, and comes back.
func TestIPv6GoesAsADocumentationAddress(t *testing.T) {
Forget()
t.Cleanup(Forget)
const ip = "2400:cb00:2048:1::c629:d7a2"
o := Options{Personal: true, Kinds: map[string]bool{"ip": true}}
out, n := Mask("ssh root@"+ip, o)
f := strings.TrimPrefix(out, "ssh root@")
a, err := netip.ParseAddr(f)
if n != 1 || err != nil || !netip.MustParsePrefix("2001:db8::/32").Contains(a) {
t.Fatalf("sent %q", out)
}
if back := Restore(`{"command":"ping6 `+f+`"}`, true); back != `{"command":"ping6 `+ip+`"}` {
t.Errorf("put back as %s", back)
}
}
// Two addresses never share a stand-in: past the 462 IPv4 ones, an
// address goes as its placeholder, and every one comes back as itself.
func TestIPStandInsNeverShared(t *testing.T) {
Forget()
t.Cleanup(Forget)
o := Options{Personal: true, Kinds: map[string]bool{"ip": true}}
seen := map[string]string{}
const total = len(ipNets)*ipHosts + 10
for i := 0; i < total; i++ {
ip := fmt.Sprintf("47.96.%d.%d", i/200, 1+i%200)
out, n := Mask("host "+ip, o)
f := strings.TrimPrefix(out, "host ")
if n != 1 {
t.Fatalf("%s: sent %q", ip, out)
}
if i < len(ipNets)*ipHosts && !docAddr(f) || i >= len(ipNets)*ipHosts && !strings.HasPrefix(f, "{{IP_") {
t.Fatalf("%s (#%d) went as %q", ip, i, f)
}
if other, ok := seen[f]; ok {
t.Fatalf("%s and %s both went as %s", other, ip, f)
}
seen[f] = ip
if again, _ := Mask("host "+ip, o); again != out {
t.Fatalf("%s: %q then %q", ip, out, again)
}
}
for f, ip := range seen {
if back := Restore("ssh "+f, false); back != "ssh "+ip {
t.Fatalf("%s put back as %q, want %s", f, back, ip)
}
}
}
// An EVM wallet's or contract's address is public, and goes as written
// whatever the local model takes it for: masked, the vendor's model took
// the placeholder for a private key and told the user to rotate it (0x0_air
// on X, 10-28). A private key, 64 hex digits, is masked still, and so is
// 0x and 40 hex digits called a key.
func TestEVMAddressGoesAsWritten(t *testing.T) {
const addr = "0x89dfBD9b4C2e7A1f3D5b6E8c0A9F2d4B7e1C3a5D"
const pk = "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
all := map[string]bool{}
for _, c := range Categories {
all[c.ID] = true
}
for _, text := range []string{
"挖矿收益打到这个合约地址 " + addr + " 就行,不需要签名",
"wallet: " + addr,
`{"to":"` + addr + `","value":"0x0"}`,
"address is " + addr + ".",
} {
for _, label := range []string{"secret", "account_number"} {
f := &fakeModel{values: map[string]string{addr: label}}
if out, n := Mask(text, Options{Secrets: true, Personal: true, Kinds: all, Model: f.find}); n != 0 {
t.Errorf("%q as %s: masked %q", text, label, out)
}
}
}
for _, c := range []struct{ text, value string }{
{"私钥 " + pk + " 别外传", pk},
{"the key is " + pk, pk},
{"api key: " + addr, addr},
{"token is " + addr, addr},
} {
f := &fakeModel{values: map[string]string{c.value: "secret"}}
if out, _ := Mask(c.text, Options{Secrets: true, Personal: true, Model: f.find}); strings.Contains(out, c.value) {
t.Errorf("%q: left in %q", c.value, out)
}
}
}
+1 -1
View File
@@ -111,7 +111,7 @@
<div class="table-wrap"><table>
<tr><th>スイッチ</th><th>見つけるもの</th></tr>
<tr><td><span class="ui">シークレットをマスク</span></td><td>秘密鍵のブロック(<code>-----BEGIN … PRIVATE KEY-----</code>)。形で見分ける API キー:<code>sk-…</code>(OpenAI、Anthropic、OpenRouter)、<code>ghp_</code>/<code>github_pat_</code>、<code>glpat-</code>、<code>AIza…</code>、<code>xox…-</code>、<code>sk_live_</code>、<code>AKIA</code>/<code>ASIA</code>、<code>hf_</code>、<code>gsk_</code>、<code>xai-</code>、<code>npm_</code>、<code>pypi-</code>、<code>dop_v1_</code>、<code>SG.</code>、それに <code>oc_sk_…</code> のような中継サービスのキー。JWT。<code>user:password@host</code> のパスワード。<code>.env</code> や設定ファイルでシークレットの名前が付いたフィールドの値:<code>DB_PASSWORD=…</code>、<code>api_key: …</code>、<code>client_secret</code>、<code>token</code>、<code>credential</code>。それと自分の <span class="ui">マスクルール</span>。</td></tr>
<tr><td><span class="ui">個人情報をマスク</span></td><td>メールアドレス、中国本土の携帯番号(11 桁の ID は別:<code>order_id</code> の値や 订单号 の後ろのものはそのまま)、チェックサムの合う中国の身分証番号と銀行カード番号。既定でオンのもの:米国の社会保障番号、パスポート番号(<em>passport</em>、护照、パスポートの後)、IBAN、誕生日(<em>birthday</em>、<em>DOB</em>、生日の近くにある、一年以上前の日付。今日の日付はそのまま)、MAC アドレス、シリアル番号(<em>S/N</em> の後)。エージェントがほぼ毎回送るので、自分でオンにするまでオフのもの:ホームフォルダのユーザー名(毎回同じ仮の名前で送るので、モデルにはプレースホルダーではなく普通のフォルダに見えます)、ユーザー名とコンピュータ名(<code>user@host</code>)、パブリック IP アドレス、クラウドストレージのバケット。</td></tr>
<tr><td><span class="ui">個人情報をマスク</span></td><td>メールアドレス、中国本土の携帯番号(11 桁の ID は別:<code>order_id</code> の値や 订单号 の後ろのものはそのまま)、チェックサムの合う中国の身分証番号と銀行カード番号。既定でオンのもの:米国の社会保障番号、パスポート番号(<em>passport</em>、护照、パスポートの後)、IBAN、誕生日(<em>birthday</em>、<em>DOB</em>、生日の近くにある、一年以上前の日付。今日の日付はそのまま)、MAC アドレス、シリアル番号(<em>S/N</em> の後)。エージェントがほぼ毎回送るので、自分でオンにするまでオフのもの:ホームフォルダのユーザー名(毎回同じ仮の名前で送るので、モデルにはプレースホルダーではなく普通のフォルダに見えます)、ユーザー名とコンピュータ名(<code>user@host</code>)、パブリック IP アドレス(ドキュメント用に予約されたアドレスとして送るので、モデルはそのまま接続に使い、コマンドの中で本物のアドレスに戻ります)、クラウドストレージのバケット。ウォレットやコントラクトのアドレス(<code>0x</code> と 16 進 40 桁)は公開情報なのでそのまま送ります。秘密鍵は引き続きマスクします。</td></tr>
<tr><td><span class="ui">マスクする語</span></td><td>入れた語そのままを <code>{{TERM_…}}</code> に。日付(<em>1990-05-12</em> など)を入れると、同じ日のどの書き方もマスクされます:<em>1990/5/12</em>、<em>1990.05.12</em>、<em>1990年5月12日</em>、<em>19900512</em>、<em>May 12, 1990</em>。<em>13/05/1990</em> のような日が先の書き方は、日と月を取り違えようがないときだけです。別の日付や <em>1990.5.12.1</em> のようなバージョン番号はマスクされません。</td></tr>
<tr><td><span class="ui">ローカルモデルで検出</span></td><td><span class="ui">検出方法</span> の中にあります。このコンピュータで動くモデルが、ルールでは見つからない自由文中の名前や住所を見つけます。オフにしない限りオンで、最初にマスクするリクエストで AstrLink Guard をダウンロードします。ダウンロードが終わるまではルールだけでマスクします。<span class="ui">シークレットをマスク</span> か <span class="ui">個人情報をマスク</span> がオンのときに使え、見つけたものは同じスイッチに従います。横のメニューでモデルを選べます:AstrLink Guard(中国語と英語、39 MB のダウンロード、コードでの誤検出が少ない、Mac では Neural Engine で動く。既定)か OpenAI の Privacy Filter(1.6 GB、GPU を使える、コード中の普通の値も多く隠す)。その下の <span class="ui">信頼度のしきい値</span> は、値をマスクするのにモデルがどれだけ確かである必要があるかです。既定は Privacy Filter が 0.5、AstrLink Guard が公開元の 0.8。上げると普通の値のマスクは減りますが、本物の名前や住所もそのまま送られやすくなります。誤検出の多くはモデルのあとのルールが既に外すので、既定値は測った中で本物の値を最も逃さない値です。</td></tr>
</table></div>
+1 -1
View File
@@ -111,7 +111,7 @@
<div class="table-wrap"><table>
<tr><th>Switch</th><th>What it finds</th></tr>
<tr><td><span class="ui">Mask secrets</span></td><td>Private key blocks (<code>-----BEGIN … PRIVATE KEY-----</code>). API keys by their shape: <code>sk-…</code> (OpenAI, Anthropic, OpenRouter), <code>ghp_</code>/<code>github_pat_</code>, <code>glpat-</code>, <code>AIza…</code>, <code>xox…-</code>, <code>sk_live_</code>, <code>AKIA</code>/<code>ASIA</code>, <code>hf_</code>, <code>gsk_</code>, <code>xai-</code>, <code>npm_</code>, <code>pypi-</code>, <code>dop_v1_</code>, <code>SG.</code>, and relay keys like <code>oc_sk_…</code>. JWTs. The password in <code>user:password@host</code>. The value of a field named for a secret, as <code>.env</code> files and configs have them: <code>DB_PASSWORD=…</code>, <code>api_key: …</code>, <code>client_secret</code>, <code>token</code>, <code>credential</code>. Your own <span class="ui">Masking rules</span>.</td></tr>
<tr><td><span class="ui">Mask personal data</span></td><td>Emails, mainland China mobile numbers (not an 11-digit id: one under <code>order_id</code> or after 订单号 goes as written), Chinese ID numbers and bank card numbers whose checksum adds up. Also on by default: US Social Security numbers, passport numbers (after <em>passport</em>, 护照 or パスポート), IBANs, birthdays (next to <em>birthday</em>, <em>DOB</em> or 生日, and over a year ago, so today&rsquo;s date stays), MAC addresses and serial numbers (after <em>S/N</em>). Off until you turn them on, since agents send them in nearly every request: the user name in home folders (sent as a made-up name, the same every turn, so the model reads a real folder rather than a placeholder), user and computer names (<code>user@host</code>), public IP addresses and cloud storage buckets.</td></tr>
<tr><td><span class="ui">Mask personal data</span></td><td>Emails, mainland China mobile numbers (not an 11-digit id: one under <code>order_id</code> or after 订单号 goes as written), Chinese ID numbers and bank card numbers whose checksum adds up. Also on by default: US Social Security numbers, passport numbers (after <em>passport</em>, 护照 or パスポート), IBANs, birthdays (next to <em>birthday</em>, <em>DOB</em> or 生日, and over a year ago, so today&rsquo;s date stays), MAC addresses and serial numbers (after <em>S/N</em>). Off until you turn them on, since agents send them in nearly every request: the user name in home folders (sent as a made-up name, the same every turn, so the model reads a real folder rather than a placeholder), user and computer names (<code>user@host</code>), public IP addresses (sent as addresses from the ranges set aside for documentation, so the model connects with them and the real address goes back into its commands) and cloud storage buckets. A wallet or contract address (<code>0x</code> and 40 hex digits) is public and goes as written; a private key is still masked.</td></tr>
<tr><td><span class="ui">Masked words</span></td><td>Each word you listed, exactly, as <code>{{TERM_…}}</code>. A date, such as <em>1990-05-12</em>, matches that day however it is written: <em>1990/5/12</em>, <em>1990.05.12</em>, <em>1990年5月12日</em>, <em>19900512</em>, <em>May 12, 1990</em>, and <em>13/05/1990</em> style only where the day can’t be read as a month. Never another date or a version like <em>1990.5.12.1</em>.</td></tr>
<tr><td><span class="ui">Find with a local model</span></td><td>Under <span class="ui">How it’s found</span>. A model on this computer finds what no rule can: a name or an address in free text. It is on unless you turned it off, and AstrLink Guard downloads with the first masked request; until it is on disk, the rules mask alone. It needs <span class="ui">Mask secrets</span> or <span class="ui">Mask personal data</span> on, and finds under the same switches. The menu beside it picks the model: AstrLink Guard (Chinese and English, a 39 MB download, few false alarms in code, on a Mac it runs on the Neural Engine; the default) or OpenAI’s Privacy Filter (1.6 GB, uses the GPU, masks more ordinary values in code). <span class="ui">Confidence threshold</span> under it is how sure the model must be before a value is masked: Privacy Filter’s default is 0.5, AstrLink Guard’s 0.8, its publisher’s. Higher masks fewer ordinary values, and lets more real names and addresses through: the rules after the model drop most false alarms already, so the default is where we measured the fewest real values lost.</td></tr>
</table></div>
+1 -1
View File
@@ -111,7 +111,7 @@
<div class="table-wrap"><table>
<tr><th>开关</th><th>能找到什么</th></tr>
<tr><td><span class="ui">脱敏密钥</span></td><td>私钥块(<code>-----BEGIN … PRIVATE KEY-----</code>)。按格式识别的 API Key:<code>sk-…</code>(OpenAI、Anthropic、OpenRouter)、<code>ghp_</code>/<code>github_pat_</code>、<code>glpat-</code>、<code>AIza…</code>、<code>xox…-</code>、<code>sk_live_</code>、<code>AKIA</code>/<code>ASIA</code>、<code>hf_</code>、<code>gsk_</code>、<code>xai-</code>、<code>npm_</code>、<code>pypi-</code>、<code>dop_v1_</code>、<code>SG.</code>,以及 <code>oc_sk_…</code> 这类中转站的 key。JWT。<code>user:password@host</code> 里的密码。<code>.env</code> 和配置文件里以密钥命名的字段的值:<code>DB_PASSWORD=…</code>、<code>api_key: …</code>、<code>client_secret</code>、<code>token</code>、<code>credential</code>。以及你的 <span class="ui">自定义脱敏规则</span>。</td></tr>
<tr><td><span class="ui">脱敏个人信息</span></td><td>邮箱、中国大陆手机号(11 位的编号不算:在 <code>order_id</code> 下或跟在「订单号」后面的照原样发出)、校验位对得上的身份证号和银行卡号。默认也开着的:美国社会安全号、护照号(跟在 <em>passport</em>、护照或パスポート后面)、IBAN、生日(旁边有 <em>birthday</em>、<em>DOB</em> 或「生日」,且是一年以前的日期,所以今天的日期不动)、MAC 地址、序列号(跟在 <em>S/N</em> 后面)。默认关闭、需要自己打开的(Agent 几乎每个请求都会带):主目录里的用户名(以一个每轮都相同的假名发出,模型看到的是正常的文件夹,而不是占位符)、用户名和主机名(<code>user@host</code>)、公网 IP 地址、云存储桶。</td></tr>
<tr><td><span class="ui">脱敏个人信息</span></td><td>邮箱、中国大陆手机号(11 位的编号不算:在 <code>order_id</code> 下或跟在「订单号」后面的照原样发出)、校验位对得上的身份证号和银行卡号。默认也开着的:美国社会安全号、护照号(跟在 <em>passport</em>、护照或パスポート后面)、IBAN、生日(旁边有 <em>birthday</em>、<em>DOB</em> 或「生日」,且是一年以前的日期,所以今天的日期不动)、MAC 地址、序列号(跟在 <em>S/N</em> 后面)。默认关闭、需要自己打开的(Agent 几乎每个请求都会带):主目录里的用户名(以一个每轮都相同的假名发出,模型看到的是正常的文件夹,而不是占位符)、用户名和主机名(<code>user@host</code>)、公网 IP 地址(以文档专用网段里的地址发出,模型照常用它连接,命令里再换回真实地址)、云存储桶。钱包或合约地址(<code>0x</code> 加 40 位十六进制)是公开的,照原样发出;私钥照样脱敏。</td></tr>
<tr><td><span class="ui">脱敏词</span></td><td>你填的每个词,精确匹配,换成 <code>{{TERM_…}}</code>。填的是日期(比如 <em>1990-05-12</em>)时,同一天的各种写法都会遮掉:<em>1990/5/12</em>、<em>1990.05.12</em>、<em>1990年5月12日</em>、<em>19900512</em>、<em>May 12, 1990</em>;<em>13/05/1990</em> 这种日在前的写法只在日和月不会混淆时才算。别的日期和 <em>1990.5.12.1</em> 这样的版本号不会被遮。</td></tr>
<tr><td><span class="ui">用本地模型查找</span></td><td>在 <span class="ui">怎么找</span> 下面。一个在这台电脑上运行的模型能找出规则找不到的东西:自由文本里的人名、地址。除非你关掉,它默认打开:第一个要脱敏的请求开始下载 AstrLink Guard,下载完成前只用规则脱敏。需要先打开 <span class="ui">脱敏密钥</span> 或 <span class="ui">脱敏个人信息</span>,找到的内容按同样的开关处理。旁边的菜单选择模型:AstrLink Guard(中英文,下载 39 MB,代码里很少误判,在 Mac 上用神经网络引擎运行;默认)或 OpenAI 的 Privacy Filter(1.6 GB,可用 GPU,代码里会遮盖更多普通值)。下面的 <span class="ui">置信度阈值</span> 是模型要多确定才遮盖一个值:Privacy Filter 默认 0.5,AstrLink Guard 默认 0.8(发布者的值)。调高会少遮一些普通值,也会让更多真实的人名、地址原样发出去;模型之后的规则已经去掉了大部分误判,所以默认值是我们测下来漏掉真实信息最少的那一档。</td></tr>
</table></div>