Skip to main content

check_session_path

Function check_session_path 

Source
pub fn check_session_path(p: &str, source: &str) -> Result<(), String>
Expand description

Classify a session-path value: does it look like a key=value workload-param token (e.g. scenario=foo) rather than a real filesystem path? The umbrella --session <kv> parser splits only on :, so a =-shaped token slipping into the path slot would silently materialise directories like <cwd>/scenario=foo/....

Heuristic: the head of head=tail matches the workload- param ABNF (alphanumeric / underscore / hyphen, no slash). A real path like /var/tmp/k=v keeps a leading slash in the head and passes through unchanged. Leading ./ or ../ likewise excludes the head from the param-shape check (the head contains a /).

Returns Err(<error message>) when the value should be rejected; Ok(()) when it’s safe to use as a session path.