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(storage_grants): authorize newer wire selectors instead of denying them
Steven Enamakel294456510509
diff --git a/crates/openhuman-core/src/modules/storage_grants.rs b/crates/openhuman-core/src/modules/storage_grants.rsindex 5bc9813c80..6aeb26a39e 100644--- a/crates/openhuman-core/src/modules/storage_grants.rs+++ b/crates/openhuman-core/src/modules/storage_grants.rs@@ -317,9 +317,14 @@ fn is_write(object: Object, selector: &str) -> bool {"Put" | "Delete" | "DeleteWhere" | "Claim" | "AtomicBatch" | "AtomicBatchChecked") | (Object::Streams,- "Append" | "AppendBatch" | "AppendBatchIfOffset" | "TruncateBefore" | "DeleteStream"+ "Append"+ | "AppendBatch"+ | "AppendBatchIfOffset"+ | "TruncateBefore"+ | "DeleteStream"+ | "Seal") | (Object::Blobs, "Put" | "PutStream" | "Delete" | "PresignPut")- | (Object::Secrets, "Set" | "Delete")+ | (Object::Secrets, "Set" | "SetIf" | "Delete")| (Object::Queues,"EnsureQueue"@@ -416,12 +421,13 @@ fn batch(grant: &StorageGrant, request: &Value) -> Result<Plan, Denied> {fn streams(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Plan, Denied> {match selector {- "ReadWindow" | "Len" => {+ "ReadWindow" | "Len" | "Info" => {let name = text(request, "stream")?;StorageGrant::prefixed(&grant.stream_prefixes, name)?;Ok(forward(name))}- "Append" | "AppendBatch" | "AppendBatchIfOffset" | "TruncateBefore" | "DeleteStream" => {+ "Append" | "AppendBatch" | "AppendBatchIfOffset" | "TruncateBefore" | "DeleteStream"+ | "Seal" => {let name = text(request, "stream")?;StorageGrant::prefixed(&grant.stream_prefixes, name)?;Ok(forward(name))@@ -431,6 +437,8 @@ fn streams(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Planlet granted = StorageGrant::prefixed(&grant.stream_prefixes, prefix)?;Ok(forward(granted))}+ // The client probes each port it was granted when it connects.+ "Capabilities" => Ok(forward("")),_ => Err(Denied::Malformed),}}@@ -450,7 +458,7 @@ fn blobs(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Plan,let granted = StorageGrant::prefixed(&grant.blob_prefixes, key)?;Ok(forward(granted))}- "List" => {+ "List" | "ListPage" => {let prefix = text(request, "prefix")?;let granted = StorageGrant::prefixed(&grant.blob_prefixes, prefix)?;Ok(forward(granted))@@ -462,11 +470,11 @@ fn blobs(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Plan,fn secrets(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Plan, Denied> {match selector {- "Get" => {+ "Get" | "GetVersioned" => {let granted = StorageGrant::prefixed(&grant.secret_prefixes, text(request, "name")?)?;Ok(forward(granted))}- "Set" | "Delete" => {+ "Set" | "SetIf" | "Delete" => {let granted = StorageGrant::prefixed(&grant.secret_prefixes, text(request, "name")?)?;Ok(forward(granted))}@@ -474,6 +482,8 @@ fn secrets(grant: &StorageGrant, selector: &str, request: &Value) -> Result<Planlet granted = StorageGrant::prefixed(&grant.secret_prefixes, text(request, "prefix")?)?;Ok(forward(granted))}+ // The client probes each port it was granted when it connects.+ "Capabilities" => Ok(forward("")),_ => Err(Denied::Malformed),}}diff --git a/crates/openhuman-core/src/modules/storage_grants_tests.rs b/crates/openhuman-core/src/modules/storage_grants_tests.rsindex f9a768fc81..16748e2ba3 100644--- a/crates/openhuman-core/src/modules/storage_grants_tests.rs+++ b/crates/openhuman-core/src/modules/storage_grants_tests.rs@@ -554,3 +554,47 @@ fn the_event_queues_grant_carries_their_collections_and_queues() {Some(tinystoragedrivers::QueueConfig::Storage));}++#[test]+fn every_selector_of_a_granted_object_is_decided_rather_than_refused_as_malformed() {+ // The module's storage client probes `Capabilities` on every object it was+ // granted, and reads and writes through the selectors the wire contract+ // added after the grant table was written. A selector that is part of the+ // contract must reach the grant check, never fall through as malformed.+ let g = grant();+ for (object, selector, request) in [+ (Object::Streams, "Capabilities", json!({})),+ (Object::Streams, "Info", json!({"stream": "log/a"})),+ (Object::Streams, "Seal", json!({"stream": "log/a"})),+ (Object::Secrets, "Capabilities", json!({})),+ (Object::Secrets, "GetVersioned", json!({"name": "token.a"})),+ (Object::Secrets, "SetIf", json!({"name": "token.a"})),+ (Object::Blobs, "ListPage", json!({"prefix": "files/"})),+ ] {+ assert!(+ authorize(&g, object, selector, &request).is_ok(),+ "{object:?} {selector}"+ );+ }+}++#[test]+fn the_selectors_added_to_the_wire_keep_the_grants_prefixes_and_read_only_rule() {+ assert_eq!(+ authorize(&grant(), Object::Streams, "Seal", &json!({"stream": "audit/a"})),+ Err(Denied::Target)+ );+ assert_eq!(+ authorize(&grant(), Object::Secrets, "SetIf", &json!({"name": "other.a"})),+ Err(Denied::Target)+ );+ assert_eq!(+ authorize(&read_only(), Object::Streams, "Seal", &json!({"stream": "log/a"})),+ Err(Denied::ReadOnly)+ );+ assert_eq!(+ authorize(&read_only(), Object::Secrets, "SetIf", &json!({"name": "token.a"})),+ Err(Denied::ReadOnly)+ );+ assert!(authorize(&read_only(), Object::Streams, "Info", &json!({"stream": "log/a"})).is_ok());+}