修复了一些已知问题

This commit is contained in:
MengMengCode
2026-07-18 21:16:29 +08:00
parent 2324494dd7
commit f28117bc5e
6 changed files with 200 additions and 45 deletions
+11
View File
@@ -11,6 +11,17 @@ import (
"golang.org/x/crypto/ssh"
)
func TestLocalImageIDRejectsPathExpressions(t *testing.T) {
for _, id := range []string{"", ".", "..", "../../etc/passwd", `..\\..\\windows`, "/absolute"} {
if got := localImageID(id); got != "__invalid_image_id__" {
t.Fatalf("localImageID(%q) = %q", id, got)
}
}
if got := localImageID("debian-13-kvm"); got != "debian-13-kvm" {
t.Fatalf("localImageID(valid) = %q", got)
}
}
func TestChpasswdStdinPreservesShellMetacharacters(t *testing.T) {
password := `pa'";$(touch /tmp/pwned); echo #\\word`
got, err := chpasswdStdin("root", password)