Files
imeai-aKode/codex-rs/plugin/src/bundled_hooks.rs
andrea.difonzo 6089fbde91 aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT
- 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>
2026-11-10 16:20:15 +01:00

119 lines
3.4 KiB
Rust

//! Temporary cleanup-hook allowlist shared by local and executor plugin discovery.
//! This narrowly authorizes known MCP cleanup calls; it does not verify plugin signatures.
use codex_config::HookHandlerConfig;
use codex_protocol::protocol::HookEventName;
struct BundledHook {
plugin_id: &'static str,
events: &'static [HookEventName],
target: BundledHookTarget,
}
enum BundledHookTarget {
McpServer {
server: &'static str,
tool: &'static str,
},
}
// Keep unsigned plugin exceptions together so they can be removed as signing lands.
const ALLOWLISTED_BUNDLED_HOOKS: &[BundledHook] = &[
BundledHook {
plugin_id: "browser@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome-dev@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome-internal@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "computer-use@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "unified-computer-use@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "cua_repl",
tool: "turn_ended",
},
},
];
/// Matches a temporary unsigned cleanup exception.
pub fn is_allowlisted_bundled_cleanup_hook(
plugin_id: &str,
event: HookEventName,
matcher: Option<&str>,
handler: &HookHandlerConfig,
) -> bool {
let HookHandlerConfig::McpTool { server, tool, .. } = handler else {
return false;
};
matcher.is_none()
&& ALLOWLISTED_BUNDLED_HOOKS.iter().any(|hook| {
hook.plugin_id == plugin_id
&& hook.events.contains(&event)
&& match hook.target {
BundledHookTarget::McpServer {
server: expected_server,
tool: expected_tool,
} => server == expected_server && tool == expected_tool,
}
})
}