mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Support trusted headers for remote exec WebSockets (#42606)
## What changed - Add `RemoteEnvironmentOptions` and `upsert_environment_with_options` so embedding hosts can attach trusted HTTP headers to remote exec-server WebSocket handshakes. - Preserve the headers across session reconnects while redacting them from debug output. - Reject invalid, duplicate, and WebSocket-controlled headers, and require `wss://` for non-loopback destinations. - Connect header-bearing loopback WebSockets directly, with DNS results restricted to loopback addresses. ## Testing - Cover header validation and redaction, delivery on initial connections and reconnects, and loopback destination enforcement. GitOrigin-RevId: f2e2b0456c8e33c13fd8ab4ee040a8b5c15e885d
This commit is contained in:
@@ -5,6 +5,7 @@ use std::time::Duration;
|
||||
|
||||
use codex_http_client::HttpClientFactory;
|
||||
use futures::future::BoxFuture;
|
||||
use http::HeaderMap;
|
||||
use tokio::sync::watch;
|
||||
|
||||
use crate::ExecServerError;
|
||||
@@ -108,6 +109,7 @@ pub(crate) enum ExecServerTransportParams {
|
||||
websocket_url: String,
|
||||
connect_timeout: Duration,
|
||||
initialize_timeout: Duration,
|
||||
http_headers: HeaderMap,
|
||||
},
|
||||
NoiseRendezvous {
|
||||
provider: Arc<dyn NoiseRendezvousConnectProvider>,
|
||||
@@ -131,11 +133,13 @@ impl std::fmt::Debug for ExecServerTransportParams {
|
||||
websocket_url,
|
||||
connect_timeout,
|
||||
initialize_timeout,
|
||||
..
|
||||
} => f
|
||||
.debug_struct("WebSocketUrl")
|
||||
.field("websocket_url", websocket_url)
|
||||
.field("connect_timeout", connect_timeout)
|
||||
.field("initialize_timeout", initialize_timeout)
|
||||
.field("http_headers", &"<redacted>")
|
||||
.finish(),
|
||||
Self::NoiseRendezvous { .. } => {
|
||||
f.debug_struct("NoiseRendezvous").finish_non_exhaustive()
|
||||
@@ -158,6 +162,7 @@ impl ExecServerTransportParams {
|
||||
websocket_url,
|
||||
connect_timeout,
|
||||
initialize_timeout: DEFAULT_REMOTE_EXEC_SERVER_INITIALIZE_TIMEOUT,
|
||||
http_headers: HeaderMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user