[team] Team vaults: rustfmt on the files this change touches
This commit is contained in:
@@ -227,7 +227,12 @@ pub fn eligible(policy: &Policy, roster: &[RosterMember], env: &str, author: &st
|
||||
/// statements were already checked.
|
||||
pub fn evaluate(policy: &Policy, roster: &[RosterMember], env: &str, author: &str, approvers: &[String]) -> Evaluation {
|
||||
let Some(rule) = policy.rule(env) else {
|
||||
return Evaluation { verdict: Verdict::UnknownEnv, eligible: vec![], counted: vec![], ignored: approvers.to_vec() };
|
||||
return Evaluation {
|
||||
verdict: Verdict::UnknownEnv,
|
||||
eligible: vec![],
|
||||
counted: vec![],
|
||||
ignored: approvers.to_vec(),
|
||||
};
|
||||
};
|
||||
let eligible = eligible(policy, roster, env, author).unwrap_or_default();
|
||||
let mut counted: Vec<String> = Vec::new();
|
||||
|
||||
@@ -180,7 +180,12 @@ pub struct Verified {
|
||||
/// with it: both signatures, every approval (signature, roster, the request's own match code), the request and
|
||||
/// envelope hashes, and the policy evaluated again. The clock is not consulted: a proof stays checkable after its
|
||||
/// request expired.
|
||||
pub fn verify_proof(proof: &Proof, identity: &[u8; 32], request_text: &str, envelope: &[u8]) -> Result<Verified, TeamError> {
|
||||
pub fn verify_proof(
|
||||
proof: &Proof,
|
||||
identity: &[u8; 32],
|
||||
request_text: &str,
|
||||
envelope: &[u8],
|
||||
) -> Result<Verified, TeamError> {
|
||||
let sig: [u8; 64] = unb64(&proof.sig).and_then(|s| s.try_into().ok()).ok_or(TeamError::BadSignature)?;
|
||||
if !verify_proof_sig(identity, &proof.text, &sig) {
|
||||
return Err(TeamError::BadSignature);
|
||||
|
||||
@@ -100,9 +100,8 @@ fn lower_hex(s: &str, len: usize) -> bool {
|
||||
}
|
||||
|
||||
pub(crate) fn pub_key(s: &str) -> Result<[u8; 32], TeamError> {
|
||||
let k: [u8; 32] = unb64(s)
|
||||
.and_then(|v| v.try_into().ok())
|
||||
.ok_or(TeamError::Invalid("pub is not base64 of 32 bytes"))?;
|
||||
let k: [u8; 32] =
|
||||
unb64(s).and_then(|v| v.try_into().ok()).ok_or(TeamError::Invalid("pub is not base64 of 32 bytes"))?;
|
||||
if k == [0; 32] {
|
||||
return Err(TeamError::Invalid("pub is all zeros"));
|
||||
}
|
||||
@@ -176,7 +175,9 @@ impl SignRequest {
|
||||
return bad("artifact_digest has the wrong length for its format");
|
||||
}
|
||||
match self.format {
|
||||
Format::Cosign => custos_sign::image_ok(&self.image).map_err(|_| TeamError::Invalid("image is not a repository"))?,
|
||||
Format::Cosign => {
|
||||
custos_sign::image_ok(&self.image).map_err(|_| TeamError::Invalid("image is not a repository"))?
|
||||
}
|
||||
_ if !self.image.is_empty() => return bad("image is for cosign only"),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ impl Statement {
|
||||
}
|
||||
let m = roster.iter().find(|m| m.id == self.member).ok_or(TeamError::NotAMember)?;
|
||||
let id: [u8; 16] = unhex(&self.member).ok_or(TeamError::NotAMember)?;
|
||||
let sig: [u8; 64] =
|
||||
unb64(&self.sig).and_then(|s| s.try_into().ok()).ok_or(TeamError::BadSignature)?;
|
||||
let sig: [u8; 64] = unb64(&self.sig).and_then(|s| s.try_into().ok()).ok_or(TeamError::BadSignature)?;
|
||||
if !crate::member::verify(&m.ed25519, &message(&req.hash(), &self.code, &id, self.at), &sig) {
|
||||
return Err(TeamError::BadSignature);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user