fix(push-model): resolve hash_ek uuid to actual EK hash#1176
fix(push-model): resolve hash_ek uuid to actual EK hash#1176ansasaki merged 1 commit intokeylime:masterfrom
Conversation
e5faf2f to
75e65af
Compare
|
I'm testing the push-model agent setup in k8s and we're using hash_ek UUIDs. Found this implementation gap between push-model agent and pull-model agent. PTAL @ansasaki @sarroutbi @sergio-correia |
sarroutbi
left a comment
There was a problem hiding this comment.
- Centralize the UUID Resolution (DRY Principle)
You currently have the "if hash_ek then ek_hash" logic duplicated in both main.rs and registration.rs.
Risk: If the logic for resolving identifiers changes (e.g., adding support for a new dynamic ID type), you have to update it in two places.
Suggestion: Add a helper method to the ContextInfo struct (in keylime/src/context_info.rs) or a local helper in the agent to resolve the identifier.
Example Helper:
fn resolve_agent_id(config_uuid: &str, ctx_info: &ContextInfo) -> String {
if config_uuid == "hash_ek" {
ctx_info.ek_hash.clone()
} else {
config_uuid.to_string()
}
}
- Case Sensitivity and Whitespace
The current check config.uuid() == "hash_ek" is very strict. Users occasionally add trailing spaces in config files or use capital letters.
Suggestion: Use .trim().to_lowercase() to make the configuration more resilient.
let uuid_config = config.uuid().trim().to_lowercase();
if uuid_config == "hash_ek" { ... }
0f629d5 to
9f3a9b1
Compare
|
Thanks for the review @sarroutbi. Updated and rebased. |
|
/packit test |
|
LGTM. It would probably be nice to have some test for the new |
Packit had an outage during the night and now it is processing the queue. |
I will add tests in follow-up, no problem. |
|
The error on Fedora 42 looks unrelated (core dump on mariadb): |
When uuid config is set to 'hash_ek', the push model agent now correctly uses the computed ek_hash from the TPM context info instead of the literal string 'hash_ek'. This aligns the push model agent behavior with the regular agent which already handles this case in keylime-agent/src/main.rs. Signed-off-by: Tuomo Tanskanen <tuomo.tanskanen@est.tech>
9f3a9b1 to
34c4337
Compare
|
Fixed @ansasaki's trim() comments, and rebased. |
Codecov Report❌ Patch coverage is Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@tuminoid Thank you for your contribution! |
Thanks for quick reviews @ansasaki, @sergio-correia and @sarroutbi ! I will follow-up with unit tests for the new util function. |
When uuid config is set to 'hash_ek', the push model agent now correctly uses the computed ek_hash from the TPM context info instead of the literal string 'hash_ek'.
This aligns the push model agent behavior with the regular agent which already handles this case in keylime-agent/src/main.rs.