A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
ci: block personal machine names in committed content
RoversXd6404cd9f876
diff --git a/.gitignore b/.gitignoreindex 1e9bedcc..66f56819 100644--- a/.gitignore+++ b/.gitignore@@ -110,6 +110,7 @@ __pycache__/# Local credentials and native release output. The privacy hook also rejects# these if they are force-added; ignore rules do not protect tracked files.+/ci/privacy-local.txt.env.env.*!.env.examplediff --git a/ci/PRIVACY.md b/ci/PRIVACY.mdindex bffe97b5..aca4665f 100644--- a/ci/PRIVACY.md+++ b/ci/PRIVACY.md@@ -29,6 +29,16 @@ for fixtures. Existing public upstream examples and specific packaging templatefiles have narrow exceptions in the scanner; do not add blanket exclusions fortests or source folders.+Quoted hostnames and hosts in URLs or after `@` ending in `.local`, `.lan`, or+`.home.arpa` are checked too; use `myhost.local` or `example.local` for fixtures.+Bare source expressions such as entry.local are not treated as hostnames.+Outside CI, the guard also reads this computer's names from the OS and an optional+ignored `ci/privacy-local.txt` (one name per line, `#` starts a comment). Those+names of at least four characters are checked case-insensitively at word boundaries without printing them.+Do not commit personal names or their hashes as a denylist. The guard rejects the+local list itself even if force-added. CI uses the structural rule only; it+cannot know a developer's private machine names.+The `privacy` Actions workflow checks the committed snapshot on pushes and pullrequests without running a Rust/mobile build. Once installed on GitHub, its`check` job can be required in repository branch rules. CI is **after upload**;diff --git a/ci/check-privacy.py b/ci/check-privacy.pyindex d9c1b483..09532659 100644--- a/ci/check-privacy.py+++ b/ci/check-privacy.py@@ -4,7 +4,9 @@import argparseimport ipaddressimport json+import osimport re+import socketimport subprocessimport sysfrom pathlib import PurePosixPath@@ -36,16 +38,79 @@ PRIVATE_KEY = re.compile(rb"-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY-----(?:\r?\n|\TOKENS = re.compile(rb"(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,}|xox[baprs]-[A-Za-z0-9-]{20,}|sk-(?:proj-|ant-)[A-Za-z0-9_-]{32,}|AKIA[0-9A-Z]{16})")SSH_IP = re.compile(rb"ssh://[^\s/@\"'<>]+@((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?=[:/\s\"'<>]|$)")DOCUMENTATION_NETS = tuple(ipaddress.ip_network(n) for n in ("192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24"))+# A machine name in a value position: quoted, after `@`, or inside a URL. A+# bare foo.local is deliberately not read as a host, because in source it is+# far more often a field access -- catalog.local, entry.local -- and the+# leak this looks for is a real name committed as a literal.+HOSTNAME = re.compile(rb"(?:['\"`]|@|://)([A-Za-z0-9][A-Za-z0-9_-]{0,62})\.(?:local|lan|home\.arpa)(?![A-Za-z0-9_.-])", re.IGNORECASE)+SAMPLE_HOSTS = set(b"alice bob example host hostname localhost machine myhost server test".split())+# Vendored labels that share the shape without naming a machine.+VENDOR_HOSTS = {+ b"dockerfile": ("third_party/material-icon-theme/",),+ b"containerfile": ("third_party/material-icon-theme/",),+}+# Personal names are never stored in the repository: they are read from the+# machine at scan time, plus this optional untracked file, one per line.+LOCAL_LIST = "ci/privacy-local.txt"def git(*args):return subprocess.check_output(["git", *args], stderr=subprocess.PIPE)+def local_names():+ """This machine's own names, read at run time and never written down.++ A denylist of personal names committed to the repository would publish+ exactly the strings it is meant to keep out, so nothing here is stored:+ the names come from the running machine and from an untracked file. On CI+ the runner's own name says nothing about the developer and would risk+ matching an ordinary word, so the check is skipped there.+ """+ if os.environ.get("CI"):+ return ()+ names = set()+ try:+ names.add(socket.gethostname())+ except OSError:+ pass+ if sys.platform == "darwin":+ for key in ("ComputerName", "LocalHostName"):+ try:+ names.add(subprocess.check_output(["scutil", "--get", key], stderr=subprocess.DEVNULL, timeout=5).decode("utf-8", "replace"))+ except (OSError, subprocess.SubprocessError):+ pass+ try:+ root = git("rev-parse", "--show-toplevel").strip().decode("utf-8", "surrogateescape")+ with open(os.path.join(root, LOCAL_LIST), "rb") as handle:+ for line in handle:+ names.add(line.split(b"#", 1)[0].decode("utf-8", "replace"))+ except (OSError, subprocess.CalledProcessError):+ pass+ found = set()+ for name in names:+ bare = name.strip().strip(".")+ for form in (bare, bare.rsplit(".", 1)[0] if "." in bare else bare):+ # Names shorter than four characters are skipped, including local+ # list entries, because they collide with ordinary source words.+ if len(form) >= 4:+ found.add(form.encode("utf-8", "replace"))+ return tuple(sorted(found))+++def personal_pattern(names=None):+ names = local_names() if names is None else names+ if not names:+ return None+ return re.compile(rb"(?<![A-Za-z0-9_-])(?:" + rb"|".join(re.escape(n) for n in names) + rb")(?![A-Za-z0-9_-])", re.IGNORECASE)++def path_issues(path):parts = PurePosixPath(path).partsname = parts[-1].lower()issues = set()+ if path == LOCAL_LIST:+ issues.add("personal-host-list: keep this file untracked")if path not in APP_TEMPLATE and (name.endswith(ARCHIVES) or any(p.lower().endswith(".app") for p in parts)):issues.add("release-artifact: distribute packages outside Git")if any(p in ("target", "XCBuildData", "DerivedData") for p in parts) or path.startswith(("ios/build/", "android/build/", "android/app/build/")):@@ -55,7 +120,7 @@ def path_issues(path):return issues-def content_issues(path, data):+def content_issues(path, data, personal=None):issues = set()if b"PRIVATE KEY-----" in data and PRIVATE_KEY.search(data):issues.add("private-key: remove key material")@@ -69,6 +134,15 @@ def content_issues(path, data):issues.add("personal-home: use an environment variable or an alice/example fixture")# Binary assets are not interpreted as text tokens or endpoint examples.if b"\0" not in data[:8000]:+ for match in HOSTNAME.finditer(data):+ host = match[1].lower()+ if host in SAMPLE_HOSTS:+ continue+ if any(path.startswith(prefix) for prefix in VENDOR_HOSTS.get(host, ())):+ continue+ issues.add("personal-hostname: use an example host in fixtures")+ if personal is not None and personal.search(data):+ issues.add("personal-machine: remove the local machine name")if any(marker in data for marker in (b"gh", b"github_pat_", b"xox", b"sk-", b"AKIA")) and TOKENS.search(data):issues.add("provider-token: remove the credential")if b"ENCRYPTED" + b"[" in data:@@ -108,6 +182,7 @@ def entries(tree=None):def check(tree=None):failures = 0count = 0+ personal = personal_pattern()with subprocess.Popen(["git", "cat-file", "--batch"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as batch:try:for path, oid in entries(tree):@@ -120,7 +195,7 @@ def check(tree=None):data = batch.stdout.read(size)if len(data) != size or batch.stdout.read(1) != b"\n":raise ValueError("Incomplete Git blob")- issues = path_issues(path) | content_issues(path, data)+ issues = path_issues(path) | content_issues(path, data, personal)count += 1for issue in sorted(issues):# No matched values, snippets or key material in terminal/CI logs.diff --git a/ci/test_privacy_guard.py b/ci/test_privacy_guard.pyindex ef2e712d..7cd9e79e 100644--- a/ci/test_privacy_guard.py+++ b/ci/test_privacy_guard.py@@ -7,6 +7,7 @@ import subprocessimport sysimport tempfileimport unittest+from unittest import mockCI = Path(__file__).resolve().parentSPEC = importlib.util.spec_from_file_location("privacy_guard", CI / "check-privacy.py")@@ -20,6 +21,32 @@ def personal_path():class Rules(unittest.TestCase):+ def test_hostname_literals_and_source_expressions(self):+ private = b"synthetic-private-machine"+ for suffix in (b".local", b".LAN", b".home.arpa"):+ for prefix in (b'"', b"'", b"`", b"user@", b"https://"):+ self.assertTrue(GUARD.content_issues("test.rs", prefix + private + suffix + b'"'))+ for data in (b'"myhost.local"', b'"example.lan"', b"entry" + b".local", b'"entry.local_name"'):+ self.assertFalse(GUARD.content_issues("test.rs", data))+ label = b'"Dockerfile' + b'.local"'+ self.assertFalse(GUARD.content_issues("third_party/material-icon-theme/icons.json", label))+ self.assertTrue(GUARD.content_issues("test.rs", label))++ def test_personal_names_are_literal_bounded_and_independent_of_exemptions(self):+ name = b"synthetic-private-machine"+ pattern = GUARD.personal_pattern([name, b"test[42]"])+ self.assertTrue(GUARD.content_issues("test.rs", name.upper(), pattern))+ self.assertTrue(GUARD.content_issues("test.rs", b"test[42]", pattern))+ self.assertFalse(GUARD.content_issues("test.rs", b"test4", pattern))+ self.assertFalse(GUARD.content_issues("test.rs", b"prefix-" + name, pattern))+ self.assertTrue(GUARD.content_issues("test.rs", b'"myhost.local"', GUARD.personal_pattern([b"myhost"])))++ def test_ci_does_not_read_machine_names_or_local_list(self):+ with mock.patch.dict(os.environ, {"CI": "true"}), mock.patch.object(GUARD.socket, "gethostname") as hostname, mock.patch("builtins.open") as opened:+ self.assertEqual(GUARD.local_names(), ())+ hostname.assert_not_called()+ opened.assert_not_called()+def test_native_and_escaped_windows_paths(self):for data in (personal_path(), b"C:\\Users\\" + b"synthetic-person\\work", b"C:\\\\Users\\\\" + b"synthetic-person\\\\work"):self.assertTrue(GUARD.content_issues("example.rs", data))@@ -85,6 +112,36 @@ class GitIntegration(unittest.TestCase):def scan(self, *args):return self.run_command([sys.executable, str(CI / "check-privacy.py"), *args])+ def test_local_list_is_used_without_disclosing_or_staging_it(self):+ self.env.pop("CI", None)+ local = self.repo / GUARD.LOCAL_LIST+ local.parent.mkdir()+ name = b"synthetic-private-machine"+ local.write_bytes(name + b" # fixture\n")+ (self.repo / "test.txt").write_bytes(name.upper())+ self.git("add", "test.txt")+ result = self.scan()+ self.assertEqual(result.returncode, 1)+ self.assertIn(b"personal-machine", result.stderr)+ self.assertNotIn(name.lower(), (result.stdout + result.stderr).lower())+ self.env["CI"] = "true"+ self.assertEqual(self.scan().returncode, 0)+ self.git("add", GUARD.LOCAL_LIST)+ self.assertIn(b"personal-host-list", self.scan().stderr)++ def test_hostname_check_reads_index_and_redacts_matches(self):+ self.env["CI"] = "true"+ name = b"synthetic-private-machine" + b".local"+ path = self.repo / "test.txt"+ path.write_bytes(b'"' + name + b'"')+ self.git("add", "test.txt")+ path.write_text('"myhost.local"')+ result = self.scan()+ self.assertEqual(result.returncode, 1)+ self.assertNotIn(name, result.stdout + result.stderr)+ self.git("add", "test.txt")+ self.assertEqual(self.scan().returncode, 0)+def test_scans_staged_bytes_and_redacts_values(self):path = self.repo / "settings.txt"secret = b"ghp" + b"_" + b"A" * 36diff --git a/mux/src/client.rs b/mux/src/client.rsindex 7b15245a..852974fb 100644--- a/mux/src/client.rs+++ b/mux/src/client.rs@@ -48,7 +48,7 @@ mod tests {fn proxied_identity_matches_its_originating_client() {let local = client_id("myhost.local", 7, Some("/local/agent"));let proxied = client_id(- "myhost.local (via proxy pid 190892)",+ "myhost.local (via proxy pid 4242)",7,Some("/remote/agent"),);@@ -60,7 +60,7 @@ mod tests {#[test]fn proxy_decoration_does_not_merge_distinct_clients() {let local = client_id("myhost.local", 7, None);- let other = client_id("myhost.local (via proxy pid 190892)", 8, None);+ let other = client_id("myhost.local (via proxy pid 4242)", 8, None);assert!(!local.same_logical_client(&other));}