
Быстрый инструмент статического анализа с открытым исходным кодом для обнаружения жестко закодированных секретов, таких как пароли, ключи API и токены, в git-репозиториях, файлах и потоках stdin с настраиваемым движком правил.
┌─○───┐ │ │╲ │ │ │ ○ │ │ ○ ░ │ └─░───┘
> [!WARNING]
> Gitleaks завершён по функциональности. Я не добавляю новые функции в Gitleaks. Будущие релизы будут только с исправлениями безопасности. Я переключаю своё внимание на [Betterleaks](https://github.com/betterleaks/betterleaks)
[license]: https://raw.githubusercontent.com/gitleaks/gitleaks/master/LICENSE
[badge-license]: https://img.shields.io/github/license/gitleaks/gitleaks.svg
[go-docs-badge]: https://pkg.go.dev/badge/github.com/gitleaks/gitleaks/v8?status
[go-docs]: https://pkg.go.dev/github.com/zricethezav/gitleaks/v8
[badge-build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml/badge.svg
[build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml
[go-report-card-badge]: https://goreportcard.com/badge/github.com/gitleaks/gitleaks/v8
[go-report-card]: https://goreportcard.com/report/github.com/gitleaks/gitleaks/v8
[dockerhub]: https://hub.docker.com/r/zricethezav/gitleaks
[dockerhub-badge]: https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg
[gitleaks-action]: https://github.com/gitleaks/gitleaks-action
[gitleaks-badge]: https://img.shields.io/badge/protected%20by-gitleaks-blue
[![GitHub Action Test][badge-build]][build]
[![Docker Hub][dockerhub-badge]][dockerhub]
[![Gitleaks Action][gitleaks-badge]][gitleaks-action]
[![GoDoc][go-docs-badge]][go-docs]
[![GoReportCard][go-report-card-badge]][go-report-card]
[![License][badge-license]][license]
Gitleaks — это инструмент для **обнаружения** секретов, таких как пароли, ключи API и токены, в git-репозиториях, файлах и всем остальном, что вы можете передать через `stdin`. Если хотите узнать больше о том, как работает механизм обнаружения, посмотрите этот блог: [Regex is (almost) all you need](https://lookingatcomputer.substack.com/p/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 также доступен в бинарной форме для многих популярных платформ и типов ОС на странице релизов. Кроме того, Gitleaks может быть реализован как pre-commit hook непосредственно в вашем репозитории или как GitHub action с помощью Gitleaks-Action.
brew install gitleaks
docker pull zricethezav/gitleaks:latest docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]
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 is installed)git clone https://github.com/gitleaks/gitleaks.git cd gitleaks make build
### Pre-Commit
1. Установите pre-commit с https://pre-commit.com/#install
2. Создайте файл `.pre-commit-config.yaml` в корне вашего репозитория со следующим содержимым: ```
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
for a native execution of gitleaks or use the gitleaks-docker pre-commit ID для выполнения gitleaks с использованием официальных Docker-образов
pre-commit autoupdatepre-commit installNote: чтобы отключить предварительный хук gitleaks, вы можете добавить `SKIP=gitleaks` к команде commit, и это пропустит выполнение gitleaks```
➜ SKIP=gitleaks git commit -m "skip gitleaks check"
Detect hardcoded secrets................................................Skipped
Gitleaks scans code, past or present, for secrets
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.
### Команды