
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.
주요 기능
| 기능 | 설명 |
|---|---|
| 간단한 우선순위 지정 | 신뢰도, 검증 상태, 분석된 심각도 점수로 순위를 매겨 트리아지를 123처럼 간단하게 만듭니다. |
| 시크릿 검증 | Expr을 사용하여 규칙 정의 내에서 직접 비동기 HTTP 요청을 수행해 탐지된 시크릿이 활성 상태인지 검증합니다. |
| 시크릿 분석 | 유효한 자격 증명을 공급자 중립적인 신원, 계정, 기능, 심각도 정보로 보강합니다. |
| 시크릿 폐기 | 선택적으로 시크릿을 폐기합니다. |
| Expr 기반 필터링 | 프래그먼트(데이터 청크) 속성(예: git 작성자, 커밋 메시지, 파일 경로)과 발견 데이터를 평가하는 상황별 규칙 필터를 작성하여 오탐을 줄입니다. |
| BPE 필터링 | BPE 토큰화를 사용하여 문자열이 얼마나 "희귀"하거나 비인간적인지 측정함으로써 자연어 오탐을 걸러냅니다. |
| 빠른 스캔 | 합리적인 기본 병렬화 설정, ahocorasick 키워드 필터, re2를 통해 빠른 성능을 달성합니다. |
| 새로운 소스 | GitHub, GitLab, Hugging Face, S3 등과 같은 소스를 지원합니다. 새로운 소스를 추가하기도 쉽습니다! |
| 컨테이너 이미지 | 모든 플랫폼, 과거 레이어, 구성, 내장된 증명(attestation)을 다이제스트 출처 및 삭제/덮어쓴 경로 보고와 함께 스캔합니다. 컨테이너 가이드를 참조하세요. |
| 이식성 | 모든 최신 OS/아키텍처에서 실행됩니다. 작은 바이너리를 어떤 시스템에도 통합할 수 있습니다. |
설치
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를 사용하고, 신원과 권한까지 확인하려면 -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 스캔은 전체 브랜치 및 태그 기록과 노트를 임시 bare 저장소로 가져옵니다. 특정 리뷰 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 디렉터리를 참고하세요.
완전한 기본 구성 및 사용자 정의 구성 예제는 scan 패키지 문서를 참고하세요.