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 projects;
25pub mod pull;
26pub mod render;
27pub mod rules;
28pub mod target;
29pub mod transport;
30pub mod tree;
31pub mod uuid;
32pub mod verify;
33pub mod yamlio;
34
35pub fn component_problem(name: &str) -> Option<&'static str> {
42 if name.is_empty() {
43 Some("must not be empty")
44 } else if name == "." || name == ".." {
45 Some("must not be `.` or `..`")
46 } else if name.contains('/') || name.contains('\\') {
47 Some("must not contain a path separator")
48 } else if name.contains('\0') {
49 Some("must not contain a NUL byte")
50 } else if name.starts_with('.') {
51 Some("must not start with `.`")
52 } else {
53 None
54 }
55}
56
57#[cfg(test)]
58mod tests {
59 use super::component_problem;
60
61 #[test]
62 fn safe_names_pass() {
63 for ok in ["prod", "gw-1", "my_gateway", "a.b", "Ignition 8"] {
64 assert_eq!(component_problem(ok), None, "{ok}");
65 }
66 }
67
68 #[test]
69 fn unsafe_names_are_refused() {
70 for bad in [
71 "", ".", "..", "a/b", "a\\b", "a\0b", ".hidden", "../x", "/abs",
72 ] {
73 assert!(component_problem(bad).is_some(), "{bad:?}");
74 }
75 }
76}