The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(config): redact storage url secrets in snapshots and keyring
Steven Enamakele68a3098d4b9
diff --git a/crates/openhuman-core/src/config/ops/loader/snapshot.rs b/crates/openhuman-core/src/config/ops/loader/snapshot.rsindex b128191f98..261e5196d8 100644--- a/crates/openhuman-core/src/config/ops/loader/snapshot.rs+++ b/crates/openhuman-core/src/config/ops/loader/snapshot.rs@@ -15,6 +15,12 @@ pub fn snapshot_config_json(config: &Config) -> Result<serde_json::Value, Stringvalue["search"][provider]["api_key"] = serde_json::Value::Null;}value["seltz"]["api_key"] = serde_json::Value::Null;+ // A storage URL may carry database credentials; show it redacted.+ if let Some(url) = config.storage.url.as_deref() {+ value["storage"]["url"] = serde_json::Value::String(+ crate::config::schema::storage::redact_url(url),+ );+ }#[cfg(feature = "modules")]let browser_billing_route = crate::modules::desktop::billing_route(config);#[cfg(not(feature = "modules"))]diff --git a/crates/openhuman-core/src/config/schema/load/secrets.rs b/crates/openhuman-core/src/config/schema/load/secrets.rsindex 7b87c411d3..12672f7f58 100644--- a/crates/openhuman-core/src/config/schema/load/secrets.rs+++ b/crates/openhuman-core/src/config/schema/load/secrets.rs@@ -101,6 +101,8 @@ pub(super) fn decrypt_config_secrets(config: &mut Config, openhuman_dir: &Path)let store = crate::security::keyring::SecretStore::new(openhuman_dir, true);decrypt_optional_secret(&store, &mut config.api_key, "api_key")?;+ // A MongoDB URL carries the database password.+ decrypt_optional_secret(&store, &mut config.storage.url, "storage.url")?;decrypt_optional_secret(&store, &mut config.seltz.api_key, "seltz.api_key")?;decrypt_optional_secret(@@ -216,6 +218,8 @@ pub(super) fn encrypt_config_secrets(config: &mut Config) -> Result<()> {let store = crate::security::keyring::SecretStore::new(parent_dir, true);encrypt_optional_secret(&store, &mut config.api_key, "api_key")?;+ // A MongoDB URL carries the database password.+ encrypt_optional_secret(&store, &mut config.storage.url, "storage.url")?;encrypt_optional_secret(&store, &mut config.seltz.api_key, "seltz.api_key")?;encrypt_optional_secret(diff --git a/crates/openhuman-core/src/config/schema/storage.rs b/crates/openhuman-core/src/config/schema/storage.rsindex d35b4d0448..a91e4fd51d 100644--- a/crates/openhuman-core/src/config/schema/storage.rs+++ b/crates/openhuman-core/src/config/schema/storage.rs@@ -38,14 +38,22 @@ impl std::fmt::Debug for StorageConfig {}}-/// `url` with any `user:password@` userinfo replaced by `***@`.+/// `url` with any `user:password@` userinfo replaced by `***@`, and the+/// query string and fragment dropped (they can carry tokens, such as MongoDB's+/// `authMechanismProperties`).pub fn redact_url(url: &str) -> String {- match (url.find("://"), url.rfind('@')) {+ let end = url.find(['?', '#']).unwrap_or(url.len());+ let (base, trimmed) = (&url[..end], end < url.len());+ let mut out = match (base.find("://"), base.rfind('@')) {(Some(scheme), Some(at)) if at > scheme => {- format!("{}://***@{}", &url[..scheme], &url[at + 1..])+ format!("{}://***@{}", &base[..scheme], &base[at + 1..])}- _ => url.to_string(),+ _ => base.to_string(),+ };+ if trimmed {+ out.push_str("?***");}+ out}#[cfg(test)]