Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
verifier: tdx: Allow equals in kernel param values
Browse files Browse the repository at this point in the history
Allow kernel parameter values to contain equal signs, for example:

```
module_foo=bar=baz,wibble_setting=2
```

Fixes: #163.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Nov 16, 2023
1 parent 9605dbd commit 4af4ceb
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions attestation-service/src/verifier/tdx/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,11 @@ fn parse_kernel_parameters(kernel_parameters: &[u8]) -> Result<Map<String, Value
if item.is_empty() {
return None;
}
let it: Vec<&str> = item.split('=').collect();
match it.len() {
1 => Some((it[0].to_owned(), Value::Null)),
2 => Some((it[0].to_owned(), Value::String(it[1].to_owned()))),
_ => {
warn!("Illegal parameter: {item}");
None
}
let it = item.split_once('=');

match it {
Some((k, v)) => Some((k.into(), v.into())),
None => Some((item.to_string(), Value::Null)),
}
})
.collect();
Expand Down Expand Up @@ -410,42 +407,45 @@ mod tests {
),
],
},
// Params containing equals in their values are silently dropped
TestData {
params: b"a==",
fail: false,
result: vec![],
result: vec![("a".into(), to_value("=").unwrap())],
},
TestData {
params: b"a==b",
fail: false,
result: vec![],
result: vec![("a".into(), to_value("=b").unwrap())],
},
TestData {
params: b"a==b=",
fail: false,
result: vec![],
result: vec![("a".into(), to_value("=b=").unwrap())],
},
TestData {
params: b"a=b=c",
fail: false,
result: vec![],
result: vec![("a".into(), to_value("b=c").unwrap())],
},
TestData {
params: b"a==b=c",
fail: false,
result: vec![],
result: vec![("a".into(), to_value("=b=c").unwrap())],
},
TestData {
params: b"module_foo=bar=baz,wibble_setting=2",
fail: false,
result: vec![],
result: vec![(
"module_foo".into(),
to_value("bar=baz,wibble_setting=2").unwrap(),
)],
},
TestData {
params: b"a=b c== d=e",
fail: false,
result: vec![
("a".into(), to_value("b").unwrap()),
("c".into(), to_value("=").unwrap()),
("d".into(), to_value("e").unwrap()),
],
},
Expand Down

0 comments on commit 4af4ceb

Please sign in to comment.