Skip to content

Commit

Permalink
revocation: Parse revocation actions flexibly
Browse files Browse the repository at this point in the history
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: keylime#489, keylime#440

Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
  • Loading branch information
ansasaki committed Jun 13, 2023
1 parent 6691c72 commit 72a996c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions keylime-agent/src/revocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<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 +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 {
Expand Down

0 comments on commit 72a996c

Please sign in to comment.