/
plugin.go
47 lines (41 loc) · 1.04 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package actions
import (
"fmt"
"log"
"strings"
"github.com/aquasecurity/postee/v2/layout"
)
const (
ApplicationScopeOwner = "<%application_scope_owner%>"
)
type Action interface {
GetName() string
Init() error
Send(map[string]string) error
Terminate() error
GetLayoutProvider() layout.LayoutProvider
}
func getHandledRecipients(recipients []string, content *map[string]string, outputName string) []string {
var result []string
for _, r := range recipients {
if r == ApplicationScopeOwner {
owners, err := getAppScopeOwners(content)
if err != nil {
log.Printf("get application scope owners error for %q: %v", outputName, err)
continue
}
result = append(result, owners...)
} else {
result = append(result, r)
}
}
return result
}
func getAppScopeOwners(content *map[string]string) ([]string, error) {
ownersIn, ok := (*content)["owners"]
if !ok {
return nil, fmt.Errorf("recipients field contains %q, but received a webhook without this data",
ApplicationScopeOwner)
}
return strings.Split(ownersIn, ";"), nil
}