Qubit Redact
Qubit Redact prevents sensitive values from leaking through Rust diagnostics:
logs, Debug output, process arguments, environment variables, and optional
HTTP traces. Define immutable policies once, then render typed results at an
explicit log-safe boundary.
Why Qubit Redact
- One policy model classifies named fields across scalar values, maps, domain objects, process diagnostics, and optional HTTP data.
- Typed results distinguish redacted values from text that is safe to write to a plain-text log.
- Malformed or truncated structured HTTP input fails closed, and diagnostic budgets bound inspection, output, and disclosure.
- The default feature set is empty; the core crate has no external runtime dependencies.
Quick Start
[]
= "0.3"
use ;
The original value remains available to application logic. Call
escape_for_log() before writing a scalar result to a plain-text log sink.
Choose a Tool
| Diagnostic input | Tool | Result and logging boundary |
|---|---|---|
| Named scalar value | Redactor::redact |
RedactedText; call escape_for_log() for plain-text logs. |
| Text-keyed map | Redactor::redact_map or redact_map_in_place |
A copied or mutated map; apply the final logging format yourself. |
| Rust struct or enum | Redact derive |
Borrowed Redacted<T> view with safe formatting. |
| Value that must be logically replaced | RedactMut derive |
Mutated value; this is not memory erasure. |
| Command arguments | ArgvRedactor |
RedactedArgv, safe to display. |
| Environment pairs | EnvRedactor |
RedactedEnvPair or LogSafeText. |
| URL, form, headers, or captured body | HttpRedactor |
Bounded, log-safe HTTP result types. |
Cargo Features
| Need | Cargo configuration |
|---|---|
| Core scalar, map, process, and text support | qubit-redact = "0.3" |
| Domain-object derives | Add qubit-redact-derive = "0.3". |
| Serialize redacted views | Enable serde and declare serde directly. |
Redact serde_json::Value or JSON text fields |
Enable json; add serde_json directly when your application uses it. |
| HTTP diagnostics | Enable http; add http directly when your application uses its types. |
[]
# HTTP diagnostics only
= { = "0.3", = ["http"] }
= "1.4"
Safety Boundaries
- Unknown field names pass through by default. Set
UnknownFieldPolicy::Redact(Sensitivity::Secret)when a boundary must mask every unclassified field;classify_field()still reportsUnknown. - Allow rules intentionally win and can disclose data. Prefer exact allow rules and treat each one as a security decision.
RedactedTextis not displayable by design. Redaction and log escaping are separate guarantees.RedactMutreplaces logical values only. It does not erase released allocations, aliases, copies, or borrowed backing storage.- HTTP redaction accepts only caller-provided captures. It never reads or buffers a network body itself.
Learn More
- English User Guide and 中文用户手册
- Runtime API documentation
- Derive crate README for field attributes and serde support
- Derive crate API documentation
Testing
# Run tests with the default feature set
# Run tests with all declared features
# Project CI checks
# Check code coverage
License
Copyright (c) 2025 - 2026. Haixing Hu. All rights reserved.
Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
Contributing
Contributions are welcome. Please follow the Rust API guidelines, keep public
API documentation and tests current, and run ./align-ci.sh to format code and
./ci-check.sh to satisfy CI requirements before submitting a pull request.
Author
Haixing Hu - Qubit Co. Ltd.
Repository: https://github.com/qubit-ltd/rs-redact