mirror of
https://github.com/openai/codex.git
synced 2026-11-20 15:07:25 +00:00
Trust hooks from materialized workspace plugins (#32301)
## What changed - Carry newly installed or updated remote plugin metadata through effective-plugin refresh callbacks, including coalesced refreshes. - After a successful refresh, record the current hook hashes for listed workspace plugins associated with the active account while preserving existing hook settings and unrelated state. - Serialize the background trust write with config mutations, and leave hooks untrusted if the write fails or the active account changes. ## Testing - Cover eligible plugin selection and escaped hook config keys. - Verify end-to-end trust for newly materialized plugin hooks, preservation of existing config, and fail-closed behavior when config cannot be written. GitOrigin-RevId: 0b150766415be6fccc117f7856a241e10ad456f2
This commit is contained in:
1 parent
dffe1f02a3
commit
076a110eb8
13 files changed
+815
-139
No files matched your search
@@ -0,0 +1,63 @@
|
||||
use super::*;
|
||||
use codex_plugin::PluginId;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn only_workspace_listed_materializations_are_eligible() {
|
||||
let materialization =
|
||||
|name: &str,
|
||||
scope: RemotePluginScope,
|
||||
discoverability: Option<RemotePluginShareDiscoverability>| {
|
||||
RemotePluginMaterialization {
|
||||
plugin_id: PluginId::new(name.to_string(), "test".to_string())
|
||||
.expect("valid plugin id"),
|
||||
scope,
|
||||
discoverability,
|
||||
authenticated_account_id: Some("account-123".to_string()),
|
||||
}
|
||||
};
|
||||
|
||||
let mut materializations = vec![
|
||||
materialization(
|
||||
"eligible",
|
||||
RemotePluginScope::Workspace,
|
||||
Some(RemotePluginShareDiscoverability::Listed),
|
||||
),
|
||||
materialization(
|
||||
"unlisted",
|
||||
RemotePluginScope::Workspace,
|
||||
Some(RemotePluginShareDiscoverability::Unlisted),
|
||||
),
|
||||
materialization(
|
||||
"private",
|
||||
RemotePluginScope::Workspace,
|
||||
Some(RemotePluginShareDiscoverability::Private),
|
||||
),
|
||||
materialization("workspace-missing", RemotePluginScope::Workspace, None),
|
||||
materialization("global", RemotePluginScope::Global, None),
|
||||
materialization("user", RemotePluginScope::User, None),
|
||||
];
|
||||
let mut wrong_account = materialization(
|
||||
"wrong-account",
|
||||
RemotePluginScope::Workspace,
|
||||
Some(RemotePluginShareDiscoverability::Listed),
|
||||
);
|
||||
wrong_account.authenticated_account_id = Some("account-456".to_string());
|
||||
materializations.push(wrong_account);
|
||||
|
||||
let plugin_ids = workspace_listed_plugin_ids(materializations, "account-123");
|
||||
|
||||
assert_eq!(plugin_ids, BTreeSet::from(["eligible@test".to_string()]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hook_trusted_hash_edit_targets_only_escaped_leaf() {
|
||||
assert_eq!(
|
||||
hook_trusted_hash_edit(r#"plugin."quoted"\path"#, "sha256:current"),
|
||||
ConfigEdit {
|
||||
key_path: r#"hooks.state."plugin.\"quoted\"\\path".trusted_hash"#.to_string(),
|
||||
value: serde_json::json!("sha256:current"),
|
||||
merge_strategy: MergeStrategy::Replace,
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user