MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / from_bypass

Method from_bypass

crates/openshell-ocsf/src/objects/process.rs:56–73  ·  view source on GitHub ↗
(binary: &str, pid: &str, ancestors: &str)

Source from the content-addressed store, hash-verified

54 /// Parses an ancestors string like "bash -> node" into a parent chain.
55 #[must_use]
56 pub fn from_bypass(binary: &str, pid: &str, ancestors: &str) -> Self {
57 let pid = pid.parse::<i64>().unwrap_or(0);
58 let mut proc = Self::new(binary, pid);
59
60 // Parse ancestor chain "grandparent -> parent" into nested parent_process
61 let parts: Vec<&str> = ancestors.split(" -> ").collect();
62 if parts.len() >= 2 {
63 let mut parent = Self::new(parts[parts.len() - 1], 0);
64 for ancestor in parts[..parts.len() - 1].iter().rev() {
65 parent = Self::new(ancestor, 0).with_parent(parent);
66 }
67 proc.parent_process = Some(Box::new(parent));
68 } else if !ancestors.is_empty() && ancestors != binary {
69 proc.parent_process = Some(Box::new(Self::new(ancestors, 0)));
70 }
71
72 proc
73 }
74}
75
76/// OCSF Actor object — the entity that initiated the event.

Callers

nothing calls this directly

Calls 3

lenMethod · 0.80
with_parentMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected