ignition_core/deploy/
mod.rs1pub mod apply;
13pub mod exclude;
14pub mod layout;
15pub mod ledger;
16pub mod lint;
17pub mod manifest;
18pub mod node;
19#[cfg(any(windows, test))]
20pub(crate) mod owner_acl;
21pub mod pair;
22pub mod plan;
23pub mod project_artifact;
24pub mod project_tags;
25pub mod projects;
26pub mod pull;
27pub mod render;
28pub mod rules;
29pub mod target;
30pub mod transport;
31pub mod tree;
32pub mod uuid;
33pub mod verify;
34pub mod yamlio;
35
36pub fn component_problem(name: &str) -> Option<&'static str> {
43 if name.is_empty() {
44 Some("must not be empty")
45 } else if name == "." || name == ".." {
46 Some("must not be `.` or `..`")
47 } else if name.contains('/') || name.contains('\\') {
48 Some("must not contain a path separator")
49 } else if name.contains('\0') {
50 Some("must not contain a NUL byte")
51 } else if name.starts_with('.') {
52 Some("must not start with `.`")
53 } else {
54 None
55 }
56}
57
58#[cfg(test)]
59mod tests {
60 use super::component_problem;
61
62 #[test]
63 fn safe_names_pass() {
64 for ok in ["prod", "gw-1", "my_gateway", "a.b", "Ignition 8"] {
65 assert_eq!(component_problem(ok), None, "{ok}");
66 }
67 }
68
69 #[test]
70 fn unsafe_names_are_refused() {
71 for bad in [
72 "", ".", "..", "a/b", "a\\b", "a\0b", ".hidden", "../x", "/abs",
73 ] {
74 assert!(component_problem(bad).is_some(), "{bad:?}");
75 }
76 }
77}