Python과 .NET에서 프로덕션 AI 에이전트와 멀티 에이전트 워크플로를 구축하세요.
한국어는 runchr 제공 번역입니다. 원문 README는 English tool page.
gitleaks
Gitleaks는 Git 저장소, 파일, stdin에서 비밀번호, API 키, 토큰 같은 하드코딩된 시크릿을 탐지하는 Go CLI 및 Docker 이미지이며, pre-commit
- Kind
- cli
- Platform
- cross-platform
프로젝트 README (번역)
GitHub ↗Written by the project's own authors, not by runchr. Snapshot taken 2026-10-29.
Gitleaks
┌─○───┐
│ │╲ │
│ │ ○ │
│ ○ ░ │
└─░───┘
경고
Gitleaks는 기능이 완성되었습니다. 더 이상 Gitleaks에 새로운 기능을 병합하지 않습니다. 향후 릴리스는 보안 패치만 제공됩니다. 저는 초점을 Betterleaks로 옮기고 있습니다.
Gitleaks는 git 저장소, 파일, 그리고 stdin을 통해 던져주는 무엇이든 간에 비밀번호, API 키, 토큰과 같은 시크릿을 탐지하는 도구입니다. 탐지 엔진이 어떻게 작동하는지 더 알고 싶다면 이 블로그를 확인하세요: Regex is (almost) all you need.
➜ ~/code(master) gitleaks git -v
○
│╲
│ ○
○ ░
░ gitleaks
Finding: "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef",
Secret: cafebabe:deadbeef
RuleID: sidekiq-secret
Entropy: 2.609850
File: cmd/generate/config/rules/sidekiq.go
Line: 23
Commit: cd5226711335c68be1e720b318b7bc3135a30eb2
Author: John
Email: [email protected]
Date: 2022-08-03T12:31:40Z
Fingerprint: cd5226711335c68be1e720b318b7bc3135a30eb2:cmd/generate/config/rules/sidekiq.go:sidekiq-secret:23
시작하기
Gitleaks는 Homebrew, Docker, 또는 Go를 사용하여 설치할 수 있습니다. Gitleaks는 또한 releases 페이지에서 많은 인기 플랫폼과 OS 유형에 대한 바이너리 형태로 제공됩니다. 추가로, Gitleaks는 저장소에 직접 pre-commit 훅으로 구현하거나 Gitleaks-Action을 사용하여 GitHub action으로 구현할 수 있습니다.
설치
# MacOS
brew install gitleaks
# Docker (DockerHub)
docker pull zricethezav/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan} :/path zricethezav/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]
# Docker (ghcr.io)
docker pull ghcr.io/gitleaks/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan} :/path ghcr.io/gitleaks/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]
# 소스에서 ( `go` 가 설치되어 있는지 확인하세요)
git clone https://github.com/gitleaks/gitleaks.git
cd gitleaks
make build
Pre-Commit
https://pre-commit.com/#install 에서 pre-commit 설치
저장소 루트에 다음 내용으로 .pre-commit-config.yaml 파일을 생성하세요:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
gitleaks를 네이티브로 실행하거나, 공식 Docker 이미지를 사용하여 gitleaks를 실행하려면 gitleaks-docker pre-commit ID를 사용하세요
pre-commit autoupdate 를 실행하여 config를 최신 repos 버전으로 자동 업데이트하세요
pre-commit install 로 설치하세요
이제 모두 준비되었습니다!
➜ git commit -m "this commit contains a secret"
Detect hardcoded secrets.................................................Failed
참고: gitleaks pre-commit 훅을 비활성화하려면 commit 명령 앞에 SKIP=gitleaks를 붙이면
gitleaks 실행을 건너뜁니다
➜ SKIP=gitleaks git commit -m "skip gitleaks check"
Detect hardcoded secrets................................................Skipped
사용법
Gitleaks는 과거 또는 현재의 코드에서 시크릿을 스캔합니다
Usage:
gitleaks [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
dir scan directories or files for secrets
git scan git repositories for secrets
help Help about any command
stdin detect secrets from stdin
version display gitleaks version
Flags:
-b, --baseline-path string path to baseline with issues that can be ignored
-c, --config string config file path
order of precedence:
1. --config/-c
2. env var GITLEAKS_CONFIG
3. env var GITLEAKS_CONFIG_TOML with the file content
4. (target path)/.gitleaks.toml
If none of the four options are used, then gitleaks will use the default config
--diagnostics string enable diagnostics (http OR comma-separated list: cpu,mem,trace). cpu=CPU prof, mem=memory prof, trace=exec tracing, http=serve via net/http/pprof
--diagnostics-dir string directory to store diagnostics output files when not using http mode (defaults to current directory)
--enable-rule strings only enable specific rules by id
--exit-code int exit code when leaks have been encountered (default 1)
-i, --gitleaks-ignore-path string path to .gitleaksignore file or folder containing one (default ".")
-h, --help help for gitleaks
--ignore-gitleaks-allow ignore gitleaks:allow comments
-l, --log-level string log level (trace, debug, info, warn, error, fatal) (default "info")
--max-archive-depth int allow scanning into nested archives up to this depth (default "0", no archive traversal is done)
--max-decode-depth int allow recursive decoding up to this depth (default "0", no decoding is done)
--max-target-megabytes int files larger than this will be skipped
--no-banner suppress banner
--no-color turn off color for verbose output
--redact uint[=100] redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)
-f, --report-format string output format (json, csv, junit, sarif, template)
-r, --report-path string report file
--report-template string template file used to generate the report (implies --report-format=template)
--timeout int set a timeout for gitleaks commands in seconds (default "0", no timeout is set)
-v, --verbose show verbose output from scan
--version version for gitleaks
Use "gitleaks [command] --help" for more information about a command.
명령어
⚠️ v8.19.0에서는 detect와 protect를 더 이상 사용하지 않게 하는 변경이 도입되었습니다. 해당 명령어들은 여전히 사용 가능하지만
--help 메뉴에서는 숨겨져 있습니다. 쉬운 명령어 변환은 이 gist를 확인하세요.
v8.19.0이 기존 명령어(detect / protect)를 깨뜨렸다고 생각되면 이슈를 열어주세요.
세 가지 스캔 모드가 있습니다: git, dir, 그리고 stdin.
Git
git 명령어를 사용하면 로컬 git 저장소를 스캔할 수 있습니다. 내부적으로 gitleaks는 git log -p 명령어를 사용하여 패치를 스캔합니다.
log-opts 옵션으로 git log -p의 동작을 구성할 수 있습니다.
예를 들어, 커밋 범위에 대해 gitleaks를 실행하려면 다음
명령어를 사용할 수 있습니다: gitleaks git -v --log-opts="--all commitA..commitB" path_to_repo. 자세한 내용은 git log 문서를 참조하세요.
위치 인수로 대상이 지정되지 않으면 gitleaks는 현재 작업 디렉터리를 git 저장소로 스캔하려고 시도합니다.
Dir
dir(별칭: files, directory) 명령어를 사용하면 디렉터리와 파일을 스캔할 수 있습니다. 예: gitleaks dir -v path_to_directory_or_file.
위치 인수로 대상이 지정되지 않으면 gitleaks는 현재 작업 디렉터리를 스캔합니다.
Stdin
stdin 명령어로 gitleaks에 데이터를 스트리밍할 수도 있습니다. 예: cat some_file | gitleaks -v stdin
베이스라인 생성
큰 저장소나 긴 이력을 가진 저장소를 스캔할 때는 베이스라인을 사용하는 것이 편리할 수 있습니다. 베이스라인을 사용하면
gitleaks는 베이스라인에 존재하는 오래된 발견 사항을 무시합니다. 베이스라인은 어떤 gitleaks 보고서든 될 수 있습니다. gitleaks 보고서를 생성하려면 --report-path 매개변수와 함께 gitleaks를 실행하세요.
gitleaks git --report-path gitleaks-report.json # gitleaks-report.json이라는 파일에 보고서를 저장합니다
베이스라인이 생성되면 detect 명령어를 다시 실행할 때 적용할 수 있습니다:
gitleaks git --baseline-path gitleaks-report.json --report-path findings.json
--baseline-path 매개변수와 함께 detect 명령어를 실행한 후, 보고서 출력(findings.json)에는 새로운 이슈만 포함됩니다.
Pre-Commit 훅
예제 pre-commit.py 스크립트를
.git/hooks/ 디렉터리에 복사하여 Gitleaks를 pre-commit 훅으로 실행할 수 있습니다.
구성 로드
우선순위는 다음과 같습니다:
--config/-c 옵션:
gitleaks git --config /home/dev/customgitleaks.toml .
파일 경로가 있는 환경 변수 GITLEAKS_CONFIG:
export GITLEAKS_CONFIG= " /home/dev/customgitleaks.toml "
gitleaks git .
파일 내용이 있는 환경 변수 GITLEAKS_CONFIG_TOML:
export GITLEAKS_CONFIG_TOML= ` cat customgitleaks.toml `
gitleaks git .
대상 경로 내의 .gitleaks.toml 파일:
gitleaks git .
네 가지 옵션 중 어느 것도 사용되지 않으면 gitleaks는 기본 구성을 사용합니다.
구성
Gitleaks는 자체 시크릿 탐지 규칙을 작성하기 위해 따를 수 있는 구성 형식을 제공합니다:
# Title for the gitleaks configuration file.
title = " Custom Gitleaks configuration "
# You have basically two options for your custom configuration:
#
# 1. define your own configuration, default rules do not apply
#
# use e.g., the default configuration as starting point:
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
#
# 2. extend a configuration, the rules are overwritten or extended
#
# When you extend a configuration the extended rules take precedence over the
# default rules. I.e., if there are duplicate rules in both the extended
# configuration and the default configuration the extended rules or
# attributes of them will override the default rules.
# Another thing to know with extending configurations is you can chain
# together multiple configuration files to a depth of 2. Allowlist arrays are
# appended and can contain duplicates.
# useDefault and path can NOT be used at the same time. Choose one.
[ extend ]
# useDefault will extend the default gitleaks config built in to the binary
# the latest version is located at:
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
useDefault = true
# or you can provide a path to a configuration to extend from.
# The path is relative to where gitleaks was invoked,
# not the location of the base config.
# path = "common_config.toml"
# If there are any rules you don't want to inherit, they can be specified here.
disabledRules = [ " generic-api-key " ]
# An array of tables that contain information that define instructions
# on how to detect secrets
[[ rules ]]
# Unique identifier for this rule
id = " awesome-rule-1 "
# Short human-readable description of the rule.
description = " awesome rule 1 "
# Golang regular expression used to detect secrets. Note Golang's regex engine
# does not support lookaheads.
regex = ''' one-go-style-regex-for-this-rule '''
# Int used to extract secret from regex match and used as the group that will have
# its entropy checked if `entropy` is set.
secretGroup = 3
# Float representing the minimum shannon entropy a regex group must have to be considered a secret.
entropy = 3.5
# Golang regular expression used to match paths. This can be used as a standalone rule or it can be used
# in conjunction with a valid `regex` entry.
path = ''' a-file-path-regex '''
# Keywords are used for pre-regex check filtering. Rules that contain
# keywords will perform a quick string compare check to make sure the
# keyword(s) are in the content being scanned. Ideally these values should
# either be part of the identiifer or unique strings specific to the rule's regex
# (introduced in v8.6.0)
keywords = [
" auth " ,
" password " ,
" token " ,
]
# Array of strings used for metadata and reporting purposes.
tags = [ " tag " , " another tag " ]
# ⚠️ In v8.21.0 `[rules.allowlist]` was replaced with `[[rules.allowlists]]`.
# This change was backwards-compatible: instances of `[rules.allowlist]` still work.
#
# You can define multiple allowlists for a rule to reduce false positives.
# A finding will be ignored if _ANY_ `[[rules.allowlists]]` matches.
[[ rules . allowlists ]]
description = " ignore commit A "
# When multiple criteria are defined the default condition is "OR".
# e.g., this can match on |commits| OR |paths| OR |stopwords|.
condition = " OR "
commits = [ " commit-A " , " commit-B " ]
paths = [
''' go\.mod ''' ,
''' go\.sum '''
]
# note: stopwords targets the extracted secret, not the entire regex match
# like 'regexes' does. (stopwords introduced in 8.8.0)
stopwords = [
''' client ''' ,
''' endpoint ''' ,
]
[[ rules . allowlists ]]
# The "AND" condition can be used to make sure all criteria match.
# e.g., this matches if |regexes| AND |paths| are satisfied.
condition = " AND "
# note: |regexes| defaults to check the _Secret_ in the finding.
# Acceptable values for |regexTarget| are "secret" (default), "match", and "line".
regexTarget = " match "
regexes = [ ''' (?i)parseur[il] ''' ]
paths = [ ''' package-lock\.json ''' ]
# You can extend a particular rule from the default co…
No comments yet.
to comment.