mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 07:52:42 +00:00
Scripts: commands read through the gate in runs the person starts, and the grants file is not written over when it cannot be read
- A command a script runs reads only where the script may, also in a run the person started; only reads of the app's own folders inside the command are exempt. - Always and script.grants.revoke leave a grants file they cannot read as it is, and fail. - script.grants names a path outside the automation read roots by its file name alone. - copy reads the source once, within the 8 MiB limit, writes those bytes, and gives the copy the source's permissions. - write joins its values as UTF-16 before making them text, so a surrogate pair split between two values is one character.
This commit is contained in:
@@ -341,7 +341,17 @@ fn list_installed(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
fn grants(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let Some(dir) = s.script_data_dir() else { return Ok(json!({"grants": [], "file": null})) };
|
||||
let file = dir.with_file_name(script::files::GRANTS_FILE);
|
||||
Ok(json!({"grants": script::files::stored_grants(dir), "file": file.to_string_lossy()}))
|
||||
// A script or a granted path outside the automation read roots is named by its file name alone.
|
||||
let mut grants = script::files::stored_grants(dir);
|
||||
for g in &mut grants {
|
||||
for key in ["script", "path"] {
|
||||
if let Some(name) = g[key].as_str().and_then(hidden_name) {
|
||||
g[key] = json!(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
let file = file.to_string_lossy();
|
||||
Ok(json!({"grants": grants, "file": super::fileio::shown_path(&file)}))
|
||||
}
|
||||
|
||||
fn grants_revoke(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
|
||||
Reference in New Issue
Block a user