-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_test.go
52 lines (43 loc) · 1.04 KB
/
filter_test.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
48
49
50
51
52
package uguisu_test
import (
"testing"
"github.com/m-mizutani/uguisu"
"github.com/m-mizutani/uguisu/pkg/models"
"github.com/stretchr/testify/assert"
)
func dropCIS3_4Filter(alert *models.Alert) bool {
if alert.RuleID == "aws_cis_3.4" { // nolint
return false
}
return true
}
func TestFilterDrop(t *testing.T) {
t.Run("detect CIS 3.4 with no filter", func(t *testing.T) {
detected := uguisu.New().Test([]*models.CloudTrailRecord{
{
EventName: "DeleteGroupPolicy",
},
})
assert.Equal(t, 1, len(detected))
})
t.Run("dropCIS3_4", func(t *testing.T) {
ug := uguisu.New()
ug.Filters = append(ug.Filters, dropCIS3_4Filter)
t.Run("drops CIS 3.4 alert", func(t *testing.T) {
detected := ug.Test([]*models.CloudTrailRecord{
{
EventName: "DeleteGroupPolicy",
},
})
assert.Equal(t, 0, len(detected))
})
t.Run("does not drop detect CIS 3.5", func(t *testing.T) {
detected := ug.Test([]*models.CloudTrailRecord{
{
EventName: "CreateTrail",
},
})
assert.Equal(t, 1, len(detected))
})
})
}