Skip to content

Commit f626137

Browse files
authored
Migrate from yaml.v2 to yaml.v3 (#156)
Since there is already a dependency on yaml.v3, we might as well upgrade the project to use yaml.v3 too. One change that affected normalizations.yaml was how YAML anchors are merged so I needed to add the `what: user-session` to retain the previous output in tests. Also in normalizations.yaml I noticed there were unused macros and I removed them.
1 parent bebb5c6 commit f626137

9 files changed

+12
-35
lines changed

aucoalesce/coalesce_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
"github.com/stretchr/testify/assert"
3131
"github.com/stretchr/testify/require"
32-
"gopkg.in/yaml.v2"
32+
"gopkg.in/yaml.v3"
3333

3434
"github.com/elastic/go-libaudit/v2/auparse"
3535
)
@@ -124,7 +124,7 @@ func readEventsFromYAML(t testing.TB, name string) []testEvent {
124124
t.Fatal("failed to find 'tests' in yaml")
125125
}
126126

127-
cases, ok := tests.(map[interface{}]interface{})
127+
cases, ok := tests.(map[string]interface{})
128128
if !ok {
129129
t.Fatalf("unexpected type %T for 'tests'", tests)
130130
}
@@ -146,7 +146,7 @@ func readEventsFromYAML(t testing.TB, name string) []testEvent {
146146
}
147147

148148
testEvents = append(testEvents, testEvent{
149-
name: name.(string),
149+
name: name,
150150
messages: msgs,
151151
})
152152
}

aucoalesce/normalizations.yaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# Macros declares some YAML anchors that can be referenced for some common
33
# object type normalizations like user-session, socket, or process.
44
macros:
5-
- &defaults
6-
subject:
7-
primary: auid
8-
secondary: uid
9-
how: [exe, comm]
10-
115
- &macro-user-session
126
subject:
137
primary: auid
@@ -18,21 +12,6 @@ macros:
1812
what: user-session
1913
how: [exe, terminal]
2014

21-
- &macro-socket
22-
<<: *defaults
23-
object:
24-
primary: [addr, path]
25-
secondary: port
26-
what: socket
27-
28-
- &macro-process
29-
<<: *defaults
30-
object:
31-
primary: [cmd, exe, comm]
32-
secondary: pid
33-
what: process
34-
how: terminal
35-
3615
- &ecs-iam
3716
category: iam
3817
type: info
@@ -1539,6 +1518,7 @@ normalizations:
15391518
object:
15401519
primary: addr
15411520
secondary: [rport]
1521+
what: user-session
15421522
record_types: CRYPTO_SESSION
15431523
source_ip: [addr]
15441524
ecs: *ecs-process

aucoalesce/normalize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"fmt"
2323
"strings"
2424

25-
"gopkg.in/yaml.v2"
25+
"gopkg.in/yaml.v3"
2626
)
2727

2828
var (

aucoalesce/normalize_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"testing"
2323

2424
"github.com/stretchr/testify/assert"
25-
"gopkg.in/yaml.v2"
25+
"gopkg.in/yaml.v3"
2626
)
2727

2828
func TestNormInit(t *testing.T) {

cmd/auparse/auparse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"os"
2828
"time"
2929

30-
"gopkg.in/yaml.v2"
30+
"gopkg.in/yaml.v3"
3131

3232
"github.com/elastic/go-libaudit/v2"
3333
"github.com/elastic/go-libaudit/v2/aucoalesce"

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ require (
77
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
88
github.com/stretchr/testify v1.7.0
99
golang.org/x/sys v0.11.0
10-
gopkg.in/yaml.v2 v2.4.0
10+
gopkg.in/yaml.v3 v3.0.1
1111
)
1212

1313
require (
1414
github.com/davecgh/go-spew v1.1.1 // indirect
1515
github.com/pmezard/go-difflib v1.0.0 // indirect
16-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
1716
)

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
4242
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
4343
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
4444
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
45-
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
46-
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
4745
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
48-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
49-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
46+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
47+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

rule/gen_testdata_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"testing"
3434

3535
"github.com/kballard/go-shellquote"
36-
"gopkg.in/yaml.v2"
36+
"gopkg.in/yaml.v3"
3737

3838
"github.com/elastic/go-libaudit/v2"
3939
"github.com/elastic/go-libaudit/v2/sys"

rule/rule_integ_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"testing"
3030

3131
"github.com/stretchr/testify/assert"
32-
"gopkg.in/yaml.v2"
32+
"gopkg.in/yaml.v3"
3333

3434
"github.com/elastic/go-libaudit/v2/rule"
3535
"github.com/elastic/go-libaudit/v2/rule/flags"

0 commit comments

Comments
 (0)