acb7f0f501ad

report the unsafe paths a whole-repo steal drops, as a steal into an existing repo does (3.2.3)

time
2026-09-28 15:34 UTC · 2 weeks ago
machine
Junes-MacBook-Pro.local
agent
claude-opus-5-5
session
harden shared path handling
parent
d5d9ef7e460f
5 files VERSION+1 −1src/exchange/exchange.v+1 −6src/exchange/steal.v+2 −1tests/cli_test.v+3 −0v.mod+1 −1
VERSION+1 −1
@@ -1 +1 @@1-3.2.21+3.2.3

view file

src/exchange/exchange.v+1 −6
@@ -264,12 +264,7 @@264264 			}265265 			decode_save(record_object.body)!266266 		}267-		for file in record.files {268-			if !snapshot.legal_path(file.path) {269-				fetched.unsafe_paths << snapshot.escape_path(file.path)270-			}271-		}272-		drop_unsafe_paths(mut record)267+		fetched.unsafe_paths << drop_unsafe_paths(mut record)273268 		for file in record.files {274269 			if !store.has_object(file.hash)! && file.hash !in fetched.repo_objects {275270 				blob := backend.get(object_key(repo, file.hash))!

view file

src/exchange/steal.v+2 −1
@@ -578,7 +578,8 @@578578 		if !body.found {579579 			continue580580 		}581-		record := decode_save(body.body)!581+		mut record := decode_save(body.body)!582+		fetched.unsafe_paths << drop_unsafe_paths(mut record)582583 		fetched.saves << record583584 	}584585 	fetched.saves = parent_first(fetched.saves)!

view file

tests/cli_test.v+3 −0
@@ -1061,6 +1061,9 @@10611061 10621062 	stolen := run_home(b_parent, home, 'steal', 'proj')10631063 	assert stolen.code == 0, stolen.err1064+	for dropped in ['../outside.txt', 'bad\\\\name', 'control\\x0dname'] {1065+		assert (stolen.out + stolen.err).contains('dropped unsafe path ${dropped}'), stolen.out + stolen.err1066+	}10641067 	assert os.read_file(os.join_path(b_parent, 'proj', 'safe.txt'))! == 'safe\n'10651068 	assert !os.exists(os.join_path(b_parent, 'outside.txt'))10661069 	assert !os.exists(os.join_path(b_parent, 'proj', 'bad', 'name'))

view file

v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 	name: 'koh3'3-	version: '3.2.2'3+	version: '3.2.3'44 	description: 'One SQLite file per repo, one line of history.'55 	license: 'MIT'66 }

view file