-
Notifications
You must be signed in to change notification settings - Fork 544
feat(crowdstrike): CrowdStrike source plugin #5122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
e96f891
Draft : Crowdstrike source with just crowdscores
85163f4
Draft: adding alerts
1951b4c
Adds alerts and some testing
b932a90
Adds alert tests
187a1b9
Adds alert to pluging
7a49bd4
review comments
e472903
fix spelling action check
3cdc570
Update plugins/source/crowdstrike/README.md
cqgaurav d5e5a18
Update plugins/source/crowdstrike/client/client.go
cqgaurav 000c9d1
Update plugins/source/crowdstrike/resources/services/incidents/crowds…
cqgaurav 7da1812
Update plugins/source/crowdstrike/resources/services/alerts/query_fet…
cqgaurav f0e6fc4
commit
eaedb0e
udpate readme
b41b849
Merge branch 'main' into crowdstrike
cqgaurav daa9990
Merge branch 'main' into crowdstrike
cqgaurav af0aca4
Change primary key for crowdscore
33b9d90
Commit release configuration files
6d2254e
remove arns
8e35e3f
Merge branch 'main' into crowdstrike
cqgaurav e744f28
allow crowdstrike
4a5c3fa
Merge branch 'main' into crowdstrike
cqgaurav 58573cf
Merge branch 'main' into crowdstrike
cqgaurav 5aeb1e2
add more docs
42160ee
fix docs
d580406
Merge branch 'main' into crowdstrike
cqgaurav f9b64d6
Merge branch 'main' into crowdstrike
cqgaurav 067bfb8
Merge branch 'main' into crowdstrike
cqgaurav d5dde4d
adds a changelog
8f3cee0
adds a dummy crowdstrike version
330bd42
generate tables
725c7ad
Merge branch 'main' into crowdstrike
cqgaurav 1dc77b9
remove changelog
9d0b2ee
Add gitignore
hermanschaaf 95ae202
Merge branch 'main' into crowdstrike
cqgaurav 7b045dc
Merge branch 'main' into crowdstrike
erezrokah 02489a8
Merge branch 'main' into crowdstrike
cqgaurav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Generate mocks for mock/unit testing | ||
| .PHONY: gen-mocks | ||
| gen-mocks: | ||
| go generate ./client/... | ||
|
|
||
| # Test unit | ||
| .PHONY: test | ||
| test: | ||
| go test -timeout 3m ./... | ||
|
|
||
| # Install tools | ||
| .PHONY: install-tools | ||
| install-tools: | ||
| @echo Installing tools from tools/tool.go | ||
| @cat tools/tool.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install % | ||
|
|
||
| # Install pre-commit hooks. This requires pre-commit to be installed (https://pre-commit.com/) | ||
| .PHONY: install-hooks | ||
| install-hooks: | ||
| pre-commit install | ||
|
|
||
| .PHONY: gen-docs | ||
| gen-docs: | ||
| rm -rf ./docs/tables/* | ||
| go run main.go doc ./docs/tables | ||
|
|
||
| .PHONY: lint | ||
| lint: | ||
| golangci-lint run --config ../../.golangci.yml | ||
|
|
||
| .PHONY: gen-code | ||
| gen-code: | ||
| grep -rl '// Code generated by codegen; DO NOT EDIT.' resources/services/* | xargs rm | ||
| go run codegen/main.go | ||
|
|
||
| # All gen targets | ||
| .PHONY: gen | ||
| gen: gen-code gen-docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Crowdstrike Plugin | ||
|
|
||
| This plugin pulls information from Crowdstrike and loads it into any supported CloudQuery destination (e.g. PostgreSQL). | ||
|
cqgaurav marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Links | ||
|
|
||
| - [Tables](./docs/tables/README.md) | ||
|
|
||
| ## Authentication | ||
|
|
||
| In order to fetch information from Crowdstrike, `cloudquery` needs to be authenticated. A ClientId and secret is required for authentication. Follow [these steps](https://www.crowdstrike.com/blog/tech-center/get-access-falcon-apis/) to set these up. Note that you will also need to enlist the client to have the appropriate scope for what you want to query. | ||
|
|
||
| ## Configuration | ||
|
|
||
| To configure CloudQuery to extract from Crowdstrike, create a `.yml` file in your CloudQuery configuration directory. | ||
| For example, the following configuration will extract information from Crowdstrike, and connect it to a `postgresql` destination plugin | ||
|
|
||
| ```yml | ||
| kind: source | ||
| spec: | ||
| # Source spec section | ||
| name: crowdstrike | ||
| path: cloudquery/crowdstrike | ||
| version: "0.0.1" # latest version of crowdstrike plugin | ||
| tables: ["*"] | ||
| destinations: ["postgresql"] | ||
| spec: | ||
| client_id: <CLIENT_ID> | ||
| client_secret: <CLIENT_SECRET> | ||
|
|
||
| ## Query Examples | ||
|
|
||
| ### Get crowdscores from all incidents | ||
|
|
||
| ```sql | ||
| select * from crowdstrike_incidents_crowdscore; | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/cloudquery/plugin-sdk/schema" | ||
| "github.com/cloudquery/plugin-sdk/specs" | ||
| "github.com/crowdstrike/gofalcon/falcon" | ||
| "github.com/rs/zerolog" | ||
| "github.com/rs/zerolog/log" | ||
| ) | ||
|
|
||
| type Client struct { | ||
| logger zerolog.Logger | ||
| spec specs.Source | ||
| Services Services | ||
| } | ||
|
|
||
| type Services struct { | ||
| Incidents Incidents | ||
| Alerts Alerts | ||
| } | ||
|
|
||
| func (*Client) Logger() *zerolog.Logger { | ||
| return &log.Logger | ||
| } | ||
|
|
||
| func (*Client) ID() string { | ||
| return "CrowdStrikeClient" | ||
|
cqgaurav marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| func New(ctx context.Context, logger zerolog.Logger, s specs.Source) (schema.ClientMeta, error) { | ||
| crowdStrikeSpec := &Spec{} | ||
| if err := s.UnmarshalSpec(&crowdStrikeSpec); err != nil { | ||
| return nil, fmt.Errorf("failed to unmarshal CrowdStrike spec: %w", err) | ||
| } | ||
| clientId, ok := os.LookupEnv("FALCON_CLIENT_ID") | ||
|
cqgaurav marked this conversation as resolved.
|
||
| if !ok { | ||
| if crowdStrikeSpec.ClientID == "" { | ||
| return nil, errors.New("missing FALCON_CLIENT_ID, either set it as an environment variable or pass it in the configuration") | ||
| } | ||
| clientId = crowdStrikeSpec.ClientID | ||
| } | ||
|
|
||
| secret, ok := os.LookupEnv("FALCON_CLIENT_SECRET") | ||
| if !ok { | ||
| if crowdStrikeSpec.ClientID == "" { | ||
| return nil, errors.New("missing FALCON_CLIENT_SECRET, either set it as an environment variable or pass it in the configuration") | ||
| } | ||
| secret = crowdStrikeSpec.ClientSecret | ||
| } | ||
|
|
||
| c, err := falcon.NewClient(&falcon.ApiConfig{ | ||
| ClientId: clientId, | ||
| ClientSecret: secret, | ||
| Context: ctx, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &Client{ | ||
| logger: logger, | ||
| Services: Services{ | ||
| Incidents: c.Incidents, | ||
| Alerts: c.Alerts, | ||
| }, | ||
| spec: s, | ||
| }, nil | ||
| } | ||
148 changes: 148 additions & 0 deletions
148
plugins/source/crowdstrike/client/mocks/mock_alerts_client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.