Files
Wesam Abousaid a3f328c043 docs: refresh for OpenCode v1.17.13, add Go coverage, and rebrand
- Bump every version pin, pricing table, and model ID to the verified
  2026-07-05 state (v1.17.13): Claude Fable 5 / Sonnet 5 on Zen, new
  free tier, deprecation sunset table, v1.17.x changelog section
- Cover gaps: OpenCode Go vs Zen billing, Anthropic subscription-login
  removal (PR #18186), MCP resources, --mini mode, --auto flag, yolo mode
- Fix correctness bugs: command-template !`cmd` syntax in docs and
  .opencode/commands, protect-secrets regex missing 'cat .env', dual
  plugin exports, quickstart PATH fix, Playwright MCP flags, ctrl+d
  keybind conflict, agent/command required-field claims
- Fix links: cursor.com, windsurf.com, platform.claude.com,
  code.claude.com, opencode.ai/discord, Vercel Grep announcement
- Rebrand: banner (Images/banner.svg), 1280x640 social preview asset,
  hero redesign with star CTA, ecosystem stats, private vulnerability
  reporting channel, CI-matching local checks, MD060 lint opt-out
2026-07-05 14:11:51 +02:00

39 lines
1.4 KiB
JavaScript

// .opencode/plugins/protect-secrets.js
//
// Block any tool call that would read, write, or shell-touch a sensitive path
// (`.env*`, `secrets/`, `credentials*`, common SSH key files). Belt-and-braces
// on top of `external_directory: deny` and gitignore — never your only line
// of defense, but a useful one.
const SENSITIVE = /(^|[\s\/"'=])(\.env(\.[^\s]*)?|secrets|credentials|id_rsa|id_ed25519|\.npmrc|\.pypirc)(\b|\/)/i;
// Pull the most likely path/command field out of a tool's arguments.
// `read`/`edit`/`write` use `filePath`; `bash` uses `command`; others vary.
function targetFromArgs(args) {
if (!args || typeof args !== "object") return "";
return (
args.filePath ??
args.path ??
args.file_path ??
args.target ??
args.command ?? // bash: scan the command line itself
""
);
}
export const ProtectSecrets = async () => {
return {
// `tool.execute.before` is a top-level hook with an (input, output) signature.
// `input.tool` is the tool name; `output.args` holds its (mutable) arguments.
// Throwing here aborts the tool call before it runs.
"tool.execute.before": async (input, output) => {
const candidate = targetFromArgs(output?.args);
if (candidate && SENSITIVE.test(String(candidate))) {
throw new Error(
`[protect-secrets] blocked ${input.tool} on sensitive path: ${candidate}`
);
}
},
};
};