Disallowing : in the path for a cached entry

This commit is contained in:
Don Olmstead 2015-08-07 16:18:11 -07:00 committed by Olmstead
parent 7189d1390e
commit 3fdee1b8e8
2 changed files with 14 additions and 1 deletions

View file

@ -110,6 +110,10 @@ func expectTrustedNotify(c *common.Config) error {
// in the workspace.
func expectCacheInWorkspace(c *common.Config) error {
for _, step := range c.Build.Cache {
if strings.Index(step, ":") != -1 {
return fmt.Errorf("Cache cannot contain : in the path")
}
cleaned := filepath.Clean(step)
if strings.Index(cleaned, "../") != -1 {

View file

@ -113,7 +113,16 @@ func Test_Linter(t *testing.T) {
},
}
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()
})
})
g.It("Should fail when : is in the path", func() {
c := &common.Config{
Build: &common.Step{
Cache: []string{".git",".git:/../"},
},
}
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()
})
})
}