Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

1.6 KB
Raw Blame
package redact

import (
	"strings"
	"testing"
)

// git@host is how every git host is reached over SSH, and was masked as
// an address, remote and all (jumy on Discord). It stays, whichever host;
// an address beside it, and one whose name only starts with git, is still
// masked, by the rules and the local model's EMAIL alike.
func TestGitRemoteIsNoEmail(t *testing.T) {
	o := Options{Secrets: true, Personal: true}
	for _, s := range []string{
		"[email protected]:yetone/magpie.git",
		"git clone [email protected]:group/sub/repo.git",
		"origin\t[email protected]:owner/repo.git (fetch)",
		"ssh -T [email protected]",
		"url = [email protected]:team/svc.git",
		"[email protected]:o/r",
	} {
		if out, n := Mask(s, o); n != 0 || out != s {
			t.Errorf("%q: %d masked: %q", s, n, out)
		}
	}
	for _, s := range []string{"[email protected]", "[email protected]", "[email protected]"} {
		in := "mail " + s + " today"
		if out, n := Mask(in, o); n != 1 || strings.Contains(out, s) {
			t.Errorf("%q: %d masked: %q", s, n, out)
		}
	}
	body := `{"messages":[{"role":"user","content":"push to [email protected]:o/r.git and tell [email protected]"}]}`
	out, n := MaskJSON([]byte(body), o)
	if n != 1 || !strings.Contains(string(out), "[email protected]:o/r.git") || strings.Contains(string(out), "[email protected]") {
		t.Fatalf("request: %d masked: %s", n, out)
	}
	f := &fakeModel{values: map[string]string{"[email protected]": "private_email"}}
	if out, n := Mask("[email protected]:o/r.git", Options{Personal: true, Model: f.find}); n != 0 {
		t.Fatalf("model's: %d masked: %q", n, out)
	}
}