Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e96f891
Draft : Crowdstrike source with just crowdscores
Nov 28, 2022
85163f4
Draft: adding alerts
Nov 28, 2022
1951b4c
Adds alerts and some testing
Nov 28, 2022
b932a90
Adds alert tests
Nov 28, 2022
187a1b9
Adds alert to pluging
Nov 28, 2022
7a49bd4
review comments
Nov 29, 2022
e472903
fix spelling action check
Nov 29, 2022
3cdc570
Update plugins/source/crowdstrike/README.md
cqgaurav Nov 29, 2022
d5e5a18
Update plugins/source/crowdstrike/client/client.go
cqgaurav Nov 29, 2022
000c9d1
Update plugins/source/crowdstrike/resources/services/incidents/crowds…
cqgaurav Nov 29, 2022
7da1812
Update plugins/source/crowdstrike/resources/services/alerts/query_fet…
cqgaurav Nov 29, 2022
f0e6fc4
commit
Nov 29, 2022
eaedb0e
udpate readme
Nov 29, 2022
b41b849
Merge branch 'main' into crowdstrike
cqgaurav Nov 29, 2022
daa9990
Merge branch 'main' into crowdstrike
cqgaurav Nov 30, 2022
af0aca4
Change primary key for crowdscore
Nov 30, 2022
33b9d90
Commit release configuration files
Nov 30, 2022
6d2254e
remove arns
Dec 1, 2022
8e35e3f
Merge branch 'main' into crowdstrike
cqgaurav Dec 1, 2022
e744f28
allow crowdstrike
Dec 1, 2022
4a5c3fa
Merge branch 'main' into crowdstrike
cqgaurav Dec 1, 2022
58573cf
Merge branch 'main' into crowdstrike
cqgaurav Dec 1, 2022
5aeb1e2
add more docs
Dec 1, 2022
42160ee
fix docs
Dec 1, 2022
d580406
Merge branch 'main' into crowdstrike
cqgaurav Dec 1, 2022
f9b64d6
Merge branch 'main' into crowdstrike
cqgaurav Dec 1, 2022
067bfb8
Merge branch 'main' into crowdstrike
cqgaurav Dec 2, 2022
d5dde4d
adds a changelog
Dec 2, 2022
8f3cee0
adds a dummy crowdstrike version
Dec 2, 2022
330bd42
generate tables
Dec 2, 2022
725c7ad
Merge branch 'main' into crowdstrike
cqgaurav Dec 2, 2022
1dc77b9
remove changelog
Dec 2, 2022
9d0b2ee
Add gitignore
hermanschaaf Dec 2, 2022
95ae202
Merge branch 'main' into crowdstrike
cqgaurav Dec 2, 2022
7b045dc
Merge branch 'main' into crowdstrike
erezrokah Dec 4, 2022
02489a8
Merge branch 'main' into crowdstrike
cqgaurav Dec 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/pr_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ azure:
- plugins/source/azure/**/*
cloudflare:
- plugins/source/cloudflare/**/*
crowdstrike:
- plugins/source/crowdstrike/**/*
digitalocean:
- plugins/source/digitalocean/**/*
datadog:
Expand Down
3 changes: 2 additions & 1 deletion .github/styles/Vocab/Base/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ Datadog
nvm
npm
Gandi
CrowdStrike
crowdstrike
parallelization
hyperscale
goroutines
arn
arns
ARN
ARNs
SCP
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/source_crowdstrike.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Source Plugin CrowdStrike Workflow

on:
pull_request:
paths:
- "plugins/source/crowdstrike/**"
- ".github/workflows/source_crowdstrike.yml"
push:
branches:
- main
paths:
- "plugins/source/crowdstrike/**"
- ".github/workflows/source_crowdstrike.yml"

jobs:
resolve-runner:
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.resolve.outputs.runner }}
steps:
- name: Check if should use large runner
id: large-runner
# We want to speed runs on the main branch which prime the cache
# We allow large runners only in this case to prevent forks from abusing them (it's enforced via runner groups access rules)
# IF YOU WANT TO USE A LARGE RUNNER YOU NEED TO ADD THE WORKFLOW TO THE `CloudQuery releases` GROUP IN https://github.com/organizations/cloudquery/settings/actions/runner-groups
if: github.event_name == 'push'
run: |
echo "runner=cloudquery-release-runner" >> $GITHUB_OUTPUT
- name: Resolve runner
id: resolve
run: |
RUNNER=${{ steps.large-runner.outputs.runner }}
echo "runner=${RUNNER:-"ubuntu-latest"}" >> $GITHUB_OUTPUT
plugins-source-crowdstrike:
timeout-minutes: 30
name: "plugins/source/crowdstrike"
needs: [resolve-runner]
runs-on: ${{ needs.resolve-runner.outputs.runner }}
defaults:
run:
working-directory: ./plugins/source/crowdstrike
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version-file: plugins/source/crowdstrike/go.mod
cache: true
cache-dependency-path: plugins/source/crowdstrike/go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
working-directory: plugins/source/crowdstrike
args: "--config ../../.golangci.yml"
- name: Get dependencies
run: go get -t -d ./...
- name: Build
run: go build .
- name: Test
run: make test
- name: gen
if: github.event_name == 'pull_request'
run: make gen
- name: Fail if generation updated files
if: github.event_name == 'pull_request'
run: test "$(git status -s | wc -l)" -eq 0
validate-release:
timeout-minutes: 30
needs: [resolve-runner]
runs-on: ${{ needs.resolve-runner.outputs.runner }}
env:
CGO_ENABLED: 0
steps:
- name: Checkout
if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push'
uses: actions/checkout@v3
- uses: actions/cache@v3
if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push'
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-1.19.3-release-cache-${{ hashFiles('plugins/source/crowdstrike/go.sum') }}
restore-keys: |
${{ runner.os }}-go-1.19.3-release-cache-plugins-source-crowdstrike
- name: Set up Go
if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push'
uses: actions/setup-go@v3
with:
go-version-file: plugins/source/crowdstrike/go.mod
- name: Install GoReleaser
if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push'
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
- name: Run GoReleaser Dry-Run
if: startsWith(github.head_ref, 'release-please--branches--main--components') || github.event_name == 'push'
run: goreleaser release --snapshot --rm-dist --skip-validate --skip-publish --skip-sign -f ./plugins/source/crowdstrike/.goreleaser.yaml
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1 change: 1 addition & 0 deletions .github/workflows/wait_for_required_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
"plugins/source/aws",
"plugins/source/azure",
"plugins/source/cloudflare",
"plugins/source/crowdstrike",
"plugins/source/digitalocean",
"plugins/source/datadog",
"plugins/source/gandi",
Expand Down
14 changes: 14 additions & 0 deletions plugins/source/crowdstrike/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variables:
component: source/crowdstrike
binary: crowdstrike

project_name: plugins/source/crowdstrike

monorepo:
tag_prefix: plugins-source-crowdstrike-
dir: plugins/source/crowdstrike

includes:
- from_file:
# Relative to the directory Go Releaser is run from (which is the root of the repository)
path: ./plugins/.goreleaser.yaml
38 changes: 38 additions & 0 deletions plugins/source/crowdstrike/Makefile
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
38 changes: 38 additions & 0 deletions plugins/source/crowdstrike/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CrowdStrike Plugin

This plugin pulls information from CrowdStrike and loads it into any supported CloudQuery destination (e.g. PostgreSQL).

## Links

- [Tables](./docs/tables/README.md)

## Authentication

In order to fetch information from CrowdStrike, `cloudquery` needs to be authenticated. A client id 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>
```

## Example

You can reduce alert fatigue by narrowing alerts down from CrowdStrike using fuzzy matching.

```sql
select * from crowdstrike_alerts_query where resources like ('%filter_here%');
```
72 changes: 72 additions & 0 deletions plugins/source/crowdstrike/client/client.go
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 (c *Client) ID() string {
return c.spec.Name
}

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")
Comment thread
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
}
Loading