Secretscan Command
The secretscan command discovers GitLab projects, clones them locally, and scans each repository for secrets using TruffleHog, Gitleaks, and/or Titus. Use it to find hardcoded credentials, API keys, and tokens across project repositories.
Basic Usage
Section titled “Basic Usage”gogatoz secretscan [options]Authentication:
export GITLAB_TOKEN=glpat_xxxexport GITLAB_URL=https://gitlab.com # optional, defaults to https://gitlab.comYou can also pass –token and –gitlab-url flags explicitly, or use --no-token for public projects.
Options
Section titled “Options”Project discovery:
--querySearch query filter for project discovery--languageComma-separated language filter--topicComma-separated topic filter--visibilityFilter by visibility:public,internal,private--membershipOnly projects the user is a member of--ownedOnly projects owned by the user--per-pageResults per API page, max 100 (default: 50)--max-pagesMaximum pages to fetch, 0 = unlimited (default: 0)
Scanning:
--scannersScanners to use:auto,trufflehog,gitleaks,titus(default:auto)--clone-depthGit clone depth, 0 = full history (default: 1)--concurrencyNumber of concurrent clone+scan workers (default: 4)--scan-dirScan pre-cloned repos in this directory (skips clone)--discard-repos-after-scanningRemove repos after scanning to save disk (default: false)
Output:
-o, --output-dirDirectory for cloned repos (required unless--scan-dir)--outputWrite output to file (default: stdout)--formatOutput format:text,json,jsonl--redactRedact secret values in output (default: false)
Global flags (–token, –gitlab-url, –verbose, –insecure-skip-tls-verify, –ca-cert, rate/HTTP tuning) apply as usual.
Scanner Requirements
Section titled “Scanner Requirements”At least one scanner must be installed:
- TruffleHog –
brew install trufflehogorpip install trufflehog - Gitleaks –
brew install gitleaksor download from GitHub - Titus – download from GitHub
Use --scanners auto to detect all available tools and run them in parallel.
Examples
Section titled “Examples”Auto-detect scanners, scan all accessible projects
Section titled “Auto-detect scanners, scan all accessible projects”gogatoz secretscan --query "" -o ./scan-resultsScan with a specific tool
Section titled “Scan with a specific tool”gogatoz secretscan --query "deploy" --scanners trufflehog -o ./scan-resultsFull git history (not just HEAD)
Section titled “Full git history (not just HEAD)”gogatoz secretscan --query "" --clone-depth 0 -o ./scan-resultsPublic projects only (no token)
Section titled “Public projects only (no token)”gogatoz secretscan --query "" --no-token --visibility public -o ./scan-resultsScan pre-cloned repos (offline mode)
Section titled “Scan pre-cloned repos (offline mode)”gogatoz secretscan --scan-dir /path/to/cloned/repos --scanners auto --redactFind hardcoded tokens across an organization
Section titled “Find hardcoded tokens across an organization”gogatoz secretscan \ --query "" \ --scanners trufflehog \ --clone-depth 0 \ --concurrency 8 \ -o ./full-scan \ --redact \ --json > secrets-report.jsonScan only CI-related projects
Section titled “Scan only CI-related projects”gogatoz secretscan \ --query "ci runner deploy" \ --membership \ --scanners gitleaks \ -o ./ci-scanComparison with enumerate
Section titled “Comparison with enumerate”| Feature | enumerate |
secretscan |
|---|---|---|
| Scans | CI config (.gitlab-ci.yml) |
Full git history |
| Finds | CI/CD misconfigurations | Hardcoded secrets in code |
| Requires clone | No (API only) | Yes (clones repos) |
| Tools | Built-in rules engine | TruffleHog, Gitleaks, Titus |
| Speed | Fast (API-based) | Slower (clones + scans) |
These commands are complementary – use both for full coverage.
- The
--scanners automode probes your PATH for available tools and runs all that are found. - Use
--discard-repos-after-scanningwhen disk space is limited. Results are written to stdout/file before repos are removed. - The
--clone-depth 0flag clones full git history, which is slower but catches secrets in old commits. - Respect GitLab rate limits when scanning many projects. Use
--concurrencyand the global rate/retry flags to tune throughput.