Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
kingfisher-scanner
Embeddable, synchronous secret detection for Rust 1.96+. The 1.x public Rust API
follows semantic versioning; breaking changes require a new major version.
[]
= "1.0.0"
= "1"
Quick start
Load and compile once, then reuse the scanner. Scanning does not contact providers, validate credentials, revoke credentials, or initialize an async runtime.
use Arc;
use ;
Custom rules and configuration
use Arc;
use ;
let rule = new;
let database = new;
let scanner = with_config;
let findings = scanner.scan_bytes?;
assert_eq!;
assert_eq!;
# Ok::
Use scan_file(path)?, scan_blob(&blob)?, or scan_blob_at_path(&blob, source_path)?
when scanning files or applying path-aware rules. Errors propagate; an empty successful
result means no findings for that call, subject to configured filters and deduplication.
Scanner and RulesDatabase are Send + Sync. Share a scanner with Arc across worker
threads. Each thread gets its own native scratch space. In async applications, schedule
CPU-bound scanning on blocking workers. Callbacks into ScannerPool::try_with must not
recursively borrow the same pool on the same thread; this returns an error.
Behavior contract
- Defaults: Base64 detection enabled (one decoding layer), redaction disabled, cross-call deduplication disabled, rule-defined entropy thresholds.
enable_dedupsuppresses previously reported content at the same source path. Concurrent first scans may both return findings. This cache grows untilreset_dedup()or scanner drop; leave it disabled for independent requests.- UTF-16/32 content is normalized to UTF-8. Offsets and byte columns refer to the normalized content, with zero-based offsets/columns and one-based lines. Base64 locations cover the encoded region, not the decoded secret's byte position.
redact_secretsreplaces the secret and every returned capture value with[REDACTED]. Fingerprints are computed before redaction. This does not zeroize caller-owned input or turn findings into non-sensitive data.- Results may include invisible component helpers. Filter with
finding.rule().visible()for user-facing reports. - Finding order, numeric fingerprints, native cache formats, and built-in detector contents are not persistent storage contracts. Catalog updates may change findings.
- The detector applies candidate rules, filters, entropy, and component requirements. It is not the CLI's complete repository traversal, reporting, or live validation pipeline.
Optional validation
No validator features are enabled by default. Enable only the protocols needed:
= { = "1.0.0", = ["validation-http"] }
validation aliases validation-http. Other features are validation-raw,
validation-grpc, validation-ethereum, validation-aws, validation-azure, validation-coinbase,
validation-gcp, validation-jwt, and validation-database. validation-all
enables all validators and their dependencies. Enabling a feature exposes validation
functions; it does not make Scanner perform network requests automatically.
Validation clients and runtime lifecycles are managed by the embedding application.
Vectorscan is a native dependency. Its build may download a platform archive;
compiling the embedded rule catalog does not download rules. For offline builds,
prepare VECTORSCAN_PREBUILT_DIR or HYPERSCAN_ROOT and set VECTORSCAN_OFFLINE=1.
See the repository's library guide
for versioning, deployment, and migration details.
Scan and validate
Enable validation-http for the high-level API. Add provider features as needed,
or validation-all for all supported families. Keep raw findings until validation
finishes and pass the full result set so hidden supporting credentials are available.
#
# async
For one independent finding, use validator.validate_finding(&finding).await.
For one finding with supporting credentials, use
validate_finding_with_context(&finding, &same_input_findings).
ValidatedFinding pairs the original finding with its outcome, optional reason,
and HTTP status. Its debug output omits credentials; it deliberately does not
implement serialization. into_redacted() redacts secret and capture values.
Validators are cloneable and share their concurrency limit. Defaults use strict
TLS, no redirects, and block internal addresses. Inject an HTTP client with
client(...), trusted endpoint variables with variable(...), and opt into local
services with allow_internal_ips(true). SDK/database/gRPC transports retain their
own clients; the outer deadline applies to all families. See the library guide for
association rules and outcome semantics.
Runnable examples
From the repository checkout:
The packaged scan_content example is also available
in the crate source.
Scan a real file with the built-in catalog, or exercise explicitly enabled local validation:
These examples avoid network validation and print no unredacted secrets.
More complete integrations (all included in the crate source):
| Example | Demonstrates |
|---|---|
scan_files |
File batches, path-aware detection, JSON Lines reports without credentials |
scan_custom_rules |
Load private YAML/TOML rules and scan a file |
scan_async |
Shared scanner, Tokio blocking workers, bounded concurrency |
http_validation |
Scan and validate against a loopback mock with Validator |
validate_file |
Scan a file with built-ins and validate against actual providers |
The HTTP example uses a local mock with synthetic credentials. It checks active,
rejected, rate-limited, and unexpected-success responses without contacting a provider.
Keep raw findings until validation finishes, then report only selected metadata;
redact_secrets: true before validation replaces the token the validator needs.
Use Validator to dispatch enabled rule families and bind supporting credentials.
It uses the same validation::ValidationEngine as CLI scans and direct validate.
The engine owns protocol dispatch and outcome classification; applications own input
association, concurrency, and reporting. Advanced callers with resolved Liquid globals
can call the engine directly. Its ValidationResult::response_body may contain
credentials and is omitted from Debug output. Prefer the high-level finding API for
ordinary integrations. .retries(n) enables YAML HTTP retries within the total deadline.
Disabled features, missing or ambiguous components, redacted inputs, and timeouts
produce explicit outcomes and credential-free reasons.
See the integration recipes for copyable dependency manifests and instructions for adapting each example.