mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 10:21:00 +00:00
Merge pull request #1731 from bradrydzewski/master
prevent custom commands in plugin
This commit is contained in:
commit
ae418bf063
2 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package transform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -61,6 +62,9 @@ func ImageEscalate(conf *yaml.Config, patterns []string) error {
|
|||
for _, c := range conf.Pipeline {
|
||||
for _, pattern := range patterns {
|
||||
if ok, _ := filepath.Match(pattern, c.Image); ok {
|
||||
if len(c.Commands) != 0 {
|
||||
return fmt.Errorf("Custom commands disabled for the %s plugin", c.Image)
|
||||
}
|
||||
c.Privileged = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,17 @@ func Test_escalate(t *testing.T) {
|
|||
ImageEscalate(c, []string{"plugins/docker"})
|
||||
g.Assert(c.Pipeline[0].Privileged).IsFalse()
|
||||
})
|
||||
|
||||
g.It("should not escalate plugin with commands", func() {
|
||||
c := newConfig(&yaml.Container{
|
||||
Image: "docker",
|
||||
Commands: []string{"echo foo"},
|
||||
})
|
||||
|
||||
err := ImageEscalate(c, []string{"docker"})
|
||||
g.Assert(c.Pipeline[0].Privileged).IsFalse()
|
||||
g.Assert(err.Error()).Equal("Custom commands disabled for the docker plugin")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue