概要
Statically compiled, zero-dependency Git pre-commit secret scanner and credentials detector written in Go. An alternative to Gitleaks and git-secrets.
セキュリティ・プライバシー計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- +1
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルCrenox — Statically Compiled Git Secret Scanner & Pre-Commit Hook
██████╗ ██████╗ ███████╗ ████╗ ██╗ ██████╗ ██╗ ██╗ ██╔════╝ ██╔══██╗ ██╔════╝ ██╔██╗ ██║ ██╔═══██╗ ╚██╗██╔╝ ██║ ██████╔╝ █████╗ ██║╚██╗██║ ██║ ██║ ╚███╔╝ ██║ ██╔══██╗ ██╔══╝ ██║ ╚████║ ██║ ██║ ██╔██╗ ╚██████╗ ██║ ██║ ███████╗ ██║ ╚███║ ╚██████╔╝ ██╔╝╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚══╝ ╚═════╝ ╚═╝ ╚═╝
Statically compiled Git pre-commit secret scanner and credentials detector written in Go.
New in v2.2.0: Unlimited 64KB+ streaming, full special-char password detection, zero silent Markdown/doc blind spots,
--include-tests, and WooCommerce & Bearer rules — View v2.2.0 Release Highlights →
What is Crenox?
Crenox is a statically compiled, zero-dependency Git pre-commit hook and credentials scanner written in Go. It automatically blocks commits of API keys, SSH private keys, cloud credentials, database connection strings, and other sensitive material before they are recorded in version control history.
It is an alternative to tools like Gitleaks, TruffleHog, and git-secrets, focusing on lower resource utilization and local workflow integration.
Crenox uses a three-tier detection pipeline designed for speed and false positive reduction:
| Tier | Engine | Purpose |
|---|---|---|
| 1 — PATTERN | Aho-Corasick automaton | Matches 138 built-in rules (137 unique IDs) + BIP-39 mnemonics in O(n) time, zero allocations |
| 2 — ENTROPY | Shannon entropy analysis | Catches unknown secrets by measuring information density (with Log2 LUT acceleration) |
| 3 — CONTEXT | Context classifier | Suppresses false positives from comments, test files, container digests, and placeholders |
A finding must survive all three tiers before it is reported.
Quick Start
Install and protect your repository in under 60 seconds:
# 1. Automatic One-Line Install (Linux, macOS, Termux)
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash
# Or via Go:
# go install github.com/crenoxhq/crenox/v2/cmd/crenox@latest
# 2. Protect current repository (if skipped during installer)
crenox install
# 3. Verify — Crenox will now scan every commit automatically
git add . && git commit -m "test"
Or scan any directory right now, without a hook:
crenox scan --recursive ./src
That is all. No configuration file required. No runtime dependencies. Works on Linux, macOS, Windows, and Android/Termux.
Crenox Pro
For engineering teams and organizations, Crenox Pro extends the free local scanner with centralized policy management, tamper-resistant hook enforcement, audit logging, and safe Git history remediation inside your own private infrastructure.
| Capability | Crenox Community (Free) | Crenox Pro (On-Premises Fleet) |
|---|---|---|
| Local pre-commit & CI secret scanning | Yes | Yes |
Bypass protection (git commit --no-verify detection & telemetry) |
— | Yes (Centralized monitoring & alerts) |
Centralized signed .crenox.yaml policy & custom rules across workstations |
Per-repo config | Fleet-wide master console |
| Supervised Just-In-Time (JIT) exemption & bypass requests | — | Approval workflow & audit trail |
| Git history redaction with automatic restore points | Manual (--history detection) |
Automated safe history purge & restore |
| Air-gapped / OIDC / enterprise audit ledger | — | Yes (Zero external telemetry) |
https://crenoxhq.github.io/crenox/crenox-demo.mp4
Start a Free 30-Day Technical Pilot → • Watch Demonstration (MP4)
Terminal Demo
asciinema play https://crenoxhq.github.io/crenox/demo.cast

Table of Contents
- What is Crenox
- Quick Start
- Crenox Pro
- Performance
- Why Crenox
- Architecture
- Signature Coverage
- Show Your Security Badge
- Installation
- Configuration
- Usage
- Output Reference
- False Positive Handling
- In the Wild (Live Archive)
- Running Tests
- Contributing
- License
Performance
Measured on real-world repositories with Crenox against the most popular alternatives, on a standard GitHub Actions Ubuntu cloud runner — the same infrastructure used in real-world CI/CD pipelines.
Filesystem Scan Results (Standard Mode Averages)
| Repository | Tool | Avg Scan Time (s) | Avg CPU Time (s) | Peak RAM (MB) | Findings |
|---|---|---|---|---|---|
| sample_secrets | Crenox | 0.0072 s | 0.0095 s | 17.7 MB | 4 |
| Gitleaks v8.18.2 | 0.0241 s | 0.0307 s | 22.7 MB | 1 | |
| Betterleaks v1.6.1 | 0.0944 s | 0.1219 s | 45.4 MB | 2 | |
| truffleHogRegexes | Crenox | 0.0073 s | 0.0105 s | 18.0 MB | 0 |
| Gitleaks v8.18.2 | 0.0372 s | 0.0498 s | 21.2 MB | 1 | |
| Betterleaks v1.6.1 | 0.1189 s | 0.1613 s | 48.5 MB | 1 | |
| serverless-node-api-boilerplate | Crenox | 0.0074 s | 0.0109 s | 18.1 MB | 6 |
| Gitleaks v8.18.2 | 0.0271 s | 0.0393 s | 23.0 MB | 2 | |
| Betterleaks v1.6.1 | 0.2510 s | 0.4711 s | 66.1 MB | 2 | |
| large_file_test (10 MB) | Crenox | 0.0111 s | 0.0138 s | 18.0 MB | 0 |
| Gitleaks v8.18.2 | 1.8080 s | 1.8326 s | 23.8 MB | 1 | |
| Betterleaks v1.6.1 | 0.7533 s | 0.8140 s | 73.0 MB | 2 |
Git History Scan Results (History Mode Averages)
| Repository | Tool | Avg Scan Time (s) | Avg CPU Time (s) | Peak RAM (MB) | Findings |
|---|---|---|---|---|---|
| sample_secrets | Crenox | 0.0096 s | 0.0136 s | 18.0 MB | 9 |
| Gitleaks v8.18.2 | 0.0285 s | 0.0384 s | 23.1 MB | 5 | |
| Betterleaks v1.6.1 | 0.2931 s | 0.5716 s | 67.5 MB | 6 | |
| truffleHogRegexes | Crenox | 0.0131 s | 0.0226 s | 18.4 MB | 3 |
| Gitleaks v8.18.2 | 0.0425 s | 0.0595 s | 23.6 MB | 6 | |
| Betterleaks v1.6.1 | 0.1309 s | 0.2237 s | 49.8 MB | 8 | |
| serverless-node-api-boilerplate | Crenox | 0.0105 s | 0.0159 s | 18.1 MB | 6 |
| Gitleaks v8.18.2 | 0.0306 s | 0.0463 s | 21.4 MB | 2 | |
| Betterleaks v1.6.1 | 0.2457 s | 0.4333 s | 66.7 MB | 2 | |
| large_file_test (10 MB) | Crenox | 0.0049 s | 0.0051 s | 13.6 MB | 0 |
| Gitleaks v8.18.2 | 0.0236 s | 0.0299 s | 23.2 MB | 0 | |
| Betterleaks v1.6.1 | 0.0320 s | 0.0394 s | 30.4 MB | 0 |
Transparent & Auditable — These results were generated by an open-source automated benchmark script running on a standard GitHub Actions Ubuntu cloud runner. The full methodology, tooling, and workflow configuration are publicly visible — results are triggered and verified by the maintainer on each release. View the latest benchmark run →
Summary:
| Metric | vs Gitleaks | vs Betterleaks |
|---|---|---|
| Speed | 2.9x to 162x faster | 6.5x to 67x faster |
| Memory | 1.2x to 1.7x less RAM | 2.2x to 4.1x less RAM |
| Recall (Accuracy) | Finds 4x more secrets on sample_secrets (4 vs 1) | Finds critical multi-file secrets missed by Betterleaks |
Why Crenox — Comparison (vs Gitleaks, TruffleHog, detect-secrets, Betterleaks)
| Feature | Crenox | Gitleaks | TruffleHog | detect-secrets | Betterleaks |
|---|---|---|---|---|---|
| Statically compiled, zero runtime dependencies | + | + | + | — (Python) | + |
| ARM / Android / Termux native support | + | partial | partial | partial | partial |
| Aho-Corasick O(n) multi-pattern matching | + | + | + | — | + |
| Shannon entropy analysis | + | + | + | + | — |
| Token efficiency (BPE tokenizer) | — | — | — | — | + |
| Context-aware false-positive suppression | + | — | — | partial | — |
| BIP-39 seed phrase detection | + | — | — | — | — |
| Single-layer Base64 decoding | + | + | + | — | + |
| Concurrent file scanning | + | + | + | + | + |
| SARIF & GitLab SAST output formatting | + | + | — | — | + |
| Global hook installation | + | + | — | — | — |
| Custom user-defined signatures | + | + | + | + | + |
| OTA self-updating binary | + | — | + | — | — |
Architecture
Detection Pipeline
git commit (staged changes)
|
[Git Interop — internal/git]
ListStagedFiles() → git diff --cached --name-status
GetStagedDiff() → git diff --cached -- <path> (modified files, added lines only)
GetStagedContent() → git show :<path> (new files, full content)
|
[Pre-flight Filters]
- Bounded streaming queue (size 1024) to keep memory footprint bounded under concurrent load
- Early directory pruning: walks ignore excluded paths (e.g. node_modules, vendor) on the fly
- Known-safe fast-path: generated/suppression files (.pb.go, _pb2.py, zz_generated*, doc.go, .snyk, etc.)
- Binary detection: null-byte scan of first 8 KB (IsBinary)
- Extension exclusion: case-insensitive match
- Path exclusion: filepath.Match glob patterns
- Test/fixture path skip (unless --include-tests is set); .md / docs/ are always scanned
- File size cap: files > 10 MB skipped
|
[Tier 1 — Aho-Corasick Trie — internal/trie/trie.go]
Built once at startup via trie.Build() — allocation-free DFA matching of 138 rules (137 unique IDs)
Case-insensitive O(n) scan using a branchless 256-byte toLower lookup table
and sync.Pool-recycled 64 KB streaming buffers to cap heap memory to ~3 MB
BIP-39 mnemonic detection: 12/15/18/21/24 words validated against 2048-word dictionary
Single-layer Base64 decoding: re-feeds decoded value through trie (catches K8s secrets)
Blob aggregation: 3+ consecutive high-entropy lines → single CRITICAL finding
|
[Tier 2 — Shannon Entropy — internal/entropy/entropy.go]
Runs independently on each line (except entropy-excluded extensions; assignment-only on JSON/YAML/etc.)
Precomputed Log2 Look-Up Table (LUT) for O(1) symbol entropy arithmetic
Single-pass candidate token extractor for Base64 and Hex character sets
Base64 tokens: entropy >= entropy_threshold (default 4.5 bits/symbol)
Hex tokens: entropy >= threshold × (4.0 / 6.0), min floor 3.0
Skips: tokens < min_secret_length (default 20), all-identical chars, Java-style identifiers
|
[Tier 3 — Context Filter — internal/context/context.go]
Checks (in order): #nosec/nolint (non-CRITICAL) → test file path → commented line → UUID → version string
→ env/config placeholder → variable name → short alpha token → self-assignment
Only Real decisions are forwarded to the reporter
|
[Reporter — internal/reporter/reporter.go]
crenox scan: pretty / plain → stderr; json / sarif / gitlab-sast → stdout (or file via -o, keeping pretty progress on stderr)
crenox run: all formats → stderr (stdout may be captured by Git)
|
exit 0 (CLEAN) | exit 1 (BLOCKED)
Tier 1 — Aho-Corasick Pattern Matching (detailed)
Source: internal/trie/trie.go
The automaton is built once at startup via trie.Build(sigs) and shared across all goroutines without locks. Automaton.Search performs zero heap allocations on the hot path.
Construction is two-phase:
- All signature prefixes are inserted into a trie with lowercased keys.
- BFS computes failure links and merges output sets so overlapping prefixes (e.g.
sk-andsk-proj-) are both reported in one pass.
The scanner applies additional logic on top of the raw trie results:
- BIP-39 mnemonics — line is tested for 12/15/18/21/24 space-separated words, all validated against
bip39.go. - Single-layer Base64 decoding — extracted values are decoded and re-fed through the trie to catch masked secrets (e.g. Kubernetes Secret manifests).
- Blob aggregation — 3+ consecutive lines of the same entropy class are collapsed into one
CRITICALfinding (massive-base64-blob/massive-hex-blob) to prevent alert fatigue. - Same-Line & Cross-Signature Deduplication — preserves distinct secrets occurring on the same line without overwriting, while upgrading lower-priority matches when a higher-severity signature covers the exact same token.
- Tier 1 Precedence over Entropy — tokens already matched by specific Tier 1 pattern rules suppress redundant Tier 2 Shannon entropy alerts on the same line.
Tier 2 — Shannon Entropy Analysis (detailed)
Source: internal/entropy/entropy.go
H(X) = - sum over i of P(xi) * log2(P(xi))
| Score | Meaning |
|---|---|
| 0.0 | All bytes identical |
| ~3.5 | English prose |
| ~5.5 – 6.5 | Cryptographically random Base64 secret |
| 8.0 | Perfectly uniform 256-symbol distribution |
Tier 2 runs as an independent per-line scan (it does not depend on Tier 1 matches) and extracts two token classes per line:
- Base64 tokens — runs of
A-Za-z0-9+/=_-; entropy must exceedentropy_threshold(default 4.5). - Hex tokens — runs of
0-9a-fA-F; must be even-length if short (< 32 characters) to filter out arbitrary non-secret hex strings; threshold is scaled:entropy_threshold × (4.0 / 6.0), floor 3.0.
Pre-filters and exclusions:
- Diversity & identifier pre-filters — Java-style identifiers (all letters/dots/underscores), all-identical-character tokens, and low-diversity strings are discarded before entropy computation.
- Credential LHS boost — when
entropy_thresholdis at the default4.5and an assignment LHS names a credential (token,secret,password,api_key, etc.), the threshold lowers to4.0to catch shorter or slightly less uniform secrets. - Always entropy-excluded files (Tier 1 pattern matching still runs):
.pem,.rsa,.crt,.pub,.nix,.lock,.sum,.xml,.html,.md,.gradle,.kts,.cmake,.patch,.diff,.plist,.editorconfig,package-lock.json,yarn.lock,pnpm-lock.yaml,bun.lock. Note:.keyfiles are not excluded from Tier 2 entropy analysis. - Assignment-only entropy files (non-assignment lines are skipped in Tier 2):
.json,.yaml,.yml,.toml,.sql,.txt,.log. - Log-line auth heuristic — lines >= 30 bytes containing
bearerorauthorization:are scanned token-by-token for high-entropy credentials.
Tier 3 — Context-Aware Filtering (detailed)
Source: internal/context/context.go
| Decision | Condition |
|---|---|
Real |
None of the suppression checks matched |
SafeComment |
Line begins with //, #, *, /*, <!--, --, ;, %, or ! (outside .npmrc/.netrc/.env/.json/.yaml/.yml/dotfiles); OR line contains #nosec / nolint inside a //, #, or /* ... */ comment outside string literals (non-CRITICAL findings only — CRITICAL Tier 1 secrets require crenox:ignore) |
SafeTestFile |
Skipped by default unless --include-tests / include_tests: true is set. Matches test/fixture suffixes (_test.go, _test.py, _test.rb, _spec.rb, .test.{js,ts,tsx,jsx}, .spec.{js,ts,tsx,jsx}, _spec.{js,ts,tsx,jsx}), sample env templates (.env.example, .env.sample, .env.template, .example.env), filenames (test_*, test-*, conftest.py), and directory segments (test, tests, testdata, fixtures, __tests__, __mocks__, mock, mocks, sample, samples, spec, specs, sumdb, apt, dpkg, node_modules, vendor, plus directories containing mock/fixture/testdata or test_/test-/_test/-test). Documentation and checksum files (.md, README.md, .rst, docs/, .po, .sum) are always scanned so secrets in docs are never silently missed |
SafeVariableName |
Variable name (left of = / :=) contains: placeholder, fixture, lorem, foobar, your_, your-, insert_, replace_, changeme, redacted, sanitized, censored, example, alphabet, charset, digits, chars, temp_, tmp_, or word-boundary test, demo, sample, table, stub, mock, fake, dummy (unless --include-tests); self-assignment (auth_token: "auth_token"); C++ mangled symbols (_ZN, _ZNK); non-secret entropy variable names (uuid, hash, checksum, id, etc.); or variable reference tokens (autoPassword, mySecret) |
SafePlaceholder |
Token matches $VAR, ${VAR}, <...>, [[...]], {{...}}, ${{...}}, ConfigAttribute[...] / ConfigAttribute(...), redacted Bearer values (Bearer <redacted>), schema casts (nullable|string, encrypted), MIME types, data: URIs, SVG path coordinates, Mozilla SOPS encrypted blocks (ENC[<ALGO>,data:...]), Age recipient public keys (age1...), or multipart form boundaries |
SafeUUID |
Token matches UUID v4 pattern xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (unless in a credential assignment) |
SafeVersionString |
Token begins with digit.digit.digit, is @<token> / @sha256: digest, pure digits, sequential character runs, or hex without a-d/f |
SafeFilePath |
Unix/Windows/XDG filesystem paths (/usr/, C:\, $XDG_...) or multi-segment API route paths |
Before Tier 3, the scanner (internal/scanner/scanner.go) also applies:
- Known-safe file fast-path (
isKnownSafeFile): Always skips.gdnsuppress,.snyk,.dotsettings,doc.go,cgmanifest.json,.git-blame-ignore-revs,product.json,.terraform.lock.hcl,*.pb.go,*.pb.gw.go,*_pb2.py,*_pb2_grpc.py, andzz_generated*. - Source-code quote enforcement: In programming source files, generic signature assignments and non-assignment Base64 entropy checks require quoted string literals so unquoted variables, types, and function calls are not flagged.
- Token plausibility checks: Rejects
printf-style format verbs (%s,%v,%d,%q), tokens identical to their signature prefix, unquoted function calls (()), unquoted regex metacharacters,ALL_CAPS_SNAKE_CASEconstants, and short-prefix pure PascalCase/CamelCase identifiers.
Inline Suppression
Place crenox:ignore on the flagged line or the preceding comment line (supported comment prefixes: //, #, /*, <!--, --, ;, %):
// crenox:ignore
apiKey := "sk_live_example_for_documentation"
apiKey := "sk_live_example_for_documentation" // crenox:ignore
# crenox:ignore
STRIPE_KEY="sk_live_example"
-- crenox:ignore
SELECT 'sk_live_example' AS sample_key;
<!-- crenox:ignore -->
<secret>sk-ant-api03-documented-example</secret>
A same-line annotation suppresses only that line. A comment-line annotation suppresses the immediately following line.
[!NOTE]
#nosecandnolintinside//,#, or/* ... */comments (outside string literals) are also honored for non-CRITICALfindings.CRITICALTier 1 secrets require an explicitcrenox:ignoreannotation or anallowlist_patternsentry.
Signature Coverage
View all 138 built-in signatures (137 unique IDs) + BIP-39 mnemonic
| Category | Signatures |
|---|---|
| AI & ML Platforms | OpenAI (sk-, sk-proj-), DeepSeek (sk-), Anthropic (sk-ant-), OpenRouter (sk-or-v1-), Cohere (co_), Together AI (tog_), Mistral AI (mis_), Groq (gsk_), Replicate (r8_), Resend (re_), Perplexity (pplx-), Fireworks AI (fw_), LangSmith (lsv2_), HuggingFace (hf_) |
| Cloud Databases & Services | Alibaba Cloud AccessKey ID (LTAI), Azure Storage Account Key (AccountKey=), Doppler (dp.st., dp.pt., dp.sa.), Supabase (sb_publishable_, sb_secret_), Turso (fn_), Tailscale (tskey-auth-, tskey-api-), Clerk (clerk_), Neon (npg_), PlanetScale (pscale_pw_), Terraform Cloud (atlasv1.) |
| DevSecOps & Analytics | Grafana Cloud Token (glc_), Infracost API Key (ico_), Datadog (ddp_), PostHog (phx_, phs_, pha_), Linear (lin_api_), Sentry (sntry_), SonarQube (squ_), Snyk (snyk_), Pulumi (pul-), Databricks (dapi), Svix Webhook (whsec_) |
| Social & Messaging | Telegram Bot API Token (bot<id>:<hash>), Discord Webhook (https://discord.com/api/webhooks/), Slack Bot (xoxb-), User (xoxp-), Workspace (xoxa-), Refresh (xoxr-), Webhook (https://hooks.slack.com/services/) |
| GitHub | Classic PAT (ghp_), OAuth (gho_), User-to-Server (ghu_), App Installation (ghs_ - classic & JWT), Refresh (ghr_), Fine-grained PAT (github_pat_), Client ID (Iv1.), Environment tokens (GITHUB_TOKEN, _GITHUB_TOKEN) |
| Heroku | API Key (HEROKU_API_KEY), OAuth Token (heroku_oauth_token) |
| GitLab | Personal Access Token (glpat-), Pipeline Trigger (glptt-), Runner Registration (GR1348941), Runner Token (glrt-) |
| Postman | API Key (PMAK-) |
| AWS | Access Key ID (AKIA), MFA Device (ABIA), STS Temporary Key (ASIA), AppSync (da2-), Secret Access Key variable assignments (aws_secret, aws_key) |
| Google Cloud | Service Account JSON ("type": "service_account"), API Key (AIzaSy), OAuth Client ID (.apps.googleusercontent.com), OAuth Client Secret (GOCSPX-) |
| Stripe & Square | Stripe Live Secret (sk_live_), Stripe Live Restricted (rk_live_), Stripe Test Secret (sk_test_), Square Access Token (sq0atp-) |
| Twilio & SendGrid | Account SID (AC), Auth Token (SK), SendGrid (SG.), Mailgun (key-) |
| npm & PyPI | npm Automation token (npm_), Auth Token (_authToken, _auth), PyPI Upload Token (pypi-) |
| JWT | JSON Web Token (eyJ, strict 3-part dot-separated regex) |
| Private Keys & Certs | Age Secret Keys (AGE-SECRET-KEY-1), RSA, EC, OpenSSH, PKCS#8, PGP, DSA — all -----BEGIN ... PRIVATE KEY----- variants, PuTTY Private Keys (PuTTY-User-Key-File-) |
| Databases & DSNs | PostgreSQL (postgresql://, postgres://), MySQL (mysql://), MongoDB SRV (mongodb+srv://), MongoDB (mongodb://), Redis (redis://), RabbitMQ (amqp://, amqps://) |
| Basic Auth | HTTPS (https://user:pass@), HTTP (http://user:pass@) |
| Vault, Cloud & Commerce | HashiCorp Vault Service (hvs.), Batch (hvb.), DigitalOcean (dop_v1_), Vercel (vercel_), Cloudflare (CF_), Shopify (shpat_, shpca_, shppa_), WooCommerce REST (ck_, cs_) |
| Generic & Frameworks | password, pass, pwd, _pass, _pwd, secret, api_key, token, auth, Bearer (bearer-token), Django SECRET_KEY =, Rails secret_key_base (secret_key_base, secret_key_base:), WordPress keys & salts (AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, NONCE_SALT) |
| Crypto Wallets | BIP-39 mnemonic (bip39-mnemonic — 12/15/18/21/24 words, validated against 2048-word dictionary) |
Custom signatures can be added in .crenox.yaml and are compiled into the same automaton at startup — no performance overhead.
Show Your Security Badge
Show that your repository is actively protected against hardcoded secrets by embedding the official Secured by Crenox badge in your README.md:
Option 1 — Platinum Silver Shield
[](https://github.com/crenoxhq/crenox)
Option 2 — Emerald Minimalist
[](https://github.com/crenoxhq/crenox)
Option 3 — DevSecOps Capsule
[](https://github.com/crenoxhq/crenox)
Installation
Homebrew (macOS & Linux)
Install Crenox via the official Homebrew tap:
brew tap crenoxhq/crenox
brew install crenox
Or install directly in a single command:
brew install crenoxhq/crenox/crenox
Termux / Android (TUR)
Install Crenox natively on Android via the Termux User Repository (TUR):
pkg install tur-repo
pkg install crenox
One-Line Automatic Installer (Linux, macOS, Termux)
Install Crenox with automatic platform architecture detection and SHA-256 integrity verification:
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash
Security & Reliability:
- Truncation Protection: Wrapped inside a syntax block to prevent partial execution if the network connection drops.
- Integrity Verification: Fail-closed verification of SHA-256 cryptographic checksums against release checksum files (
checksums.txtor.sha256) before execution (bypass only with explicit--skip-verifyorCRENOX_SKIP_VERIFY=1).- Zero Root Requirement: Automatically falls back to
$HOME/.local/binwithout failure ifsudois unavailable.- Termux / Android Support: Automatically detects Termux environments and deploys directly to
$PREFIX/bin.- Interactive
/dev/tty: Supports interactive hook selection even when piped fromcurl.
Automation & Non-Interactive Flags:
# Install binary & automatically protect current Git repository:
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash -s -- --local
# Install binary & protect ALL Git repositories globally:
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash -s -- --global
# Install binary only (skip Git hook setup):
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash -s -- --no-hook
# Pin to a specific version or custom directory:
curl -fsSL https://crenoxhq.github.io/crenox/install.sh | bash -s -- --version=v2.2.0 --dir=/usr/local/bin
Go Toolchain
go install github.com/crenoxhq/crenox/v2/cmd/crenox@latest
Pre-compiled Standalone Binaries (Manual Download)
Download the binary for your platform from the GitHub Releases page:
# Linux / macOS (replace <version> and <arch>, e.g. linux-amd64, darwin-arm64):
wget https://github.com/crenoxhq/crenox/releases/download/<version>/crenox-<version>-<arch> -O crenox
chmod +x crenox
sudo mv crenox /usr/local/bin/
# Android (Termux):
wget https://github.com/crenoxhq/crenox/releases/download/<version>/crenox-<version>-android-arm64 -O $PREFIX/bin/crenox
chmod +x $PREFIX/bin/crenox
# Verify installation:
crenox version
Native pre-commit Framework
# .pre-commit-config.yaml
repos:
- repo: https://github.com/crenoxhq/crenox
rev: v2.2.0 # Replace with the latest release version
hooks:
- id: crenox
GitHub Actions CI/CD
- name: Run Crenox Secret Scanner
uses: crenoxhq/crenox@v2
with:
args: "-r ."
Build from Source
git clone https://github.com/crenoxhq/crenox.git
cd crenox
make build # outputs to dist/crenox
./dist/crenox version
Git Hook Setup
Protect the current repository:
crenox install # installs .git/hooks/pre-commit
crenox install --force # overwrites an existing hook
Protect every repository on this machine (global):
crenox install --global
# Creates ~/.config/crenox/hooks/pre-commit
# Runs: git config --global core.hooksPath ~/.config/crenox/hooks
Remove global hook:
git config --global --unset core.hooksPath
Full uninstall — removes binary, hooks, and config directory:
crenox uninstall
Configuration
Crenox searches for .crenox.yaml in this order:
--config/-cflag value.crenox.yamlin the scanned target directory or repository root.crenox.yamlin the current working directory~/.crenox.yamlin the home directory
With no config file, built-in defaults apply. Omitted scalar fields keep their default values.
[!IMPORTANT] List replacement behavior: Specifying
exclude_pathsorexclude_extensionsin.crenox.yamlreplaces the built-in default list for that field rather than appending to it. If you customize either list, include the default entries you still want to keep.
Full configuration reference
# Shannon entropy threshold (bits/symbol). Range: 0.0 to 8.0.
# Raise to reduce false positives. Lower to increase sensitivity.
# Default: 4.5
entropy_threshold: 4.5
# Minimum token length for entropy analysis.
# Tokens shorter than this produce unreliable scores.
# Default: 20
min_secret_length: 20
# Maximum file size to scan. Files exceeding this are skipped
# (logged in `crenox run`; skipped silently in `crenox scan`).
# Default: 10485760 (10 MB)
max_file_size_bytes: 10485760
# Whether to scan binary files (detected by null-byte in first 8 KB).
# Default: false
scan_binary_files: false
# Whether to scan test, fixture, and sample-env files normally skipped.
# Note: documentation files (.md, .rst, docs/) are already scanned by default.
# Default: false
include_tests: false
# Glob patterns (relative to repo root) to skip entirely.
# Specifying this field replaces the built-in default list below:
exclude_paths:
- "vendor/**"
- "node_modules/**"
- "dist/**"
- "build/**"
- "out/**"
- "target/**"
- "bin/**"
- ".next/**"
- ".nuxt/**"
- ".yarn/**"
- ".git/**"
- "*.lock"
- "go.sum"
- "package-lock.json"
- "pnpm-lock.yaml"
- "yarn.lock"
- "bun.lock"
- "bun.lockb"
- "**/locales/**"
- "**/i18n/**"
- "**/*.min.js"
- "**/*.min.css"
- "**/go/pkg/mod/**"
- "**/var/lib/apt/**"
- "**/var/lib/dpkg/**"
- "**/*.ziphash"
- "**/.env.example"
- "**/.env.sample"
- "**/.env.template"
- "**/.example.env"
# File extensions to skip (case-insensitive).
# Specifying this field replaces the built-in default list below:
exclude_extensions:
- ".png"
- ".jpg"
- ".jpeg"
- ".gif"
- ".bmp"
- ".ico"
- ".svg"
- ".woff"
- ".woff2"
- ".ttf"
- ".eot"
- ".mp4"
- ".webm"
- ".mp3"
- ".ogg"
- ".zip"
- ".tar"
- ".gz"
- ".bz2"
- ".xz"
- ".7z"
- ".pdf"
- ".doc"
- ".docx"
- ".xls"
- ".xlsx"
- ".exe"
- ".dll"
- ".so"
- ".dylib"
- ".a"
- ".o"
- ".css"
- ".scss"
- ".csv"
- ".hex"
- ".eml"
- ".msg"
- ".mbox"
- ".vcf"
- ".ics"
- ".cache"
- ".ziphash"
- ".pb.go"
- ".gen.go"
- ".g.go"
- ".map"
# Allowlist: findings whose token matches are silently ignored.
# Supports exact strings, filepath.Match globs, and '*' matching across '/'.
allowlist_patterns:
- "AKIAIOSFODNN7EXAMPLE"
- "sk_test_*"
- "*-dummy-token-*"
# Disable individual detection tiers. Use with caution.
disable_tiers:
trie: false # disables Tier 1 Aho-Corasick matching
entropy: false # disables Tier 2 entropy analysis
context: false # disables Tier 3 suppression — expect many false positives
# Stop after the first finding. Useful in CI fail-fast loops.
fail_fast: false
# Print debug output to stderr.
verbose: false
# Custom signatures compiled into the Aho-Corasick automaton alongside builtins.
# Regular expressions are compiled and validated at config load time; invalid regexes,
# empty prefixes, non-ASCII prefixes, duplicate IDs, or invalid severities fail fast.
# Severity must be one of: CRITICAL, HIGH, MEDIUM, LOW (defaults to HIGH if omitted).
custom_signatures:
- id: "internal-api-key"
description: "Proprietary internal service credential"
prefix: "mycompany_key_"
severity: "CRITICAL"
regex: "^mycompany_key_[a-zA-Z0-9]{32}$"
Entropy Threshold Reference
| Value | Behavior |
|---|---|
| 3.0 | Very sensitive — may flag base32 identifiers |
| 3.5 | High sensitivity — catches most secrets, slightly elevated noise |
| 4.5 | Default — cryptographically random secrets, low false-positive rate |
| 5.0+ | Strict — may miss weak passwords; minimal noise |
Usage
Automatic (Pre-commit Hook)
After crenox install, the hook fires on every git commit and scans only staged content:
- New files — full content via
git show :<path> - Modified files — added lines only via
git diff --cached -- <path>
Ad-hoc Scanning
# Single file
crenox scan config/production.yaml
# Directory (non-recursive)
crenox scan ./config
# Directory, recursive (skips .git, build, node_modules automatically)
crenox scan -r ./src
# Full Git history audit (streams git log --all --full-history -p -m; scans file diffs, commit messages, and merge commits)
crenox scan --history .
# JSON output — written to stdout for piping
crenox scan -f json -r ./src | jq '.findings[] | select(.severity == "CRITICAL")'
# JSON output — written to stdout for piping
crenox scan -f json -r ./src | jq '.findings[] | select(.severity == "CRITICAL")'
# SARIF output saved directly to file (keeps pretty terminal logs on stderr)
crenox scan -r -f sarif -o crenox.sarif .
# GitLab Secret Detection SAST report
crenox scan -r -f gitlab-sast -o gl-secret-detection-report.json .
In both ad-hoc directory mode and full Git history mode, scans are processed concurrently using
max(runtime.NumCPU(), 4)worker pools. Multi-file reporting guarantees that identical secrets appearing across separate files are each reported with their exact file path and line location. In history mode, Git log diffs and commit messages across all branches and merge commits are streamed with chunk deduplication by token value.
CI Integration
GitHub Actions (Official Reusable Action)
The easiest way to integrate Crenox into your GitHub Actions workflow is by using our official reusable action. It handles Go installation and scanning automatically:
- name: Run Crenox Git Secrets Scanner
uses: crenoxhq/crenox@v2
with:
version: 'latest' # Optional: specific version to use (e.g. 'v2.2.0')
args: '-r .' # Optional: arguments to pass (default: '-r .'; or '--history .')
sarif: 'true' # Optional: set to 'true' to export findings as a SARIF report
To upload the results to GitHub Advanced Security (Code Scanning Alerts), configure the upload step:
- name: Upload SARIF report
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: crenox-results.sarif
[!TIP] You can inspect the official action.yml file in the root of this repository to use as a template or reference for building your own custom GitHub Actions.
GitLab CI/CD (Secret Detection SAST)
crenox-secret-detection:
stage: test
image: golang:1.23
before_script:
- go install github.com/crenoxhq/crenox/v2/cmd/crenox@latest
script:
- crenox scan -r -f gitlab-sast -o gl-secret-detection-report.json .
artifacts:
reports:
secret_detection: gl-secret-detection-report.json
Command Reference
crenox run — pre-commit hook entry point
Scans staged changes only. Invoked automatically by the Git hook. All output formats (pretty, plain, json, sarif, gitlab-sast) write to stderr so Git hook stdout is never disturbed. Enforces strict positional argument validation (cobra.NoArgs).
Zero-Tolerance Blocking Policy: Any detected finding, regardless of severity (CRITICAL, HIGH, MEDIUM, LOW), blocks the commit with exit code 1.
Fail-Closed Scan Integrity: Any unreadable file, inaccessible path, permission denial, or broken Git pipe halts execution and blocks the commit with exit code 1 (scan_error). A clean status (exit 0) is emitted only when 100% of eligible files have been scanned with zero findings.
| Flag | Default | Description |
|---|---|---|
-c, --config |
auto-detected | Path to .crenox.yaml |
-f, --format |
pretty |
pretty json plain sarif gitlab-sast |
--fail-fast |
false | Stop after the first finding |
--include-tests |
false | Scan test and fixture files normally skipped |
-v, --verbose |
false | Debug output to stderr |
crenox scan [path...] — ad-hoc scanner
Scans targeted files, directories, or historical Git commit logs. Human-readable formats (pretty, plain) write to stderr; machine-readable formats (json, sarif, gitlab-sast) write to stdout unless -o is used (in which case the report is written to the file and pretty progress/findings are written to stderr). Enforces fail-closed scan integrity: if any file is unreadable or a history process fails, scanning halts with an incomplete scan report and exit code 1.
| Flag | Default | Description |
|---|---|---|
-c, --config |
auto-detected | Path to .crenox.yaml |
-f, --format |
pretty |
pretty json plain sarif gitlab-sast |
-o, --output |
Write report directly to file, keeping pretty progress on stderr | |
-r, --recursive |
false | Walk subdirectories |
--history |
false | Scan entire Git commit history |
--fail-fast |
false | Stop after the first finding |
--include-tests |
false | Scan test and fixture files normally skipped |
-v, --verbose |
false | Debug output to stderr |
crenox install — hook installer
Installs the Crenox pre-commit hook into the repository's resolved hooks path (supporting standard .git/hooks/pre-commit, worktrees, and submodules) or globally. Enforces strict positional argument validation (cobra.NoArgs).
| Flag | Default | Description |
|---|---|---|
--global |
false | Install globally via core.hooksPath |
--repo |
. |
Target repository root |
-f, --force |
false | Overwrite existing hook |
crenox update — OTA self-updater
Downloads the latest stable release for the current OS/arch from GitHub Releases, performs strict SHA-256 checksum verification, and atomically replaces the running executable. Enforces strict positional argument validation (cobra.NoArgs).
Integrity Verification: Checksums must be valid 64-character hexadecimal SHA-256 hashes (^[a-fA-F0-9]{64}$). If a checksum is missing, invalid, or does not match the binary, the update immediately aborts and cleans up temporary files.
| Flag | Default | Description |
|---|---|---|
--beta |
false | Allow updating to pre-release (beta) versions |
--skip-verify |
false | Skip SHA-256 checksum verification (not recommended) |
A background check runs on each invocation, querying the API at most once per 24 hours. The result is cached at ~/.config/crenox/last_check.json. A notice is printed to stderr if a newer version is available.
crenox uninstall — full removal
Removes Crenox from your system cleanly (cobra.NoArgs):
- Unsets global
git config --global core.hooksPathif it is managed by Crenox (leaves third-party hook managers untouched). - Removes the
crenoxbinary fromPATH(or prints the appropriate package manager command if installed viapkg,dpkg/apt,Homebrew,pacman, orrpm). - Removes
~/.config/crenox. - Removes the local repository
pre-commithook if it was generated by Crenox.
crenox version — version metadata
Prints the Crenox version tag, short commit SHA, build timestamp, and maintainer link (crenox version or crenox --version).
Output Reference
Output Examples
Clean (exit 0):
CRENOX CLEAN — 4 file(s) scanned in 3.2ms
Blocked by Finding (exit 1):
CRITICAL cmd/main.go:12
[PATTERN] GitHub Personal Access Token (classic)
Token: ghp_AB****************************cdef
→ token := "ghp_AB****************************cdef"
HIGH config/settings.go:8
[ENTROPY] High-entropy BASE64 string (entropy=6.23)
Token: wJalrX******************************tnEY
Entropy: 6.2300 bits/symbol
→ AWS_SECRET = "wJalrX******************************tnEY"
────────────────────────────────────────────────────────────────────
CRENOX SCAN COMPLETE
Files scanned : 4
Elapsed : 5.1ms
Findings : CRITICAL:1 HIGH:1 MEDIUM:0 LOW:0
────────────────────────────────────────────────────────────────────
COMMIT BLOCKED — remove the secrets above and try again.
Hint: If this is a false positive, append '// crenox:ignore' to the preceding line or at the end of the line.
Incomplete Scan / Fail-Closed (exit 1):
SCAN INCOMPLETE — 1 file(s) failed to be read or processed:
• secret.key: open secret.key: permission denied
Commit blocked because the scan was incomplete (fail-closed security policy).
JSON Schema (crenox scan -f json — written to stdout):
{
"crenox_version": "v2.x.x",
"status": "blocked",
"scanned_files": 4,
"elapsed_ms": 5,
"findings": [
{
"file_path": "cmd/main.go",
"line": 12,
"severity": "CRITICAL",
"tier": "PATTERN",
"signature_id": "github-pat-classic",
"description": "GitHub Personal Access Token (classic)",
"token": "ghp_AB****************************cdef",
"entropy": 4.92,
"line_snippet": "token := \"ghp_AB****************************cdef\""
}
]
}
When an unreadable file or pipeline failure triggers fail-closed protection, -f json emits:
{
"crenox_version": "v2.x.x",
"status": "scan_error",
"scanned_files": 3,
"elapsed_ms": 2,
"failed_files": [
{
"path": "secret.key",
"error": "open secret.key: permission denied"
}
],
"findings": []
}
SARIF (crenox scan -f sarif — written to stdout): OASIS SARIF 2.1.0 JSON format, compatible with GitHub Advanced Security Code Scanning.
GitLab SAST (crenox scan -f gitlab-sast — written to stdout): GitLab Secret Detection SAST report schema (v15.0.0), compatible with GitLab CI/CD Security tab.
False Positive Handling
Tier 3 automatically eliminates the vast majority of false positives. For persistent cases:
| Method | When to use |
|---|---|
crenox:ignore comment |
One-off suppression for a specific line (//, #, /*, <!--, --, ;, %) |
#nosec / nolint comment |
Suppresses non-CRITICAL findings inside //, #, or /* ... */ comments |
Safe variable name (dummy_, fake_, mock_) |
Test or documentation values that look like secrets |
| Automatic Mock Value Filter | Automatically ignores generic/entropy rules if values contain mock/fake/test/dummy |
| Entropy File Exclusions | Skips raw Tier 2 entropy checks on .pem, .rsa, .crt, .pub, .lock, .sum, .md, .html, .xml, build files (Tier 1 pattern matching still runs; .key files are still scanned) |
| Function Call Protection | Automatically filters out unquoted code function calls and methods containing parentheses |
| Source RHS Quote Enforcement | Automatically skips unquoted RHS tokens (variables, struct types, function calls) in source code files |
| Rust/C++ Generic Type Filter | Unquoted tokens containing < or > (e.g. Option<u64>, Vec<T>) are never reported as secrets |
| Lowercase Identifier Filter | Tokens composed entirely of lowercase letters and underscores (e.g. pass_summaries) are rejected by generic rules |
| Git Commit SHA Filter | 20-char and 40-char pure hex tokens are rejected by high-entropy-hex; 40/64-char hex with hash/commit/sha/digest context are suppressed |
| Container Digest Filter | Docker and OCI container image digests (sha256:[a-f0-9]{64}) and @<token> refs are automatically suppressed |
| SVG Vector Path Filter | High-entropy SVG path coordinates (d="M...") are automatically recognized and ignored |
| Example Env Template Filter | Sample configurations (.env.example, .env.sample, .env.template, .example.env) are excluded from scanning by default |
| Bun Lockfile Filter | Bun lockfiles (bun.lock, bun.lockb) are automatically excluded from scans by default alongside npm, yarn, and pnpm lockfiles |
| Pytest & Test Framework Filter | Python/Ruby/JS/Go test naming conventions (test_*.py, *_test.py, *_test.rb, conftest.py, test-*, *_test.go, *.test.*, *.spec.*) are automatically recognized as test paths |
| Tier 1 Pattern Precedence | Lines matched by specific Tier 1 pattern rules automatically suppress duplicate Tier 2 Shannon entropy alerts |
| Temporary Variable Filter | Variables prefixed with temp_ or tmp_ are treated as safe runtime placeholders |
| YAML Key Name Filter | Key names without values (e.g. api-key:) are detected and discarded before being reported |
allowlist_patterns in config |
Known safe tokens used repeatedly across the codebase |
| Move to test file path | Values in tests/, testdata/, *_test.go, etc. are suppressed by default (use --include-tests to scan them); .md and docs/ are always scanned |
${ENV_VAR} reference syntax |
Replaced at runtime — not a hardcoded secret |
exclude_paths in config |
Entire directories that should never be scanned (replaces defaults when set) |
Raise entropy_threshold |
Codebase has many long high-entropy non-secret identifiers |
# .crenox.yaml
allowlist_patterns:
- "AKIAIOSFODNN7EXAMPLE" # exact match
- "sk_test_*" # all Stripe test keys
- "*-placeholder-*"
Running Tests
make test # all tests with race detector
make bench # benchmarks
make cover # HTML coverage report → coverage.html
make lint # staticcheck
Representative benchmark output (shows zero allocations on the hot scan path):
BenchmarkShannonSmall-8 1456561 793.4 ns/op 0 B/op 0 allocs/op
BenchmarkSearch-8 2041 613,592 ns/op 0 B/op 0 allocs/op <- 0 allocs
BenchmarkSearchWithHit-8 4171 292,044 ns/op 0 B/op 0 allocs/op
BenchmarkAutomatonBuild-8 692 1,909,695 ns/op 324,642 B/op 310 allocs/op
BenchmarkAnalyze-8 10000 144,090 ns/op 14,880 B/op 107 allocs/op
BenchmarkFullPipeline-8 697 2,039,775 ns/op 67,483 B/op 1202 allocs/op
Contributing
Contributions are welcome. All contributors must agree to the Contributor License Agreement. By submitting a pull request you agree that your contribution is licensed to CrenoxHQ under the terms of the CLA. This protects the project's open-source continuity and dual-licensing sustainability model. Please see CONTRIBUTING.md for contribution guidelines.
Maintainer
Maintained by CrenoxHQ — https://github.com/crenoxhq
License
GNU Affero General Public License v3.0.
Commercial SaaS deployment or distribution of a modified version without releasing the source under AGPL-3.0 is prohibited. See LICENSE for full terms.
関連プロジェクトを探す
読み込み中…