Port sq key approvals list to the user ID designator framework.
- See #434.
This commit is contained in:
parent
b203dacd00
commit
c7795149c2
@ -13,6 +13,8 @@ use crate::cli::types::FileOrStdout;
|
|||||||
|
|
||||||
use crate::cli::examples::*;
|
use crate::cli::examples::*;
|
||||||
use crate::cli::types::cert_designator::*;
|
use crate::cli::types::cert_designator::*;
|
||||||
|
use crate::cli::types::UserIDDesignators;
|
||||||
|
use crate::cli::types::userid_designator;
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
#[clap(
|
#[clap(
|
||||||
@ -99,29 +101,16 @@ pub struct ListCommand {
|
|||||||
OneValue,
|
OneValue,
|
||||||
ApprovalsListDoc>,
|
ApprovalsListDoc>,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
pub userids: UserIDDesignators<
|
||||||
|
userid_designator::ExistingUserIDEmailNameArgs,
|
||||||
|
userid_designator::OptionalValue>,
|
||||||
|
|
||||||
#[clap(
|
#[clap(
|
||||||
long = "pending",
|
long = "pending",
|
||||||
help = "List unapproved certifications",
|
help = "List unapproved certifications",
|
||||||
)]
|
)]
|
||||||
pub pending: bool,
|
pub pending: bool,
|
||||||
|
|
||||||
#[clap(
|
|
||||||
long = "name",
|
|
||||||
help = "List certifications on this name user ID",
|
|
||||||
)]
|
|
||||||
pub names: Vec<String>,
|
|
||||||
|
|
||||||
#[clap(
|
|
||||||
long = "email",
|
|
||||||
help = "List certifications on this email address user ID",
|
|
||||||
)]
|
|
||||||
pub emails: Vec<String>,
|
|
||||||
|
|
||||||
#[clap(
|
|
||||||
long = "userid",
|
|
||||||
help = "List certifications on this user ID",
|
|
||||||
)]
|
|
||||||
pub userids: Vec<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Documentation for the cert designators for the key approvals list
|
/// Documentation for the cert designators for the key approvals list
|
||||||
|
@ -25,15 +25,23 @@ pub fn dispatch(sq: Sq, command: approvals::Command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn list(sq: Sq, cmd: approvals::ListCommand) -> Result<()> {
|
fn list(sq: Sq, cmd: approvals::ListCommand) -> Result<()> {
|
||||||
let cert =
|
|
||||||
sq.resolve_cert(&cmd.cert, sequoia_wot::FULLY_TRUSTED)?.0;
|
|
||||||
|
|
||||||
let vcert = cert.with_policy(sq.policy, sq.time)?;
|
|
||||||
let store = sq.cert_store_or_else()?;
|
let store = sq.cert_store_or_else()?;
|
||||||
|
|
||||||
let uid_filter = make_userid_filter(
|
let cert =
|
||||||
&cmd.names, &cmd.emails, &cmd.userids)?;
|
sq.resolve_cert(&cmd.cert, sequoia_wot::FULLY_TRUSTED)?.0;
|
||||||
for uid in vcert.userids().filter(uid_filter) {
|
let vcert = cert.with_policy(sq.policy, sq.time)?;
|
||||||
|
let userids = cmd.userids.resolve(&vcert)?;
|
||||||
|
|
||||||
|
// resolve returns ResolvedUserIDs, which contain UserIDs, but we
|
||||||
|
// need ValidUserIDAmalgamations.
|
||||||
|
let all = userids.is_empty();
|
||||||
|
let mut designated_userids = BTreeSet::from_iter(
|
||||||
|
userids.into_iter().map(|u| u.userid().clone()));
|
||||||
|
for uid in vcert.userids() {
|
||||||
|
if ! all && ! designated_userids.remove(uid.userid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
wprintln!(initial_indent = " - ", "{}",
|
wprintln!(initial_indent = " - ", "{}",
|
||||||
String::from_utf8_lossy(uid.value()));
|
String::from_utf8_lossy(uid.value()));
|
||||||
|
|
||||||
@ -89,6 +97,7 @@ fn list(sq: Sq, cmd: approvals::ListCommand) -> Result<()> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert!(designated_userids.is_empty());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user