We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b7969e1 + cf63b9a commit 9f5c87dCopy full SHA for 9f5c87d
1 file changed
vmm/src/main_service.rs
@@ -51,13 +51,17 @@ fn app_id_of(compose_file: &str) -> String {
51
truncate40(&hex_sha256(compose_file)).to_string()
52
}
53
54
-/// Validate the label of the VM. Valid chars are alphanumeric, dash and underscore.
+/// Validate the VM label, restricting it to a safe character set to prevent injection vectors.
55
fn validate_label(label: &str) -> Result<()> {
56
- if label
57
- .chars()
58
- .any(|c| !c.is_alphanumeric() && c != '-' && c != '_')
59
- {
60
- bail!("Invalid name: {}", label);
+ fn is_valid_label_char(c: char) -> bool {
+ c.is_ascii_alphanumeric()
+ || matches!(
+ c,
+ '-' | '_' | '.' | ' ' | '@' | '~' | '!' | '$' | '^' | '(' | ')'
61
+ )
62
+ }
63
+ if !label.chars().all(is_valid_label_char) {
64
+ bail!("Invalid name: {label}");
65
66
Ok(())
67
0 commit comments