mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-24 23:59:30 +00:00
Improve secret availability checks (#3271)
This commit is contained in:
@@ -102,27 +102,6 @@ func (s Secret) IsRepository() bool {
|
||||
return s.RepoID != 0 && s.OrgID == 0
|
||||
}
|
||||
|
||||
// Match returns true if an image and event match the restricted list.
|
||||
// Note that EventPullClosed are treated as EventPull.
|
||||
func (s *Secret) Match(event WebhookEvent) bool {
|
||||
// if there is no filter set secret matches all webhook events
|
||||
if len(s.Events) == 0 {
|
||||
return true
|
||||
}
|
||||
// tread all pull events the same way
|
||||
if event == EventPullClosed {
|
||||
event = EventPull
|
||||
}
|
||||
// one match is enough
|
||||
for _, e := range s.Events {
|
||||
if e == event {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// a filter is set but the webhook did not match it
|
||||
return false
|
||||
}
|
||||
|
||||
var validDockerImageString = regexp.MustCompile(
|
||||
`^(` +
|
||||
`[\w\d\-_\.]+` + // hostname
|
||||
|
Reference in New Issue
Block a user