fix: harden the vault before release
Require a private passphrase and loopback-or-token admin auth. New vaults use Argon2id; existing PBKDF2 vaults still open, and new snapshot metadata is encrypted. Wormhole tokens survive restart, offset uploads seal into the vault, and client-certificate uploads are real. Reject the command provider and keep Postgres passwords off the process arguments. Keep the interruptible canvas motion.
This commit is contained in:
@@ -12,8 +12,9 @@ struct Cli {
|
||||
command: Commands,
|
||||
#[arg(long, env = "TESSERA_DATA_DIR", default_value = "./data")]
|
||||
data_dir: String,
|
||||
#[arg(long, env = "TESSERA_VAULT_PASSPHRASE", default_value = "dev-vault-key")]
|
||||
vault_pass: String,
|
||||
/// Required for vault commands. No default; the published example passphrase is rejected for new vaults.
|
||||
#[arg(long, env = "TESSERA_VAULT_PASSPHRASE")]
|
||||
vault_pass: Option<String>,
|
||||
#[arg(long, env = "TESSERA_HUB_URL", default_value = "http://127.0.0.1:8787")]
|
||||
hub_url: String,
|
||||
}
|
||||
@@ -98,14 +99,24 @@ fn main() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn require_passphrase(cli: &Cli) -> Result<&str> {
|
||||
match cli.vault_pass.as_deref() {
|
||||
Some(pass) if !pass.is_empty() => Ok(pass),
|
||||
_ => anyhow::bail!(
|
||||
"Set TESSERA_VAULT_PASSPHRASE or pass --vault-pass. Tessera does not ship a default passphrase."
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmd_seed_demo(cli: &Cli, force: bool, reset: bool) -> Result<()> {
|
||||
let data = std::path::Path::new(&cli.data_dir);
|
||||
let vault_pass = require_passphrase(cli)?;
|
||||
if reset {
|
||||
tessera_demo::clear_demo(data, &cli.vault_pass)?;
|
||||
tessera_demo::clear_demo(data, vault_pass)?;
|
||||
println!("Demo seed cleared.");
|
||||
return Ok(());
|
||||
}
|
||||
let report = tessera_demo::apply(data, &cli.vault_pass, force)?;
|
||||
let report = tessera_demo::apply(data, vault_pass, force)?;
|
||||
if report.skipped {
|
||||
println!(
|
||||
"Demo seed already applied ({} orbits, {} snapshots). Use --force to re-seed.",
|
||||
@@ -130,7 +141,7 @@ fn cmd_init(cli: &Cli) -> Result<()> {
|
||||
println!("Vault already initialized.");
|
||||
return Ok(());
|
||||
}
|
||||
Vault::init(&vp, &cli.vault_pass).context("init vault")?;
|
||||
Vault::init(&vp, require_passphrase(cli)?).context("init vault")?;
|
||||
println!("Vault initialized at {}", vp.display());
|
||||
Ok(())
|
||||
}
|
||||
@@ -142,7 +153,7 @@ fn cmd_status(cli: &Cli) -> Result<()> {
|
||||
}
|
||||
let vp = vault_path(&cli.data_dir);
|
||||
if vp.join("config").exists() {
|
||||
let vault = Vault::open(&vp, &cli.vault_pass)?;
|
||||
let vault = Vault::open(&vp, require_passphrase(cli)?)?;
|
||||
let n = vault.list_snapshots()?.len();
|
||||
println!("Vault: online — {n} snapshots");
|
||||
} else {
|
||||
@@ -197,7 +208,7 @@ fn cmd_snap(cli: &Cli, orbit_name: Option<String>) -> Result<()> {
|
||||
}
|
||||
|
||||
fn cmd_list(cli: &Cli) -> Result<()> {
|
||||
let vault = Vault::open(&vault_path(&cli.data_dir), &cli.vault_pass)?;
|
||||
let vault = Vault::open(&vault_path(&cli.data_dir), require_passphrase(cli)?)?;
|
||||
for s in vault.list_snapshots()? {
|
||||
println!(
|
||||
"{} {} {} bytes orbit={}",
|
||||
@@ -211,14 +222,14 @@ fn cmd_list(cli: &Cli) -> Result<()> {
|
||||
}
|
||||
|
||||
fn cmd_reconstitute(cli: &Cli, snapshot_id: Uuid, target: String) -> Result<()> {
|
||||
let vault = Vault::open(&vault_path(&cli.data_dir), &cli.vault_pass)?;
|
||||
let vault = Vault::open(&vault_path(&cli.data_dir), require_passphrase(cli)?)?;
|
||||
let n = vault.restore_snapshot(snapshot_id, std::path::Path::new(&target))?;
|
||||
println!("Reconstituted {n} bytes to {target}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cmd_decay(cli: &Cli, preset: &str) -> Result<()> {
|
||||
let mut vault = Vault::open(&vault_path(&cli.data_dir), &cli.vault_pass)?;
|
||||
let mut vault = Vault::open(&vault_path(&cli.data_dir), require_passphrase(cli)?)?;
|
||||
let pruned = vault.prune_with_decay(preset)?;
|
||||
println!("{} snapshots decayed.", pruned.len());
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user