-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathitem-security.go
40 lines (34 loc) · 933 Bytes
/
item-security.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
package main
type ItemSecurity struct {
name, description, kind string
}
func (is *ItemSecurity) Name() string {
return is.name
}
func (is *ItemSecurity) Description() string {
return is.description
}
func (is *ItemSecurity) Kind() string {
return is.kind
}
func (is *ItemSecurity) Lint(config *Config, params LinterParams) (ResultMap, error) {
resultSecurity := make(ResultMap)
problem := "privileged"
for _, item := range config.Items {
if item.Kind != is.Kind() {
continue
}
if item.Spec != nil && item.Spec.Template != nil {
for _, container := range item.Spec.Template.Spec.Containers {
name := container.Name
if container.SecurityContext != nil {
if container.SecurityContext.Privileged == true {
resultSecurity[problem] = append(resultSecurity[problem],
ContainerSpec{item.Metadata.Namespace, item.Metadata.Name, name})
}
}
}
}
}
return resultSecurity, nil
}