Klarion

io.github.0x1Adi由 GitHub 账号 0x1Adi 发布v0.4.3更新于 Oct 24, 2026

Secret scanning for AI agents: rules and entropy find candidates, a model decides which are real.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

Klarion 扫描代码中的密钥(API key、密码、令牌),先用本地规则和熵检测找出候选,再由 AI 模型判断哪些是真的。

可以做什么
  • 在写入代码或提交前扫描文本或文件中的密钥,候选由模型判定或交给调用它的 agent 判断
  • 识别已知密钥格式、password = value 式赋值、凭据文件以及藏在 base64 或十六进制中的密钥,并做随机性检查
  • 报告发现项,含严重级别、位置、掩码后的值和带置信度的判定
  • 抑制误报并查看被抑制的内容
  • 除 MCP 服务器外,还提供命令行扫描、提交钩子和 CI 用法
适用场景
适合在助手编写或修改代码时,于文件落盘或提交之前拦截密钥;也适合对某个被标记的字符串是否为真实凭据(而非测试值或哈希)做二次判断。
运行要求
以本地进程(stdio)方式在用户机器上运行,可通过 Homebrew、Go、发布版二进制或打包文件安装。判定需要模型:默认使用 ANTHROPIC_API_KEY,也可在 .klarion.toml 中配置 OpenAI 兼容密钥、本地 Ollama 模型或 Claude Code 登录。未配置模型时,服务器把候选交给调用它的 agent 判断。
安装前请注意
服务器会读取传给它的任意路径,建议逐次批准调用而不要自动批准。每个候选附近的代码片段会发送给你选择的模型提供方,除非关闭 send_secret;使用本地模型可让数据留在本机。它只发现密钥而不修复,发现的凭据应轮换。本地钩子可被 git commit --no-verify 绕过。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Klarion,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README


Klarion finds secrets in your code: API keys, passwords and tokens.

It works in two steps:

  1. Find. Fast local checks flag anything that looks like a secret.
  2. Check. An AI model reads each one with the code around it and decides if it is real.

Pattern scanners stop at step 1, so they also flag test values, IDs and hashes. Klarion shows you the real leaks.

It runs where the leak happens

A Claude Code hook that blocks the write before the file exists. The agent cannot route around it, not through the file tools and not through Bash.

[A coding agent is told to hardcode an AWS key pair. Klarion's pre-tool hook blocks the write at 95% confidence, and the agent reports that it cannot land the credentials through Bash or the file tools.]

console
$ klarion scan .
services/billing/client.py  [critical] stripe-secret-key  39:18  sk_l****4bQx    verdict: secret (confidence 0.96)    | stripe.api_key = "sk_l****4bQx"
Summary: 1 finding(s) across 1 file(s), 198 suppressed [1204 files scanned in 612ms]

Install

macOS:

sh
brew install 0x1Adi/tap/klarion

Anywhere else, with Go 1.25 or newer:

sh
go install github.com/0x1Adi/Klarion/cmd/klarion@latest

Or download a binary from the releases page.

Klarion needs an AI model. Pick one:

ModelSetup
Anthropic (default)export ANTHROPIC_API_KEY=...
OpenAI or compatibleexport OPENAI_API_KEY=... and set provider = "openai"
Local model, nothing leaves your machineRun Ollama and set provider = "ollama"
Your Claude Code loginSet provider = "claude-cli"

Settings go in .klarion.toml under [ai]. All options are in the reference.

Use it

What you wantHow
Scan a folderklarion scan .
Block commits that add a secretklarion protect
Block commits with the pre-commit frameworkThe .pre-commit-config.yaml below
Stop Claude Code from writing a secret/plugin marketplace add 0x1Adi/Klarion, /plugin install klarion@klarion, then restart Claude Code
Stop Cline, Cursor or any MCP agent from writing a secretThe MCP server below
Fail pull requests that add a secretThe GitHub Action below
Start on a repo that already has findingsklarion baseline create, so only new secrets fail
yaml
# .github/workflows/secrets.ymlname: secret-scanon: [push, pull_request]
jobs:  klarion:    runs-on: ubuntu-latest    permissions:      contents: read      security-events: write    steps:      - uses: actions/checkout@v6        with:          fetch-depth: 0      - uses: 0x1Adi/[email protected]        with:          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

On a pull request it scans only what the PR adds. It caches the AI answers, so unchanged code costs nothing. Findings show in the job log. On a private repo without GitHub Code Security, add upload-sarif: "false" to skip the Security tab upload. GitLab CI and every option are in the reference.

yaml
# .pre-commit-config.yamlrepos:  - repo: https://github.com/0x1Adi/Klarion    rev: v0.4.3    hooks:      - id: klarion        stages: [pre-commit]

Without the stages line the hook is off and runs only when you ask for it, with pre-commit run --hook-stage manual klarion. The klarion hook builds Klarion with Go the first time it runs; use id: klarion-system if klarion is already installed. Everyone who commits needs a model set up.

json
// ~/.cline/mcp.json, or the MCP settings of any other client{  "mcpServers": {    "klarion": {      "command": "klarion",      "args": ["mcp"]    }  }}

The agent calls scan_text before it writes code and scan_file before it commits. Approve each call rather than auto-approving the server: scan_file reads any path it is given. With no model configured the server hands each candidate and its decision rules to that agent to judge, so it needs no API key. Configure one and Klarion judges instead. Full steps, including the tools and how to verify the install: llms-install.md.

Results

Klarion found about 1.7× more real secrets than gitleaks, and 89% of its alerts were real (gitleaks: 91%).

We tested Klarion v0.3.0 on CredData: 337 real open source repos where Samsung labeled the lines that hold secrets. These numbers cover code outside test folders.

Klariongitleaksdetect-secrets
Real secrets found35%21%35%
Alerts that were real89%91%34%
False alarms on flask and rails933247

Good to know:

  • Klarion skips test fixtures and docs examples on purpose. CredData counts those as real. Counted that way, Klarion found 9% and gitleaks 46%.
  • Klarion's numbers come from a sample of 612 AI checks with one model (Claude Haiku). The likely range is 30 to 40% found and 82 to 97% real.
  • CredData's labels came from what other scanners found, which helps those scanners.

Full method and data: benchmark/REPORT.md.

How it works

[Step 1 runs local checks and finds candidates. Step 2 an AI model checks each one: real secrets fail the scan, the rest are hidden.]
  • Step 1 runs on your machine. It looks for known key formats, password = value style lines, credential files like .pgpass, and secrets hidden in base64 or hex. It also checks how random a string looks.
  • Step 2 asks the model. Each candidate goes out with a few lines of code. The model answers secret, false positive or uncertain. Uncertain counts as a secret.
  • You can see what was hidden. Run klarion scan . --show-suppressed.
  • Your code goes only to the model you pick. Set send_secret = false to send a masked value instead. It is less accurate.

Limits

  • It needs a model. Without one, klarion scan and the commit hooks stop with an error. The Claude Code hook still blocks provider keys such as AWS, GitHub and Stripe, and the MCP server hands the candidates and its rules to your agent to judge.
  • No API key? A hosted judge with no setup is coming. Join the list.
  • The model can be wrong. Check what it hid with --show-suppressed.
  • It finds secrets, it does not fix them. Rotate any secret it finds.
  • Local hooks can be skipped with git commit --no-verify. Run Klarion in CI too, with the Action. The pre-commit hook checks staged changes only, so in CI it has nothing to check.

More

Reference · Benchmark · Design · Changelog · Contributing · Security

MIT © The Klarion Authors

来源:README.md,提交 cb36931

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

3
  1. v0.4.3最新Sep 21, 2026
  2. v0.4.1Sep 19, 2026
  3. v0.3.8Sep 18, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分