Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 79 additions & 1 deletion crates/openhuman-app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,22 @@ async fn snapshot_config_json_redacts_every_search_key_but_keeps_settings() {
assert!(snapshot["config"]["seltz"]["api_key"].is_null());
}

#[tokio::test]
async fn snapshot_config_json_redacts_browser_upstream_proxy_credentials() {
let mut cfg = Config::default();
cfg.browser.upstream_proxies = vec![crate::config::schema::BrowserUpstreamProxy {
domains: vec!["reddit.com".into()],
url: "http://resi-user:hunter2@gate.example:7000".into(),
}];
let snapshot = snapshot_config_json(&cfg).await.unwrap();
let serialized = snapshot.to_string();
assert!(!serialized.contains("hunter2"));
assert!(!serialized.contains("resi-user"));
let proxy = &snapshot["config"]["browser"]["upstream_proxies"][0];
assert_eq!(proxy["domains"][0], "reddit.com");
assert!(proxy["url"].as_str().unwrap().contains("gate.example"));
}

#[tokio::test]
async fn snapshot_config_json_redacts_the_storage_url_credentials() {
let mut cfg = Config::default();
Expand Down
21 changes: 11 additions & 10 deletions crates/openhuman-core/src/config/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,17 @@ pub use tinychannels_bus::config::{
};
pub use tokenjuice::TokenjuiceConfig;
pub use tools::{
BrowserConfig, ComposioConfig, ComposioDirectBaseUrls, ComposioHostCredential, CurlConfig,
GitbooksConfig, HttpHeader, HttpRequestConfig, IntegrationToggle, IntegrationsConfig,
LegacySearchInputs, McpAuthConfig, McpClientConfig, McpClientIdentityConfig, McpServerConfig,
McpToolExposure, MultimodalConfig, MultimodalFileConfig, PresentationMode, ProviderRoute,
SearchConfig, SearchEngineCredentials, SearchHostCredential, SearchProviderSettings,
SearxngConfig, SecretsConfig, SeltzConfig, UnknownKeyedSearchProvider, COMPOSIO_MODE_BACKEND,
COMPOSIO_MODE_DIRECT, COMPOSIO_MODE_DISABLED, MANAGED_SEARCH_PROVIDERS, SEARCH_ENGINE_BRAVE,
SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA, SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL,
SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY, SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER,
SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
BrowserConfig, BrowserUpstreamProxy, ComposioConfig, ComposioDirectBaseUrls,
ComposioHostCredential, CurlConfig, GitbooksConfig, HttpHeader, HttpRequestConfig,
IntegrationToggle, IntegrationsConfig, LegacySearchInputs, McpAuthConfig, McpClientConfig,
McpClientIdentityConfig, McpServerConfig, McpToolExposure, MultimodalConfig,
MultimodalFileConfig, PresentationMode, ProviderRoute, SearchConfig, SearchEngineCredentials,
SearchHostCredential, SearchProviderSettings, SearxngConfig, SecretsConfig, SeltzConfig,
UnknownKeyedSearchProvider, COMPOSIO_MODE_BACKEND, COMPOSIO_MODE_DIRECT,
COMPOSIO_MODE_DISABLED, MANAGED_SEARCH_PROVIDERS, SEARCH_ENGINE_BRAVE, SEARCH_ENGINE_DISABLED,
SEARCH_ENGINE_EXA, SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL, SEARCH_ENGINE_QUERIT,
SEARCH_ENGINE_TAVILY, SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS,
SEARCH_ROLE_SEARCH,
};
pub use update::{UpdateConfig, UpdateRestartStrategy};
pub use web_chat_config::WebChatConfig;
Expand Down
31 changes: 31 additions & 0 deletions crates/openhuman-core/src/config/schema/tools/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ pub struct BrowserConfig {
/// placeholder off: a fill or type that carries one is refused.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub keychain_command: Option<String>,
/// Destination domains the browser reaches through an upstream HTTP
/// proxy, for sites that refuse this machine's own address (a datacenter
/// range, say). Each entry's `domains` match themselves and every
/// subdomain. TinySecurity still authorizes every such destination, and
/// the proxy's own host and port as well; TinyComputer then tunnels with
/// `CONNECT` (`browser.egress.upstream_proxies` in its module config).
/// Applies only with browser egress enforcement (`security-module`).
/// Empty, the default, routes nothing.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub upstream_proxies: Vec<BrowserUpstreamProxy>,
Comment thread
senamakel marked this conversation as resolved.
Resolved
}

/// One `[browser] upstream_proxies` entry. `url` is an
/// `http://user:password@host:port` proxy URL with percent-encoded
/// credentials; it is never logged, and `Debug` leaves it out.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct BrowserUpstreamProxy {
/// Destination domains routed through this proxy, such as `reddit.com`.
pub domains: Vec<String>,
/// The proxy URL. Only `http://` proxies are supported.
pub url: String,
}

impl std::fmt::Debug for BrowserUpstreamProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BrowserUpstreamProxy")
.field("domains", &self.domains)
.field("url", &"[REDACTED]")
.finish()
}
}

/// Action kinds `[browser] unattended_actions` may name: the gated direct
Expand Down Expand Up @@ -159,6 +189,7 @@ impl Default for BrowserConfig {
unattended_actions: Vec::new(),
learn_from_tasks: true,
keychain_command: None,
upstream_proxies: Vec::new(),
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions crates/openhuman-core/src/config/schema/tools/browser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,38 @@ fn an_allowed_kind_resolves_to_its_static_canonical_name() {
assert_eq!(config.unattended_kind("click"), None);
assert_eq!(config.unattended_kind("#secret selector"), None);
}

#[test]
fn upstream_proxies_parse_from_toml_and_default_to_none() {
let parsed: BrowserConfig = toml::from_str(
r#"upstream_proxies = [{ domains = ["reddit.com", "redd.it"], url = "http://user:hunter2@gate.example:7000" }]"#,
)
.unwrap();
assert_eq!(
parsed.upstream_proxies,
vec![BrowserUpstreamProxy {
domains: vec!["reddit.com".into(), "redd.it".into()],
url: "http://user:hunter2@gate.example:7000".into(),
}]
);
let absent: BrowserConfig = toml::from_str("enabled = true").unwrap();
assert!(absent.upstream_proxies.is_empty());
// Unset, the key is not written back.
let written = toml::to_string(&BrowserConfig::default()).unwrap();
assert!(!written.contains("upstream_proxies"));
}

#[test]
fn an_upstream_proxy_url_never_appears_in_debug_output() {
let config = BrowserConfig {
upstream_proxies: vec![BrowserUpstreamProxy {
domains: vec!["reddit.com".into()],
url: "http://user:hunter2@gate.example:7000".into(),
}],
..BrowserConfig::default()
};
let debug = format!("{config:?}");
assert!(!debug.contains("hunter2"));
assert!(!debug.contains("gate.example"));
assert!(debug.contains("reddit.com"));
}
2 changes: 1 addition & 1 deletion crates/openhuman-core/src/config/schema/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod mcp;
pub mod multimodal;
pub mod search;

pub use browser::BrowserConfig;
pub use browser::{BrowserConfig, BrowserUpstreamProxy};
pub use http::{CurlConfig, HttpRequestConfig};
pub use integrations::{
ComposioConfig, ComposioDirectBaseUrls, ComposioHostCredential, IntegrationToggle,
Expand Down
26 changes: 21 additions & 5 deletions crates/openhuman-core/src/modules/browser_egress_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,35 @@ fn registered_scopes() -> &'static parking_lot::Mutex<Vec<BrowserScope>> {
pub(crate) const BROWSER_POLICY_ALIAS: &str = "openhuman-browser-egress";
pub(crate) const BROWSER_POLICY_ALIAS_GENERATION: u64 = 1;

/// The `browser.egress` value TinyComputer is loaded and refreshed with.
pub(crate) fn browser_dial_alias() -> Value {
serde_json::json!({
/// The `browser.egress` value TinyComputer is loaded and refreshed with: the
/// stable alias, plus `[browser] upstream_proxies` when any are configured.
/// Those stay in this host-private section because their URLs carry
/// credentials; every dial they cause, the proxy's own included, still comes
/// back through [`BrowserEgressHost::authorize`].
pub(crate) fn browser_dial_alias(config: &crate::config::Config) -> Value {
let mut alias = serde_json::json!({
"policy_id": BROWSER_POLICY_ALIAS,
"generation": BROWSER_POLICY_ALIAS_GENERATION,
})
});
let upstreams = &config.browser.upstream_proxies;
if !upstreams.is_empty() {
tracing::debug!(
upstream_proxies = upstreams.len(),
"[computer] browser egress routes domains through upstream proxies"
);
alias["upstream_proxies"] = upstreams
.iter()
.map(|proxy| serde_json::json!({ "url": proxy.url, "domains": proxy.domains }))
.collect();
Comment thread
senamakel marked this conversation as resolved.
Resolved
}
alias
}

/// Make sure the browser's destination-only policy is registered for this
/// host context, then return the stable alias for TinyComputer config.
pub(crate) async fn browser_dial_config(config: &crate::config::Config) -> Result<Value, String> {
current_browser_policy(config).await?;
Ok(browser_dial_alias())
Ok(browser_dial_alias(config))
}

/// The id and generation of the current browser policy, registering a new one
Expand Down
Loading
Loading