mirror of
https://github.com/openai/codex.git
synced 2026-09-05 15:18:41 +00:00
## What changed - Define the `network/policyRequest` RPC payloads for associating a network request with a process and returning an `allow`, `deny`, or `ask` decision. - Cover HTTP, HTTPS CONNECT, and SOCKS5 TCP/UDP requests, with shared size limits for callback fields. - Add the backward-compatible `requestPolicyDecisions` remote proxy option so executors can opt in to sending policy decisions to clients. - Re-export the new protocol types from `codex-exec-server`. ## Testing - Verify the request and decision JSON shapes. - Verify that the proxy opt-in is omitted and defaults to `false` for legacy configurations, while an enabled value round-trips. GitOrigin-RevId: 65b0a0723d1abb6e4f504a41d3a0dd41f5f21bf7
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use crate::ProcessId;
|
|
|
|
pub const NETWORK_POLICY_REQUEST_METHOD: &str = "network/policyRequest";
|
|
pub const MAX_NETWORK_POLICY_HOST_BYTES: usize = 253;
|
|
pub const MAX_NETWORK_POLICY_PROCESS_ID_BYTES: usize = 256;
|
|
pub const MAX_NETWORK_POLICY_REASON_BYTES: usize = 1024;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct NetworkPolicyRequestParams {
|
|
pub process_id: ProcessId,
|
|
pub request: ExecServerNetworkPolicyRequest,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ExecServerNetworkPolicyRequest {
|
|
pub protocol: ExecServerNetworkProtocol,
|
|
pub host: String,
|
|
pub port: u16,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ExecServerNetworkProtocol {
|
|
Http,
|
|
HttpsConnect,
|
|
Socks5Tcp,
|
|
Socks5Udp,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct NetworkPolicyRequestResponse {
|
|
pub decision: ExecServerNetworkPolicyDecision,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum ExecServerNetworkPolicyDecision {
|
|
Allow,
|
|
Deny { reason: String },
|
|
Ask { reason: String },
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "network_policy_tests.rs"]
|
|
mod tests;
|