Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

从“发现”到“止血”:MongoDB Kingfisher 如何重塑密钥泄露的响应闭环

项目背景与痛点

密钥泄露早已不是“会不会发生”的问题,而是“什么时候被发现”的问题。一个误提交到公开仓库的 AWS Access Key,从暴露到被扫描器抓取,平均窗口只有几分钟;而多数团队从“收到告警”到“完成轮换”,往往要按天计算。这个时间差,就是攻击者全部的操作空间。

现有的密钥扫描工具,大多停留在链条的第一环。gitleaks、detect-secrets 这类基于正则与熵值的工具,擅长在海量文本里“捞可疑字符串”,但它们交付的是一份需要人工二次甄别的清单:哪些是真实凭证?哪些是早已失效的测试数据?哪些是文档里的示例?误报率一高,工程师就会对告警脱敏,安全工具沦为 CI 里一条被 continue-on-error 跳过的流水线。

更关键的是第三环几乎无人覆盖:就算确认了泄露,这个密钥到底能打开多少扇门?它是只读的 S3 凭证,还是拥有整个组织 AdministratorAccess 的根账号密钥?影响范围(blast radius)不明,就无法判断该走“下个迭代再处理”还是“立刻拉响 P0 事故”。

MongoDB 开源的 Kingfisher,正是冲着这条断裂的链条来的:检测 → 实时验证 → 影响面测绘 → 快速撤销,它试图把四个孤立动作压进一条流水线。

核心技术揭秘

Kingfisher 选择 Rust 作为实现语言,这个决策本身就有信息量。密钥扫描是典型的 I/O 密集 + CPU 密集混合负载:既要遍历海量文件、处理编码与二进制伪装,又要对每一行文本跑上百条正则。Go 生态里已有成熟竞品,Rust 带来的是更低的内存占用、可预测的扫描延迟,以及一个无运行时依赖的静态二进制——这对把它们塞进 CI 容器或开发机 pre-commit 钩子至关重要。

整体数据流大致如下:

graph TD subgraph "扫描阶段" A[代码仓库 / 本地目录 / 容器镜像] --> B[文件遍历 + 二进制与噪声过滤] B --> C[规则引擎:正则 + 熵值 + 上下文] C --> D{"候选密钥命中?"} D -->|"否"| E[丢弃并继续遍历] D -->|"是"| F[去重与上下文片段提取] end subgraph "验证与响应阶段" F --> G{"实时验证开关?"} G -->|"开启"| H[调用服务商只读 API 校验活性] G -->|"关闭"| I[标记为未验证线索] H --> J[权限探测:测绘影响范围] I --> K[生成结构化报告] J --> K end K --> L[SARIF / JSON / 终端输出]

规则引擎层是 950+ 规则的落点。这些规则不只是“匹配一串 32 位十六进制”,而是带着服务商前缀、长度约束和上下文断言的结构化描述——比如某类 token 必须出现在特定变量名附近,或者必须满足校验位算法。这样一来,纯熵值筛选常见的“随机字符串误报”被大幅压掉。

实时验证层是 Kingfisher 真正拉开差距的地方,也是技术难度最高的一环。它针对每一类规则,调用对应服务的最小权限只读端点来确认凭证是否仍然存活:云厂商用身份查询接口换回调用者身份,SaaS 平台用 me / auth.test 类接口探活。这一步的价值是双重的——既把“疑似”变成“确认”,又顺手拿到了身份上下文(账号 ID、角色、作用域),成为下一步影响面分析的天然输入。

影响面测绘延续同一思路:从验证返回的身份信息出发,映射到可触达的资源类型与权限级别,把“泄露了一个 token”翻译成“泄露了一个能读写生产环境对象存储的角色”。这正是安全团队真正需要的语言。

功能亮点与差异

对比同类工具,Kingfisher 的差异化可以概括为三点。

其一,把验证当作一等公民。gitleaks 基本不做活体验证,trufflehog 虽有验证但规则覆盖面相对收敛。Kingfisher 的护城河是“950+ 规则 × 验证覆盖度”的乘积——规则数量决定召回,验证覆盖决定精度,两者同时做大的工程成本很高。

其二,闭环而非单点。多数工具止步于“报告”,撤销动作留给人工。Kingfisher 明确把“快速撤销”写进产品叙事,意味着输出物不只是问题清单,还包含可执行的处置指引。

其三,MongoDB 的工程信誉背书。这类工具最怕的是“扫描器本身成为新的泄露源”(比如把扫到的密钥上报到云端)。开源 + 可离线运行,让它更容易通过企业安全评审。

应用场景与落地建议

放进生产环境,有几件事必须先想清楚。

**第一,出网策略与合规。**实时验证意味着把真实凭证发给第三方服务商的 API。这在很多金融、政企环境中是不可接受的。务必提供离线/受限模式,在涉密仓库里关闭验证,只做静态检测。

**第二,验证请求本身要节制。**对同一个候选密钥反复探活可能触发对方的速率限制甚至风控策略,扫描器需要内置缓存与去重,避免“验证”变成“骚扰”。

**第三,历史提交扫描的成本。**全量 Git 历史扫描的 I/O 量是工作区扫描的数十倍,建议在首次接入时跑一次全历史做基线,之后只扫增量。

**第四,误报基线管理。**用基线文件冻结已确认的“样例密钥/测试凭证”,否则团队很快会重新陷入告警疲劳。

**第五,撤销流程要预先编排。**工具能告诉你“这把钥匙能开哪些门”,但按下撤销按钮的仍然是人。建议把影响面报告与你现有的 IAM 轮换剧本、密钥托管系统打通,让“发现”到“吊销”之间的路径尽可能短。

适用场景很清晰:有多云/SaaS 凭证散落、有合规审计压力、CI/CD 流水线成熟的中大型团队;以及把密钥扫描嵌入 pre-commit 与 PR 门禁,从源头阻断的开发团队。

综合评价

优点:定位精准,把密钥治理中最痛的两个缺口——活体验证与影响面测绘——真正做成了产品能力;Rust 带来的性能与部署便利性让它在 CI 场景下几乎零摩擦;950+ 规则的开源体量在同类中属于第一梯队。

短板:实时验证天然依赖出网与第三方 API 的稳定性,覆盖面也受限于服务商是否有可用的只读探测端点,长尾自建服务的验证能力会明显弱于主流 SaaS;影响面测绘的准确性高度依赖返回的身份上下文丰富度,遇到权限粒度粗的凭证容易给出过于保守(或过于笼统)的结论;“快速撤销”更多是引导而非全自动,距离“一键止血”仍有距离。

一句话总结:它不是又一个密钥正则扫描器,而是一次把“检测工程”升级为“响应工程”的尝试——值得放进你的安全工具链,但别指望它能替你做撤销决策。

关于

GitHub 原始描述(英文)

Detect leaked secrets + live validation. Map blast radius across your stack. Revoke fast. 950+ rules.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1551
价值分
816
活跃状态
活跃

语言占比

CSS
Dockerfile
HTML
JavaScript
Makefile
PowerShell
Python
Rust
Shell
TypeScript

README

Detect and Validate Secrets Anywhere. Map Access. Revoke Fast.

Kingfisher Logo
Apache 2.0 License Container downloads
GitHub downloads PyPI downloads

Find leaked secrets. Validate what’s live. Map the blast radius. Revoke fast.

Kingfisher is a fast, free, open-source secret scanner and credential response tool built in Rust. It detects leaked secrets with hundreds of built-in rules, validates which credentials are active, maps access for supported credential types, and revokes supported secrets—all in one Apache-2.0-licensed release:

Detect → Validate → Map → Triage → Revoke

  • scan source code, Git history, cloud storage, container images, archives, and developer platforms
  • validate which credentials are active
  • map a leaked secret’s identity, permissions, and reachable resources
  • triage findings in a browser, or output as SARIF, JSON, TOON
  • send real-time alerts to Slack, Microsoft Teams, Discord, Mattermost, Google Chat, or any JSON webhook
  • revoke supported secrets

Defender workflow: Follow the end-to-end defender workflow for secret detection, validation, notifications, blast-radius mapping, and revocation.

Embed Kingfisher in Rust, Python, or JavaScript

Add Kingfisher’s fast secret scanning, live credential validation, and revocation to your own applications through Python, Rust, or the native Node SDK preview. Everything runs in-process, with no CLI subprocess required.

Embeddable credential security engine: detection, live validation, and explicit revocation in Python and Rust

Scan Targets

Kingfisher handles local files and directories, Git repositories and history, compressed and office-document archives, SQLite databases, Python bytecode, Docker images, source-hosting organizations, cloud object storage, collaboration tools, and API-development platforms.

Files / Dirs Local Git GitHub GitLab Azure Repos Bitbucket Gitea Hugging Face
Files / Dirs
Files / Dirs
Local Git
Local Git
GitHub
GitHub
GitLab
GitLab
Azure Repos
Azure Repos
Bitbucket
Bitbucket
Gitea
Gitea
Hugging Face
Hugging Face
Docker Jira Confluence Slack Teams Postman AWS S3 Google Cloud Azure Blob Storage
Docker
Docker
Jira
Jira
Confluence
Confluence
Slack
Slack
Microsoft Teams
Teams
Postman
Postman
AWS S3
AWS S3
Google Cloud Storage
Cloud Storage
Azure Blob Storage
Azure Blob Storage

For target-specific commands, authentication, scope, and pagination behavior, use the platform integration guide.

Discover, validate, and revoke — open source options

All four tools detect secrets. Kingfisher and Betterleaks 2.0 RC5 also include credential revocation for supported providers.

Built-in capability Kingfisher Betterleaks 2.0 RC5 TruffleHog OSS Gitleaks
(Find) Secret discovery ✅ ✅ ✅ ✅
(Validate) Live credential verification ✅ ✅ ✅ ❌
(Revoke) Credential revocation ✅ ✅ ❌ ❌
License Apache-2.0 MIT AGPL-3.0 MIT

✅ Built in · ❌ Not supported as a built-in capability.

Built for Speed and Accuracy

Kingfisher’s multithreaded Vectorscan engine recorded the lowest runtime on every repository in the published benchmark suite, from small projects through the Linux kernel and GitLab monorepo. Lower runtimes are better.

Kingfisher runtime comparison across open source repositories

See the benchmarks for validation results, network-request counts, and the test environment, and deployment options for local, CI, and embedded use.

Why Kingfisher

Stage What Kingfisher provides Learn more
Detect A blazingly fast, multithreaded Vectorscan regex engine combines SIMD-accelerated matching with language-aware verification across repositories, files, archives, cloud storage, containers, and developer platforms Scanning, integrations, benchmarks
Validate Live provider checks that distinguish active credentials from static candidates Validation and filtering
Map Read-only blast-radius analysis for supported providers, including AWS role and GCP service-account reachability, bounded Bedrock discovery, and Google API-key probes Blast radius
Triage A local and hosted browser viewer for filtering, deduplication, prioritization, blast-radius inspection, and export Viewer usage, hosted guide
Alert Real-time notifications for findings, with per-sink confidence, validation, and access-map filters Alert webhooks
Revoke Conservative provider-specific containment workflows for supported credentials Revocation

Live validation, advanced cloud blast-radius analysis, visual triage, real-time alerts, and supported revocation all ship in the free, open source Kingfisher. There is no separate paid or enterprise tier.

Examples for different targets (replace credential placeholders with values from your secret store):

# Local files or a repository, including its Git history
kingfisher scan /path/to/code --format json

# Working tree only, without live credential checks
kingfisher scan /path/to/code \
    --git-history none \
    --no-validate \
    --format json

# Staged changes, archives, or office documents
kingfisher scan . \
    --staged \
    --format json
kingfisher scan backup.tar.gz credentials.xlsx --format json

# Remote Git repository; private GitHub repositories use KF_GITHUB_TOKEN
KF_GITHUB_TOKEN="..." \
    kingfisher scan https://github.com/my-org/my-repo.git --format json

# GitHub organization, or a user's repositories and gist history
KF_GITHUB_TOKEN="..." \
    kingfisher scan github \
        --organization my-org \
        --format json
KF_GITHUB_TOKEN="..." \
    kingfisher scan github \
        --user alice \
        --include-gists \
        --format json

# GitLab group, including subgroups and snippets
KF_GITLAB_TOKEN="..." \
    kingfisher scan gitlab \
        --group my-group \
        --include-subgroups \
        --include-snippets \
        --format json

# Azure DevOps repositories
KF_AZURE_TOKEN="..." \
    kingfisher scan azure \
        --azure-organization my-org \
        --format json

# Bitbucket workspace and snippets
KF_BITBUCKET_TOKEN="..." \
    kingfisher scan bitbucket \
        --workspace my-team \
        --include-snippets \
        --format json

# Gitea organization; private clones may also need KF_GITEA_USERNAME
KF_GITEA_TOKEN="..." KF_GITEA_USERNAME="scanner" \
    kingfisher scan gitea \
        --organization my-org \
        --format json

# Hugging Face repositories and buckets visible to an organization
KF_HUGGINGFACE_TOKEN="..." \
    kingfisher scan huggingface \
        --huggingface-organization my-org \
        --format json

# Hugging Face bucket: selected paths, with reusable content and listing checkpoints
KF_HUGGINGFACE_TOKEN="..." \
    kingfisher scan huggingface \
        --huggingface-bucket hf://buckets/my-org/data \
        --path-prefix configs/ \
        --file-extension env \
        --object-cache-dir ./object-cache \
        --format json

# AWS S3 using a local profile (public buckets can be scanned without credentials)
kingfisher scan s3 my-bucket \
    --profile security \
    --path-prefix configs/ \
    --format json

# AWS S3 using explicit credentials; add KF_AWS_SESSION_TOKEN for temporary credentials
KF_AWS_KEY="..." KF_AWS_SECRET="..." \
    kingfisher scan s3 my-bucket --format json

# Google Cloud Storage using a service-account file (also supports default credentials)
GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json" \
    kingfisher scan gcs my-bucket --format json

# Azure Blob Storage: container URL and a SAS token with read/list permission
KF_AZURE_STORAGE_SAS="sv=...&sp=rl&sig=..." \
    kingfisher scan azure-blob https://myaccount.blob.core.windows.net/my-container \
        --path-prefix configs/ \
        --skip-path-prefix configs/generated/ \
        --file-extension env \
        --object-cache-dir ./object-cache \
        --format json

# Container image from a registry, or a saved image archive; private registries use KF_DOCKER_TOKEN="user:password"
kingfisher scan docker ghcr.io/owasp/wrongsecrets/wrongsecrets-master:latest-master --format json
kingfisher scan docker \
    --archive image.tar \
    --format json

# Jira Cloud issues and comments; omit KF_JIRA_USER for a server bearer token
KF_JIRA_USER="[email protected]" KF_JIRA_TOKEN="..." \
    kingfisher scan jira \
        --url https://example.atlassian.net \
        --jql "updated >= -30d" \
        --skip-project ARCHIVE \
        --include-comments \
        --format json

# Confluence Cloud pages; omit KF_CONFLUENCE_USER for a server bearer token
KF_CONFLUENCE_USER="[email protected]" KF_CONFLUENCE_TOKEN="..." \
    kingfisher scan confluence \
        --url https://example.atlassian.net/wiki \
        --cql 'space = "ENG"' \
        --format json

# Slack messages and files, or Microsoft Teams messages
KF_SLACK_TOKEN="..." \
    kingfisher scan slack "api_key OR password" --format json
KF_TEAMS_TOKEN="..." \
    kingfisher scan teams "api_key OR password" --format json

# Postman collections and environments in a workspace
KF_POSTMAN_TOKEN="..." \
    kingfisher scan postman \
        --workspace my-workspace-id \
        --format json

See usage for the full command reference and integrations for platform-specific examples, including Azure Blob Storage, GitLab, Azure DevOps, Gitea, Slack, and Jira.

See Kingfisher in action with basic scan and validation examples, the end-to-end defender workflow, platform-specific scan examples, blast-radius examples, direct revocation, and CI and pre-commit deployment.

Real-Time Alerts

Send findings to the place your responders already watch. When a scan completes, Kingfisher can POST a summary with active/inactive counts, top rules, optional per-finding details, and a link to the full report.

# Repeat --alert-webhook to fan out; Slack and Teams are inferred from the URL hosts
kingfisher scan /path/to/repository \
    --alert-webhook "$SLACK_SECURITY_WEBHOOK" \
    --alert-webhook "$TEAMS_SECURITY_WEBHOOK"

Slack, Microsoft Teams, Discord, Mattermost, Google Chat, and generic JSON webhooks are supported. Confidence, validation, and access-map filters plus detail levels can be set globally from the CLI or per destination in kingfisher.yaml; payloads also carry stable finding fingerprints for deduplication. Alert delivery is best-effort and never changes the scan exit code.

See the alert webhook guide for payload formats, --alert-* flags, finding filters, and configuration examples.

Map the Blast Radius. Revoke the Credential.

For supported credentials, --blast-radius goes beyond a live/inactive verdict. It maps the credential identity, recorded permissions, candidate role or service-account paths, and resource scopes. This includes AWS role-assumption and GCP service-account impersonation analysis, bounded Bedrock model discovery and availability checks, and exact read methods accepted by a bounded Google API-key probe allowlist.

The HTML triager opens directly into an investigation workspace. Review active credentials and coverage gaps, then trace each identity to policy evidence, candidate privilege paths, and recorded resources. AWS, GCP, and Azure mappings are included in the open-source release.

Kingfisher viewer walkthrough: inspect blast-radius evidence and trace identities to resources

A 10-second walkthrough of actual viewer screens using synthetic data. Prefer a still image? Open the policy investigation or resource map.

The Blast Radius view separates observed API access from policy grants and conditional paths. Search evidence, filter providers, or switch to the resource map. Risk explanations and coverage gaps are included automatically using the same API results. Use --aws-region or --gcp-project to expand discovery. Existing report formats and legacy severity fields remain supported.

Kingfisher blast-radius policy and capability investigation

Screenshots use a synthetic, credential-free report. See the triager workflow and collection limits.

Kingfisher also provides explicit, defender-led revocation for supported credentials. Revocation is opt-in and is exposed only where Kingfisher has a bounded provider workflow; responders should always confirm the target and operational impact before containment.

Performance, Accuracy, and Extensible Rules

  • Performance: multithreaded, Hyperscan‑powered scanning built for huge codebases
  • Extensible rules: Betterleaks is the main catalog, with selected Veles detectors and rare documented first-party rules filling gaps; both Betterleaks TOML (.toml) and the Kingfisher rule format (.yml/.yaml) are fully supported via --rules-path (built-in rules, docs/RULES.md)
  • Validation and defender-led revocation: validate discovered credentials live, then revoke supported credentials from the CLI. For supported provider flows, responders can contain a leaked token even when its owner is unknown or has left the company (docs/USAGE.md, docs/REVOCATION_PROVIDERS.md)
  • Blast-radius mapping in the open-source release: use --blast-radius (alias --access-map) to map supported credentials to identities, permissions, candidate role/service-account paths, and resource scopes. All 43 providers—including AWS IAM, GCP hierarchy/impersonation, and Azure Graph/ARM RBAC mapping—are included in the Apache-2.0 release (blast-radius docs)
  • Broad provider coverage: detect and validate credentials across cloud, AI, developer tooling, databases, SaaS, messaging, identity, and cryptographic systems through the Betterleaks- and Veles-based candidate catalog
  • Compressed Files: Supports extracting and scanning compressed files for secrets, including tar.gz/bz2/xz, ZIP-family containers (zip, jar, docx, xlsx, pptx, odt, epub, hwpx, and more), asar, HWP (Hancom OLE2/CFBF binary with DEFLATE/zlib stream decoding), and EGG (ALZip; raw-byte scanning)
  • SQLite Database Scanning: Automatically extracts and scans SQLite database contents for secrets stored in table rows
  • PDF Text Scanning: Extracts page text from PDFs, including Git history and archive members, with decompression/output limits; no OCR or password-protected PDF support
  • Python Bytecode (.pyc) Scanning: Extracts and scans string constants from compiled Python (.pyc, .pyo) files
  • Baseline management: generate and track baselines to suppress known secrets (docs/BASELINE.md)
  • Checksum-aware custom detection: Kingfisher custom rules can verify token checksums offline before validation (checksum intelligence)
  • Report Viewer (local + hosted): Visualize and triage Kingfisher, SARIF, Gitleaks, and TruffleHog output locally with kingfisher view ./report.json or online with the hosted viewer. Multiple files, directories, and imported third-party reports are merged and deduplicated. See docs/USAGE.md.
  • Audit reporting: Generate compliance-oriented HTML reports with scan metadata and validation ordering
  • Embedding: Scan in-process from Rust, Python, or the Node SDK preview, with explicit validation and revocation APIs

Basic Usage Demo

kingfisher scan /path/to/scan --view-report

NOTE: Replay has been slowed down for demo Kingfisher secret scanning demo

Getting Started

Quick Start

Install with your preferred package manager:

# Homebrew (macOS/Linux)
brew install kingfisher

# PyPI wrapper
uv tool install kingfisher-bin

See the full installation guide for all installation methods, installer options, and pre-commit hook installation.

The examples below use Bash syntax. Replace credential placeholders with values from your secret store; local scans need no platform credentials. See the environment-variable reference for other authentication options.

Then scan a repository, including its Git history:

kingfisher scan /path/to/repository --format json

Open the results in the bundled local viewer:

kingfisher scan /path/to/repository --view-report

Scan files and Git history

# Clone a private GitHub repository and scan its Git history (omit the token for public repositories)
KF_GITHUB_TOKEN="..." \
    kingfisher scan https://github.com/my-org/my-repo.git --format json

# Scan checked-out files without Git history or live validation
kingfisher scan /path/to/repository \
    --git-history none \
    --no-validate \
    --format json

# Check staged changes before committing
kingfisher scan . \
    --staged \
    --format json

# Scan an archive or an office document
kingfisher scan backup.tar.gz credentials.xlsx --format json

# Focus on configuration files and skip generated content
kingfisher scan /path/to/repository \
    --path-prefix configs/ \
    --skip-path-prefix configs/generated/ \
    --file-extension env \
    --file-extension yaml \
    --format json

# Show only live credentials and map their access
kingfisher scan /path/to/repository \
    --only-valid \
    --blast-radius \
    --format json

# Include active credentials and high-confidence assumed or locally derived secrets
kingfisher scan /path/to/repository \
    --validation-filter actionable \
    --format json

Save and combine reports

# Save a JSON report and open it later
kingfisher scan /path/to/repository \
    --format json \
    --output findings.json
kingfisher view findings.json

# Export SARIF for code-scanning integrations
kingfisher scan /path/to/repository \
    --format sarif \
    --output findings.sarif

# Generate a standalone HTML audit report
kingfisher scan /path/to/repository \
    --format html \
    --output audit.html

# Import and combine Kingfisher, Gitleaks, and TruffleHog reports
kingfisher view findings.json gitleaks.json trufflehog.jsonl

# Load every supported report in a directory
kingfisher view ./reports/

Scan source-hosting organizations

Use a token with read access to the repositories you want to scan. See the integration guide for provider-specific permissions and self-hosted endpoints.

# GitHub organization
KF_GITHUB_TOKEN="..." \
    kingfisher scan github \
        --organization my-org \
        --format json
# GitHub user and their gist history
KF_GITHUB_TOKEN="..." \
    kingfisher scan github \
        --user alice \
        --include-gists \
        --format json

# GitLab group, including nested subgroups
KF_GITLAB_TOKEN="..." \
    kingfisher scan gitlab \
        --group my-group \
        --include-subgroups \
        --include-snippets \
        --format json

# Azure Repos organization
KF_AZURE_TOKEN="..." \
    kingfisher scan azure \
        --azure-organization my-org \
        --format json

# Bitbucket workspace
KF_BITBUCKET_TOKEN="..." \
    kingfisher scan bitbucket \
        --workspace my-team \
        --include-snippets \
        --format json

# Gitea organization
KF_GITEA_TOKEN="..." KF_GITEA_USERNAME="scanner" \
    kingfisher scan gitea \
        --organization my-org \
        --format json

# Hugging Face organization
KF_HUGGINGFACE_TOKEN="..." \
    kingfisher scan huggingface \
        --huggingface-organization my-org \
        --format json

# Preview the GitHub repository scope without scanning
KF_GITHUB_TOKEN="..." \
    kingfisher scan github \
        --organization my-org \
        --list-only

Scan cloud storage

For S3 and GCS, use a bucket name without s3:// or gs://. Azure Blob uses a full container URL. Use --path-prefix to select object names; S3 and GCS also accept the existing --prefix option. Omit prefix selection to scan the whole bucket or container.

# AWS S3: whole bucket with explicit credentials
KF_AWS_KEY="..." KF_AWS_SECRET="..." \
    kingfisher scan s3 my-bucket --format json

# AWS S3: temporary credentials also require the session token
KF_AWS_KEY="..." KF_AWS_SECRET="..." KF_AWS_SESSION_TOKEN="..." \
    kingfisher scan s3 my-bucket --format json

# AWS S3: only objects under backups/production/, using a named AWS profile
kingfisher scan s3 my-bucket \
    --prefix backups/production/ \
    --profile security \
    --format json

# Google Cloud Storage: whole bucket using a service-account file
GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json" \
    kingfisher scan gcs my-bucket --format json

# Google Cloud Storage: only objects under exports/daily/, using existing Application Default Credentials
kingfisher scan gcs my-bucket \
    --prefix exports/daily/ \
    --format json

# Azure Blob Storage: container SAS with read (r) and list (l) permissions
KF_AZURE_STORAGE_SAS="sv=...&sp=rl&sig=..." \
    kingfisher scan azure-blob \
        https://myaccount.blob.core.windows.net/my-container --format json

# Azure Blob Storage: account-key authentication (account name is inferred for standard Azure endpoints)
KF_AZURE_STORAGE_KEY="..." \
    kingfisher scan azure-blob https://myaccount.blob.core.windows.net/my-container --format json

# Azure Blob Storage: an existing Entra access token for https://storage.azure.com/
KF_AZURE_STORAGE_TOKEN="..." \
    kingfisher scan azure-blob https://myaccount.blob.core.windows.net/my-container --format json

# Hugging Face bucket: selected paths with resumable downloads
KF_HUGGINGFACE_TOKEN="..." \
    kingfisher scan huggingface \
        --huggingface-bucket hf://buckets/my-org/data \
        --path-prefix configs/ \
        --object-cache-dir ./object-cache \
        --format json

Authenticate to S3 with KF_AWS_KEY / KF_AWS_SECRET or --profile; GCS uses Application Default Credentials, or an explicit --service-account /path/to/key.json. See the S3 and GCS guides for authentication and public-bucket examples. Azure Blob accepts a container URL; set exactly one of the SAS, account-key, or Entra-token variables, or omit all three for anonymous access to a public container with list/read permissions; see the Azure Blob guide.

Use --path-prefix, --skip-path-prefix, --file-extension, and --skip-file-extension to select paths across local files, Git repositories, archive members, and cloud storage. S3, GCS, Azure Blob, and Hugging Face buckets apply selection before downloading and accept --object-cache-dir to resume interrupted listings and reuse unchanged content. Cached content is rescanned so each report stays complete. Custom HTTP verification services can use OAuth2 password-grant authentication.

Scan containers or run Kingfisher in Docker

# Scan a registry image
kingfisher scan docker ghcr.io/owasp/wrongsecrets/wrongsecrets-master:latest-master --format json

# Pull a private registry image
KF_DOCKER_TOKEN="user:password" \
    kingfisher scan docker ghcr.io/my-org/my-image:latest --format json

# Scan an image exported with docker save
kingfisher scan docker \
    --archive image.tar \
    --format json

# Run Kingfisher against the current directory without installing it
docker run \
    --rm \
    -v "$PWD":/src \
    ghcr.io/mongodb/kingfisher:latest scan /src \
    --format json

# Run in Docker and serve the report viewer to the host
docker run \
    --rm \
    -v "$PWD":/src \
    -p 127.0.0.1:7890:7890 \
    ghcr.io/mongodb/kingfisher:latest scan /src \
    --view-report \
    --view-report-address 0.0.0.0

For the Docker viewer, open localhost:7890 in your browser.

Scan issues, documents, and messages

Jira and Confluence Cloud API tokens require the account email as well as the token. For server bearer tokens, omit KF_JIRA_USER or KF_CONFLUENCE_USER. See the integration guide for required scopes and search behavior.

# Jira Cloud: search a project and include issue comments
KF_JIRA_USER="[email protected]" KF_JIRA_TOKEN="..." \
    kingfisher scan jira \
        --url https://example.atlassian.net \
        --jql "project = SEC" \
        --include-comments \
        --format json

# Confluence Cloud: scan pages in a space
KF_CONFLUENCE_USER="[email protected]" KF_CONFLUENCE_TOKEN="..." \
    kingfisher scan confluence \
        --url https://example.atlassian.net/wiki \
        --cql 'space = "ENG"' \
        --format json

# Slack: search messages and associated files
KF_SLACK_TOKEN="..." \
    kingfisher scan slack "api_key OR password" --format json

# Microsoft Teams: search messages
KF_TEAMS_TOKEN="..." \
    kingfisher scan teams "api_key OR password" --format json

# Postman: scan a workspace's collections and environments
KF_POSTMAN_TOKEN="..." \
    kingfisher scan postman \
        --workspace my-workspace-id \
        --format json

Validate or revoke a known credential

# Validate a GitHub personal access token directly
export GITHUB_PAT="..."
kingfisher validate \
    --rule github-pat "$GITHUB_PAT" \
    --format json

# Revoke that token when ready to contain the exposure
kingfisher revoke \
    --rule github-pat "$GITHUB_PAT" \
    --format json

See direct validation and supported revocation providers for other credential types.

See the installation guide for pre-built binaries, Docker, mise, Windows, pre-commit hooks, release verification, and source builds. See the usage guide for validation filters, output formats, scan scope, and command examples.

Live validation and blast-radius mapping make authorized requests to provider APIs. Review the relevant documentation and use them only where you are authorized to inspect the target account.

Common Workflows

Goal Start here
Run an end-to-end credential response Defender workflow
Scan GitHub, GitLab, Azure Repos, Bitbucket, Gitea, Hugging Face, S3, GCS, Azure Blob Storage, Docker, Jira, Confluence, Slack, Teams, or Postman Platform integrations
Configure authentication and environment variables Environment-variable reference
Validate or revoke a known credential Direct validation, revocation
Map identity, permissions, and affected resources Blast-radius guide
Run scans and inspect reports in a native workspace Kingfisher wizard
Triage one or more reports visually Viewer usage, hosted guide
Configure CI, pre-commit, or centralized scanning Deployment, advanced configuration
Send real-time alerts to chat or webhook destinations Alert webhooks
Produce repository coverage and audit evidence Repository audit log
Suppress existing findings without hiding new ones Baselines
Write or import custom rules Rule authoring
Embed the scanner in Rust, Python or JavaScript/TypeScript Rust library, Python SDK, Node SDK

Output for People and Machines

Kingfisher supports human-readable output plus TOON, JSON, JSONL, SARIF, BSON, and HTML reports. Use JSON for structured output in scripts and integrations:

kingfisher scan /path/to/repository \
    --format json \
    --no-update-check

Machine consumers should use structured validation outcomes and finding fingerprints rather than parsing display labels. See output and validation semantics, finding fingerprints, and the full documentation index.

Rust Embedding Examples

The library guide includes runnable examples for kingfisher-core, kingfisher-rules, kingfisher-scanner, and the kingfisher-bin library. Copyable integration recipes cover file batches, private rules, async services, and scanning plus HTTP validation. For example, from a repository checkout:

cargo run --locked -p kingfisher-scanner --example http_validation --features validation

Verifying Releases

Before installing a pinned release, verify that your download came from Kingfisher’s release workflow and matches the version you requested. This catches tampered downloads and substitution with an older genuine release, which matters when Kingfisher is your CI secrets gate. Follow the release verification steps.

Documentation

Project

Kingfisher is used in MongoDB’s production security workflows and is integrated by projects such as Prowler, MegaLinter, Osmedeus, DefectDojo, and hk. Weblate uses its pre-commit hook. Read more about its lineage, evolution, and public adoption.

Contributions are welcome. See CONTRIBUTING.md, report vulnerabilities through SECURITY.md, and file feature requests in GitHub Issues.

Kingfisher is licensed under the Apache License 2.0.

评论

暂无评论