npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leak-hunter

v0.4.0

Published

Cross-platform repository secret scanner

Downloads

817

Readme

leak-hunter

語言: English | 繁體中文 | 简体中文 | 日本語 | 한국어 | Tiếng Việt | ไทย | Français | Deutsch

leak-hunter 是一套以本機執行為優先的防禦型 Repo 敏感資訊掃描 CLI。它提供單一跨平台 binary,可掃描 GitHub repository URL、owner/repo 簡寫、GitHub SSH target,或本機資料夾,並輸出 Text、JSON、Markdown 報告。

Rust crate 是唯一的核心實作;npm package leak-hunter 是 thin wrapper,用來安裝並執行 GitHub Release 內由 cargo-dist 產生的 native binary。

安裝

cargo install --path .

或使用 npm package:

npm install -g leak-hunter
leak-hunter --help

快速開始

leak-hunter .
leak-hunter --json --min-risk 50 .
leak-hunter --format markdown --output leak-hunter-report.md owner/repo

支援的 GitHub target:

leak-hunter https://github.com/doggy8088/holidaybook
leak-hunter github.com/doggy8088/holidaybook
leak-hunter doggy8088/holidaybook
leak-hunter [email protected]:doggy8088/holidaybook.git

CLI 選項

| 選項 | 說明 | |---|---| | --json | 輸出 machine-readable JSON,等同 JSON report shortcut。 | | --format <text\|json\|markdown> | 選擇報告格式。 | | --output <path> | 將報告寫入檔案;必要時自動建立父目錄。 | | --min-risk <0-100> | 只顯示達到風險門檻的 findings。 | | --include <glob> / --exclude <glob> | 限制掃描範圍,可重複指定。 | | --no-default-exclude | 關閉內建排除規則。 | | --max-file-size-mb <n> | 單檔掃描大小上限。 | | --concurrency <n> | 並行掃描檔案數。 | | --no-redact | 輸出原文 secret;僅限本機人工複核。 | | --keep-temp | 保留 GitHub target 的暫存 clone。 | | --cache-dir <dir> | 指定 GitHub 暫存 clone 目錄,預設 .leak-hunter-cache。 | | --branch <name> | 掃描指定 branch 或 tag。 | | --debug | 將掃描決策、候選 finding 分數與 min-risk 篩選原因輸出到 stderr。 | | -v, --version | 顯示版本資訊。 |

--json 與明確指定的 --format 互斥,以避免 CI 腳本產生模稜兩可的輸出。

報告

Text report 適合直接在終端機閱讀:

leak-hunter . --format text

內容會以 Leak Hunter ASCII banner 開場,並包含 target、實際掃描 root、掃描時間、掃描與略過檔案數、finding 數、風險 bucket、redaction 狀態與 finding 表格。

JSON report 適合 CI 保存、後續 jq 處理或匯入其他系統:

leak-hunter . --json --output leak-hunter-report.json

範例查詢高風險 finding:

leak-hunter . --json \
  | jq '.findings[] | select(.riskScore >= 75) | {type, filePath, lineNumber, riskScore}'

掃描策略

  1. 解析本機或 GitHub target。
  2. GitHub repository 會 clone 到 .leak-hunter-cache--cache-dir 指定目錄。
  3. 使用 gitignore-aware walker、.leakhunterignore 與 include / exclude glob;.leakhunterignore 使用 .gitignore 語法。
  4. 略過 binary 或超過大小上限的檔案。
  5. 套用內建 pattern inventory 與 context-aware risk model。
  6. 對 package-lock npm integrity hashes、Firebase public API key context、docs/example 等常見 noise 降噪。
  7. 預設 redaction,依風險分數、路徑與位置排序輸出。
  8. 清除 GitHub 暫存 clone,除非使用 --keep-temp

偵測重點

目前重建的 rules 包含:

  • OpenAI、Google API Key、GitHub Token、Stripe、Slack、Sentry、Docker Hub PAT
  • AWS access key / secret key pairing
  • Azure Storage connection string / AccountKey / SAS URI
  • Popular framework app secrets,例如 Django、Flask、Rails、Laravel、NextAuth、Nuxt、Spring、ASP.NET 等
  • Database connection strings and URIs,例如 SQL Server-style connection string、PostgreSQL、MongoDB、Redis
  • JWT、PEM private key、GCP service account JSON、Google OAuth client secret

npm package 與 checksum

npm/postinstall.cjs 會依平台對應 cargo-dist target,下載 release archive 與對應 .sha256,驗證 SHA-256 後才解壓縮並安裝 native binary。npm 發佈使用 Trusted Publishing / OIDC,不使用長期 NPM_TOKEN。發布前的 prepublishOnly 會先跑 npm 測試、npm pack --dry-run,並確認所有 release archive 與 checksum 都已存在。

開發

cargo fmt --all -- --check
cargo test
cargo build --release
npm test
npm pack --dry-run

Self-scan:

cargo run --quiet -- --json --min-risk 40 . \
  | jq '{findings: .summary.findings, filesEnumerated: .summary.filesEnumerated}'

安全

Redaction 預設啟用。不要發佈未遮罩的報告。測試 fixture 必須使用 synthetic values,並用字串片段組合,避免觸發 GitHub push protection。