Plug-ins: a failed grants write leaves the generation raised

The key store's generation for a plug-in folder now only goes up. When
writing or removing a signed grants.json fails after the raise, the
generation stays raised: the file left in place grants nothing and its
plug-ins ask for approval again. Before, the earlier generation was put
back, so a later raise could reach a generation a copy of the file was
already signed at, and that copy granted again.

- Keeping a lower generation than the kept one is an error.
- A signed file larger than 1 MiB is found before the raise, so the
  file in place keeps its grants when nothing can be written.
- A kept generation within two of the largest 64-bit value is not
  raised, so a signed write never fails after the raise for lack of a
  next generation.
This commit is contained in:
dotCooCoo committed 2026-11-21 14:08:20 -08:00
1 parent 389116e3a9
commit d60e2998d7
6 files changed
+225 -60

No files matched your search

+1 -1
View File
@@ -1218,7 +1218,7 @@ fn remove(s: &mut Session, p: &Value) -> Result<Value> {
let installed = registry::get(id).is_some();
// Settings and cache the store keeps for an id that isn't installed are deleted too.
let stored = !installed && vectorcraft_plugins::manifest::valid_id(id) && s.has_plugin_storage(id);
// Installed again, it asks again. A grant that can't be removed still approves the module, and
// Installed again, it asks again. A grant that can't be removed may still approve the module, and
// so may a grants file that can't be opened or read. One that is too large or doesn't hold a
// list approves nothing and doesn't stop the removal.
let forget = || s.store_grant_in(&turn, id, None) || !s.holds_plugin_grant(id);
+49 -41
View File
@@ -211,6 +211,11 @@ fn put(dir: &Path, file: &str, bytes: &[u8]) -> bool {
if std::fs::File::open(&path).is_ok_and(|old| holds(old, bytes)) {
return true;
}
#[cfg(test)]
if file == GRANTS_FILE && GRANTS_WRITE_FAILS.get() {
log::warn!("can't save {}: the test fails it", path.display());
return false;
}
let written = std::fs::create_dir_all(dir).and_then(|()| write_atomic(&path, bytes));
if let Err(e) = &written {
log::warn!("can't save {}: {e}", path.display());
@@ -285,6 +290,9 @@ thread_local! {
/// Tests: removing [`GRANTS_FILE`] fails on this thread while the file still reads, as when
/// another program holds it open.
pub(crate) static GRANTS_DELETE_FAILS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
/// Tests: writing [`GRANTS_FILE`] fails on this thread and leaves the file as it was, as on a
/// full volume.
pub(crate) static GRANTS_WRITE_FAILS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
/// Tests: [`Session::put_back_plugin`] writes the old module back on this thread and then
/// reports a failure, as when the last flush of a copy fails.
pub(crate) static PUT_BACK_FAILS_AFTER_WRITE: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
@@ -730,8 +738,9 @@ impl Session {
/// written at the generation after the raised one with the MAC of its grants for this folder
/// ([`grant_keys`]), making the key when the key store holds none; the key store then keeps that
/// generation ([`put_grants`]). A signed file left empty is removed after raising the generation
/// ([`take_signed_grants`]). A file VectorCraft didn't write for this folder ([`Trust::Unsigned`])
/// grants nothing: a grant replaces it with a file that holds that grant alone, and removing one
/// ([`take_signed_grants`]). The generation is never lowered: when the file can't be written or
/// removed after the raise, the file in place grants nothing and its plug-ins ask again. A file
/// VectorCraft didn't write for this folder ([`Trust::Unsigned`]) grants nothing: a grant replaces it with a file that holds that grant alone, and removing one
/// raises the generation ([`raise_generation`]), then takes out the entry for `id` and leaves the
/// rest unsigned. Removing a grant when there is no file, or when the file grants nothing
/// (unsigned, too large or not a list) and has no entry to take out, also raises the generation
@@ -1611,10 +1620,12 @@ fn trust_of(dir: &Path, signed: &SignedGrants) -> Trust {
/// is raised first ([`raise_generation`]), the file is written at the generation after the raised one
/// with its MAC, and the key store keeps that generation once the file is written. Every signed write
/// is then at a generation no file was signed at before, a write whose generation wasn't kept
/// included, since that one is at most one past the generation the key store kept. When the file
/// isn't written, the generation kept before is put back. When the file's generation can't be kept,
/// the file is at a generation the key store doesn't hold, so it grants nothing, and the write
/// reports a failure. Call it in the store's turn ([`StoreTurn`]).
/// included, since that one is at most one past the generation the key store kept. A file too large
/// either way is found before the raise, and then nothing changes. The kept generation only goes up:
/// when the file isn't written after the raise, the generation stays raised, so the file in place
/// grants nothing and its plug-ins ask again. When the file's generation can't be kept, the file is
/// at a generation the key store doesn't hold, so it grants nothing either. Both report a failure.
/// Call it in the store's turn ([`StoreTurn`]).
fn put_grants(dir: &Path, entries: Vec<serde_json::Value>, signed: bool) -> bool {
let path = dir.join(GRANTS_FILE);
let folder = plugin_store_key(dir);
@@ -1634,25 +1645,26 @@ fn put_grants(dir: &Path, entries: Vec<serde_json::Value>, signed: bool) -> bool
return false;
}
};
let Some((before, raised)) = raise_generation(dir) else { return false };
let Some(next) = raised.checked_add(1) else {
log::warn!("not updating the stored plug-in grants {}: the generation can't be raised", path.display());
keep_generation(dir, &folder, before);
return false;
};
let mac = serde_json::to_vec(&entries).ok().and_then(|grants| grant_keys::sign(&key, &folder, next, &grants));
let file = mac
.and_then(|mac| serde_json::to_value(SignedGrants { version: GRANTS_VERSION, generation: Some(next), grants: entries, mac: Some(mac) }).ok());
let Some(bytes) = grants_bytes(file) else {
// A file too large to keep is found before the raise, at the longest generation and a MAC of its
// length, so the file in place keeps its grants when nothing can be written.
let mut file =
SignedGrants { version: GRANTS_VERSION, generation: Some(u64::MAX), grants: entries, mac: Some("0".repeat(2 * grant_keys::KEY_LEN)) };
if grants_bytes(serde_json::to_value(&file).ok()).is_none() {
log::warn!("not updating the stored plug-in grants {}: {}", path.display(), too_large(MAX_GRANTS_FILE));
keep_generation(dir, &folder, before);
return false;
};
if !put(dir, GRANTS_FILE, &bytes) {
keep_generation(dir, &folder, before);
return false;
}
keep_generation(dir, &folder, next)
let Some(raised) = raise_generation(dir) else { return false };
let Some(next) = raised.checked_add(1) else {
log::warn!("not updating the stored plug-in grants {}: the generation can't be raised", path.display());
return false;
};
file.generation = Some(next);
file.mac = serde_json::to_vec(&file.grants).ok().and_then(|grants| grant_keys::sign(&key, &folder, next, &grants));
let Some(bytes) = file.mac.as_ref().and_then(|_| grants_bytes(serde_json::to_value(&file).ok())) else {
log::warn!("not updating the stored plug-in grants {}: {}", path.display(), too_large(MAX_GRANTS_FILE));
return false;
};
put(dir, GRANTS_FILE, &bytes) && keep_generation(dir, &folder, next)
}
/// `file` written as the bytes of a grants file: pretty-printed, or compact when that is larger than
@@ -1675,34 +1687,30 @@ fn keep_generation(dir: &Path, folder: &Path, generation: u64) -> bool {
}
/// Remove the signed grants file of the plug-in store `dir` → whether it is gone. Its generation is
/// raised first, so that no copy of the file grants anything once it is gone; when the file can't be
/// removed, the generation is put back, so the file keeps its grants, and when that can't be put back
/// either, the file grants nothing. The file holds no grant but the one being removed. Nothing is
/// removed when the generation can't be raised. Call it in the store's turn ([`StoreTurn`]).
/// raised first, so that no copy of the file grants anything once it is gone. The generation stays
/// raised when the file can't be removed: the file left in place then grants nothing, and its
/// plug-ins ask again. The file holds no grant but the one being removed. Nothing is removed when
/// the generation can't be raised. Call it in the store's turn ([`StoreTurn`]).
fn take_signed_grants(dir: &Path) -> bool {
let Some((before, _)) = raise_generation(dir) else { return false };
if take(dir, GRANTS_FILE) {
return true;
}
keep_generation(dir, &plugin_store_key(dir), before);
false
raise_generation(dir).is_some() && take(dir, GRANTS_FILE)
}
/// Keep a generation two past the one kept for the grants file of the plug-in store `dir`, so that
/// no signed copy of the file made before grants anything → the generation kept before and the one
/// kept now; `None`, with a log record, when the key store can't read or keep it or the generation
/// is too large to raise. A signed write whose generation wasn't kept is at the generation after the
/// kept one ([`put_grants`]), so the new generation is past it too. The generation comes from the key
/// store alone, never from a file, which anyone can edit.
fn raise_generation(dir: &Path) -> Option<(u64, u64)> {
/// no signed copy of the file made before grants anything → the generation kept now; `None`, with a
/// log record, when the key store can't read or keep it or the generation is within two of the
/// largest 64-bit value. A signed write whose generation wasn't kept is at the generation after the
/// kept one ([`put_grants`]), so the new generation is past it too. The generation comes from the
/// key store alone, never from a file, which anyone can edit, and it is never lowered again.
fn raise_generation(dir: &Path) -> Option<u64> {
let folder = plugin_store_key(dir);
let raised = grant_keys::current_generation(&folder).and_then(|generation| {
let next = generation.checked_add(2);
// A signed write goes one past the raised generation, so that one must fit too.
let next = generation.checked_add(3).and(generation.checked_add(2));
let next = next.ok_or_else(|| grant_keys::KeyStoreError("the generation can't be raised".into()))?;
grant_keys::set_current_generation(&folder, next).map(|()| (generation, next))
grant_keys::set_current_generation(&folder, next).map(|()| next)
});
match raised {
Ok(generations) => Some(generations),
Ok(generation) => Some(generation),
Err(e) => {
log::warn!("not changing the stored plug-in grants {}: {e}", dir.join(GRANTS_FILE).display());
None
+11 -5
View File
@@ -6,9 +6,9 @@
//! machine) grants nothing.
//!
//! The key store also keeps a generation for each plug-in folder, raised on every signed write of
//! its grants file, and the file carries its generation inside the MAC. A file whose generation is
//! not the one kept (an earlier copy put back over the current file, or a write whose generation
//! the key store didn't keep) grants nothing either.
//! its grants file and never lowered, and the file carries its generation inside the MAC. A file
//! whose generation is not the one kept (an earlier copy put back over the current file, or a write
//! whose generation the key store didn't keep or that failed after the raise) grants nothing either.
//!
//! The process uses one key store ([`set_grant_key_store`]); the apps use the system's
//! ([`use_os_grant_keys`]). In a process that sets none, every grants file counts as one whose key
@@ -182,9 +182,15 @@ pub(crate) fn current_generation(folder: &Path) -> Result<u64, KeyStoreError> {
Ok(current_store().ok_or_else(|| KeyStoreError("there is no key store".into()))?.generation(folder)?.unwrap_or(0))
}
/// Keep `generation` for the grants file of the plug-in store whose folder is `folder`.
/// Keep `generation` for the grants file of the plug-in store whose folder is `folder`. The kept
/// generation only goes up: one lower than the kept one is an error, and the kept one stays, since a
/// lower one could match a file signed before.
pub(crate) fn set_current_generation(folder: &Path, generation: u64) -> Result<(), KeyStoreError> {
current_store().ok_or_else(|| KeyStoreError("there is no key store".into()))?.set_generation(folder, generation)
let store = current_store().ok_or_else(|| KeyStoreError("there is no key store".into()))?;
if store.generation(folder)?.is_some_and(|kept| generation < kept) {
return Err(KeyStoreError("the key store keeps a later generation".into()));
}
store.set_generation(folder, generation)
}
/// The start of every MAC input: what it is a MAC of, and the version of the file.
+153 -4
View File
@@ -2918,8 +2918,9 @@ fn a_grants_file_that_cannot_be_deleted_keeps_the_stored_module() {
}
/// When the last grant can't be removed because `grants.json` can't be deleted, a replacing module
/// that asks for no permissions doesn't stay in the store: the store gets back the module the grant
/// still covers, and the grant is left as it was.
/// that asks for no permissions doesn't stay in the store: the store gets back the earlier module,
/// and the file is left as it was. The generation was raised before the removal and stays raised, so
/// the file left in place grants nothing and the module asks again.
#[test]
fn a_grants_file_whose_deletion_fails_keeps_the_stored_module() {
let folder = crate::tests_links::Folder::new("plugin-store-undeletable-grants");
@@ -2939,8 +2940,8 @@ fn a_grants_file_whose_deletion_fails_keeps_the_stored_module() {
run(&mut s, "plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(&plain), "replace": true}));
crate::store::GRANTS_DELETE_FAILS.set(false);
assert_eq!(std::fs::read(&file).unwrap(), approved, "the store gets the module the grant covers back");
assert_eq!(std::fs::read(&grants).unwrap(), recorded, "the grant stays as it was");
assert_eq!(run(&mut s, "plugin.inspect", json!({"dataBase64": approved_data}))["needsApproval"], false, "the grant still covers the module");
assert_eq!(std::fs::read(&grants).unwrap(), recorded, "the file stays as it was");
assert_eq!(run(&mut s, "plugin.inspect", json!({"dataBase64": approved_data}))["needsApproval"], true, "the file left in place grants nothing");
run(&mut s, "plugin.remove", json!({"id": id}));
assert!(!grants.exists(), "a removal that can delete the file forgets the grant");
@@ -4938,6 +4939,154 @@ fn a_write_whose_generation_wasnt_kept_grants_nothing_after_a_revoke() {
}
}
/// A signed write that fails after raising the generation leaves the generation raised: the file
/// left in place, signed at the generation before the raise, grants nothing and its plug-ins ask
/// again, and so does a copy of it put back after a later write.
#[test]
fn a_grants_write_that_fails_leaves_the_generation_raised() {
let keys = std::sync::Arc::new(crate::store::grant_keys::MemoryGrantKeys::default());
let _keys = ThreadKeys::using(SharedKeys::new(&keys));
let kept = |dir: &std::path::Path| kept_generation(&keys, dir);
let folder = crate::tests_links::Folder::new("plugin-store-write-fails");
let id = "test.engine.permissions.writefails";
let other = "test.engine.permissions.writefailsother";
let data = vectorcraft_format::base64_encode(&asking(id, r#"["doc.read"]"#, &json!({"objects": []})));
let other_data = vectorcraft_format::base64_encode(&asking(other, r#"["doc.read"]"#, &json!({"objects": []})));
let grants = folder.0.join("grants.json");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
run(&mut s, "plugin.install", json!({"dataBase64": data, "grant": ["doc.read"]}));
let earlier = std::fs::read(&grants).unwrap();
assert_eq!((generation_of(&earlier), kept(&folder.0)), (Some(3), Some(3)));
crate::store::GRANTS_WRITE_FAILS.set(true);
let grant = vectorcraft_plugins::permissions::Grant {
id: other.into(),
hash: vectorcraft_plugins::permissions::sha256_hex(b"module"),
permissions: vec![vectorcraft_plugins::permissions::Permission::DocRead],
};
let written = s.store_grant(other, Some(grant));
crate::store::GRANTS_WRITE_FAILS.set(false);
assert!(!written, "the write reports a failure");
assert_eq!(std::fs::read(&grants).unwrap(), earlier, "the file is left as it was");
assert_eq!(kept(&folder.0), Some(5), "the generation stays raised");
assert_eq!(starts_from(&folder.0, id, &data), (false, true), "the file left in place grants nothing");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
run(&mut s, "plugin.install", json!({"dataBase64": other_data, "grant": ["doc.read"]}));
assert_eq!((generation_of(&std::fs::read(&grants).unwrap()), kept(&folder.0)), (Some(8), Some(8)), "the next write is past the raise");
assert_eq!(starts_from(&folder.0, other, &other_data), (true, false), "the next write keeps its grant");
std::fs::write(&grants, &earlier).unwrap();
assert_eq!(starts_from(&folder.0, id, &data), (false, true), "the copy from before the raise grants nothing");
std::fs::remove_file(&grants).unwrap();
let mut s = session();
s.attach_plugin_store(folder.0.clone());
_ = s.execute("plugin.remove", &json!({"id": id}));
_ = s.execute("plugin.remove", &json!({"id": other}));
}
/// A revoke whose signed grants file can't be removed leaves the generation raised: the grant left in
/// the file doesn't come back, and a later removal takes the file away.
#[test]
fn a_revoke_whose_grants_file_cant_be_removed_doesnt_bring_the_grant_back() {
let keys = std::sync::Arc::new(crate::store::grant_keys::MemoryGrantKeys::default());
let _keys = ThreadKeys::using(SharedKeys::new(&keys));
let kept = |dir: &std::path::Path| kept_generation(&keys, dir);
let folder = crate::tests_links::Folder::new("plugin-store-remove-fails");
let id = "test.engine.permissions.removefails";
let data = vectorcraft_format::base64_encode(&asking(id, r#"["doc.read"]"#, &json!({"objects": []})));
let grants = folder.0.join("grants.json");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
run(&mut s, "plugin.install", json!({"dataBase64": data, "grant": ["doc.read"]}));
let recorded = std::fs::read(&grants).unwrap();
crate::store::GRANTS_DELETE_FAILS.set(true);
let revoked = s.store_grant(id, None);
crate::store::GRANTS_DELETE_FAILS.set(false);
assert!(!revoked, "the removal reports a failure");
assert_eq!(std::fs::read(&grants).unwrap(), recorded, "the file is left as it was");
assert_eq!(kept(&folder.0), Some(5), "the generation stays raised");
assert_eq!(starts_from(&folder.0, id, &data), (false, true), "the revoked grant doesn't come back");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
assert!(s.store_grant(id, None), "a later removal is recorded");
assert!(!grants.exists(), "and takes the file away");
std::fs::write(&grants, &recorded).unwrap();
assert_eq!(starts_from(&folder.0, id, &data), (false, true), "the copy put back grants nothing");
std::fs::remove_file(&grants).unwrap();
let mut s = session();
s.attach_plugin_store(folder.0.clone());
_ = s.execute("plugin.remove", &json!({"id": id}));
}
/// The key store's generation for a folder only goes up: a lower one is refused and the kept one
/// stays, while the same one and a higher one are kept.
#[test]
fn the_kept_grants_generation_is_never_lowered() {
let keys = std::sync::Arc::new(crate::store::grant_keys::MemoryGrantKeys::default());
let _keys = ThreadKeys::using(SharedKeys::new(&keys));
let folder = crate::tests_links::Folder::new("plugin-store-generation-lowered");
let store = crate::store::plugin_store_key(&folder.0);
assert!(crate::store::grant_keys::set_current_generation(&store, 5).is_ok());
assert!(crate::store::grant_keys::set_current_generation(&store, 3).is_err(), "a lower generation is refused");
assert_eq!(crate::store::grant_keys::current_generation(&store), Ok(5), "the kept one stays");
assert!(crate::store::grant_keys::set_current_generation(&store, 5).is_ok(), "the same one is kept");
assert!(crate::store::grant_keys::set_current_generation(&store, 6).is_ok());
assert_eq!(crate::store::grant_keys::current_generation(&store), Ok(6));
}
/// A kept generation within two of the largest 64-bit value isn't raised: a signed write leaves the
/// file and the generation as they are, and the file keeps its grant. Three below it, the write goes
/// to the largest value.
#[test]
fn a_kept_generation_near_the_largest_value_isnt_raised() {
use vectorcraft_plugins::permissions::{Grant, Permission, sha256_hex};
for (kept_before, written) in [(u64::MAX - 2, None), (u64::MAX - 3, Some(u64::MAX))] {
let keys = std::sync::Arc::new(crate::store::grant_keys::MemoryGrantKeys::default());
let _keys = ThreadKeys::using(SharedKeys::new(&keys));
let folder = crate::tests_links::Folder::new(&format!("plugin-store-generation-near-max-{}", u64::MAX - kept_before));
let store = crate::store::plugin_store_key(&folder.0);
let id = "test.engine.permissions.nearmax";
let other = "test.engine.permissions.nearmaxother";
let wasm = asking(id, r#"["doc.read"]"#, &json!({"objects": []}));
let data = vectorcraft_format::base64_encode(&wasm);
let grants = folder.0.join("grants.json");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
run(&mut s, "plugin.install", json!({"dataBase64": data, "grant": ["doc.read"]}));
crate::store::grant_keys::GrantKeyStore::set_generation(keys.as_ref(), &store, kept_before).unwrap();
let file =
crate::store::signed_grants_file(&folder.0, &json!([{"id": id, "hash": sha256_hex(&wasm), "permissions": ["doc.read"]}]).to_string());
std::fs::write(&grants, &file).unwrap();
assert_eq!(starts_from(&folder.0, id, &data), (true, false), "{kept_before}: the file grants");
let mut s = session();
s.attach_plugin_store(folder.0.clone());
let grant = Grant { id: other.into(), hash: sha256_hex(b"module"), permissions: vec![Permission::DocRead] };
assert_eq!(s.store_grant(other, Some(grant)), written.is_some(), "{kept_before}");
match written {
None => {
assert_eq!(std::fs::read(&grants).unwrap(), file, "{kept_before}: the file is left as it is");
assert_eq!(kept_generation(&keys, &folder.0), Some(kept_before), "{kept_before}: the generation too");
assert_eq!(starts_from(&folder.0, id, &data), (true, false), "{kept_before}: the file keeps its grant");
}
Some(generation) => {
assert_eq!(
(generation_of(&std::fs::read(&grants).unwrap()), kept_generation(&keys, &folder.0)),
(Some(generation), Some(generation))
);
assert_eq!(starts_from(&folder.0, id, &data), (true, false), "{kept_before}: the new file keeps the grant");
}
}
std::fs::remove_file(&grants).unwrap();
vectorcraft_plugins::registry::remove(id);
vectorcraft_plugins::registry::revoke(id);
}
}
/// The user agreed once: a heavy filter kept in the plug-in store is installed again at the next
/// start without asking, with its budget.
#[test]
+10 -8
View File
@@ -378,20 +378,22 @@ followed by the SHA-256 of the folder's resolved path in hexadecimal, in the sam
generation for a folder counts as generation 0. VectorCraft reads the generation from the key store only, never from
`grants.json`. Each time VectorCraft writes a signed `grants.json`, in the folder's turn (`disabled.lock`), it first
raises the kept generation by two, then writes the file at the generation after the raised one, and then keeps that
generation; when the file can't be written, it puts the earlier generation back. When it removes a signed
`grants.json`, it raises the generation by two first, and puts the earlier one back when the file can't be removed;
when the key store can't put it back either, the file grants nothing.
When the key store can't keep the generation of a write, the file just written grants nothing, and the write reports a
failure. That file is one generation past the kept one, so the next raise by two moves past it. When raising the
generation by two would pass the largest 64-bit value, VectorCraft logs a warning and changes nothing.
generation. When it removes a signed `grants.json`, it raises the generation by two first. The kept generation never
goes down: when the file can't be written or removed after the raise, the generation stays raised, the file left in
place grants nothing, and each plug-in it names that lists permissions asks for approval again. VectorCraft checks
before the raise whether the signed file would be larger than 1 MiB; when it would, VectorCraft logs a warning and
leaves the file and the generation as they are. When the key store can't keep the generation of a write, the file
just written grants nothing, and the write reports a failure. That file is one generation past the kept one, so the
next raise by two moves past it. When the kept generation is within two of the largest 64-bit value, VectorCraft
logs a warning and leaves the file and the generation as they are.
VectorCraft compares the MAC in constant time. A `grants.json` without the MAC of its generation, its grants and its
folder, or at another generation than the one the key store keeps for the folder, grants nothing, and each plug-in it
names that lists permissions asks for approval again. This covers a file that an earlier version wrote (a plain JSON
list), a grant that another program edited or added, a file whose `mac` was removed or changed, a file copied from
another `Plug-ins` folder or another computer, an earlier copy of the file put back after a grant was revoked or the
file was removed, a write whose generation the key store didn't keep, and a file whose key is no longer in the key
store. The next approval replaces such a file with a signed file that holds that grant alone, making a key first when
file was removed, a write whose generation the key store didn't keep, a file left in place by a write or removal that
failed, and a file whose key is no longer in the key store. The next approval replaces such a file with a signed file that holds that grant alone, making a key first when
the key store has none. When a grant is forgotten without an approval (`plugin.remove`, installing a module that lists
no permissions under that id, or a folder load that forgets the grant), VectorCraft raises the generation by two, then
takes that entry out of such a file and leaves the rest unsigned, so no earlier signed copy brings the entry back. It
+1 -1
View File
@@ -2660,7 +2660,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **An install automation asked for needs the person to start it (G17):** an approval question that a control request, MCP, injected input or a file dialog one of them opened leads to keeps OK disabled and refuses every confirm, a person's click included; it says to choose Object › Plug-ins › Install Plug-in…, and `ui.installPlugin` answers `approval: "personMustStartInstall"`. The person's own Install Plug-in…, File › Open or drop inspects the module again and asks a new question. Automation's `replace: true` no longer skips the question about taking another module's place, and that question now opens in the approval dialog for everyone. VectorCraft's own rule. Regressions: `crates/ui-egui/src/tests/automation.rs`, `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged.
- **A plug-in with no permissions ends its id's grant (G17):** installing a module that lists no permissions under a granted id forgets the grant, in the process and in `grants.json`, so the formerly approved bytes need a new approval. Attaching a `Plug-ins` folder whose module for that id lists no permissions forgets it too, and plug-in folders forget the process's grant. A refused install leaves the grant. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_safe_mode.rs`. Scores and hours unchanged.
- **A grant that can't be forgotten stops counting in the whole process (G17):** when such a grant can't be removed from `grants.json`, no session in the process that uses the same `Plug-ins` folder, by any path to it, counts it for `plugin.inspect`, `plugin.install` or loading plug-ins, until `grants.json` can be written for that plug-in; another process on the folder reads `grants.json` as it is. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged.
- **An edited grants file grants nothing (G17):** `grants.json` carries a generation and an HMAC-SHA-256 of its folder, generation and grants, made with a random key kept in the system key store (Keychain, Credential Manager, the Secret Service) and compared in constant time; the key store keeps each folder's generation, raised on every signed write and removal. A file without that MAC or at another generation (an earlier version's plain list, an edited or added grant, a removed or changed MAC, a file copied from another folder, an earlier copy put back after a revoke, a write whose generation wasn't kept) grants nothing, and its plug-ins ask for approval again; the next approval replaces it with a signed file. When the key store can't be reached, an approval lasts for the session only and the file is left as it is. VectorCraft's own rule. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged.
- **An edited grants file grants nothing (G17):** `grants.json` carries a generation and an HMAC-SHA-256 of its folder, generation and grants, made with a random key kept in the system key store (Keychain, Credential Manager, the Secret Service) and compared in constant time; the key store keeps each folder's generation, raised on every signed write and removal and never lowered. A file without that MAC or at another generation (an earlier version's plain list, an edited or added grant, a removed or changed MAC, a file copied from another folder, an earlier copy put back after a revoke, a write whose generation wasn't kept, a file left in place by a failed write or removal) grants nothing, and its plug-ins ask for approval again; the next approval replaces it with a signed file. When the key store can't be reached, an approval lasts for the session only and the file is left as it is. VectorCraft's own rule. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged.
- **Plug-in commands (G17):** a filter or live effect may declare up to 32 `commands` (`{id, label, params?}`); each is the command `plugin.<id>.<command>` while the plug-in is installed, in a submenu named after the plug-in under Object › Plug-ins (Effect › Plug-ins for a live effect) whatever menu the manifest names, with its label escaped. Commands are recorded in actions, listed in Keyboard Shortcuts for the user to give a shortcut, and run through `run` and MCP with their parameters checked first (a command with parameters opens a dialog from its menu item or shortcut). A run uses the plug-in's permissions (a live effect with commands may also hold `doc.write` and `state`, and gets them without a `permissions` list), is one undo step named after the command, and on failure (a trap or an exhausted instruction budget) leaves the document and the undo history as they were with an error naming the plug-in and the command. For a command and for `plugin.run`, an `ids` that is not a list of object ids is an error rather than the selection. A malformed entry is refused by name when the module is installed. Regressions: `crates/plugins/src/manifest.rs`, `crates/plugins/src/permissions.rs`, `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_fuzz.rs`, `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged.
- **Filter plug-ins call commands (G17, #2186):** a filter at plug-in API level 2 with the `commands` permission names the commands it may run in its manifest's `commandAllowlist` and runs them with `env.vc_call`, reading each result with `env.vc_call_result`. Each call sees what the calls before it changed; the calls and the filter's output are one undo step, and a run that fails, is canceled or makes a call that fails leaves every document, its selection and its history as they were. Commands that read or write files, use the clipboard, change preferences or the view, run scripts, actions or plug-ins, switch documents or undo are never called, and a manifest that lists one is refused when the module is installed. A command counts as taking a file or folder when its params description or schema names a file key as a param; a word in the description's prose or result does not count. Each exemption for a key that names part of the document names a param its command takes, which `every_command_is_sorted` checks, and Image Trace's path fidelity setting (`params.paths`, `savedPreset.paths`) is exempt only inside those settings. The install dialog lists the allowed commands. A run makes at most 1,000 calls, and each call costs 10,000 instructions of its budget. Regressions: `crates/plugins/tests/call.rs`, `crates/engine/tests/plugin_call.rs`, `crates/engine/src/cmd/plugin_call.rs`. Scores and hours unchanged.
- **The command sweep sends file and folder params into its temp folder by the command catalog:** the sweeps in `crates/engine/tests/command_sweep.rs` take each command's file and folder keys from the catalog (`cmd::location_keys`, the same key list the plug-in call rules use, less the keys that name part of the document in a command), read every key a params description names (`{path | name …}`, `{folder? (…)}` included) and its schema's params, and send every string under such a key, in arrays and in objects inside them (`paths: [{ids, path}]`), as a location in the temp folder, so a command added later is swept and checked without editing the sweep. `diffPath` counts as a file key, and Slice Options' `url` and Export for Screens' `folders` do not. Regressions: `sweep_cases_name_files_only_inside_the_temp_folder` and `sweep_cases_send_the_file_keys_of_the_command_catalog` in `command_sweep`, `location_keys_come_from_the_command_catalog` in `cmd::plugin_call`. Scores and hours unchanged.