1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! A process-global redaction hook (#456 H5).
//!
//! Secrets are resolved on raw config text long before they become typed values,
//! so the CLI tracks the resolved *values* in `cli::secrets::registry` and scrubs
//! them from anything it emits. `faucet-core` cannot see that registry — it has
//! no secrets layer and must not gain one — yet core is where two outbound
//! surfaces are built:
//!
//! - the **DLQ envelope**'s `error.message` ([`crate::dlq::build_envelope`]),
//! which is written to a file or object store, and
//! - any error text a host application forwards onward.
//!
//! An error string routinely embeds the material that produced it: `reqwest`'s
//! `Display` includes the request URL, so a REST source whose API key rides a
//! query parameter leaks the key; connection-string leakage in a CDC error has
//! already been a filed bug here (#84).
//!
//! So core exposes a hook: a host installs a scrubber once at startup, and core
//! routes outbound text through [`redact`]. With no hook installed, [`redact`] is
//! the identity function and costs one atomic load — library users who never
//! resolve secrets pay nothing and see no behaviour change.
use OnceLock;
/// A scrubber: takes text, returns it with every known secret replaced.
pub type Redactor = ;
/// Install the process-wide redactor. The **first** call wins; later calls are
/// ignored and return `false`, so a second `install_observability` (or a test
/// that runs after one) can never swap the scrubber out from under a run.
/// Whether a redactor has been installed.
/// Scrub `text` with the installed redactor, or return it unchanged when none is
/// installed.
///
/// Call this on every string core hands to a destination outside the process.