ShriD5/claude-mods/tree/main/secret-guard
secret-guard
tool.call hook으로 Write, Edit, MultiEdit, NotebookEdit와 Bash 리디렉션이 실제처럼 보이는 자격 증명을 파일에 쓰지 못하게 하며 플레이스홀더와 .env는 허용합니다.
이 mod 소개
secret-guard는 tool.call hook으로 파일 도구가 쓰려는 텍스트와 Bash 리디렉션 내용을 검사하고, 실제처럼 보이는 자격 증명이 있으면 호출을 거부합니다. AWS, Anthropic/OpenAI, GitHub, Slack, Stripe, Google 키, 개인 키 블록, 비밀번호가 포함된 DB URL을 감지합니다. xxxx, process.env.X, EXAMPLE 키, localhost, example.com, postgres:postgres, 파일에 이미 있는 비밀과 .env 계열은 통과시키지만 .env.example/.sample/.template은 계속 보호합니다. CLAUDE.md와 AGENTS.md는 더 엄격하게 검사합니다. 차단되면 발견한 종류와 줄을 알리고 비밀을 출력하지 않은 채 환경 변수를 사용하라고 안내합니다. claude --plugin-dir ./secret-guard 또는 marketplace로 설치하고 /secret-guard에서 유형별 차단 내역을 확인합니다.
설치
먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.
claude plugin marketplace add ShriD5/claude-mods claude plugin install secret-guard
원문 / README
secret-guard
Stops Claude from writing secrets into files. When a Write, Edit, MultiEdit or NotebookEdit would put a real-looking credential into a file, or a Bash command would echo, printf, tee or heredoc one into a file, the call is refused. Claude is told what it found and on which line, and to read the value from an environment variable instead, with the value kept in a gitignored .env. The secret itself is never repeated back.
🔒 secret-guard blocked a GitHub token in config.ts
It catches:
- AWS access keys (
AKIA…,ASIA…) - Anthropic keys (
sk-ant-…), OpenAI keys (sk-proj-…, legacysk-…), and other longsk-…keys - GitHub tokens (
ghp_,gho_,ghu_,ghs_,ghr_,github_pat_) - Slack tokens (
xoxb-,xoxp-, …) and Slack webhook URLs - Stripe live keys (
sk_live_,rk_live_) - Google API keys (
AIza…) - private key blocks (
-----BEGIN … PRIVATE KEY-----with a key body) - database URLs with an inline password (
postgres://,mysql://,mongodb+srv://,redis://,amqp://)
It lets these through:
- Placeholders:
xxxx,your-key-here,<api-key>,${VAR},process.env.X,AKIA…EXAMPLE, low-variety strings. - Dev defaults: database URLs to
localhostor a docker service name, documentation hosts likeexample.com, and default passwords likepostgres:postgres. - Secrets the file already holds: editing next to an existing key isn't blocked.
- Env files:
.env,.env.local,.env.productionand.dev.vars, which is where the deny message tells Claude to put secrets..env.example,.env.sampleand.env.templateare still guarded, because those get committed.
CLAUDE.md and AGENTS.md get extra-strict checks. In those files any credential-named assignment with a random-looking value (api_key: "q8Zr…") is blocked too. The deny reason also tells Claude why: these files are often committed and public, and in a public sample of 25,784 CLAUDE.md files, 275 contained real-looking secrets.
Run /secret-guard to see how many secrets it has blocked so far, broken down by type.
Install
claude --plugin-dir ./secret-guard
or add this repo as a marketplace and install it with /plugin.
Options
None. The rules live in hooks/detect.ts. Each one is a regex for a format a real service issues, followed by placeholder checks.
How it works
A tool.call hook reads the text a file tool is about to write, or the files a Bash command redirects into, and runs the detector on it. If anything new turns up, it answers { deny } so the tool never runs. The running count is kept in $.store.
배지 받기
내 프로젝트인가요? 이 배지를 README나 웹사이트에 넣으면 이 페이지로 연결됩니다.
동명의 다른 작품
- secret-guarddavidho27941 · ★ 1
- secret-guard0xGondarxyz · ★ 0
