Expand description
KeyHog Scanner: A high-performance, multi-layered secret detection engine.
This crate implements the core scanning logic, combining SIMD pre-filtering, Aho-Corasick literal matching, regex fallback, and ML-based confidence scoring.
§Module map (by pipeline stage)
The modules below are declared in dependency order, but they READ in pipeline
order, the same bytes→finding flow as [docs/src/architecture.md] and the
method-level map in [engine] (engine::mod “# The one flow”). To find a
responsibility, locate its stage:
- Config / state / shared types: [
scanner_config], [scan_state], [types],hw_probe(hardware routing), [error]. - Phase 1 · prefilter (cheap “could a detector fire here?”)
[
alphabet_filter], [bigram_bloom], [prefix_trie],ascii_ci,simd/simdsieve_prefilter(feature-gated),prefilter_degrade(loud Law-10 fallback). - Compile and lifecycle (detectors → matchers):
compiled_scanner/, [compiler],shared_regexes, [static_intern]. - Scan engine (phase 1 triggers + phase 2 extraction; CPU or GPU):
[
engine] (start at its header doc), [pipeline],gpu. Public scan entry methods live incompiled_scanner/runtime.rsand dispatch here. - Decode-through (nested base64/hex/url/unicode, recursive)
decode, [decode_structure]. - Entropy:
entropyis now the single home for all of it: the keyword/scanner detection logic plus the fast Shannon-entropy primitiveentropy::fast(+entropy::avx512/entropy::fast_x86/entropy::fast_neonSIMD impls, arch-gated). - Confidence / ML:
ml_scorer(serves the embeddedweights.bin; trained out-of-band by the repo’sml/), [confidence],probabilistic_gate. - Context, fragment reassembly, multiline, suppression, resolution
context,fragment_cache, [multiline],suppression,resolution,structured. - Specialized validators:
checksum,jwt,aws,homoglyph, [unicode_hardening]. - Cross-cutting:
platform_compat,placeholder_words,telemetry,util_hash.
Most single-file modules are one responsibility each; the multi-file engine
is the exception and carries its own internal map in engine::mod.
Re-exports§
pub use crate::hw_probe::probe_hardware;pub use crate::hw_probe::select_backend;pub use crate::hw_probe::HardwareCaps;pub use crate::hw_probe::ScanBackend;pub use crate::util_hash::FNV_OFFSET_BASIS;pub use crate::util_hash::FNV_PRIME;
Modules§
- aws
- Offline AWS account-ID recovery from an access-key ID (no network/verify). Offline AWS account-ID recovery + canary-token classification.
- checksum
- Service-specific credential checksum validation (GitHub, npm, Slack, etc.). Checksum-aware credential validation.
- context
- Code context analysis (comments, assignments, test files). Structural context analysis: understand WHERE in code a potential secret appears.
- decode
- Decode-through pipeline for nested encodings (base64, hex, URL, etc.). Decode-through scanning: decode encoded strings before pattern matching.
- entropy
- Shannon entropy analysis for secret detection. Shannon entropy analysis for distinguishing secrets from ordinary text.
- gpu
- GPU-accelerated matching via wgpu. GPU-accelerated batch inference for the MoE classifier via wgpu compute shaders.
- hw_
probe - Hardware capability detection and backend selection. Hardware capability probing with once-cached results.
- jwt
- JWT structural validation and anomaly detection. JWT structural validation.
- ml_
scorer - Machine learning inference for secret scoring. ML-based secret scoring with a tiny mixture-of-experts network.
- resolution
- Match resolution and deduplication. Match resolution: when multiple detectors match the same region, keep only the most specific, highest-confidence match. Eliminates duplicates.
- telemetry
- Per-scan telemetry: always-on counters + opt-in
--dogfoodevents. Lightweight per-scan telemetry. - util_
hash - Shared FNV-1a hash + content-keyed memoization primitives. Single home for the seed every per-scan cache keys on, plus the bounded thread-local cache helper they all share, so a hash change can never re-key only some caches. Shared non-cryptographic hash + content-keyed memoization primitives.
Structs§
- Backend
Recovery Receipt - Complete, non-secret receipt for automatic recovery of stable input bytes.
- Bigram
Prefilter Corpus Status - Rejection effectiveness measured over one explicitly named input corpus.
- Bigram
Prefilter Status - Build-time hash-table density diagnostics for the Layer-0.5 prefilter.
- Coalesced
Scan Outcome - Result of one fallible coalesced dispatch, including any completed recovery.
- Compiled
Scanner - Compiled
Scanner Runtime - GpuBackend
Availability - GpuBackend
Candidate Status - GpuLiteral
Artifact - Serialized VYRE literal matcher plus the cache identity used by runtime.
- GpuLiteral
Artifacts - The runtime GPU presence matcher artifacts derivable without a GPU device.
- Phase1
Admission Plan - Exact per-chunk phase-1 admissions computed while an autoroute key is built. The plan is intentionally opaque: callers can only reuse it through the scanner boundary that verifies its internal totals and exact live chunk identity. GPU region presence does not consume this plan because VYRE owns that path’s trigger admission.
- Phase1
Admission Summary - Exact direct-literal admission totals for one routed scan batch.
- Phase2
Keyword Trigger Summary - Exact phase-2 keyword-trigger density for one routed scan batch.
- Recovered
Input Range - One exact source-byte interval completed after the selected backend faulted.
- Scan
Execution Route - Recall-equivalent execution choices resolved for one scan request.
- Scanner
Config - Scanner-side configuration: the canonical
ScanConfig, the single owned source of truth for every shared detection knob (decode depth, entropy, ML, confidence floor, keyword lists, …). PLUS the two knobs that are scanner-crate-local and have no place onkeyhog-core’sScanConfig: - Scanner
Tuning Config - Explicit per-scanner performance-route tuning.
Enums§
- Bigram
Prefilter State - Operator-visible health state for the Layer-0.5 selective anchor prefilter.
- GpuInit
Policy - Scan
Error - Errors returned while compiling detector patterns into a scanner.
Functions§
- compile_
gpu_ literal_ artifacts - Compatibility entry point for callers that supplied Hyperscan tuning. GPU literal artifacts now depend only on the canonical detector plan.
- compile_
gpu_ literal_ artifacts_ default - Compile GPU literal artifacts from the canonical detector plan.
- gpu_
batch_ input_ limit - VRAM-adaptive GPU batch-input limit. Bigger buffers mean fewer device dispatches per multi-TB scan; each kernel launch is a fixed ~50-300 µs cost regardless of payload, so doubling the input halves dispatch overhead. Capped by host VRAM (input + transition tables + match output must fit) and by a 1 GiB upper bound so the pre-compile time stays bounded.
- gpu_
batch_ input_ limit_ bounds - The
[floor, cap]the resolved GPU batch input limit is clamped into: the 128 MiB unknown-host floor and the 1 GiB pre-compile-time ceiling that bound the VRAM table. A Tier-A override is clamped into this range so no config/CLI value can request a buffer the sizing contract forbids. - gpu_
literal_ artifact_ cache_ dir - Canonical runtime directory for serialized GPU literal matcher artifacts.
- is_
entropy_ detector - True when
detector_idnames the pure-entropy fallback family ("entropy"or any"entropy-*"id such asentropy-token). - is_
generic_ or_ entropy_ detector - True for a detector that fires via the entropy / phase2-generic path (the
generic-*family + entropy fallback), carrying ZERO patterns by design. - profile_
dump - Print and reset the unified profile tree. Safe to call when profiling was off (prints a single “disabled” line).
- profile_
reset - Discard all accumulated counters without printing (warm-up between runs).
- regex_
dfa_ limit_ default - The compiled-default per-regex DFA size limit ([
REGEX_SIZE_LIMIT_BYTES]): the cap that takes effect when no--regex-dfa-limit/regex_dfa_limitoverride is set. Exposed sokeyhog config --effectivecan report the real active default instead of a misleading “off” - an unset limit is never truly off, it falls back to this compiled cap. - set_
gpu_ batch_ input_ limit - Override the GPU batch input limit for this process. Call before scanning.
0resets to the VRAM-adaptive default; any other value is clamped intogpu_batch_input_limit_boundsat read time. Tier-A config knob (compiled default -> TOML -> CLI), the sizing analogue ofcrate::types::set_regex_dfa_limit. - set_
perf_ trace_ enabled - Enable or disable low-level phase timing traces for this process.
- set_
profile_ enabled - Enable or disable the scanner’s detailed diagnostic profile collector.
- set_
regex_ dfa_ limit - Override the per-regex DFA size limit for this process. Call before scanning.
0resets to the compiled default. Tier-A config knob (default → TOML → CLI).
Type Aliases§
- Result
- Specialized Result type for scanning operations.