mirror of
https://gitlab.com/keys.openpgp.org/hagrid.git
synced 2025-10-06 00:23:08 +02:00
cargo: cargo fmt --all
This commit is contained in:
@@ -57,10 +57,7 @@ impl<'a> DumpStats<'a> {
|
||||
}
|
||||
self.progress.set_message(&format!(
|
||||
"prefix {} dumpd {:5} keys, {:5} Errors ({:3} keys/s)",
|
||||
self.prefix,
|
||||
self.count_total,
|
||||
self.count_err,
|
||||
self.kps_partial
|
||||
self.prefix, self.count_total, self.count_err, self.kps_partial
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -100,11 +97,7 @@ pub fn do_dump(config: &HagridConfig) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dump_dir_recursively(
|
||||
stats: &mut DumpStats,
|
||||
output_file: &mut File,
|
||||
dir: &Path,
|
||||
) -> Result<()> {
|
||||
fn dump_dir_recursively(stats: &mut DumpStats, output_file: &mut File, dir: &Path) -> Result<()> {
|
||||
for path in WalkDir::new(dir)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
|
@@ -164,7 +164,8 @@ fn import_from_file(db: &KeyDatabase, input: &Path, multi_progress: &MultiProgre
|
||||
if !tpk_status.is_revoked {
|
||||
for (email, status) in &tpk_status.email_status {
|
||||
if status == &EmailAddressStatus::NotPublished {
|
||||
db.set_email_published(&key_fpr.clone().try_into().unwrap(), &email).unwrap();
|
||||
db.set_email_published(&key_fpr.clone().try_into().unwrap(), &email)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@ use anyhow::Result;
|
||||
|
||||
use clap::{App, Arg, SubCommand};
|
||||
|
||||
mod dump;
|
||||
mod import;
|
||||
mod regenerate;
|
||||
mod dump;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct HagridConfigs {
|
||||
@@ -64,7 +64,9 @@ fn main() -> Result<()> {
|
||||
.possible_values(&["dev", "stage", "prod"]),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("regenerate").about("Regenerate symlink directory"))
|
||||
.subcommand(SubCommand::with_name("dump").about("Dump whole database into a large keyring file"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("dump").about("Dump whole database into a large keyring file"),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("import")
|
||||
.about("Import keys into Hagrid")
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use aes_gcm::{
|
||||
aead::{Aead, OsRng},
|
||||
AeadCore, Aes256Gcm, Nonce, Key, KeyInit,
|
||||
AeadCore, Aes256Gcm, Key, KeyInit, Nonce,
|
||||
};
|
||||
use sha2::{Sha256, Digest};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
const NONCE_LEN: usize = 12;
|
||||
|
||||
@@ -27,7 +27,9 @@ impl SealedState {
|
||||
return Err("invalid sealed value: too short");
|
||||
}
|
||||
let (sealed, nonce) = data.split_at(data.len() - NONCE_LEN);
|
||||
let unsealed = self.cipher.decrypt(Nonce::from_slice(nonce), sealed)
|
||||
let unsealed = self
|
||||
.cipher
|
||||
.decrypt(Nonce::from_slice(nonce), sealed)
|
||||
.map_err(|_| "invalid key/nonce/value: bad seal")?;
|
||||
|
||||
core::str::from_utf8(&unsealed)
|
||||
@@ -37,7 +39,8 @@ impl SealedState {
|
||||
|
||||
pub fn seal(&self, input: &str) -> Vec<u8> {
|
||||
let nonce = Aes256Gcm::generate_nonce(&mut OsRng);
|
||||
let mut sealed = self.cipher
|
||||
let mut sealed = self
|
||||
.cipher
|
||||
.encrypt(&nonce, input.as_bytes())
|
||||
.expect("sealing works");
|
||||
sealed.extend(nonce);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use std::{fs::File, path::Path, io::Write};
|
||||
use std::{fs::File, io::Write, path::Path};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
@@ -23,9 +23,7 @@ pub fn do_generate(count: u64, output_path: &Path, fprs_path: Option<&Path>) ->
|
||||
None
|
||||
};
|
||||
for i in 0..count {
|
||||
let (cert, _) =
|
||||
CertBuilder::general_purpose(None, Some(util::gen_email(i)))
|
||||
.generate()?;
|
||||
let (cert, _) = CertBuilder::general_purpose(None, Some(util::gen_email(i))).generate()?;
|
||||
cert.serialize(&mut output)?;
|
||||
if let Some(ref mut output_fprs) = output_fprs {
|
||||
writeln!(output_fprs, "{}", cert)?;
|
||||
|
@@ -23,10 +23,7 @@ pub fn do_genreqs(host: &str, fprs_path: &Path) -> Result<()> {
|
||||
let result = match rng.gen_range(0, 3) {
|
||||
0 => {
|
||||
let email = util::gen_email(rng.gen_range(0, fingerprints.len() as u64));
|
||||
stdout.write_fmt(format_args!(
|
||||
"GET {}/vks/v1/by-email/{}\n",
|
||||
host, email
|
||||
))
|
||||
stdout.write_fmt(format_args!("GET {}/vks/v1/by-email/{}\n", host, email))
|
||||
}
|
||||
1 => {
|
||||
let random_fpr = fingerprints.choose(&mut rng).unwrap();
|
||||
|
Reference in New Issue
Block a user