Logs
Patchsets
Range Diff ↕
1: 3bd44da ! 1: 9002592 chore(pgs): add validation to project names
@@ filehandlers/assets/handler.go project := getProject(s) projectName := shared.GetProjectName(entry) + err = shared.ValidateProjectName(projectName) + if err != nil { + return "", err + } + logger = logger.With("project", projectName) // find, create, or update project if we haven't already done it @@ pgs/cli.go func (c *Cmd) link(projectName, linkTo string) error { c.Log.Info("user running `link` command", "user", c.User.Name, "project", projectName, "link", linkTo) + err := shared.ValidateProjectName(projectName) + if err != nil { + return err + } + projectDir := linkTo - _, err := c.Dbpool.FindProjectByName(c.User.ID, linkTo) + _, err = c.Dbpool.FindProjectByName(c.User.ID, linkTo) if err != nil { e := fmt.Errorf("(%s) project doesn't exist", linkTo) return e @@ shared/bucket.go return fmt.Sprintf("static-%s", userID) } +func ValidateProjectName(projectName string) error { + if projectName == "pico-private" { + if projectName == "pico-private" || projectName == "pico-imgs" { + return fmt.Errorf("%s is an invalid project name", projectName) + } + return nil +} + func GetProjectName(entry *utils.FileEntry) string { if entry.Mode.IsDir() && strings.Count(entry.Filepath, string(os.PathSeparator)) == 0 { return entry.Filepath
Range Diff ↕
1: 9002592 = 1: 9002592 chore(pgs): add validation to project names
-: ------- > 2: cd17cf4 chore: update pobj
-: ------- > 3: a00def2 chore: complete impl
Range Diff ↕
1: 9002592 = 1: 9002592 chore(pgs): add validation to project names
2: cd17cf4 = 2: cd17cf4 chore: update pobj
3: a00def2 = 3: a00def2 chore: complete impl
-: ------- > 4: 0ed7dc9 chore: update pobj
-: ------- > 5: 8ff1131 working!
Range Diff ↕
1: 9002592 = 1: 9002592 chore(pgs): add validation to project names
2: cd17cf4 = 2: cd17cf4 chore: update pobj
3: a00def2 = 3: a00def2 chore: complete impl
4: 0ed7dc9 = 4: 0ed7dc9 chore: update pobj
5: 8ff1131 = 5: 8ff1131 working!
-: ------- > 6: 0c8ad0d chore(obj): prep service def
Patchset ps-28
chore(pgs): add validation to project names
Eric Bower
pgs/cli.go
+6
-1
shared/bucket.go
+7
-0
chore(pgs): add validation to project names
filehandlers/assets/handler.go
link
+5
-0
+5
-0
1diff --git a/filehandlers/assets/handler.go b/filehandlers/assets/handler.go
2index 22edce6..1c32d82 100644
3--- a/filehandlers/assets/handler.go
4+++ b/filehandlers/assets/handler.go
5@@ -268,6 +268,11 @@ func (h *UploadAssetHandler) Write(s ssh.Session, entry *utils.FileEntry) (strin
6
7 project := getProject(s)
8 projectName := shared.GetProjectName(entry)
9+ err = shared.ValidateProjectName(projectName)
10+ if err != nil {
11+ return "", err
12+ }
13+
14 logger = logger.With("project", projectName)
15
16 // find, create, or update project if we haven't already done it
pgs/cli.go
link
+6
-1
+6
-1
1diff --git a/pgs/cli.go b/pgs/cli.go
2index 0af5802..8e82241 100644
3--- a/pgs/cli.go
4+++ b/pgs/cli.go
5@@ -374,8 +374,13 @@ func (c *Cmd) unlink(projectName string) error {
6 func (c *Cmd) link(projectName, linkTo string) error {
7 c.Log.Info("user running `link` command", "user", c.User.Name, "project", projectName, "link", linkTo)
8
9+ err := shared.ValidateProjectName(projectName)
10+ if err != nil {
11+ return err
12+ }
13+
14 projectDir := linkTo
15- _, err := c.Dbpool.FindProjectByName(c.User.ID, linkTo)
16+ _, err = c.Dbpool.FindProjectByName(c.User.ID, linkTo)
17 if err != nil {
18 e := fmt.Errorf("(%s) project doesn't exist", linkTo)
19 return e