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

add HTTP datasource #3294

Merged
merged 34 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
791901f
add HTTP datasource
he2ss Oct 23, 2024
4fc9e2d
remove unwanted comments
he2ss Oct 23, 2024
8315cdd
remove unused code
he2ss Oct 23, 2024
066bda9
add server close on dying tomb + acquis mode
he2ss Oct 23, 2024
5577e10
remove unwanted trace
he2ss Oct 23, 2024
2cc5c4e
Merge branch 'master' into feat/acquisition/add-http-datasource
he2ss Oct 23, 2024
1784d54
fix branch
he2ss Oct 23, 2024
329a957
fix lint
he2ss Oct 24, 2024
fc29db9
make transform unmarshal works + fix lint
he2ss Oct 24, 2024
9bc0f74
handle gzip encoding
he2ss Oct 24, 2024
4713184
fix lint
he2ss Oct 24, 2024
0e6031c
assert line.src in tests
he2ss Oct 24, 2024
e9bf32e
validate path + better naming
he2ss Oct 24, 2024
075bb92
comment for now chunk_size param
he2ss Oct 25, 2024
bdb0a40
handle ndjson + adapt tests to code and not the inverse
he2ss Oct 25, 2024
da457ee
remove unused param in func
he2ss Oct 25, 2024
5de442a
forgotten file
he2ss Oct 25, 2024
a53e2a9
fix comments
he2ss Oct 25, 2024
6004557
fix lint
he2ss Oct 28, 2024
8141609
update metrics + fix tests
he2ss Oct 28, 2024
168b452
fix laurence comments
he2ss Oct 28, 2024
e39cf00
Merge branch 'master' into feat/acquisition/add-http-datasource
he2ss Oct 28, 2024
d5a485c
fix typo
he2ss Oct 28, 2024
750a6b6
constructor for types.Event
blotus Oct 28, 2024
6d5df68
more parameters for MakeEvent
blotus Oct 28, 2024
bfd32a1
fix laurence comments
he2ss Oct 29, 2024
85f74d0
fix laurence comments
he2ss Oct 29, 2024
99a988e
properly copy event in transform
blotus Oct 29, 2024
4488700
Merge branch 'master' into feat/acquisition/add-http-datasource
mmetc Nov 1, 2024
a171274
list build tag in makefile
mmetc Nov 1, 2024
8605cec
test: use assertions
mmetc Nov 4, 2024
4c9450b
Merge branch 'master' into feat/acquisition/add-http-datasource
mmetc Nov 4, 2024
2293770
types.NewEvent() -> types.MakeEvent()
mmetc Nov 4, 2024
aadc31a
float comparison with assert.InDelta()
mmetc Nov 4, 2024
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
12 changes: 12 additions & 0 deletions pkg/acquisition/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !no_datasource_http

package acquisition

import (
httpacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/http"
)

//nolint:gochecknoinits
func init() {
registerDataSource("http", func() DataSource { return &httpacquisition.HTTPSource{} })
}
1 change: 1 addition & 0 deletions pkg/acquisition/modules/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ func cwLogToEvent(log *cloudwatchlogs.OutputLogEvent, cfg *LogStreamTailConfig)
evt.Process = true
evt.Type = types.LOG
evt.ExpectMode = cfg.ExpectMode
evt.Unmarshaled = make(map[string]interface{})
cfg.logger.Debugf("returned event labels : %+v", evt.Line.Labels)
return evt, nil
}
3 changes: 2 additions & 1 deletion pkg/acquisition/modules/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
if d.metricsLevel != configuration.METRICS_NONE {
linesRead.With(prometheus.Labels{"source": containerConfig.Name}).Inc()
}
evt := types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: types.TIMEMACHINE}
evt := types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: types.TIMEMACHINE, Unmarshaled: make(map[string]interface{})}

Check warning on line 337 in pkg/acquisition/modules/docker/docker.go

View check run for this annotation

Codecov / codecov/patch

pkg/acquisition/modules/docker/docker.go#L337

Added line #L337 was not covered by tests
out <- evt
d.logger.Debugf("Sent line to parsing: %+v", evt.Line.Raw)
}
Expand Down Expand Up @@ -580,6 +580,7 @@
l.Process = true
l.Module = d.GetName()
var evt types.Event
evt.Unmarshaled = make(map[string]interface{})
if !d.Config.UseTimeMachine {
evt = types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: types.LIVE}
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/acquisition/modules/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func (f *FileSource) tailFile(out chan types.Event, t *tomb.Tomb, tail *tail.Tai
if f.config.UseTimeMachine {
expectMode = types.TIMEMACHINE
}
out <- types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: expectMode}
out <- types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: expectMode, Unmarshaled: make(map[string]interface{})}
}
}
}
Expand Down Expand Up @@ -684,7 +684,7 @@ func (f *FileSource) readFile(filename string, out chan types.Event, t *tomb.Tom
linesRead.With(prometheus.Labels{"source": filename}).Inc()

// we're reading logs at once, it must be time-machine buckets
out <- types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: types.TIMEMACHINE}
out <- types.Event{Line: l, Process: true, Type: types.LOG, ExpectMode: types.TIMEMACHINE, Unmarshaled: make(map[string]interface{})}
}
}

Expand Down
Loading