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
//! The posture registry: every security opt-out the process has taken (ADR 0013 R10).
//!
//! Secure by default means the safe behaviour needs no code and every weakening has a name. Each
//! `dangerous_*` / `insecure_*` API in the workspace calls [`record_dangerous`] when the opt-out
//! is taken (a builder method, a constructor, a config switch), with a stable `id` (the API's
//! path, `"<crate>::<Type>::dangerous_<what>"`) and `reopens`, one sentence
//! naming the finding or risk the opt-out brings back. [`dangerous_opt_outs`] lists what was
//! recorded; the prod posture check reads it and refuses to start with an opt-out the operator has
//! not accepted.
//!
//! The registry is process-wide and records each id once: the first `reopens` text wins and later
//! calls with the same id are no-ops, so an opt-out taken per request still costs one map lookup,
//! not one entry. Nothing is allocated until the first call; a process that never opts out pays
//! nothing, and [`dangerous_opt_outs`] is then empty.
//!
//! ```
//! use id_effect::observability::posture::{dangerous_opt_outs, record_dangerous};
//!
//! record_dangerous("example::insecure_plaintext", "transport is neither encrypted nor authenticated");
//! record_dangerous("example::insecure_plaintext", "ignored: recorded once");
//! let found = dangerous_opt_outs();
//! assert!(found.contains(&("example::insecure_plaintext", "transport is neither encrypted nor authenticated")));
//! ```
use BTreeMap;
use ;
static OPT_OUTS: = new;
/// Records that the process took the dangerous opt-out `id`, which reopens `reopens`.
///
/// The hook every `dangerous_*` / `insecure_*` API calls. Records once per `id`, process-wide;
/// the first `reopens` text is kept.
/// The opt-outs recorded so far, as `(id, reopens)` pairs sorted by id (empty if none).