هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
Gitleaks uses regex rules (AWS keys, GitHub tokens, Azure connection strings, private keys, JWTs …) plus entropy to find secrets. It scans the whole Git history (a secret deleted in a later commit is still leaked), plain folders, or only staged changes in a pre-commit hook. In CI it fails the pipeline when it finds something.
When a secret is found: rotate it first, then clean the history.
طريقة الكتابة
gitleaks git [PATH] [OPTIONS]
gitleaks dir [PATH] [OPTIONS]
gitleaks protect --stagedالأجزاء الرئيسية
Commands
git[PATH]- Scan the Git history of a repo.
dir[PATH]- Scan files (no Git needed).
stdin- Scan text from a pipe.
protect--staged- Scan staged changes (pre-commit; older name, still used).
الخيارات 8
الأكثر استخدامًا
Flags
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Scan a repo's full history
gitleaks git -v --redact .2Scan a folder that is not a repo
gitleaks dir --redact ./config3Only recent commits
gitleaks git --log-opts="--since=2026-10-01" .4Stop secrets before commit
cat .pre-commit-config.yaml repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.21.2 hooks: - id: gitleaks pre-commit install5Use it in GitHub Actions
cat .github/workflows/secrets.yml - uses: actions/checkout@v4 with: { fetch-depth: 0 } - uses: gitleaks/gitleaks-action@v2 env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }6Report as SARIF
gitleaks git -f sarif -r gitleaks.sarif --redact .7Add your own rule and an allow list
cat .gitleaks.toml [extend] useDefault = true [[rules]] id = "s0sta-installer-key" description = "Installer key" regex = '''INSTALL_KEY\s*=\s*['"][a-f0-9]{32}['"]''' [allowlist] paths = ['''docs/examples/''']8Accept old findings with a baseline
gitleaks git -r baseline.json -f json . gitleaks git --baseline-path baseline.json .9Scan text from a pipe
kubectl get configmap app -o yaml | gitleaks stdin --redact10After a leak: rotate, then clean history
لا يوجد شيء يطابق هذا الفلتر.
انتبه
- Deleting the file is not enough: the secret is in the history and maybe in forks and caches. Rotate it.
- Do not print found secrets in CI logs — use
--redact.
الملفات
.gitleaks.toml- Rules and allow lists.
.gitleaksignore- Fingerprints of accepted findings.
نصائح للحفظ
- GitHub push protection (secret scanning) is a second layer; use both.
رموز الخروج
0 | No leaks. |
1 | Leaks found (or error). |