mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Disallowing : in the path for a cached entry
This commit is contained in:
parent
7189d1390e
commit
3fdee1b8e8
2 changed files with 14 additions and 1 deletions
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue