Skip to content

Commit

Permalink
revocation: Parse revocation actions flexibly
Browse files Browse the repository at this point in the history
Make the accepted list format more flexible by parsing with the
keylime::list_parser.

Fixes: #489, #440

Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
  • Loading branch information
ansasaki committed Jun 26, 2023
1 parent 9f3ed54 commit a780c6d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions keylime-agent/src/revocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::config::{AgentConfig, KeylimeConfig};
use crate::crypto;
use crate::error::*;
use crate::secure_mount;
use keylime::list_parser::parse_list;
use log::*;
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down Expand Up @@ -196,11 +197,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::<Vec<&str>>();
let mut action_list = parse_list(&actions)?;
let action_data;
let unzipped = mount.join("unzipped");
let action_file = unzipped.join("action_list");
Expand All @@ -209,10 +206,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 {
Expand Down Expand Up @@ -240,7 +234,7 @@ fn run_revocation_actions(
);
error!("{}", msg);
return Err(Error::Script(
String::from(action),
action.to_string(),
e.exe_code()?,
e.stderr()?,
));
Expand Down

0 comments on commit a780c6d

Please sign in to comment.