github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/deploy/remote/location.go (about) 1 package deployremote 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 "strings" 8 9 "github.com/henvic/wedeploycli/userhome" 10 ) 11 12 var home = userhome.GetHomeDir() 13 14 var forbiddenLocations = []string{ 15 home, 16 filepath.Join(home, "Downloads"), 17 filepath.Join(home, "Desktop"), 18 filepath.Join(home, "Documents"), 19 filepath.Join(home, "Pictures"), 20 filepath.Join(home, "Library"), 21 filepath.Join(home, "Library", "Keychains"), 22 filepath.Join(home, ".ssh"), 23 filepath.Join(home, ".gnupg"), 24 "/", 25 "/etc", 26 "/root", 27 "/tmp", 28 "/private", 29 "/bin", 30 "/home", 31 "/mnt", 32 "/Volumes", 33 "/Users", 34 } 35 36 func getWorkingDirectory() (wd string, err error) { 37 wd, err = os.Getwd() 38 39 if err != nil { 40 return "", err 41 } 42 43 for _, f := range forbiddenLocations { 44 if strings.EqualFold(f, wd) { 45 return "", fmt.Errorf("refusing to deploy from inside the top-level of \"%v\" because it might be unsafe", wd) 46 } 47 } 48 49 return wd, nil 50 }