[team] Team vaults: rustfmt on the files this change touches

This commit is contained in:
2026-11-17 12:15:18 +01:00
parent e3ede760bd
commit 3bb05bf6f1
8 changed files with 138 additions and 45 deletions
+42 -13
View File
@@ -565,7 +565,13 @@ impl Vault {
/// A new team vault with `founder` as its only member, the default policy, and no keys yet
/// ([`Vault::team_create_keys`]). The caller saves it where the team keeps it.
pub fn create_team(name: &str, founder: &MemberKey, founder_name: &str, handles: &[String], now: i64) -> Result<Vault, Error> {
pub fn create_team(
name: &str,
founder: &MemberKey,
founder_name: &str,
handles: &[String],
now: i64,
) -> Result<Vault, Error> {
let name = name.trim();
if !canon::text_ok(name, 64) || !canon::text_ok(founder_name.trim(), 64) || !handles_ok(handles) {
return Err(Error::Team("a team or member name is 1 to 64 printable characters".into()));
@@ -749,7 +755,13 @@ impl Vault {
}
let gone = t.members.remove(at);
t.epoch = t.epoch.checked_add(1).ok_or(Error::Corrupted)?;
t.removed.push(RemovedMember { id: gone.id.clone(), name: gone.name.clone(), at: now, by: by.into(), epoch: t.epoch });
t.removed.push(RemovedMember {
id: gone.id.clone(),
name: gone.name.clone(),
at: now,
by: by.into(),
epoch: t.epoch,
});
if t.policy.envs.iter().any(|r| r.approvers.contains(&gone.id)) {
for r in t.policy.envs.iter_mut() {
r.approvers.retain(|a| *a != gone.id);
@@ -793,7 +805,8 @@ impl Vault {
return Err(Error::Team("an approver is not a member".into()));
}
let env = rule.env.clone();
let detail = format!("{env}: {} approval(s){}", rule.approvals, if rule.others { ", not the author" } else { "" });
let detail =
format!("{env}: {} approval(s){}", rule.approvals, if rule.others { ", not the author" } else { "" });
t.policy.set_rule(rule).map_err(team_err)?;
t.sign_policy();
t.log(now, TeamAction::PolicySet, by, Some(detail));
@@ -854,7 +867,12 @@ impl Vault {
}
/// An Android key for one project (`apk`), scoped to it. Slow: RSA-4096. The caller saves.
pub fn team_create_android(&mut self, spec: &crate::signing::AndroidKey, by: &str, now: i64) -> Result<String, Error> {
pub fn team_create_android(
&mut self,
spec: &crate::signing::AndroidKey,
by: &str,
now: i64,
) -> Result<String, Error> {
self.team()?;
let id = self.signing_create_android(spec, now)?;
self.team_mut()?.log(now, TeamAction::KeysCreated, by, Some(id.clone()));
@@ -876,7 +894,9 @@ impl Vault {
|| new.secret.is_empty()
|| new.secret.expose().len() > MAX_SECRET
{
return Err(Error::Team("a target needs a name, a project, an environment and a credential (≤ 64 KiB)".into()));
return Err(Error::Team(
"a target needs a name, a project, an environment and a credential (≤ 64 KiB)".into(),
));
}
let id = short_id();
let name = new.name.trim().to_owned();
@@ -927,7 +947,12 @@ impl Vault {
/// request this team vault signed for the target's project and environment within 25 hours, and this
/// (target, deployment) was never released before. Returns the plaintext to seal to the request's key.
/// The caller saves.
pub fn team_target_release(&mut self, request: &str, by: &str, now: i64) -> Result<(Zeroizing<String>, TargetRequest), Error> {
pub fn team_target_release(
&mut self,
request: &str,
by: &str,
now: i64,
) -> Result<(Zeroizing<String>, TargetRequest), Error> {
let now_s = seconds(now);
let req = TargetRequest::check(request, now_s).map_err(team_err)?;
let signed: Vec<(String, String, i64)> = self
@@ -1068,7 +1093,13 @@ impl Vault {
/// A member approves without signing (the policy needs more): the statement to post. `shown_code` is the code
/// the card showed.
pub fn team_approve(&self, text: &str, key: &MemberKey, shown_code: &str, now: i64) -> Result<Statement, TeamError> {
pub fn team_approve(
&self,
text: &str,
key: &MemberKey,
shown_code: &str,
now: i64,
) -> Result<Statement, TeamError> {
let req = self.team_check_request(text, now)?;
self.team_may_approve(&req, &key.id())?;
approve(key, &req, shown_code, seconds(now))
@@ -1077,7 +1108,8 @@ impl Vault {
/// Records a refusal by `by`; the request is never signed here afterwards. The caller saves.
pub fn team_refuse(&mut self, text: &str, by: &str, reason: &str, now: i64) -> Result<(), Error> {
let req = SignRequest::parse(text).map_err(team_err)?;
let entry = self.team_audit_entry(&req, Outcome::Refused, by, Some(reason.chars().take(200).collect()), None, &[], now);
let entry =
self.team_audit_entry(&req, Outcome::Refused, by, Some(reason.chars().take(200).collect()), None, &[], now);
self.signing.audit.push(entry);
let hash = req.hash_hex();
self.team_mut()?.mark_seen(hash, seconds(now));
@@ -1149,11 +1181,8 @@ impl Vault {
let me = key.id();
let me_member = roster.iter().find(|m| m.id == me).ok_or(TeamError::NotAMember)?;
let rule = t.policy.rule(&req.env).ok_or(TeamError::UnknownEnv)?;
let mut approvals: Vec<Statement> = statements
.iter()
.filter(|s| s.member != me && s.verify(&req, &roster).is_ok())
.cloned()
.collect();
let mut approvals: Vec<Statement> =
statements.iter().filter(|s| s.member != me && s.verify(&req, &roster).is_ok()).cloned().collect();
if rule.approvals > 0 {
let code = shown_code.ok_or(TeamError::WrongMatch)?;
may_approve(&t.policy, &roster, &req.env, &req.author, &me)?;