Reach
zn-gate reach 显示本机编程智能体能访问的内容(只显示名称,绝不显示值),并给出修复每项发现的命令。只读。
zn-gate reach 回答一个问题:本机的编程智能体能访问什么?它显示 zn 保护了哪些智能体、某个文件夹中 .env 文件里的密钥名称、你个人文件夹中的凭据文件、含有密钥的环境变量,以及 zn audit 在 MCP 服务器和智能体配置中发现的内容。每项发现都附带修复它的命令。
npx -y zn-gate reach
请在你工作的文件夹中运行。它不发送任何内容,不启动任何 hook,也不修改任何东西。
检查内容
- 智能体: Claude Code、Codex CLI、Cursor 和 OpenCode。显示每个智能体是否在本机,以及 zn 是为你的用户保护它,还是只为某个项目保护。它使用
zn-gate check的安装检查,不启动任何 hook。 - 文件夹中的
.env文件: 其中密钥的名称,绝不显示值。链接文件不会被跟随。 - **你个人文件夹中的凭据文件,**例如
~/.aws/credentials、SSH 密钥、~/.npmrc和~/.kube/config。zn 只检查它们是否存在,从不打开它们。 - 环境变量: 名称或值看起来像密钥的变量,只显示名称。
- 本文件夹和你的用户的 MCP 服务器与智能体配置: 采用与
zn audit相同的规则。
示例
在三个智能体都受保护的机器上,报告很简短:
zn-gate reach: what can the coding agents on this machine reach?
Read: agent settings in your home folder and this folder, .env files here, names of environment variables. Nothing was sent anywhere.
AGENTS
Claude Code protected by zn (run `zn-gate check` to test it)
Codex CLI protected by zn (run `zn-gate check` to test it)
Cursor protected by zn (run `zn-gate check` to test it)
OpenCode not found on this machine
Nothing to fix. Your agents run with zn-gate.
需要处理时,每项发现都有严重程度、简短说明和修复命令。以下是对一个虚构项目运行一次的真实输出(密钥和 AWS 凭据文件均为虚构):
zn-gate reach: what can the coding agents on this machine reach?
Read: agent settings in your home folder and this folder, .env files here, names of environment variables. Nothing was sent anywhere.
AGENTS
Claude Code not protected
Codex CLI not found on this machine
Cursor not found on this machine
OpenCode not found on this machine
HIGH Claude Code is on this machine and zn does not protect it
It can read any file and run any command you allow.
Fix: npx -y zn-gate init
WHAT THEY CAN REACH (secrets and credential files an agent could read; names only, never values)
HIGH .env in this folder has 2 secrets (OPENAI_API_KEY, DATABASE_URL)
Claude Code can read them today.
Fix: npx -y zn-gate env shadow .env
MEDIUM 1 credential file in your home folder (~/.aws/credentials)
Claude Code can read them today.
Fix: npx -y zn-gate init
NEXT: fix the high ones
1. npx -y zn-gate init
2. npx -y zn-gate env shadow .env
2 high, 1 medium, 0 low.
严重程度取决于安装情况。当本机有 zn 尚未保护的智能体时,.env 文件或凭据文件为 high 或 medium。尚未安装任何智能体时为 low;zn 保护了它找到的所有智能体时,仅作信息提示。环境变量始终为 low。
选项
| 选项 | 作用 |
|---|---|
[path] |
要检查的文件夹。默认为当前文件夹 |
--json |
同样的报告,以 JSON 格式输出 |
--sarif |
以 SARIF 2.1.0 格式输出报告,用于代码扫描。针对所检查文件夹中文件的发现作为结果(智能体可读取密钥的 .env 文件为 ZNR002);智能体、凭据文件和环境变量则作为本次运行的通知 |
--fail-on high|medium|low|none |
发现达到或高于该级别的项目时以退出码 1 结束。默认值 none 使 reach 以退出码 0 结束。用法错误或运行失败时退出码为 2 |
--remember |
将本次运行的计数(high、medium、low 和日期)保存到 ~/.zn/reach-last.json,下次带 --remember 运行时会显示上次的计数。不加此选项,reach 不写入任何内容 |
它绝不会做的事
- 绝不显示密钥值,也绝不打开凭据文件。
- 不通过网络发送任何内容,也不启动任何 hook。
- 除非你使用
--remember,否则不写入任何内容。
如果在大型文件夹中检查超时,报告会说明有部分文件未被检查。npx -y zn-gate audit --include-home 会检查全部文件。
在配置流程中的位置
zn-gate reach显示你的智能体目前能访问什么。npx -y zn-gate init为每个智能体提供保护。快速开始npx -y zn-gate check测试 zn 是否能阻止你的智能体读取测试用的.env文件。Checknpx -y zn-gate env shadow .env把.env文件中的明文密钥移入本地保险库。
要修复某项发现,运行它显示的命令。对于未受保护的智能体,命令是 npx -y zn-gate init。对于环境变量,请在你自己的终端中运行 npx -y zn-gate secret set NAME,然后在需要值的位置写入 __ZN_NAME__。