diff --git a/model/secret.go b/model/secret.go index 159fba5d54..1cfd8a1081 100644 --- a/model/secret.go +++ b/model/secret.go @@ -44,6 +44,9 @@ type Secret struct { // Match returns true if an image and event match the restricted list. func (s *Secret) Match(event string) bool { + if len(s.Events) == 0 { + return true + } for _, pattern := range s.Events { if match, _ := filepath.Match(pattern, event); match { return true diff --git a/model/secret_test.go b/model/secret_test.go index b2f39149be..16e1e65942 100644 --- a/model/secret_test.go +++ b/model/secret_test.go @@ -21,6 +21,10 @@ func TestSecret(t *testing.T) { secret.Events = []string{"pull_request"} g.Assert(secret.Match("push")).IsFalse() }) + g.It("should match when no event filters defined", func() { + secret := Secret{} + g.Assert(secret.Match("pull_request")).IsTrue() + }) g.It("should pass validation") g.Describe("should fail validation", func() { g.It("when no image")