pub struct ObservationOptions {
pub subject_ref: String,
pub observed_at: Option<String>,
pub probe_security_principal: bool,
pub include_namespace_context_digest: bool,
pub include_executable_digest: bool,
pub include_arguments_digest: bool,
pub include_security_context_digest: bool,
}Expand description
Disclosure and probe budget options for observe_process and open_continuity_handle.
By default, probe_security_principal is true and all four digest context
facts (namespace_context_digest, executable_digest, arguments_digest,
security_context_digest) are false (status: "not-probed").
Fields§
§subject_ref: StringReport-local process subject ID (^[a-z][a-z0-9-]{0,63}$, default "process-target").
observed_at: Option<String>Optional explicit UTC timestamp (YYYY-MM-DDTHH:MM:SSZ); defaults to current system UTC time.
probe_security_principal: boolProbe execution_context.security_principal (default true).
include_namespace_context_digest: boolOpt in to execution_context.namespace_context_digest (default false).
include_executable_digest: boolOpt in to execution_context.executable_digest (default false).
include_arguments_digest: boolOpt in to execution_context.arguments_digest (default false).
include_security_context_digest: boolOpt in to execution_context.security_context_digest (default false).
Implementations§
Source§impl ObservationOptions
impl ObservationOptions
Sourcepub fn with_all_context_facts(self) -> Self
pub fn with_all_context_facts(self) -> Self
Enable all opt-in execution-context facts supported by the platform.
Examples found in repository?
14fn main() -> ExitCode {
15 let mut args = std::env::args().skip(1);
16 let mut pid: Option<u32> = None;
17 let mut observed_at: Option<String> = None;
18 let mut subject_ref = String::from("process-target");
19 let mut all_context = false;
20 let mut host_id_ref = Some(String::from("id-host-local"));
21 let mut host_ns = String::from("urn:3leaps:identity-evidence:host-scope:test-fixture:v0");
22 let mut host_val = String::from("local-qualification-host");
23 let mut host_deriv_id =
24 String::from("urn:3leaps:identity-evidence:derivation:caller-supplied-host-scope:v0");
25 let mut host_deriv_rev = String::from(DEFAULT_DERIVATION_REV);
26 let mut host_stability = String::from("boot");
27 let mut host_clone = String::from("regenerated");
28
29 while let Some(arg) = args.next() {
30 match arg.as_str() {
31 "--pid" => {
32 let Some(raw) = args.next() else {
33 eprintln!("error: --pid requires a numeric value");
34 return ExitCode::from(2);
35 };
36 match raw.parse::<u32>() {
37 Ok(v) => pid = Some(v),
38 Err(_) => {
39 eprintln!("error: invalid --pid value: {raw}");
40 return ExitCode::from(2);
41 }
42 }
43 }
44 "--observed-at" => {
45 let Some(v) = args.next() else {
46 eprintln!("error: --observed-at requires a value");
47 return ExitCode::from(2);
48 };
49 observed_at = Some(v);
50 }
51 "--subject-ref" => {
52 let Some(v) = args.next() else {
53 eprintln!("error: --subject-ref requires a value");
54 return ExitCode::from(2);
55 };
56 subject_ref = v;
57 }
58 "--all-context" => {
59 all_context = true;
60 }
61 "--no-host-id-ref" => {
62 host_id_ref = None;
63 }
64 "--host-id-ref" => {
65 let Some(v) = args.next() else {
66 eprintln!("error: --host-id-ref requires a value");
67 return ExitCode::from(2);
68 };
69 host_id_ref = Some(v);
70 }
71 "--host-namespace" => {
72 let Some(v) = args.next() else {
73 eprintln!("error: --host-namespace requires a value");
74 return ExitCode::from(2);
75 };
76 host_ns = v;
77 }
78 "--host-value" => {
79 let Some(v) = args.next() else {
80 eprintln!("error: --host-value requires a value");
81 return ExitCode::from(2);
82 };
83 host_val = v;
84 }
85 "--host-derivation-id" => {
86 let Some(v) = args.next() else {
87 eprintln!("error: --host-derivation-id requires a value");
88 return ExitCode::from(2);
89 };
90 host_deriv_id = v;
91 }
92 "--host-derivation-rev" => {
93 let Some(v) = args.next() else {
94 eprintln!("error: --host-derivation-rev requires a value");
95 return ExitCode::from(2);
96 };
97 host_deriv_rev = v;
98 }
99 "--host-stability" => {
100 let Some(v) = args.next() else {
101 eprintln!("error: --host-stability requires a value");
102 return ExitCode::from(2);
103 };
104 host_stability = v;
105 }
106 "--host-clone-behavior" => {
107 let Some(v) = args.next() else {
108 eprintln!("error: --host-clone-behavior requires a value");
109 return ExitCode::from(2);
110 };
111 host_clone = v;
112 }
113 other => {
114 eprintln!("error: unrecognized flag {other}");
115 return ExitCode::from(2);
116 }
117 }
118 }
119
120 let Some(target_pid) = pid else {
121 eprintln!("error: --pid <1..=2147483647> is required");
122 return ExitCode::from(2);
123 };
124
125 let host_scope = HostScope {
126 identifier_ref: host_id_ref,
127 namespace: host_ns,
128 value: host_val,
129 derivation: ProfileRef::new(host_deriv_id, host_deriv_rev),
130 stability: host_stability,
131 clone_behavior: host_clone,
132 };
133
134 let mut options = ObservationOptions {
135 subject_ref,
136 observed_at,
137 ..ObservationOptions::default()
138 };
139 if all_context {
140 options = options.with_all_context_facts();
141 }
142
143 let obs = match observe_process(target_pid, &host_scope, &options) {
144 Ok(v) => v,
145 Err(refusal) => {
146 eprintln!("refused:{refusal}");
147 return ExitCode::from(1);
148 }
149 };
150
151 let raw = match serde_json::to_vec(&obs) {
152 Ok(b) => b,
153 Err(e) => {
154 eprintln!("serialization-error:{e}");
155 return ExitCode::from(1);
156 }
157 };
158 let admitted = match admit_report_bytes(&raw) {
159 Ok(a) => a,
160 Err(e) => {
161 eprintln!("canonicalization-error:{e}");
162 return ExitCode::from(1);
163 }
164 };
165
166 let mut out = std::io::stdout().lock();
167 if out.write_all(&admitted.canonical_bytes).is_err() || out.write_all(b"\n").is_err() {
168 return ExitCode::from(1);
169 }
170 ExitCode::SUCCESS
171}Trait Implementations§
Source§impl Clone for ObservationOptions
impl Clone for ObservationOptions
Source§impl Debug for ObservationOptions
impl Debug for ObservationOptions
Source§impl Default for ObservationOptions
impl Default for ObservationOptions
impl Eq for ObservationOptions
Source§impl PartialEq for ObservationOptions
impl PartialEq for ObservationOptions
impl StructuralPartialEq for ObservationOptions
Auto Trait Implementations§
impl Forget for ObservationOptions
impl Freeze for ObservationOptions
impl RefUnwindSafe for ObservationOptions
impl Send for ObservationOptions
impl Sync for ObservationOptions
impl Unpin for ObservationOptions
impl UnsafeUnpin for ObservationOptions
impl UnwindSafe for ObservationOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.