mirror of
https://github.com/harness/drone.git
synced 2025-05-07 04:21:35 +08:00
Disallowing : in the path for a cached entry
This commit is contained in:
parent
7189d1390e
commit
3fdee1b8e8
@ -110,6 +110,10 @@ func expectTrustedNotify(c *common.Config) error {
|
|||||||
// in the workspace.
|
// in the workspace.
|
||||||
func expectCacheInWorkspace(c *common.Config) error {
|
func expectCacheInWorkspace(c *common.Config) error {
|
||||||
for _, step := range c.Build.Cache {
|
for _, step := range c.Build.Cache {
|
||||||
|
if strings.Index(step, ":") != -1 {
|
||||||
|
return fmt.Errorf("Cache cannot contain : in the path")
|
||||||
|
}
|
||||||
|
|
||||||
cleaned := filepath.Clean(step)
|
cleaned := filepath.Clean(step)
|
||||||
|
|
||||||
if strings.Index(cleaned, "../") != -1 {
|
if strings.Index(cleaned, "../") != -1 {
|
||||||
|
@ -114,6 +114,15 @@ func Test_Linter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()
|
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 New Issue
Block a user