- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
139 lines
5.1 KiB
Rust
139 lines
5.1 KiB
Rust
//! Installs application requirements at startup and explicit config/account reloads.
|
|
//! Config construction rejects superseded policy snapshots.
|
|
|
|
use super::ApplicationPolicyLoad;
|
|
use super::ApplicationPolicySnapshot;
|
|
use super::ConfigManager;
|
|
use codex_config::ApplicationRequirementsToml;
|
|
use codex_config::NetworkDomainPermissionToml;
|
|
use codex_http_client::DestinationPolicy;
|
|
use codex_http_client::NetworkPolicyDenied;
|
|
use std::io;
|
|
use std::sync::Arc;
|
|
|
|
pub(crate) fn destination_policy(
|
|
application: Option<&ApplicationRequirementsToml>,
|
|
) -> DestinationPolicy {
|
|
match application.and_then(|application| application.network.as_ref()) {
|
|
Some(network) if network.enabled => DestinationPolicy::Restricted {
|
|
allowed_hosts: network
|
|
.domains
|
|
.iter()
|
|
.filter(|&(_host, permission)| *permission == NetworkDomainPermissionToml::Allow)
|
|
.map(|(host, _permission)| host.clone())
|
|
.collect(),
|
|
},
|
|
Some(_) | None => DestinationPolicy::Unrestricted,
|
|
}
|
|
}
|
|
|
|
impl ConfigManager {
|
|
pub(super) async fn refresh_local_network_policy(
|
|
&self,
|
|
) -> io::Result<codex_config::loader::LocalApplicationRequirements> {
|
|
let _reload = self
|
|
.network_policy_reload
|
|
.acquire()
|
|
.await
|
|
.map_err(io::Error::other)?;
|
|
self.load_local_network_policy(self.network_policy.policy().revision())
|
|
.await
|
|
}
|
|
|
|
async fn load_local_network_policy(
|
|
&self,
|
|
application_revision: codex_http_client::NetworkPolicyRevision,
|
|
) -> io::Result<codex_config::loader::LocalApplicationRequirements> {
|
|
let local_revision = self.local_network_policy.policy().revision();
|
|
let result = async {
|
|
let sources = codex_config::loader::load_local_application_requirements(
|
|
codex_exec_server::LOCAL_FS.as_ref(),
|
|
&self.loader_overrides,
|
|
)
|
|
.await?;
|
|
let application = sources.compose()?;
|
|
self.local_network_policy
|
|
.publish(local_revision, destination_policy(application.as_ref()));
|
|
Ok(sources)
|
|
}
|
|
.await;
|
|
if result.is_err() {
|
|
self.local_network_policy.unavailable(local_revision);
|
|
self.fail_application_policy(application_revision)?;
|
|
}
|
|
result
|
|
}
|
|
|
|
pub(crate) async fn refresh_application_network_policy(
|
|
&self,
|
|
) -> io::Result<ApplicationPolicyLoad> {
|
|
let _reload = self
|
|
.network_policy_reload
|
|
.acquire()
|
|
.await
|
|
.map_err(io::Error::other)?;
|
|
let revision = self.network_policy.policy().revision();
|
|
let local_sources = self.load_local_network_policy(revision).await?;
|
|
let result = local_sources
|
|
.compose()
|
|
.map(|application| destination_policy(application.as_ref()));
|
|
match result {
|
|
Ok(policy) => {
|
|
let mut current = self.network_policy_snapshot.write().map_err(|_| {
|
|
io::Error::other("application network policy snapshot lock poisoned")
|
|
})?;
|
|
if !self.network_policy.publish(revision, policy.clone()) {
|
|
*current = None;
|
|
return Err(io::Error::other(NetworkPolicyDenied::Revoked));
|
|
}
|
|
let next = ApplicationPolicySnapshot { revision, policy };
|
|
// Concurrent config loads may finish together if their actual inputs are unchanged.
|
|
let snapshot = match current.as_ref() {
|
|
Some(snapshot) if snapshot.as_ref() == &next => Arc::clone(snapshot),
|
|
_ => {
|
|
let snapshot = Arc::new(next);
|
|
*current = Some(Arc::clone(&snapshot));
|
|
snapshot
|
|
}
|
|
};
|
|
Ok(ApplicationPolicyLoad { snapshot })
|
|
}
|
|
Err(error) => {
|
|
self.fail_application_policy(revision)?;
|
|
Err(error)
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(super) fn check_application_policy_load(
|
|
&self,
|
|
load: &ApplicationPolicyLoad,
|
|
) -> io::Result<()> {
|
|
let current = self
|
|
.network_policy_snapshot
|
|
.read()
|
|
.map_err(|_| io::Error::other("application network policy snapshot lock poisoned"))?;
|
|
if self.network_policy.policy().revision() != load.snapshot.revision
|
|
|| !current
|
|
.as_ref()
|
|
.is_some_and(|snapshot| Arc::ptr_eq(snapshot, &load.snapshot))
|
|
{
|
|
return Err(io::Error::other(NetworkPolicyDenied::Revoked));
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn fail_application_policy(
|
|
&self,
|
|
revision: codex_http_client::NetworkPolicyRevision,
|
|
) -> io::Result<()> {
|
|
let mut current = self
|
|
.network_policy_snapshot
|
|
.write()
|
|
.map_err(|_| io::Error::other("application network policy snapshot lock poisoned"))?;
|
|
self.network_policy.unavailable(revision);
|
|
*current = None;
|
|
Ok(())
|
|
}
|
|
}
|