diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f74fc9e4..1314555fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,6 +19,14 @@ jobs: - checkout - run: make test + build-image: + executor: + name: default + steps: + - checkout + - setup_remote_docker + - run: make build-image + workflows: main: jobs: @@ -30,3 +38,11 @@ workflows: filters: tags: only: /[0-9]+(\.[0-9]+)*(-.*)*/ + - build-image: + requires: + - test + - lint + filters: + tags: + only: /[0-9]+(\.[0-9]+)*(-.*)*/ + diff --git a/.dockerignore b/.dockerignore index b4a295abc..41b1e1762 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,10 @@ +.circleci .git +.github +.golangci.yml +_config.yml +config_example.yaml +*.md +hack imgs +OWNERS diff --git a/CHANGELOG.md b/CHANGELOG.md index 539428b8b..62aada2bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,16 @@ # Changelog +## 2.19.1 - 2020-12-02 +#### Fix +- Fix dockerfile to build the new kafka output ([PR#56](https://github.com/falcosecurity/falcosidekick/pull/132) thanks to [@cpanato](https://github.com/cpanato)) + ## 2.19.0 - 2020-12-01 #### New - New output : **Apache Kafka** ([PR#124](https://github.com/falcosecurity/falcosidekick/pull/124) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) -- New output : **Cloudwatch Logs** ([PR#127](https://github.com/falcosecurity/falcosidekick/pull/127) thanks to [@pcpanato](https://github.com/cpanato)) +- New output : **Cloudwatch Logs** ([PR#127](https://github.com/falcosecurity/falcosidekick/pull/127) thanks to [@cpanato](https://github.com/cpanato)) #### Enhancement - Bump Golang version to `1.15` ([PR#128](https://github.com/falcosecurity/falcosidekick/pull/128) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) -- Add a contributing document ([PR#123](https://github.com/falcosecurity/falcosidekick/pull/123) thanks to [@pcpanato](https://github.com/cpanato)) +- Add a contributing document ([PR#123](https://github.com/falcosecurity/falcosidekick/pull/123) thanks to [@cpanato](https://github.com/cpanato)) - Add a `.dockerignore` for small images ([PR#126](https://github.com/falcosecurity/falcosidekick/pull/126) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) - Refactor HTTP server handler ([PR#116](https://github.com/falcosecurity/falcosidekick/pull/116) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) - Add test for `Discord` ([PR#117](https://github.com/falcosecurity/falcosidekick/pull/117) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) @@ -18,15 +22,15 @@ #### New - New output : **Google Chat** ([PR#107](https://github.com/falcosecurity/falcosidekick/pull/107) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) #### Enhancement -- Add test for `Mattermost` ([PR#99](https://github.com/falcosecurity/falcosidekick/pull/99) thanks to [@pcpanato](https://github.com/cpanato)) -- Add golangci lint ([PR#100](https://github.com/falcosecurity/falcosidekick/pull/100) thanks to [@pcpanato](https://github.com/cpanato)) -- Dependecies: update several deps ([PR#103](https://github.com/falcosecurity/falcosidekick/pull/103) thanks to [@pcpanato](https://github.com/cpanato)) -- clean a bit the `Circleci` config ([PR#106](https://github.com/falcosecurity/falcosidekick/pull/106) thanks to [@pcpanato](https://github.com/cpanato)) -- Use `testify` to check the test results ([PR#108](https://github.com/falcosecurity/falcosidekick/pull/108) [PR#112](https://github.com/falcosecurity/falcosidekick/pull/112) thanks to [@pcpanato](https://github.com/cpanato)) +- Add test for `Mattermost` ([PR#99](https://github.com/falcosecurity/falcosidekick/pull/99) thanks to [@cpanato](https://github.com/cpanato)) +- Add golangci lint ([PR#100](https://github.com/falcosecurity/falcosidekick/pull/100) thanks to [@cpanato](https://github.com/cpanato)) +- Dependecies: update several deps ([PR#103](https://github.com/falcosecurity/falcosidekick/pull/103) thanks to [@cpanato](https://github.com/cpanato)) +- clean a bit the `Circleci` config ([PR#106](https://github.com/falcosecurity/falcosidekick/pull/106) thanks to [@cpanato](https://github.com/cpanato)) +- Use `testify` to check the test results ([PR#108](https://github.com/falcosecurity/falcosidekick/pull/108) [PR#112](https://github.com/falcosecurity/falcosidekick/pull/112) thanks to [@cpanato](https://github.com/cpanato)) - Refactor type assertion in output ([PR#110](https://github.com/falcosecurity/falcosidekick/pull/110) thanks to [@KeisukeYamashita](https://github.com/KeisukeYamashita)) -- Add test for `Rocketchat` ([PR#113](https://github.com/falcosecurity/falcosidekick/pull/113) thanks to [@pcpanato](https://github.com/cpanato)) +- Add test for `Rocketchat` ([PR#113](https://github.com/falcosecurity/falcosidekick/pull/113) thanks to [@cpanato](https://github.com/cpanato)) #### Fix -- Fix stats for `Mattermost` ([PR#99](https://github.com/falcosecurity/falcosidekick/pull/99) thanks to [@pcpanato](https://github.com/cpanato)) +- Fix stats for `Mattermost` ([PR#99](https://github.com/falcosecurity/falcosidekick/pull/99) thanks to [@cpanato](https://github.com/cpanato)) ## 2.17.0 - 2020-11-13 #### New @@ -49,7 +53,7 @@ #### Fix - Fix unsupported chars in a label name for `AlertManager` ([PR#78](https://github.com/falcosecurity/falcosidekick/pull/78) thanks to [@epcim](https://github.com/epcim)) #### Note -The Helm chart has been migrated to [falcosecurity/charts](https://github.com/falcosecurity/charts/tree/master/falcosidekick), the official repository chart of `falco` organization. You can now install it from [artifacthub.io](https://artifacthub.io/packages/helm/falcosecurity/falcosidekick). +The Helm chart has been migrated to [falcosecurity/charts](https://github.com/falcosecurity/charts/tree/master/falcosidekick), the official repository chart of `falco` organization. You can now install it from [artifacthub.io](https://artifacthub.io/packages/helm/falcosecurity/falcosidekick). ## 2.14.0 - 2020-08-10 #### New @@ -96,7 +100,7 @@ This release is the last one with an Helm chart, the next ones will be in [Falco - New output : **DogStatsD** - New metrics : *running goroutines*, *number of used CPU* #### Enhancement -- :boom: Standardization of metric names (to be consistent between *expar* and *(Dog)StatsD*) +- :boom: Standardization of metric names (to be consistent between *expar* and *(Dog)StatsD*) - :boom: New namespace for metrics (*inputs*), will be used for future *inputs* (*fifo*, *gRPC*) #### Fix - *StatsD* implementation worked only with *DogStatsD* ([issue #49](https://github.com/falcosecurity/falcosidekick/issues/49)) @@ -168,20 +172,20 @@ This release is the last one with an Helm chart, the next ones will be in [Falco - Falcosidekick can now be deployed with Helm (see [README](https://github.com/falcosecurity/falcosidekick/blob/master/README.md)) ([PR#25](https://github.com/falcosecurity/falcosidekick/pull/25) thanks to [@SweetOps](https://github.com/SweetOps)) ## 2.2.0 - 2019-06-13 -#### New +#### New - A minimum priority for each output can be set - New output : **Influxdb** ([issue #4](https://github.com/falcosecurity/falcosidekick/issues/4)) #### Fix - Panic happened when trying to add `customfields` but falco event hadn't ## 2.1.0 - 2019-06-12 -#### New +#### New - Custom fields can be added to falco events (see [README](https://github.com/falcosecurity/falcosidekick/blob/master/README.md)) ([PR#26](https://github.com/falcosecurity/falcosidekick/pull/26) thanks to [@zetaab](https://github.com/zetaab)) #### Fix - Fix `Slack.Output` in config.go ([PR#24](https://github.com/falcosecurity/falcosidekick/pull/24) thanks to [@SweetOps](https://github.com/SweetOps)) ## 2.0.0 - 2019-05-23 -#### New +#### New - New output : **Elasticsearch** ([issue #14](https://github.com/falcosecurity/falcosidekick/issues/14)) - **New configuration method : we can now use a config file in YAML and/or env vars** (see *README*) ([issue #17](https://github.com/falcosecurity/falcosidekick/issues/17)) - New endpoint : `/debug/vars` gives access to Golang + Custom metrics (see *README*) ([issue #17](https://github.com/falcosecurity/falcosidekick/issues/17)) @@ -237,7 +241,7 @@ This release is the last one with an Helm chart, the next ones will be in [Falco ## 1.0.2 - 2018-10-10 #### Enhancement - Update changelog -- Update README with new Slack Options + more info +- Update README with new Slack Options + more info ## 1.0.1 - 2018-10-10 #### New diff --git a/Dockerfile b/Dockerfile index 9f360290f..45662a3f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,21 @@ -# Build image (Golang) -FROM golang:1.14-alpine AS build-stage -ENV GO111MODULE on -ENV CGO_ENABLED 0 +ARG BUILDER_IMAGE=golang:1.15.5-alpine +ARG BASE_IMAGE=alpine:3.12 -RUN apk add --no-cache gcc git make +FROM ${BUILDER_IMAGE} AS build-stage + +RUN apk add --update --no-cache alpine-sdk ca-certificates librdkafka coreutils WORKDIR /src ADD . . RUN go mod download -RUN go build -o falcosidekick +RUN go build -tags musl -gcflags all=-trimpath=/src -asmflags all=-trimpath=/src -a -installsuffix cgo -o falcosidekick . # Final Docker image -FROM alpine AS final-stage +FROM ${BASE_IMAGE} AS final-stage LABEL MAINTAINER "Thomas Labarussias " -RUN apk add --no-cache ca-certificates +RUN apk add --update --no-cache ca-certificates librdkafka # Create user falcosidekick RUN addgroup -S falcosidekick && adduser -u 1234 -S falcosidekick -G falcosidekick @@ -24,6 +24,7 @@ RUN addgroup -S falcosidekick && adduser -u 1234 -S falcosidekick -G falcosideki USER 1234 WORKDIR ${HOME}/app +COPY --from=build-stage /src/LICENSE . COPY --from=build-stage /src/falcosidekick . EXPOSE 2801 diff --git a/Makefile b/Makefile index 538460028..1aab9e9e5 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ GOPROXY := https://proxy.golang.org endif export GOPROXY GO ?= go +DOCKER ?= docker TEST_FLAGS ?= -v -race # Directories. @@ -33,6 +34,10 @@ GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER) falcosidekick: $(GO) build -o $@ +.PHONY: build-image +build-image: + $(DOCKER) build . -t falcosecurity/falcosidekick:latest + ## -------------------------------------- ## Test ## -------------------------------------- diff --git a/go.mod b/go.mod index 501646c10..9680a7268 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Azure/azure-event-hubs-go/v3 v3.3.3 github.com/DataDog/datadog-go v4.2.0+incompatible github.com/aws/aws-sdk-go v1.35.30 - github.com/confluentinc/confluent-kafka-go v1.5.2 // indirect + github.com/confluentinc/confluent-kafka-go v1.5.2 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.14.0 github.com/nats-io/nats.go v1.10.0 @@ -17,5 +17,4 @@ require ( golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 google.golang.org/api v0.35.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 - gopkg.in/confluentinc/confluent-kafka-go.v1 v1.5.2 ) diff --git a/go.sum b/go.sum index aa73ab6ee..660c460ad 100644 --- a/go.sum +++ b/go.sum @@ -849,8 +849,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/confluentinc/confluent-kafka-go.v1 v1.5.2 h1:g0WBLy6fobNUU8W/e9zx6I0Yl79Ya+BDW1NwzAlTiiQ= -gopkg.in/confluentinc/confluent-kafka-go.v1 v1.5.2/go.mod h1:ZdI3yfYmdNSLQPNCpO1y00EHyWaHG5EnQEyL/ntAegY= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= diff --git a/outputs/client.go b/outputs/client.go index ce1a913aa..76ba554ec 100644 --- a/outputs/client.go +++ b/outputs/client.go @@ -15,8 +15,9 @@ import ( "cloud.google.com/go/pubsub" "github.com/DataDog/datadog-go/statsd" "github.com/aws/aws-sdk-go/aws/session" + "github.com/confluentinc/confluent-kafka-go/kafka" + "github.com/falcosecurity/falcosidekick/types" - "gopkg.in/confluentinc/confluent-kafka-go.v1/kafka" ) // ErrHeaderMissing = 400 diff --git a/outputs/kafka.go b/outputs/kafka.go index d7779d54a..4c4de9d54 100644 --- a/outputs/kafka.go +++ b/outputs/kafka.go @@ -5,8 +5,9 @@ import ( "log" "github.com/DataDog/datadog-go/statsd" + "github.com/confluentinc/confluent-kafka-go/kafka" + "github.com/falcosecurity/falcosidekick/types" - "gopkg.in/confluentinc/confluent-kafka-go.v1/kafka" ) // NewKafkaClient returns a new output.Client for accessing the Apache Kafka.