Skip to content
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

Filebeat Okta module #16362

Merged
merged 33 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a223aee
initial commit for okta
Feb 13, 2020
ce70c8d
Add a TLS test and more debug output to httpjson input
Feb 13, 2020
9c169e0
Add okta module
Feb 14, 2020
eba83af
Add Rate Limit support
Feb 16, 2020
eaed64c
Merge in httpjson input updates
Feb 16, 2020
0be2725
Update fields and add test cases for OKTA module
Feb 16, 2020
7603b21
Update documentation
Feb 16, 2020
8d3bf6e
Merge httpjson input changes
Mar 2, 2020
c2b7af2
Update pipeline.js
Mar 2, 2020
20feaac
Use *regexp.Regexp in config instead of String
Mar 2, 2020
1178d9e
Change OKTA to Okta
Mar 3, 2020
c09c80f
Address some review changes
Mar 9, 2020
377128f
Address review comments
Mar 9, 2020
13d2b36
Address review comments
Mar 9, 2020
a813b5f
merge with master
Mar 11, 2020
89bd3d9
merge with master
Mar 11, 2020
663eeaa
Copy okta.uuid to _id field
Mar 12, 2020
e87d543
Update document and some pipeline funcs
Mar 16, 2020
3293fc9
More renaming from OKTA to Okta
Mar 16, 2020
d004227
More renaming from OKTA to Okta
Mar 16, 2020
d24155c
More renaming from OKTA to Okta
Mar 16, 2020
d00c7c9
Update test result file for Okta
Mar 16, 2020
7893176
Update fields
Mar 17, 2020
7a4996f
Add dashboard
Mar 17, 2020
3432c5f
Add setEventOutcome to set event.outcome properly
Mar 17, 2020
84a5a2c
Add function to drop null fields
Mar 17, 2020
5968252
Update visualization titles
Mar 17, 2020
49dc1b3
Add description for dashboard
Mar 17, 2020
6ecbe17
Address title format for dashboard
Mar 17, 2020
18113c3
Update CHANGELOG. Remove a debug statement.
Mar 18, 2020
95e5923
Update CHANGELOG. Remove a debug statement.
Mar 18, 2020
4163dd4
Update module.yml with help information on disabling SSL verification.
Mar 18, 2020
643f578
Merge branch 'master' into filebeat-okta
Mar 18, 2020
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
569 changes: 569 additions & 0 deletions filebeat/docs/fields.asciidoc

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions filebeat/docs/modules/okta.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
////
This file is generated! See scripts/docs_collector.py
////

[[filebeat-module-okta]]
[role="xpack"]

:modulename: okta
:has-dashboards: false

== OKTA module
alakahakai marked this conversation as resolved.
Show resolved Hide resolved

beta[]

This is a filebeat module for retrieving system logs from OKTA via API.
alakahakai marked this conversation as resolved.
Show resolved Hide resolved

:has-dashboards!:

:modulename!:


[float]
=== Fields

For a description of each field in the module, see the
<<exported-fields-okta,exported fields>> section.

2 changes: 2 additions & 0 deletions filebeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This file is generated! See scripts/docs_collector.py
* <<filebeat-module-nats>>
* <<filebeat-module-netflow>>
* <<filebeat-module-nginx>>
* <<filebeat-module-okta>>
* <<filebeat-module-osquery>>
* <<filebeat-module-panw>>
* <<filebeat-module-postgresql>>
Expand Down Expand Up @@ -70,6 +71,7 @@ include::modules/mysql.asciidoc[]
include::modules/nats.asciidoc[]
include::modules/netflow.asciidoc[]
include::modules/nginx.asciidoc[]
include::modules/okta.asciidoc[]
include::modules/osquery.asciidoc[]
include::modules/panw.asciidoc[]
include::modules/postgresql.asciidoc[]
Expand Down
10 changes: 10 additions & 0 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ filebeat.modules:
# can be added under this section.
#input:

#--------------------------------- OKTA Module ---------------------------------
- module: okta
system:
enabled: true
# API key to access OKTA
#var.api_key

# URL of the OKTA REST API
#var.url

#------------------------------- Osquery Module -------------------------------
- module: osquery
result:
Expand Down
1 change: 1 addition & 0 deletions x-pack/filebeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 27 additions & 10 deletions x-pack/filebeat/input/httpjson/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,44 @@ import (

// Config contains information about httpjson configuration
type config struct {
APIKey string `config:"api_key"`
HTTPClientTimeout time.Duration `config:"http_client_timeout"`
HTTPHeaders common.MapStr `config:"http_headers"`
HTTPMethod string `config:"http_method" validate:"required"`
HTTPRequestBody common.MapStr `config:"http_request_body"`
Interval time.Duration `config:"interval"`
JSONObjects string `config:"json_objects_array"`
Pagination *Pagination `config:"pagination"`
TLS *tlscommon.Config `config:"ssl"`
URL string `config:"url" validate:"required"`
APIKey string `config:"api_key"`
AuthenticationScheme string `config:"authentication_scheme"`
HTTPClientTimeout time.Duration `config:"http_client_timeout"`
HTTPHeaders common.MapStr `config:"http_headers"`
HTTPMethod string `config:"http_method" validate:"required"`
HTTPRequestBody common.MapStr `config:"http_request_body"`
Interval time.Duration `config:"interval"`
JSONObjects string `config:"json_objects_array"`
NoHTTPBody bool `config:"no_http_body"`
Pagination *Pagination `config:"pagination"`
RateLimit *RateLimit `config:"rate_limit"`
TLS *tlscommon.Config `config:"ssl"`
URL string `config:"url" validate:"required"`
}

// Pagination contains information about httpjson pagination settings
type Pagination struct {
IsEnabled bool `config:"enabled"`
ExtraBodyContent common.MapStr `config:"extra_body_content"`
Header *Header `config:"header"`
IDField string `config:"id_field"`
RequestField string `config:"req_field"`
URL string `config:"url"`
}

// HTTP Header information for pagination
type Header struct {
FieldName string `config:"field_name"`
RegexPattern string `config:"regex_pattern"`
}

// HTTP Header Rate Limit information
type RateLimit struct {
Limit string `config:"limit"`
Reset string `config:"reset"`
Remaining string `config:"remaining"`
}

func (c *config) Validate() error {
switch strings.ToUpper(c.HTTPMethod) {
case "GET":
Expand Down
41 changes: 33 additions & 8 deletions x-pack/filebeat/input/httpjson/httpjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ func testSetup(t *testing.T) {
})
}

func runTest(t *testing.T, m map[string]interface{}, run func(input *httpjsonInput, out *stubOutleter, t *testing.T)) {
// Setup httpbin environment
func runTest(t *testing.T, isTLS bool, m map[string]interface{}, run func(input *httpjsonInput, out *stubOutleter, t *testing.T)) {
testSetup(t)
// Create test http server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Create an http test server according to whether TLS is used
var newServer = httptest.NewServer
if isTLS {
newServer = httptest.NewTLSServer
}
ts := newServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
req, err := ioutil.ReadAll(r.Body)
defer r.Body.Close()
Expand Down Expand Up @@ -154,7 +157,29 @@ func TestGET(t *testing.T) {
"http_method": "GET",
"interval": 0,
}
runTest(t, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
runTest(t, false, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
group, _ := errgroup.WithContext(context.Background())
group.Go(input.run)

events, ok := out.waitForEvents(1)
if !ok {
t.Fatalf("Expected 1 events, but got %d.", len(events))
}
input.Stop()

if err := group.Wait(); err != nil {
t.Fatal(err)
}
})
}

func TestGetHTTPS(t *testing.T) {
m := map[string]interface{}{
"http_method": "GET",
"interval": 0,
"ssl.verification_mode": "none",
}
runTest(t, true, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
group, _ := errgroup.WithContext(context.Background())
group.Go(input.run)

Expand All @@ -176,7 +201,7 @@ func TestPOST(t *testing.T) {
"http_request_body": map[string]interface{}{"test": "abc", "testNested": map[string]interface{}{"testNested1": 123}},
"interval": 0,
}
runTest(t, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
runTest(t, false, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
group, _ := errgroup.WithContext(context.Background())
group.Go(input.run)

Expand All @@ -198,7 +223,7 @@ func TestRepeatedPOST(t *testing.T) {
"http_request_body": map[string]interface{}{"test": "abc", "testNested": map[string]interface{}{"testNested1": 123}},
"interval": 10 ^ 9,
}
runTest(t, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
runTest(t, false, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
group, _ := errgroup.WithContext(context.Background())
group.Go(input.run)

Expand All @@ -219,7 +244,7 @@ func TestRunStop(t *testing.T) {
"http_method": "GET",
"interval": 0,
}
runTest(t, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
runTest(t, false, m, func(input *httpjsonInput, out *stubOutleter, t *testing.T) {
input.Run()
input.Stop()
input.Run()
Expand Down
Loading