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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Secrets a plugin needs before any front runs, such as the passphrase of
//! an encrypted session store, which opens before the session is restored.
//!
//! A plugin asks for one in `build` with `app.add_secret(..)`
//! ([`AppCliExt`](crate::host::cli::AppCliExt)) and reads it from
//! [`Secrets`], there from `build` on. The launcher learns what the build
//! asks for when it describes it ([`describe`](crate::describe)) and,
//! when stdin is a terminal, whatever the front, asks the user for each
//! one the environment does not hold, once per launcher, whatever the
//! restarts. A secret reaches the agent's process alone, as the variable
//! [`rig_harness_protocol::secret_variable`] of its name
//! (`RIG_SECRET_CRYPT`); a piped run gets only what the environment
//! has. A secret not given is `None`, and the plugin decides what then.
//!
//! No process rig starts gets a secret: not cargo or any other launcher
//! child, not `/reload`'s build, not a command started through
//! [`Processes`](crate::services::Processes) (the shell and every tool), not
//! the terminal view's editor. A plugin that starts a process with a bare
//! `std::process::Command` passes its secrets on: start processes with
//! `Processes`. What this protects from: tools, the model's commands,
//! build scripts and proc macros, and helper programs. What it does not:
//! the same user reading the agent's environment (`/proc/<pid>/environ`),
//! and plugin code, which is trusted as all Bevy plugin code is.
//!
//! ```
//! use rig_harness::prelude::*;
//!
//! #[derive(Default)]
//! struct CryptPlugin;
//!
//! impl Plugin for CryptPlugin {
//! fn build(&self, app: &mut App) {
//! app.add_secret(Secret::new("crypt", "Passphrase for this machine's sessions"));
//! let passphrase = app
//! .world()
//! .get_resource::<Secrets>()
//! .and_then(|secrets| secrets.get("crypt"))
//! .map(str::to_owned);
//! // Open the session store with it, or refuse to start without.
//! # drop(passphrase);
//! }
//! }
//! ```
use BTreeMap;
use fmt;
use *;
use ;
/// A secret a plugin asks for: its name, which names its variable, and
/// what the launcher asks.
/// The secrets this agent was given. The harness takes them from the
/// process's environment while it is built, unless the app inserted its
/// own, as a test does: `Secrets::from_iter([("crypt", "passphrase")])`.
/// Its `Debug` shows names only.
;
/// Secrets by name, such as a test's.