Improved logging for debugging offline attestation - #1
Conversation
|
|
||
| if let Ok(vcek_bytes) = result { | ||
| debug!("fetched vcek from {:?}", source); | ||
| let source_label = match source { |
There was a problem hiding this comment.
We can add the Display trait to VCEKSource to avoid having to do this match multiple times:
impl std::fmt::Display for VCEKSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
<put the match here>
}
https://doc.rust-lang.org/std/fmt/trait.Display.html
Then in these debugs you can just pass the variable
| return Err(anyhow!("FMC version mismatch")); | ||
| } | ||
|
|
||
| debug!("SNP TCB verification passed"); |
There was a problem hiding this comment.
This might be more opinion/personal, but I'm not certain the community will be into adding this much debug - especially for the success cases I think it's a bit excessive, based on what the rest of the repo does. I think the extra one for user-passed certs is useful, and enriching with more specific data is useful, but I think maybe evaluate some of these other ones if they are really needed?
There was a problem hiding this comment.
agree. Now that i think of it, success messages might be redundant.
3d5b96e to
b6ce10e
Compare
amd-aliem
left a comment
There was a problem hiding this comment.
Just a small conciseness suggestion, and the CI is failing (I think you need to do a clippy run or something), but looks good!
| @@ -175,10 +180,35 @@ impl Snp { | |||
| // default dir should contain the /vcek segment | |||
| let path = path.unwrap_or(KDS_OFFLINE_STORE_PATH.to_string()); | |||
| let hw_id = self.parse_hw_id_from_vcek(att_report, proc_gen.clone()); | |||
| // Truncate hw_id to first 8 hex chars for log output — sufficient for | |||
| // operator correlation without exposing the full hardware identifier. | |||
| let hw_id_prefix = &hw_id[..hw_id.len().min(8)]; | |||
| let vcek_path = format!("{}/vcek/{}/vcek.der", path, hw_id); | |||
| let vcek_bytes = std::fs::read(&vcek_path) | |||
| .with_context(|| format!("Failed to read VCEK from offline store at {}", vcek_path))?; | |||
| Ok(vcek_bytes) | |||
|
|
|||
| debug!( | |||
| "VCEK offline store lookup: hwId={}... store={}", | |||
| hw_id_prefix, path | |||
| ); | |||
|
|
|||
| match std::fs::read(&vcek_path) { | |||
| Ok(vcek_bytes) => { | |||
There was a problem hiding this comment.
I'm pretty sure this full hw_id is already shown in the logs (when fetching the KDS URL the hwid is in the path, and probably also in the attestation report as well). The comment somewhat implies it's for a security reason, which is why I'm pointing it out?
Also I think this debug that you added in the parent function above already covers the success case:
if let Ok(vcek_bytes) = result {
debug!("fetched vcek from {:?}", source);
info!("VCEK fetched successfully from {}", source);
return Ok(vcek_bytes);
}
So you can probably just add debug for the failure case here to avoid adding a lot of lines of debug code:
let vcek_path = format!("{}/vcek/{}/vcek.der", path, hw_id);
std::fs::read(&vcek_path)
.inspect_err(|e| debug!("VCEK offline store miss: {vcek_path}: {e}"))
.with_context(|| format!("Failed to read VCEK from {vcek_path}"))
4b24c5c to
a7db003
Compare
f9c461f to
540908e
Compare
Signed-off-by: Harshitha Gowda <hgowda@amd.com>
540908e to
c8de39a
Compare
Added clear logs for when: