Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(security): store secrets in an encrypted file backend

Steven Enamakel3bec2464755a
diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs
index 6e180650d8..505558994a 100644
--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs
+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs
@@ -168,14 +168,21 @@ pub(crate) fn storage_master_key() -> Result<[u8; KEY_LEN], String> {
pub(crate) fn storage_master_key_resolvable() -> bool {
let env_set =
|name: &str| std::env::var_os(name).is_some_and(|v| !v.to_string_lossy().trim().is_empty());
+ // Cached outcomes first: a loaded key answers yes, and a denied keychain
+ // is not asked again this session.
+ if matches!(MASTER_KEY.get(), Some(Ok(Some(_)))) {
+ return true;
+ }
+ let host_denied = HOST_KEY_UNAVAILABLE.get().is_some();
let dir = crate::security::secret_storage::store::workspace_dir_for_file_backend();
resolvable(
- matches!(MASTER_KEY.get(), Some(Ok(Some(_)))),
+ false,
env_set(MASTER_KEY_ENV) || env_set(MASTER_KEY_FILE_ENV),
- // A host source counts only when it already holds the key: an empty
- // one would have a key minted into it by the load.
- key_source::installed_master_key_source()
- .is_some_and(|source| matches!(source.load(), Ok(Some(_)))),
+ // A host source counts only when it already holds the key (an empty
+ // one would have a key minted into it by the load), and is read last.
+ !host_denied
+ && key_source::installed_master_key_source()
+ .is_some_and(|source| matches!(source.load(), Ok(Some(_)))),
dir.join("keyring/master.key").is_file(),
)
}
diff --git a/crates/openhuman-core/src/storage/layout/run.rs b/crates/openhuman-core/src/storage/layout/run.rs
index 9525d1b475..ffcb8d7e56 100644
--- a/crates/openhuman-core/src/storage/layout/run.rs
+++ b/crates/openhuman-core/src/storage/layout/run.rs
@@ -198,7 +198,11 @@ fn dry_run(target: &Target, resuming: bool) -> Result<DryRun, LayoutError> {
None => {
let mut plan = plan::scan(&target.workspace())?;
// What the import step would copy into encrypted secrets.
- let candidates = super::credentials::candidates(&target.profile_dir);
+ // Once Import finished, a resume uses the list it recorded.
+ let candidates = match state.as_ref() {
+ Some(s) if s.has(Step::Import) => s.credentials.clone(),
+ _ => super::credentials::candidates(&target.profile_dir),
+ };
plan.entries
.extend(plan::scan_credentials(&target.profile_dir, &candidates));
plan.entries.sort_by(|a, b| a.path.cmp(&b.path));