アップデート一覧に戻る
New releaseNov 28, 2026

betterleaks v2.0.0-rc.16

ファイルシステム、git履歴、コンテナ、クラウドソースに対応した高速で設定可能なシークレットスキャナー。Exprベースのフィルタリング、認証情報の検証、分析機能を備えています。

共有

Betterleaks

 + ○
   ▾

Betterleaksは、設定可能で高速かつ徹底的なシークレットスキャナーです。Gitleaksを開発したメンバー(オリジナルの作者を含む)によってメンテナンスされています。 検出エンジンの仕組みについては、こちらのブログ記事シリーズをご覧ください: 1. Regex is all you need、2. Rare Not Random、3. Express YourCELf、4. Better generic secrets detection。

開発は以下によって支援されています Aikido Security

主な機能

機能説明
シンプルな優先順位付け信頼度、検証ステータス、分析された重大度スコアでランク付けし、トリアージを123のように簡単にします。
シークレットの検証Exprを使用してルール定義内から直接非同期HTTPリクエストを行うことで、検出されたシークレットが有効かどうかを検証します。
シークレットの分析有効な認証情報を、プロバイダーに依存しないID、アカウント、機能、重大度の情報で強化します。
シークレットの失効オプションでシークレットを失効させます。
Exprベースのフィルタリングフラグメント(データチャンク)の属性(git作者、コミットメッセージ、ファイルパスなど)と検出データを評価するコンテキストルールフィルターを記述し、誤検知を削減します。
BPEフィルタリングBPEトークン化を使用して文字列がどれだけ「レア」か、または人間的でないかを測定することで、自然言語の誤検知を除外します。
高速スキャン適切なデフォルトの並列化設定、ahocorasickキーワードフィルター、re2により高速なパフォーマンスを実現します。
新しいソースGitHub、GitLab、Hugging Face、S3などのソースをサポートします。新しいソースの追加も簡単です!
コンテナイメージすべてのプラットフォーム、履歴レイヤー、設定、埋め込みアテステーションをスキャンし、ダイジェストの来歴と削除/上書きされたパスのレポートを提供します。コンテナガイドをご覧ください。
ポータビリティあらゆるモダンなOS/Archで動作します。小さなバイナリはあらゆるシステムに統合できます。

インストール

mainブランチはv2開発用です。V1のメンテナンスとドキュメントはv1.xブランチにあります。

v1からのアップグレードですか?CLI、設定、レポート、SDKの変更についてはv2移行ガイドをご覧ください。

最初の安定版v2リリースまでは、パッケージマネージャーやDockerのlatestタグが 依然としてv1を提供する場合があります。それまでは、移行ガイドのリリース候補の手順 を使用してv2をお試しください。

# Package managers
brew install betterleaks
brew install --cask betterleaks/tap/betterleaks

# Fedora Linux
sudo dnf install betterleaks

# Containers (stable v2)
docker pull ghcr.io/betterleaks/betterleaks:v2

# Go
go install github.com/betterleaks/betterleaks/v2@latest

# Source
git clone https://github.com/betterleaks/betterleaks
cd betterleaks
make build

Stable v2 リリースでは、tap の betterleaks cask と Docker の :v2 および :latest タグが更新されます。Homebrew core は別途更新されます。v1 を v2 と併用してインストールするには、brew install --cask betterleaks/tap/betterleaks@1(コマンド: betterleaks-v1)または Docker の :v1 タグを使用してください。

使用方法

スキャンはデフォルトで、認証情報プロバイダーへのリクエストを行わずにシークレットを検出します。認証情報を検証するには -v / --validate を、さらに ID と権限も解決するには -a / --analyze を使用してください。分析は検証を暗黙的に含みます。環境変数を通じてこれらのステージを有効にするには、BETTERLEAKS_VALIDATE=true または BETTERLEAKS_ANALYZE=true を設定してください。明示的なフラグは対応する変数を上書きします。

# Scan the filesystem
betterleaks /path/to/target
# Equivalent explicit command
betterleaks filesystem /path/to/target
# Short command alias
betterleaks fs /path/to/target
# Flags may also precede the command
betterleaks --no-banner fs /path/to/target

# Validate detected credentials
betterleaks fs /path/to/target -v
# Validate and analyze identity and permissions
betterleaks fs /path/to/target -a

# Scan a git repo
betterleaks git /path/to/repo

# Also scan merge commit patches (against the first parent)
betterleaks git /path/to/repo --include=merges

# Scan a remote PR's commits relative to its base branch
betterleaks git https://github.com/owner/repo \
  --clone-ref=refs/pull/123/head --revision=main..refs/pull/123/head

# Automatically detect a remote repository and scan its history
betterleaks https://github.com/betterleaks/betterleaks
# The default command can also be named explicitly
betterleaks auto https://github.com/betterleaks/betterleaks
# Explicitly download and scan a web response (without crawling)
betterleaks url https://example.com/config.txt

# Scan GitHub org
betterleaks github https://github.com/betterleaks
# Scan GitHub user
betterleaks github https://github.com/cooluser123456789 --include issues,prs,actions,releases,gists
# Scan a PR's title, description, and comments
betterleaks github https://github.com/betterleaks/betterleaks/pull/113

# Scan GitLab group or project
betterleaks gitlab https://gitlab.com/mygroup
betterleaks gitlab https://gitlab.com/mygroup/myproject --include issues,mrs,releases,ci-jobs
# Scan a specific GitLab merge request
betterleaks gitlab https://gitlab.com/mygroup/myproject/-/merge_requests/42

# Scan Hugging Face models, datasets, Spaces, and buckets
betterleaks huggingface https://huggingface.co/myorg
betterleaks hf https://huggingface.co/datasets/myorg/mydataset
betterleaks hf --include=discussions,prs https://huggingface.co/myorg/model
betterleaks hf hf://buckets/myorg/mybucket/path

# Scan a public s3 dataset (Common Crawl).
betterleaks s3 https://commoncrawl.s3.us-east-1.amazonaws.com/crawl-data/CC-MAIN-2018-17/segments/1524125937193.1/warc/
# Enumerate and scan every bucket in a Cloudflare R2 account
betterleaks s3 'https://<account-id>.r2.cloudflarestorage.com/*'

# Scan a registry image: every platform, historical layer, and image metadata
betterleaks container ghcr.io/owner/app:latest
# Scan one platform of a public image without saved registry credentials
betterleaks container ubuntu:24.04 --platform linux/amd64 --anonymous
# Scan an image from the local Docker daemon, or a `docker save` archive
betterleaks container --daemon docker myapp:latest
betterleaks container --archive image.tar

# Scan stdin
cat some_file.txt | betterleaks stdin

# Revalidate a known credential without running detection
printf '%s\n' "$GITHUB_TOKEN" | betterleaks validate --rule github-pat

# Find rule IDs that support credential analysis
betterleaks config show ids --analysis

# Validate it and resolve identity and permissions
printf '%s\n' "$GITHUB_TOKEN" | betterleaks analyze --rule github-pat

# Print only its status (for example, VALID)
printf '%s\n' "$GITHUB_TOKEN" | betterleaks validate --rule github-pat --simple

Git URL スキャンは、ブランチとタグの完全な履歴に加えてノートを一時的なベアリポジトリにフェッチします。特定のレビュー用 ref やパターンを追加するには --clone-ref を、アドバタイズされたすべての ref をフェッチするには --clone-all-refs を使用します。リソースの選択、コミットフィルター、ステージ変更のスキャンについては、Git スキャンガイドを参照してください。

キー付きマッチフィンガープリントには --hmac-key または BETTERLEAKS_FINGERPRINT_HMAC_KEY を使用します。詳細はフィンガープリントのプライバシーとキーの設定を参照してください。

-j / --jobs は検出の並行性のみを制御し、デフォルトは 4 * GOMAXPROCS です。ソースはそれぞれ独自に読み取りとダウンロードの上限を管理します。

ルールは、明示的な認証情報の失効のために任意の revoke Expr を定義することもできます。設定済みのサポートを確認するには betterleaks config show ids --revocation を、実行するには betterleaks revoke --rule <id> を使用します。スキャンが失効を実行することはありません。詳細は失効ガイドを参照してください。

Go SDK

Betterleaks は Go ライブラリとして埋め込むこともできます。スキャナーとアナライザーはデフォルトでサイレントであり、複数のスキャンにまたがって安全に再利用できます。

go get github.com/betterleaks/betterleaks/v2
package main

import (
	"fmt"

	"github.com/betterleaks/betterleaks/v2/config"
	"github.com/betterleaks/betterleaks/v2/scan"
)

func main() {
	cfg, err := config.Default()
	if err != nil {
		panic(err)
	}
	scanner, err := scan.New(cfg)
	if err != nil {
		panic(err)
	}

	const token = "ghp_aB3dE5fG7hI9jK1mN3pQ5rS7tU9vW1xY3zA5" // betterleaks:allow
	for _, finding := range scanner.ScanString("GITHUB_TOKEN=" + token) {
		fmt.Println(finding.RuleID)
	}
}

カスタム設定、分析、正規表現エンジン、並行スキャンをカバーする実行可能なSDKの例については、examplesディレクトリを参照してください。

カテゴリ