diff --git a/.goreleaser-dev.yaml b/.goreleaser-dev.yaml index 98772780..af24e57a 100644 --- a/.goreleaser-dev.yaml +++ b/.goreleaser-dev.yaml @@ -68,3 +68,27 @@ builds: binary: "plugins/blackstork/terraform@{{ .Version }}" ldflags: "-X main.version={{.Version}}" no_unique_dist_dir: true + + - id: hackerone + main: ./internal/hackerone/cmd + binary: "plugins/blackstork/hackerone@{{ .Version }}" + ldflags: "-X main.version={{.Version}}" + no_unique_dist_dir: true + + - id: virustotal + main: ./internal/virustotal/cmd + binary: "plugins/blackstork/virustotal@{{ .Version }}" + ldflags: "-X main.version={{.Version}}" + no_unique_dist_dir: true + + - id: splunk + main: ./internal/splunk/cmd + binary: "plugins/blackstork/splunk@{{ .Version }}" + ldflags: "-X main.version={{.Version}}" + no_unique_dist_dir: true + + - id: stixview + main: ./internal/stixview/cmd + binary: "plugins/blackstork/stixview@{{ .Version }}" + ldflags: "-X main.version={{.Version}}" + no_unique_dist_dir: true diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bcd19b62..0b67100a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -95,6 +95,42 @@ builds: - windows - darwin + - id: hackerone + main: ./internal/hackerone/cmd + binary: "plugins/blackstork/hackerone@{{ .Version }}" + flags: "-trimpath" + goos: + - linux + - windows + - darwin + + - id: virustotal + main: ./internal/virustotal/cmd + binary: "plugins/blackstork/virustotal@{{ .Version }}" + flags: "-trimpath" + goos: + - linux + - windows + - darwin + + - id: splunk + main: ./internal/splunk/cmd + binary: "plugins/blackstork/splunk@{{ .Version }}" + flags: "-trimpath" + goos: + - linux + - windows + - darwin + + - id: stixview + main: ./internal/stixview/cmd + binary: "plugins/blackstork/stixview@{{ .Version }}" + flags: "-trimpath" + goos: + - linux + - windows + - darwin + archives: - id: fabric format: tar.gz @@ -122,6 +158,10 @@ archives: - postgresql - sqlite - terraform + - hackerone + - virustotal + - splunk + - stixview name_template: >- plugins_ {{- .Os }}_ diff --git a/.mockery.yaml b/.mockery.yaml index f5abb328..51c97f6d 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -14,6 +14,18 @@ packages: interfaces: Client: github.com/blackstork-io/fabric/internal/openai/client: + config: + interfaces: + Client: + github.com/blackstork-io/fabric/internal/hackerone/client: + config: + interfaces: + Client: + github.com/blackstork-io/fabric/internal/virustotal/client: + config: + interfaces: + Client: + github.com/blackstork-io/fabric/internal/splunk/client: config: interfaces: Client: \ No newline at end of file diff --git a/docs/plugins/hackerone.md b/docs/plugins/hackerone.md new file mode 100644 index 00000000..307c4516 --- /dev/null +++ b/docs/plugins/hackerone.md @@ -0,0 +1,91 @@ +--- +title: blackstork/hackerone +weight: 20 +type: docs +--- + +# `blackstork/hackerone` plugin + +## Installation + +To install the plugin, add it to `plugin_versions` map in the Fabric global configuration block (see [Global configuration]({{< ref "configs.md#global-configuration" >}}) for more details), with a version constraint restricting which available versions of the plugin the codebase is compatible with: + +```hcl +fabric { + plugin_versions = { + "blackstork/hackerone" = "=> v0.0.0-dev" + } +} +``` + +## Data sources + +The plugin has the following data sources available: + +### `hackerone_reports` + +#### Configuration + +The data source supports the following configuration parameters: + +```hcl +config data hackerone_reports { + api_token = # required + api_username = # required +} +``` + +#### Usage + +The data source supports the following parameters in the data blocks: + +```hcl +data hackerone_reports { + assignee = # optional + bounty_awarded_at__gt = # optional + bounty_awarded_at__lt = # optional + bounty_awarded_at__null = # optional + closed_at__gt = # optional + closed_at__lt = # optional + closed_at__null = # optional + created_at__gt = # optional + created_at__lt = # optional + custom_fields = # optional + disclosed_at__gt = # optional + disclosed_at__lt = # optional + disclosed_at__null = # optional + first_program_activity_at__gt = # optional + first_program_activity_at__lt = # optional + first_program_activity_at__null = # optional + hacker_published = # optional + id = # optional + inbox_ids = # optional + keyword = # optional + last_activity_at__gt = # optional + last_activity_at__lt = # optional + last_program_activity_at__gt = # optional + last_program_activity_at__lt = # optional + last_program_activity_at__null = # optional + last_public_activity_at__gt = # optional + last_public_activity_at__lt = # optional + last_report_activity_at__gt = # optional + last_report_activity_at__lt = # optional + page_number = # optional + program = # optional + reporter = # optional + reporter_agreed_on_going_public = # optional + severity = # optional + size = # optional + sort = # optional + state = # optional + submitted_at__gt = # optional + submitted_at__lt = # optional + swag_awarded_at__gt = # optional + swag_awarded_at__lt = # optional + swag_awarded_at__null = # optional + triaged_at__gt = # optional + triaged_at__lt = # optional + triaged_at__null = # optional + weakness_id = # optional +} +``` \ No newline at end of file diff --git a/docs/plugins/splunk.md b/docs/plugins/splunk.md new file mode 100644 index 00000000..28ee1b41 --- /dev/null +++ b/docs/plugins/splunk.md @@ -0,0 +1,52 @@ +--- +title: blackstork/splunk +weight: 20 +type: docs +--- + +# `blackstork/splunk` plugin + +## Installation + +To install the plugin, add it to `plugin_versions` map in the Fabric global configuration block (see [Global configuration]({{< ref "configs.md#global-configuration" >}}) for more details), with a version constraint restricting which available versions of the plugin the codebase is compatible with: + +```hcl +fabric { + plugin_versions = { + "blackstork/splunk" = "=> v0.0.0-dev" + } +} +``` + +## Data sources + +The plugin has the following data sources available: + +### `splunk_search` + +#### Configuration + +The data source supports the following configuration parameters: + +```hcl +config data splunk_search { + auth_token = # required + deployment_name = # optional + host = # optional +} +``` + +#### Usage + +The data source supports the following parameters in the data blocks: + +```hcl +data splunk_search { + earliest_time = # optional + latest_time = # optional + max_count = # optional + rf = # optional + search_query = # required + status_buckets = # optional +} +``` \ No newline at end of file diff --git a/docs/plugins/stixview.md b/docs/plugins/stixview.md new file mode 100644 index 00000000..3df909b9 --- /dev/null +++ b/docs/plugins/stixview.md @@ -0,0 +1,50 @@ +--- +title: blackstork/stixview +weight: 20 +type: docs +--- + +# `blackstork/stixview` plugin + +## Installation + +To install the plugin, add it to `plugin_versions` map in the Fabric global configuration block (see [Global configuration]({{< ref "configs.md#global-configuration" >}}) for more details), with a version constraint restricting which available versions of the plugin the codebase is compatible with: + +```hcl +fabric { + plugin_versions = { + "blackstork/stixview" = "=> v0.0.0-dev" + } +} +``` + + + +## Content providers +The plugin has the following content providers available: + +### `stixview` + +#### Configuration + +The content provider doesn't support configuration. + +#### Usage + +The content source supports the following parameters in the content blocks: + +```hcl +content stixview { + caption = # optional + gist_id = # optional + height = # optional + show_footer = # optional + show_idrefs = # optional + show_labels = # optional + show_marking_nodes = # optional + show_sidebar = # optional + show_tlp_as_tags = # optional + stix_url = # optional + width = # optional +} +``` diff --git a/docs/plugins/virustotal.md b/docs/plugins/virustotal.md new file mode 100644 index 00000000..fe4930ca --- /dev/null +++ b/docs/plugins/virustotal.md @@ -0,0 +1,48 @@ +--- +title: blackstork/virustotal +weight: 20 +type: docs +--- + +# `blackstork/virustotal` plugin + +## Installation + +To install the plugin, add it to `plugin_versions` map in the Fabric global configuration block (see [Global configuration]({{< ref "configs.md#global-configuration" >}}) for more details), with a version constraint restricting which available versions of the plugin the codebase is compatible with: + +```hcl +fabric { + plugin_versions = { + "blackstork/virustotal" = "=> v0.0.0-dev" + } +} +``` + +## Data sources + +The plugin has the following data sources available: + +### `virustotal_api_usage` + +#### Configuration + +The data source supports the following configuration parameters: + +```hcl +config data virustotal_api_usage { + api_key = # required +} +``` + +#### Usage + +The data source supports the following parameters in the data blocks: + +```hcl +data virustotal_api_usage { + end_date = # optional + group_id = # optional + start_date = # optional + user_id = # optional +} +``` \ No newline at end of file diff --git a/examples/plugins/basic/content_greeting.go b/examples/plugins/basic/content_greeting.go index a23a2a0d..eb6e381e 100644 --- a/examples/plugins/basic/content_greeting.go +++ b/examples/plugins/basic/content_greeting.go @@ -16,7 +16,7 @@ func makeGreetingContentProvider() *plugin.ContentProvider { return &plugin.ContentProvider{ // Config is optional, in this case we don't need it // We only define the schema for the arguments - Args: &hcldec.ObjectSpec{ + Args: hcldec.ObjectSpec{ "name": &hcldec.AttrSpec{ Name: "name", Required: true, diff --git a/examples/plugins/basic/data_random_numbers.go b/examples/plugins/basic/data_random_numbers.go index 718ea869..b71ba47e 100644 --- a/examples/plugins/basic/data_random_numbers.go +++ b/examples/plugins/basic/data_random_numbers.go @@ -22,7 +22,7 @@ const ( func makeRandomNumbersDataSource() *plugin.DataSource { return &plugin.DataSource{ // Config is optional, we can define the schema for the config that is reusable for this data source - Config: &hcldec.ObjectSpec{ + Config: hcldec.ObjectSpec{ "min": &hcldec.AttrSpec{ Name: "min", Required: false, @@ -35,7 +35,7 @@ func makeRandomNumbersDataSource() *plugin.DataSource { }, }, // We define the schema for the arguments - Args: &hcldec.ObjectSpec{ + Args: hcldec.ObjectSpec{ "length": &hcldec.AttrSpec{ Name: "length", Required: true, diff --git a/examples/templates/stixview/data.csv b/examples/templates/stixview/data.csv new file mode 100644 index 00000000..94ecff74 --- /dev/null +++ b/examples/templates/stixview/data.csv @@ -0,0 +1,4 @@ +id,active,name,age,height +b8fa4bb0-6dd4-45ba-96e0-9a182b2b932e,true,Stacey,26,1.98 +b0086c49-bcd8-4aae-9f88-4f46b128e709,false,Myriam,33,1.81 +a12d2a8c-eebc-42b3-be52-1ab0a2969a81,true,Oralee,31,2.23 \ No newline at end of file diff --git a/examples/templates/stixview/example.fabric b/examples/templates/stixview/example.fabric new file mode 100644 index 00000000..4815c695 --- /dev/null +++ b/examples/templates/stixview/example.fabric @@ -0,0 +1,18 @@ +fabric { + cache_dir = "./.fabric" + plugin_registry { + mirror_dir = "dist/plugins" + } + plugin_versions = { + "blackstork/stixview" = "0.0.0-dev" + } +} + +document "example" { + title = "Using stixview plugin" + content stixview { + gist_id = "6a0fbb0f6e7faf063c748b23f9c7dc62" + height = 500 + width = 500 + } +} \ No newline at end of file diff --git a/examples/templates/virustotal/example.fabric b/examples/templates/virustotal/example.fabric new file mode 100644 index 00000000..1326ca2e --- /dev/null +++ b/examples/templates/virustotal/example.fabric @@ -0,0 +1,26 @@ +fabric { + cache_dir = "./.fabric" + plugin_registry { + mirror_dir = "dist/plugins" + } + plugin_versions = { + "blackstork/virustotal" = "0.0.0-dev" + } +} + +config data virustotal_api_usage { + api_key = "" +} + +document "example" { + title = "Using virustotal plugin" + + data virustotal_api_usage "my_usage" { + user_id = "" + start_date = "20240201" + end_date = "20240203" + } + content text { + text = "{{.data.virustotal_api_usage.my_usage.daily}}" + } +} \ No newline at end of file diff --git a/gen.go b/gen.go index 2c3806a4..7b070f0f 100644 --- a/gen.go +++ b/gen.go @@ -1,4 +1,4 @@ package main -//go:generate go run github.com/vektra/mockery/v2@v2.40.1 +//go:generate go run github.com/vektra/mockery/v2@v2.42.0 //go:generate go run github.com/bufbuild/buf/cmd/buf@v1.29.0 generate diff --git a/go.mod b/go.mod index 21a4528a..ce65d656 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/elastic/go-elasticsearch/v8 v8.11.1 github.com/golang-cz/devslog v0.0.8 github.com/google/go-github/v58 v58.0.0 + github.com/google/go-querystring v1.1.0 github.com/hashicorp/go-hclog v0.14.1 github.com/hashicorp/go-plugin v1.6.0 github.com/hashicorp/hcl/v2 v2.19.1 @@ -19,7 +20,6 @@ require ( github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-sqlite3 v1.14.20 github.com/pelletier/go-toml/v2 v2.1.1 - github.com/sanity-io/litter v1.5.5 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -60,7 +60,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.4.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect diff --git a/go.sum b/go.sum index 32272415..4e094f86 100644 --- a/go.sum +++ b/go.sum @@ -37,7 +37,6 @@ github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHf github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -151,7 +150,6 @@ github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOS github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= @@ -159,8 +157,6 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:Om github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= -github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -181,7 +177,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/mocks/internalpkg/github/client.go b/mocks/internalpkg/github/client.go index f1c3ffa4..1906e71c 100644 --- a/mocks/internalpkg/github/client.go +++ b/mocks/internalpkg/github/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.42.0. DO NOT EDIT. package github_mocks diff --git a/mocks/internalpkg/hackerone/client/client.go b/mocks/internalpkg/hackerone/client/client.go new file mode 100644 index 00000000..ba8120c9 --- /dev/null +++ b/mocks/internalpkg/hackerone/client/client.go @@ -0,0 +1,97 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package client_mocks + +import ( + context "context" + + client "github.com/blackstork-io/fabric/internal/hackerone/client" + + mock "github.com/stretchr/testify/mock" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +type Client_Expecter struct { + mock *mock.Mock +} + +func (_m *Client) EXPECT() *Client_Expecter { + return &Client_Expecter{mock: &_m.Mock} +} + +// GetAllReports provides a mock function with given fields: ctx, req +func (_m *Client) GetAllReports(ctx context.Context, req *client.GetAllReportsReq) (*client.GetAllReportsRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetAllReports") + } + + var r0 *client.GetAllReportsRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.GetAllReportsReq) (*client.GetAllReportsRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.GetAllReportsReq) *client.GetAllReportsRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.GetAllReportsRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.GetAllReportsReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_GetAllReports_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAllReports' +type Client_GetAllReports_Call struct { + *mock.Call +} + +// GetAllReports is a helper method to define mock.On call +// - ctx context.Context +// - req *client.GetAllReportsReq +func (_e *Client_Expecter) GetAllReports(ctx interface{}, req interface{}) *Client_GetAllReports_Call { + return &Client_GetAllReports_Call{Call: _e.mock.On("GetAllReports", ctx, req)} +} + +func (_c *Client_GetAllReports_Call) Run(run func(ctx context.Context, req *client.GetAllReportsReq)) *Client_GetAllReports_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.GetAllReportsReq)) + }) + return _c +} + +func (_c *Client_GetAllReports_Call) Return(_a0 *client.GetAllReportsRes, _a1 error) *Client_GetAllReports_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_GetAllReports_Call) RunAndReturn(run func(context.Context, *client.GetAllReportsReq) (*client.GetAllReportsRes, error)) *Client_GetAllReports_Call { + _c.Call.Return(run) + return _c +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClient(t interface { + mock.TestingT + Cleanup(func()) +}) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/internalpkg/openai/client/client.go b/mocks/internalpkg/openai/client/client.go index 4e250032..e6fea8a5 100644 --- a/mocks/internalpkg/openai/client/client.go +++ b/mocks/internalpkg/openai/client/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.42.0. DO NOT EDIT. package client_mocks diff --git a/mocks/internalpkg/splunk/client/client.go b/mocks/internalpkg/splunk/client/client.go new file mode 100644 index 00000000..46b34180 --- /dev/null +++ b/mocks/internalpkg/splunk/client/client.go @@ -0,0 +1,215 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package client_mocks + +import ( + context "context" + + client "github.com/blackstork-io/fabric/internal/splunk/client" + + mock "github.com/stretchr/testify/mock" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +type Client_Expecter struct { + mock *mock.Mock +} + +func (_m *Client) EXPECT() *Client_Expecter { + return &Client_Expecter{mock: &_m.Mock} +} + +// CreateSearchJob provides a mock function with given fields: ctx, req +func (_m *Client) CreateSearchJob(ctx context.Context, req *client.CreateSearchJobReq) (*client.CreateSearchJobRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for CreateSearchJob") + } + + var r0 *client.CreateSearchJobRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.CreateSearchJobReq) (*client.CreateSearchJobRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.CreateSearchJobReq) *client.CreateSearchJobRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.CreateSearchJobRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.CreateSearchJobReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_CreateSearchJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSearchJob' +type Client_CreateSearchJob_Call struct { + *mock.Call +} + +// CreateSearchJob is a helper method to define mock.On call +// - ctx context.Context +// - req *client.CreateSearchJobReq +func (_e *Client_Expecter) CreateSearchJob(ctx interface{}, req interface{}) *Client_CreateSearchJob_Call { + return &Client_CreateSearchJob_Call{Call: _e.mock.On("CreateSearchJob", ctx, req)} +} + +func (_c *Client_CreateSearchJob_Call) Run(run func(ctx context.Context, req *client.CreateSearchJobReq)) *Client_CreateSearchJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.CreateSearchJobReq)) + }) + return _c +} + +func (_c *Client_CreateSearchJob_Call) Return(_a0 *client.CreateSearchJobRes, _a1 error) *Client_CreateSearchJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_CreateSearchJob_Call) RunAndReturn(run func(context.Context, *client.CreateSearchJobReq) (*client.CreateSearchJobRes, error)) *Client_CreateSearchJob_Call { + _c.Call.Return(run) + return _c +} + +// GetSearchJobByID provides a mock function with given fields: ctx, req +func (_m *Client) GetSearchJobByID(ctx context.Context, req *client.GetSearchJobByIDReq) (*client.GetSearchJobByIDRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetSearchJobByID") + } + + var r0 *client.GetSearchJobByIDRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.GetSearchJobByIDReq) (*client.GetSearchJobByIDRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.GetSearchJobByIDReq) *client.GetSearchJobByIDRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.GetSearchJobByIDRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.GetSearchJobByIDReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_GetSearchJobByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSearchJobByID' +type Client_GetSearchJobByID_Call struct { + *mock.Call +} + +// GetSearchJobByID is a helper method to define mock.On call +// - ctx context.Context +// - req *client.GetSearchJobByIDReq +func (_e *Client_Expecter) GetSearchJobByID(ctx interface{}, req interface{}) *Client_GetSearchJobByID_Call { + return &Client_GetSearchJobByID_Call{Call: _e.mock.On("GetSearchJobByID", ctx, req)} +} + +func (_c *Client_GetSearchJobByID_Call) Run(run func(ctx context.Context, req *client.GetSearchJobByIDReq)) *Client_GetSearchJobByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.GetSearchJobByIDReq)) + }) + return _c +} + +func (_c *Client_GetSearchJobByID_Call) Return(_a0 *client.GetSearchJobByIDRes, _a1 error) *Client_GetSearchJobByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_GetSearchJobByID_Call) RunAndReturn(run func(context.Context, *client.GetSearchJobByIDReq) (*client.GetSearchJobByIDRes, error)) *Client_GetSearchJobByID_Call { + _c.Call.Return(run) + return _c +} + +// GetSearchJobResults provides a mock function with given fields: ctx, req +func (_m *Client) GetSearchJobResults(ctx context.Context, req *client.GetSearchJobResultsReq) (*client.GetSearchJobResultsRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetSearchJobResults") + } + + var r0 *client.GetSearchJobResultsRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.GetSearchJobResultsReq) (*client.GetSearchJobResultsRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.GetSearchJobResultsReq) *client.GetSearchJobResultsRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.GetSearchJobResultsRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.GetSearchJobResultsReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_GetSearchJobResults_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSearchJobResults' +type Client_GetSearchJobResults_Call struct { + *mock.Call +} + +// GetSearchJobResults is a helper method to define mock.On call +// - ctx context.Context +// - req *client.GetSearchJobResultsReq +func (_e *Client_Expecter) GetSearchJobResults(ctx interface{}, req interface{}) *Client_GetSearchJobResults_Call { + return &Client_GetSearchJobResults_Call{Call: _e.mock.On("GetSearchJobResults", ctx, req)} +} + +func (_c *Client_GetSearchJobResults_Call) Run(run func(ctx context.Context, req *client.GetSearchJobResultsReq)) *Client_GetSearchJobResults_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.GetSearchJobResultsReq)) + }) + return _c +} + +func (_c *Client_GetSearchJobResults_Call) Return(_a0 *client.GetSearchJobResultsRes, _a1 error) *Client_GetSearchJobResults_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_GetSearchJobResults_Call) RunAndReturn(run func(context.Context, *client.GetSearchJobResultsReq) (*client.GetSearchJobResultsRes, error)) *Client_GetSearchJobResults_Call { + _c.Call.Return(run) + return _c +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClient(t interface { + mock.TestingT + Cleanup(func()) +}) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/internalpkg/virustotal/client/client.go b/mocks/internalpkg/virustotal/client/client.go new file mode 100644 index 00000000..d3ee7a54 --- /dev/null +++ b/mocks/internalpkg/virustotal/client/client.go @@ -0,0 +1,156 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package client_mocks + +import ( + context "context" + + client "github.com/blackstork-io/fabric/internal/virustotal/client" + + mock "github.com/stretchr/testify/mock" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +type Client_Expecter struct { + mock *mock.Mock +} + +func (_m *Client) EXPECT() *Client_Expecter { + return &Client_Expecter{mock: &_m.Mock} +} + +// GetGroupAPIUsage provides a mock function with given fields: ctx, req +func (_m *Client) GetGroupAPIUsage(ctx context.Context, req *client.GetGroupAPIUsageReq) (*client.GetGroupAPIUsageRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetGroupAPIUsage") + } + + var r0 *client.GetGroupAPIUsageRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.GetGroupAPIUsageReq) (*client.GetGroupAPIUsageRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.GetGroupAPIUsageReq) *client.GetGroupAPIUsageRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.GetGroupAPIUsageRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.GetGroupAPIUsageReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_GetGroupAPIUsage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetGroupAPIUsage' +type Client_GetGroupAPIUsage_Call struct { + *mock.Call +} + +// GetGroupAPIUsage is a helper method to define mock.On call +// - ctx context.Context +// - req *client.GetGroupAPIUsageReq +func (_e *Client_Expecter) GetGroupAPIUsage(ctx interface{}, req interface{}) *Client_GetGroupAPIUsage_Call { + return &Client_GetGroupAPIUsage_Call{Call: _e.mock.On("GetGroupAPIUsage", ctx, req)} +} + +func (_c *Client_GetGroupAPIUsage_Call) Run(run func(ctx context.Context, req *client.GetGroupAPIUsageReq)) *Client_GetGroupAPIUsage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.GetGroupAPIUsageReq)) + }) + return _c +} + +func (_c *Client_GetGroupAPIUsage_Call) Return(_a0 *client.GetGroupAPIUsageRes, _a1 error) *Client_GetGroupAPIUsage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_GetGroupAPIUsage_Call) RunAndReturn(run func(context.Context, *client.GetGroupAPIUsageReq) (*client.GetGroupAPIUsageRes, error)) *Client_GetGroupAPIUsage_Call { + _c.Call.Return(run) + return _c +} + +// GetUserAPIUsage provides a mock function with given fields: ctx, req +func (_m *Client) GetUserAPIUsage(ctx context.Context, req *client.GetUserAPIUsageReq) (*client.GetUserAPIUsageRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetUserAPIUsage") + } + + var r0 *client.GetUserAPIUsageRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.GetUserAPIUsageReq) (*client.GetUserAPIUsageRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *client.GetUserAPIUsageReq) *client.GetUserAPIUsageRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.GetUserAPIUsageRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *client.GetUserAPIUsageReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Client_GetUserAPIUsage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserAPIUsage' +type Client_GetUserAPIUsage_Call struct { + *mock.Call +} + +// GetUserAPIUsage is a helper method to define mock.On call +// - ctx context.Context +// - req *client.GetUserAPIUsageReq +func (_e *Client_Expecter) GetUserAPIUsage(ctx interface{}, req interface{}) *Client_GetUserAPIUsage_Call { + return &Client_GetUserAPIUsage_Call{Call: _e.mock.On("GetUserAPIUsage", ctx, req)} +} + +func (_c *Client_GetUserAPIUsage_Call) Run(run func(ctx context.Context, req *client.GetUserAPIUsageReq)) *Client_GetUserAPIUsage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*client.GetUserAPIUsageReq)) + }) + return _c +} + +func (_c *Client_GetUserAPIUsage_Call) Return(_a0 *client.GetUserAPIUsageRes, _a1 error) *Client_GetUserAPIUsage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Client_GetUserAPIUsage_Call) RunAndReturn(run func(context.Context, *client.GetUserAPIUsageReq) (*client.GetUserAPIUsageRes, error)) *Client_GetUserAPIUsage_Call { + _c.Call.Return(run) + return _c +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClient(t interface { + mock.TestingT + Cleanup(func()) +}) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/parser/definitions/fabric_block.go b/mocks/parser/definitions/fabric_block.go index dfe386b9..aa6abfaa 100644 --- a/mocks/parser/definitions/fabric_block.go +++ b/mocks/parser/definitions/fabric_block.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.3. DO NOT EDIT. +// Code generated by mockery v2.42.0. DO NOT EDIT. package definitions_mocks diff --git a/tools/docgen/main.go b/tools/docgen/main.go index fafdddbf..97286374 100644 --- a/tools/docgen/main.go +++ b/tools/docgen/main.go @@ -15,10 +15,14 @@ import ( "github.com/blackstork-io/fabric/internal/elasticsearch" "github.com/blackstork-io/fabric/internal/github" "github.com/blackstork-io/fabric/internal/graphql" + "github.com/blackstork-io/fabric/internal/hackerone" "github.com/blackstork-io/fabric/internal/openai" "github.com/blackstork-io/fabric/internal/postgresql" + "github.com/blackstork-io/fabric/internal/splunk" "github.com/blackstork-io/fabric/internal/sqlite" + "github.com/blackstork-io/fabric/internal/stixview" "github.com/blackstork-io/fabric/internal/terraform" + "github.com/blackstork-io/fabric/internal/virustotal" "github.com/blackstork-io/fabric/plugin" ) @@ -52,6 +56,10 @@ func main() { postgresql.Plugin(version), sqlite.Plugin(version), terraform.Plugin(version), + hackerone.Plugin(version, nil), + virustotal.Plugin(version, nil), + splunk.Plugin(version, nil), + stixview.Plugin(version), } // generate markdown for each plugin for _, p := range plugins {