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
test(agent): rename and extend endpoint safety test for bearer credentials\n\nRenamed `is_https_endpoint_accepts_only_tls` to `is_safe_endpoint_for_bearer_accepts_tls_and_loopback` and updated the test to cover the new behaviour where cleartext HTTP is accepted for loopback addresses, since bearer credentials never leave the host in that case. The test now also rejects cleartext for remote hosts and unparseable values, ensuring the safety check is both permissive for local traffic and strict otherwise.\n\nAuto-committed-on: dragonfly\n
Steven Enamakelac8dca4e414f
diff --git a/src/embed/agent_tests.rs b/src/embed/agent_tests.rsindex 8f6a27f876..750fe86509 100644--- a/src/embed/agent_tests.rs+++ b/src/embed/agent_tests.rs@@ -116,14 +116,23 @@ fn route_debug_redacts_bearer_and_url_embedded_credentials() {}#[test]-fn is_https_endpoint_accepts_only_tls() {- assert!(is_https_endpoint("https://api.example.com/v1"));- assert!(is_https_endpoint("https://127.0.0.1:8443"));- assert!(!is_https_endpoint("http://api.example.com/v1"));+fn is_safe_endpoint_for_bearer_accepts_tls_and_loopback() {+ // TLS is always safe for a bearer.+ assert!(is_safe_endpoint_for_bearer("https://api.example.com/v1"));+ assert!(is_safe_endpoint_for_bearer("https://127.0.0.1:8443"));+ // Cleartext is refused for remote hosts...+ assert!(!is_safe_endpoint_for_bearer("http://api.example.com/v1"));+ assert!(!is_safe_endpoint_for_bearer("http://192.168.1.10/v1"));+ // ...but accepted for loopback, where the credential never leaves the host.+ assert!(is_safe_endpoint_for_bearer("http://127.0.0.1:8080/v1"));+ assert!(is_safe_endpoint_for_bearer("http://localhost:8080/v1"));+ assert!(is_safe_endpoint_for_bearer("http://[::1]:8080/v1"));+ assert!(is_safe_endpoint_for_bearer("http://127.0.0.2:8080/v1"));// Unparseable or non-URL values are refused, not silently allowed, so a// bearer can never ride a cleartext or ambiguous channel.- assert!(!is_https_endpoint("api.example.com"));- assert!(!is_https_endpoint("ftp://api.example.com"));+ assert!(!is_safe_endpoint_for_bearer("api.example.com"));+ assert!(!is_safe_endpoint_for_bearer("ftp://api.example.com"));+ assert!(!is_safe_endpoint_for_bearer("http://api.example.com:8080"));}#[test]