From 72a996c7f694221cd6d8ee4d83a92ee0b8b11cbe Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Tue, 13 Jun 2023 14:57:14 +0200 Subject: [PATCH] revocation: Parse revocation actions flexibly The revocation_actions and revocation actions list file accepted only a single format of list. Make the accepted list format more flexible by accepting: * comma separated strings * space separated strings * newline separated strings * quoted or unquoted strings * list inside square brackets or not Fixes: #489, #440 Signed-off-by: Anderson Toshiyuki Sasaki --- keylime-agent/src/revocation.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/keylime-agent/src/revocation.rs b/keylime-agent/src/revocation.rs index 37a7d0882..fa5c55e44 100644 --- a/keylime-agent/src/revocation.rs +++ b/keylime-agent/src/revocation.rs @@ -3,7 +3,7 @@ #[macro_use] use actix_web::rt; -use crate::config::{AgentConfig, KeylimeConfig}; +use crate::config::{parse_list, AgentConfig, KeylimeConfig}; use crate::crypto; use crate::error::*; use crate::secure_mount; @@ -196,11 +196,7 @@ fn run_revocation_actions( // The actions from the configuration file takes precedence over the actions from the // actions_list file let actions = config_actions.unwrap_or_default(); - let mut action_list = actions - .split(',') - .map(|script| script.trim()) - .filter(|script| !script.is_empty()) - .collect::>(); + let mut action_list = parse_list(&actions); let action_data; let unzipped = mount.join("unzipped"); let action_file = unzipped.join("action_list"); @@ -209,10 +205,7 @@ fn run_revocation_actions( action_data = std::fs::read_to_string(&action_file) .expect("unable to read action_list"); - let file_actions = action_data - .split('\n') - .map(|script| script.trim()) - .filter(|script| !script.is_empty()); + let file_actions = parse_list(&action_data); action_list.extend(file_actions); } else {