difftreelog
refactor remove secret fields
in: trunk
5 files changed
Cargo.lockdiffbeforeafterboth83 packageslockfile v3
Might be heavy and slow!
aho-corasick
0.7.14crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0ddepends onused byanyhow
1.0.34crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7used byatty
0.2.14crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8depends onautocfg
1.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464aused bybase-x
0.2.8crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28bused bybitflags
1.2.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693bumpalo
3.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820used bycfg-if
0.1.10crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822used bycfg-if
1.0.0crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbaf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fdclap
3.0.0-beta.2crates.io↘ 11↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142depends onused byclap_derive
3.0.0-beta.2crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1used byconst_fn
0.4.3crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afabused bydiscard
1.0.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0used byenv_logger
0.8.2crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661eused bygetrandom
0.2.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8used byhashbrown
0.9.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04used byheck
0.3.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205depends onused byhermit-abi
0.1.17crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8depends onused byhostname
0.3.1crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867depends onused byhumantime
2.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7aused byindexmap
1.6.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2depends onused byitoa
0.4.6crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6used bylazy_static
1.4.0crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646libc
0.2.79crates.io↘ 0↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743lockfile
0.2.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9e9b01c4735c76fec1c390661ac8794722f0af0b5eb742500308f94b2caae40fdepends onused bylog
0.4.14crates.io↘ 1↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710depends onmatch_cfg
0.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4used bymemchr
2.3.3crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400used byonce_cell
1.5.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0used byos_str_bytes
2.3.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2ac6fe3538f701e339953a3ebbe4f39941aababa8a3f6964635b24ab526daeacused byppv-lite86
0.2.9crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20used byproc-macro-error
1.0.4crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumda25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38cused byproc-macro-error-attr
1.0.4crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869used byproc-macro-hack
0.5.19crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5proc-macro2
1.0.24crates.io↘ 1↖ 11sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71depends onquote
1.0.7crates.io↘ 1↖ 11sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumaa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37depends onrand
0.8.3crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7eused byrand_chacha
0.3.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0ddepends onused byrand_core
0.6.2crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7depends onrand_hc
0.3.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73depends onused byredox_syscall
0.2.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9depends onused byregex
1.4.1crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820bused byregex-syntax
0.6.20crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11cused byremove_dir_all
0.5.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7depends onused byrustc_version
0.2.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030adepends onused byryu
1.0.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86eused bysemver
0.9.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403depends onused bysemver-parser
0.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3used byserde
1.0.117crates.io↘ 1↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1adepends onserde_derive
1.0.117crates.io↘ 3↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74edepends onserde_json
1.0.59crates.io↘ 3↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95depends onsha1
0.6.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0dused bystandback
0.2.11crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf4e0831040d2cf2bdfd51b844be71885783d489898a192f254ae25d57cce725cdepends onstdweb
0.4.20crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5depends onused bystdweb-derive
0.5.3crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50efused bystdweb-internal-macros
0.2.9crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11depends onused bystdweb-internal-runtime
0.1.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0used bystrsim
0.10.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623used bysyn
1.0.44crates.io↘ 3↖ 8sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fddtempfile
3.2.0crates.io↘ 6↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22used bytermcolor
1.1.0crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75fdepends ontextwrap
0.12.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789depends onused bythread_local
1.0.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14depends onused bytime
0.2.25crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7depends onused bytime-macros
0.1.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1used bytime-macros-impl
0.1.1crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8faused bytoml
0.5.7crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645depends onused byunicode-segmentation
1.6.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0used byunicode-width
0.1.8crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3unicode-xid
0.2.1crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564used byvec_map
0.8.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191used byversion_check
0.9.2crates.io↘ 0↖ 4sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aedwasi
0.10.2+wasi-snapshot-preview1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumfd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6used bywasm-bindgen
0.2.68crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42depends onused bywasm-bindgen-backend
0.2.68crates.io↘ 7↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68depends onwasm-bindgen-macro
0.2.68crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038used bywasm-bindgen-macro-support
0.2.68crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498feused bywinapi
0.3.9crates.io↘ 2↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419winapi-i686-pc-windows-gnu
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6used bywinapi-util
0.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178depends onused bywinapi-x86_64-pc-windows-gnu
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183fused by
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,15 @@
tempfile = "3.2"
once_cell = "1.5"
hostname = "0.3.1"
+age-core = "0.6.0"
+peg = "0.7.0"
+
+nixlike = {path = "crates/nixlike"}
+rage = "0.6.0"
+age = { version = "0.6.0", features = ["ssh", "armor"] }
+base64 = "0.13.0"
+ascii85 = "0.2.1"
+chrono = { version = "0.4.19", features = ["serde"] }
[workspace]
members = ["crates/nixlike"]
src/cmds/secrets/mod.rsdiffbeforeafterboth--- a/src/cmds/secrets/mod.rs
+++ b/src/cmds/secrets/mod.rs
@@ -1,10 +1,7 @@
use crate::{fleetdata::FleetSecret, host::Config};
use anyhow::{bail, Result};
use clap::Clap;
-use std::{
- collections::BTreeMap,
- io::{Cursor, Read},
-};
+use std::io::{self, Cursor, Read};
#[derive(Clap)]
pub enum Secrets {
@@ -19,6 +16,8 @@
/// Override secret if already present
#[clap(long)]
force: bool,
+ #[clap(long)]
+ public: Option<String>,
},
}
@@ -37,51 +36,40 @@
machines,
name,
force,
+ public,
} => {
let recipients = machines
.iter()
- .map(|m| config.recipient(&m))
+ .map(|m| config.recipient(m))
.collect::<Result<Vec<_>>>()?;
- let secret_data = {
+ let secret = {
let mut input = vec![];
- std::io::stdin().read_to_end(&mut input)?;
+ io::stdin().read_to_end(&mut input)?;
- let data: BTreeMap<String, String> = serde_json::from_slice(&input)?;
- let mut transformed_data: BTreeMap<String, String> = BTreeMap::new();
- for (k, v) in data {
- if k.ends_with("_pub") {
- transformed_data.insert(k, v);
- } else if k.ends_with("_secret") {
- let mut encrypted = vec![];
- let recipients = recipients
- .iter()
- .cloned()
- .map(|r| Box::new(r) as Box<dyn age::Recipient>)
- .collect();
- let mut encryptor = age::Encryptor::with_recipients(recipients)
- .wrap_output(&mut encrypted)?;
- std::io::copy(&mut Cursor::new(v.as_bytes()), &mut encryptor)?;
- drop(encryptor);
-
- transformed_data.insert(k, ascii85::encode(&encrypted));
- } else {
- bail!("unknown key type: {:?}", k);
- }
- }
- transformed_data
+ let mut encrypted = vec![];
+ let recipients = recipients
+ .iter()
+ .cloned()
+ .map(|r| Box::new(r) as Box<dyn age::Recipient>)
+ .collect();
+ let mut encryptor =
+ age::Encryptor::with_recipients(recipients).wrap_output(&mut encrypted)?;
+ io::copy(&mut Cursor::new(input), &mut encryptor)?;
+ ascii85::encode(&encrypted)
};
let mut data = config.data_mut();
- if data.secrets.contains_key(&name) && !force {
+ if data.secret.contains_key(&name) && !force {
bail!("secret already defined");
}
- data.secrets.insert(
+ data.secret.insert(
name,
FleetSecret {
- owners: machines.clone(),
+ owners: machines,
expire_at: None,
- data: secret_data,
+ secret,
+ public,
},
);
}
src/fleetdata.rsdiffbeforeafterboth--- a/src/fleetdata.rs
+++ b/src/fleetdata.rs
@@ -16,7 +16,7 @@
pub hosts: BTreeMap<String, HostData>,
#[serde(default)]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
- pub secrets: BTreeMap<String, FleetSecret>,
+ pub secret: BTreeMap<String, FleetSecret>,
}
#[derive(Serialize, Deserialize)]
@@ -26,5 +26,7 @@
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub expire_at: Option<DateTime<Utc>>,
- pub data: BTreeMap<String, String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub public: Option<String>,
+ pub secret: String,
}
src/keys.rsdiffbeforeafterboth--- a/src/keys.rs
+++ b/src/keys.rs
@@ -27,7 +27,7 @@
} else {
warn!("Loading key for {}", host);
let key = self
- .command_on(&host, "cat", false)
+ .command_on(host, "cat", false)
.arg("/etc/ssh/ssh_host_ed25519_key.pub")
.run_string()?;
self.update_key(host, key.clone());