fix: import/bootstrap hardening, canonical registry URLs, GUI canonical add path

- plain clones count as present; import refuses non-empty targets
- registry stores canonical https URLs; bootstrap matches provider by host
- clone URLs and repo names validated; GitHub link-style pagination
- bridge passes the canonical path to grove add; fix flaky instance test

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-11-16 18:58:28 +01:00
1 parent fdc5a8f5a6
commit 3cba9784a3
8 files changed
+273 -59

No files matched your search

+16 -7
View File
@@ -45,11 +45,15 @@ impl Bridge {
if let Err(e) = validate(args) {
return json!({"ok": false, "output": format!("rejected: {e}")});
}
if sub == "add"
&& let Err(e) = self.check_migrate_args(args)
{
return json!({"ok": false, "output": format!("rejected: {e}")});
// `add` gets the canonical path the check validated, not the string it was given.
let mut checked: Vec<String> = args.to_vec();
if sub == "add" {
match self.check_migrate_args(args) {
Ok(canon) => checked[1] = canon.to_string_lossy().into_owned(),
Err(e) => return json!({"ok": false, "output": format!("rejected: {e}")}),
}
}
let args = &checked[..];
let mut cmd = Command::new(&self.grove_bin);
if let Some(c) = &self.config {
cmd.arg("--config").arg(c);
@@ -94,12 +98,12 @@ impl Bridge {
}
/// `add <path>` only for an existing directory directly under `<root>/<group>/`.
fn check_migrate_args(&self, args: &[String]) -> Result<(), String> {
fn check_migrate_args(&self, args: &[String]) -> Result<PathBuf, String> {
let [_, path] = args else {
return Err("add takes exactly one path".into());
};
let cfg = self.loaded_config().ok_or("no readable configuration")?;
check_migrate_path(&cfg, Path::new(path)).map(|_| ())
check_migrate_path(&cfg, Path::new(path))
}
/// Where `grove add` writes its safety backup.
@@ -255,7 +259,7 @@ mod tests {
)).unwrap();
// A stand-in `grove` that reports what it was asked to do.
let fake = base.join("grove");
std::fs::write(&fake, "#!/bin/sh\necho \"migrated: $3/wt\"\n").unwrap();
std::fs::write(&fake, "#!/bin/sh\necho \"migrated: $4/wt\"\n").unwrap();
std::fs::set_permissions(&fake, std::fs::Permissions::from_mode(0o755)).unwrap();
let b = Bridge {
grove_bin: fake,
@@ -268,6 +272,11 @@ mod tests {
);
assert_eq!(ok["ok"], true, "{ok}");
assert!(ok["output"].as_str().unwrap().starts_with("migrated:"));
// A path with `..`/symlink parts reaches `grove add` in canonical form.
let sneaky = format!("{}/work/../work/proj", base.display());
let canon = base.join("work/proj").canonicalize().unwrap();
let r = b.cli(&["add".into(), sneaky], "");
assert_eq!(r["output"], format!("migrated: {}/wt", canon.display()));
let bad = b.cli(
&["add".into(), base.join("elsewhere").display().to_string()],
"",
+1
View File
@@ -124,6 +124,7 @@ mod tests {
fn tmp_sock(tag: &str) -> PathBuf {
let d = std::env::temp_dir().join(format!("gg-{tag}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&d); // leftovers of an earlier run with the same pid
std::fs::create_dir_all(&d).unwrap();
std::fs::set_permissions(&d, std::fs::Permissions::from_mode(0o700)).unwrap();
d.join("gui.sock")