nix: Key names can contain one path component only
Well, I changed my mind and this should be cleaner.
This commit is contained in:
parent
28b635a6e8
commit
2886662e18
1 changed files with 3 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::path::{Component as PathComponent, Path};
|
use std::path::Path;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
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"));
|
return Err(ValidationErrorType::new("Secret key name cannot be absolute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for component in path.components() {
|
if path.components().collect::<Vec<_>>().len() != 1 {
|
||||||
if component == PathComponent::ParentDir {
|
return Err(ValidationErrorType::new("Secret key name cannot contain path separators"));
|
||||||
return Err(ValidationErrorType::new("Secret key name cannot refer to parent directory"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue