nix: Key names can contain one path component only

Well, I changed my mind and this should be cleaner.
This commit is contained in:
Zhaofeng Li 2021-02-10 18:17:49 -08:00
parent 28b635a6e8
commit 2886662e18

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::convert::TryFrom;
use std::path::{Component as PathComponent, Path};
use std::path::Path;
use std::process::Stdio;
use async_trait::async_trait;
@ -219,10 +219,8 @@ fn validate_keys(keys: &HashMap<String, Key>) -> Result<(), ValidationErrorType>
return Err(ValidationErrorType::new("Secret key name cannot be absolute"));
}
for component in path.components() {
if component == PathComponent::ParentDir {
return Err(ValidationErrorType::new("Secret key name cannot refer to parent directory"));
}
if path.components().collect::<Vec<_>>().len() != 1 {
return Err(ValidationErrorType::new("Secret key name cannot contain path separators"));
}
}
Ok(())