diff --git a/plugins/gcpaudit/go.mod b/plugins/gcpaudit/go.mod index daab09f3..ae0cb09d 100644 --- a/plugins/gcpaudit/go.mod +++ b/plugins/gcpaudit/go.mod @@ -6,7 +6,6 @@ require ( cloud.google.com/go/pubsub v1.30.0 github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b github.com/falcosecurity/plugin-sdk-go v0.7.3 - github.com/stretchr/testify v1.8.2 github.com/valyala/fastjson v1.6.4 google.golang.org/api v0.114.0 ) @@ -16,14 +15,12 @@ require ( cloud.google.com/go/compute v1.18.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v0.12.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.7.1 // indirect github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/net v0.8.0 // indirect golang.org/x/oauth2 v0.6.0 // indirect @@ -34,5 +31,4 @@ require ( google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 // indirect google.golang.org/grpc v1.53.0 // indirect google.golang.org/protobuf v1.29.1 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/gcpaudit/go.sum b/plugins/gcpaudit/go.sum index 48cbf5ff..6ca882e5 100644 --- a/plugins/gcpaudit/go.sum +++ b/plugins/gcpaudit/go.sum @@ -151,7 +151,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/gcpaudit/pkg/gcpaudit/extract_test.go b/plugins/gcpaudit/pkg/gcpaudit/extract_test.go deleted file mode 100644 index 97047567..00000000 --- a/plugins/gcpaudit/pkg/gcpaudit/extract_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package gcpaudit - -import ( - "bytes" - _ "embed" - "io" - "testing" - "time" - "unsafe" - - "github.com/falcosecurity/plugin-sdk-go/pkg/sdk" - "github.com/stretchr/testify/assert" -) - -var ( - //go:embed test.json - eventsJSON string -) - -type InMemoryEventReader struct { - Buffer []byte - ValEventNum uint64 - ValTimestamp uint64 -} - -func (i *InMemoryEventReader) EventNum() uint64 { - return i.ValEventNum -} - -func (i *InMemoryEventReader) Timestamp() uint64 { - return i.ValTimestamp -} - -func (i *InMemoryEventReader) Reader() io.ReadSeeker { - return bytes.NewReader(i.Buffer) -} - -type testExtractRequest struct { - fieldID uint64 - fieldType uint32 - field string - isList bool - argPresent bool - argIndex uint64 - argKey string -} - -type jsonData struct { - fileName string - content string -} - -func (t *testExtractRequest) FieldID() uint64 { - return t.fieldID -} - -func (t *testExtractRequest) FieldType() uint32 { - return t.fieldType -} - -func (t *testExtractRequest) Field() string { - return t.field -} - -func (t *testExtractRequest) ArgKey() string { - return t.argKey -} - -func (t *testExtractRequest) ArgIndex() uint64 { - return t.argIndex -} - -func (t *testExtractRequest) ArgPresent() bool { - return t.argPresent -} - -func (t *testExtractRequest) IsList() bool { - return t.isList -} - -func (t *testExtractRequest) SetValue(v interface{}) { - -} - -func (t *testExtractRequest) SetPtr(unsafe.Pointer) { - -} - -func fieldEntryToRequest(id uint64, field *sdk.FieldEntry, req *testExtractRequest) { - req.fieldID = id - req.field = field.Name - req.isList = field.IsList - if field.Type == "string" { - req.fieldType = sdk.FieldTypeCharBuf - } else { - req.fieldType = sdk.FieldTypeUint64 - } - req.argPresent = false - if field.Arg.IsIndex { - req.argPresent = true - req.argIndex = 0 - } else if field.Arg.IsKey { - req.argPresent = true - req.argKey = "sample" - } -} - -func TestExtractor_SampleFile(t *testing.T) { - req := &testExtractRequest{} - e := &Plugin{} - fields := e.Fields() - - for idx, field := range fields { - fieldEntryToRequest(uint64(idx), &field, req) - reader := &InMemoryEventReader{ - Buffer: []byte(eventsJSON), - ValEventNum: uint64(idx), - ValTimestamp: uint64(time.Now().UnixNano()), - } - - ret := e.Extract(req, reader) - assert.Nil(t, ret, field) - } -}