feat: add FTP and SFTP upload support
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package ssh
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateSFTPRemotePathRejectsTraversal(t *testing.T) {
|
||||
if got, err := validateSFTPRemotePath("snapgo/2026/image.png"); err != nil || got != "snapgo/2026/image.png" {
|
||||
t.Fatalf("valid path: got %q err=%v", got, err)
|
||||
}
|
||||
|
||||
for _, value := range []string{
|
||||
"",
|
||||
"/absolute/image.png",
|
||||
"~/image.png",
|
||||
"../image.png",
|
||||
"snapgo/../../image.png",
|
||||
"snapgo\\image.png",
|
||||
} {
|
||||
if _, err := validateSFTPRemotePath(value); err == nil {
|
||||
t.Errorf("expected %q to be rejected", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSFTPProbePathRejectsTraversalPrefix(t *testing.T) {
|
||||
if _, err := sftpProbePath("../../outside"); err == nil {
|
||||
t.Fatal("expected traversal prefix to fail")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user