-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathplugin.go
More file actions
64 lines (55 loc) · 1.55 KB
/
plugin.go
File metadata and controls
64 lines (55 loc) · 1.55 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package outputs
import (
"fmt"
"strings"
"github.com/aquasecurity/postee/v2/data"
"github.com/aquasecurity/postee/v2/layout"
"github.com/aquasecurity/postee/v2/log"
)
const (
ApplicationScopeOwner = "<%application_scope_owner%>"
EventCategoryAttribute = "event_category"
CategoryIncident = "incident"
CategoryInsights = "insights"
CategoryScanResult = "scan_result"
EmptyID = ""
ResourceTypeKey = "resourceTypeKey"
CodeRepoResource = "code-repository"
)
type Output interface {
GetType() string
GetName() string
Init() error
Send(map[string]string) (data.OutputResponse, error)
Terminate() error
GetLayoutProvider() layout.LayoutProvider
CloneSettings() *data.OutputSettings //TODO shouldn't return reference
}
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.Logger.Errorf("get application scope owners error for %q: %v", outputName, err)
continue
}
for _, owner := range owners {
if owner != "" {
result = append(result, owner)
}
}
} else if r != "" {
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
}