-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Issif/v1.0.6
## 1.0.6 - 2019-05-09 #### New - Add `SLACK_HIDE_FIELDS` env var, to enable concise output in Slack (fields are not displayed) ([issue #15](https://github.com/Issif/falcosidekick/issues/15)) #### Enhancement - Remove `/checkPayload` endpoint, not usefull anymore - Change of how enabled/disabled outputs are printed in log (more concise view) - Falco's payload is printed in log if `DEBUG=true`
- Loading branch information
Showing
9 changed files
with
377 additions
and
362 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,35 +1,51 @@ | ||
# Changelog | ||
|
||
## 1.0.4 - 2019-02-01 | ||
#### New | ||
- Add of **go mod** ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
#### Enhancement | ||
- Use of *go mod* is Dockerfile for build ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
- Add email maintener in Dockerfile ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
|
||
## 1.0.3 - 2019-01-30 | ||
#### New | ||
- new output : **Alert Manager** | ||
#### Enhancement | ||
- add status of posts to Outputs in logs (stdout) | ||
|
||
## 1.0.2 - 2018-10-10 | ||
#### Enhancement | ||
- update changelog | ||
- update README with new Slack Options + more info | ||
|
||
## 1.0.1 - 2018-10-10 | ||
#### New | ||
- new Slack Options : `SLACK_FOOTER`, `SLACK_ICON` | ||
#### Enhancements | ||
- new Slack Options : `SLACK_FOOTER`, `SLACK_ICON` | ||
- add output status in log to get those which are enabled | ||
- check of `LISTEN_PORT` in `init()` : port must be an integer between 1 and 65535 | ||
- long string in slack field values are not splitten anymore | ||
|
||
#### Fix | ||
- some log level tags were missing | ||
- fix cert errors in alpine ([PR#1](https://github.com/Issif/falcosidekick/pull/1) thanks to [@palmerabollo](https://github.com/palmerabollo)) | ||
|
||
## 1.0.0 - 2018-10-10 | ||
# Changelog | ||
|
||
## 1.0.6 - 2019-05-09 | ||
#### New | ||
- Add `SLACK_HIDE_FIELDS` env var, to enable concise output in Slack (fields are not displayed) ([issue #15](https://github.com/Issif/falcosidekick/issues/15)) | ||
#### Enhancement | ||
- Remove `/checkPayload` endpoint, not usefull anymore | ||
- Change of how enabled/disabled outputs are printed in log (more concise view) | ||
- Falco's payload is printed in log if `DEBUG=true` | ||
|
||
## 1.0.5 - 2019-04-09 | ||
#### New | ||
- Add a `/test` endpoint which sends a fake event to all enabled outputs | ||
- Add a `DEBUG` env var, if enabled, payload for enabled outputs will be printed in stdout | ||
#### Enhancement | ||
- Reformate some logs outputs to be nicer | ||
- Add a check on payload's body from falco to avoid to send empty's ones to outputs | ||
|
||
## 1.0.4 - 2019-02-01 | ||
#### New | ||
- Add of **go mod** ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
#### Enhancement | ||
- Use of *go mod* is Dockerfile for build ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
- Add email maintener in Dockerfile ([PR#1](https://github.com/Issif/falcosidekick/pull/9) thanks to [@perriea](https://github.com/perriea)) | ||
|
||
## 1.0.3 - 2019-01-30 | ||
#### New | ||
- new output : **Alert Manager** | ||
#### Enhancement | ||
- add status of posts to Outputs in logs (stdout) | ||
|
||
## 1.0.2 - 2018-10-10 | ||
#### Enhancement | ||
- update changelog | ||
- update README with new Slack Options + more info | ||
|
||
## 1.0.1 - 2018-10-10 | ||
#### New | ||
- new Slack Options : `SLACK_FOOTER`, `SLACK_ICON` | ||
#### Enhancements | ||
- new Slack Options : `SLACK_FOOTER`, `SLACK_ICON` | ||
- add output status in log to get those which are enabled | ||
- check of `LISTEN_PORT` in `init()` : port must be an integer between 1 and 65535 | ||
- long string in slack field values are not splitten anymore | ||
|
||
#### Fix | ||
- some log level tags were missing | ||
- fix cert errors in alpine ([PR#1](https://github.com/Issif/falcosidekick/pull/1) thanks to [@palmerabollo](https://github.com/palmerabollo)) | ||
|
||
## 1.0.0 - 2018-10-10 | ||
- First tagged release |
This file contains 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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
# Build image (Golang) | ||
FROM golang:1.11-alpine3.8 AS build-stage | ||
ENV GO111MODULE on | ||
ENV CGO_ENABLED 0 | ||
|
||
RUN apk add --no-cache gcc git make | ||
|
||
WORKDIR /src | ||
ADD . . | ||
|
||
RUN go mod download | ||
RUN go build -o falcosidekick | ||
|
||
# Final Docker image | ||
FROM alpine:3.8 AS final-stage | ||
LABEL MAINTAINER "Thomas Labarussias <[email protected]>" | ||
|
||
RUN apk add --no-cache ca-certificates | ||
|
||
# Create user falcosidekick | ||
RUN addgroup -S falcosidekick && adduser -S falcosidekick -G falcosidekick | ||
USER falcosidekick | ||
|
||
WORKDIR ${HOME}/app | ||
COPY --from=build-stage /src/falcosidekick . | ||
|
||
EXPOSE 2801 | ||
|
||
ENTRYPOINT ["./falcosidekick"] | ||
# Build image (Golang) | ||
FROM golang:1.11-alpine3.8 AS build-stage | ||
ENV GO111MODULE on | ||
ENV CGO_ENABLED 0 | ||
|
||
RUN apk add --no-cache gcc git make | ||
|
||
WORKDIR /src | ||
ADD . . | ||
|
||
RUN go mod download | ||
RUN go build -o falcosidekick | ||
|
||
# Final Docker image | ||
FROM alpine:3.8 AS final-stage | ||
LABEL MAINTAINER "Thomas Labarussias <[email protected]>" | ||
|
||
RUN apk add --no-cache ca-certificates | ||
|
||
# Create user falcosidekick | ||
RUN addgroup -S falcosidekick && adduser -S falcosidekick -G falcosidekick | ||
USER falcosidekick | ||
|
||
WORKDIR ${HOME}/app | ||
COPY --from=build-stage /src/falcosidekick . | ||
|
||
EXPOSE 2801 | ||
|
||
ENTRYPOINT ["./falcosidekick"] |
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,66 +1,66 @@ | ||
package outputs | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
"os" | ||
"strings" | ||
|
||
"github.com/Issif/falcosidekick/types" | ||
) | ||
|
||
const ( | ||
alertmanagerURL string = "/api/v1/alerts" | ||
) | ||
|
||
type alertmanagerIncident struct { | ||
Labels map[string]string `json:"labels,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
} | ||
|
||
func newAlertmanagerPayload(falcopayload types.FalcoPayload) []alertmanagerIncident { | ||
var alertmanagerincident alertmanagerIncident | ||
alertmanagerincident.Labels = make(map[string]string) | ||
alertmanagerincident.Annotations = make(map[string]string) | ||
|
||
for i, j := range falcopayload.OutputFields { | ||
switch j.(type) { | ||
case string: | ||
//AlertManger doesn't support dots in a label name | ||
alertmanagerincident.Labels[strings.Replace(i, ".", "_", -1)] = j.(string) | ||
} | ||
} | ||
alertmanagerincident.Labels["source"] = "falco" | ||
alertmanagerincident.Labels["rule"] = falcopayload.Rule | ||
|
||
alertmanagerincident.Annotations["info"] = falcopayload.Output | ||
alertmanagerincident.Annotations["summary"] = falcopayload.Rule | ||
|
||
var a []alertmanagerIncident | ||
|
||
a = append(a, alertmanagerincident) | ||
|
||
return a | ||
} | ||
|
||
// AlertmanagerPost posts event to Alert Manager | ||
func AlertmanagerPost(falcopayload types.FalcoPayload) { | ||
alertmanagerPayload := newAlertmanagerPayload(falcopayload) | ||
b := new(bytes.Buffer) | ||
json.NewEncoder(b).Encode(alertmanagerPayload) | ||
|
||
if os.Getenv("DEBUG") == "true" { | ||
log.Printf("[DEBUG] : AlertManager's payload : %v\n", b) | ||
} | ||
|
||
resp, err := http.Post(os.Getenv("ALERTMANAGER_HOST_PORT")+alertmanagerURL, "application/json; charset=utf-8", b) | ||
if err != nil { | ||
log.Printf("[ERROR] : AlertManager - %v\n", err.Error()) | ||
} else if resp.StatusCode != 200 { | ||
log.Printf("[ERROR] : AlertManager - %v\n", resp) | ||
} else { | ||
log.Printf("[INFO] : AlertManager - Post sent successfully\n") | ||
} | ||
} | ||
package outputs | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
"os" | ||
"strings" | ||
|
||
"github.com/Issif/falcosidekick/types" | ||
) | ||
|
||
const ( | ||
alertmanagerURL string = "/api/v1/alerts" | ||
) | ||
|
||
type alertmanagerIncident struct { | ||
Labels map[string]string `json:"labels,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
} | ||
|
||
func newAlertmanagerPayload(falcopayload types.FalcoPayload) []alertmanagerIncident { | ||
var alertmanagerincident alertmanagerIncident | ||
alertmanagerincident.Labels = make(map[string]string) | ||
alertmanagerincident.Annotations = make(map[string]string) | ||
|
||
for i, j := range falcopayload.OutputFields { | ||
switch j.(type) { | ||
case string: | ||
//AlertManger doesn't support dots in a label name | ||
alertmanagerincident.Labels[strings.Replace(i, ".", "_", -1)] = j.(string) | ||
} | ||
} | ||
alertmanagerincident.Labels["source"] = "falco" | ||
alertmanagerincident.Labels["rule"] = falcopayload.Rule | ||
|
||
alertmanagerincident.Annotations["info"] = falcopayload.Output | ||
alertmanagerincident.Annotations["summary"] = falcopayload.Rule | ||
|
||
var a []alertmanagerIncident | ||
|
||
a = append(a, alertmanagerincident) | ||
|
||
return a | ||
} | ||
|
||
// AlertmanagerPost posts event to Alert Manager | ||
func AlertmanagerPost(falcopayload types.FalcoPayload) { | ||
alertmanagerPayload := newAlertmanagerPayload(falcopayload) | ||
b := new(bytes.Buffer) | ||
json.NewEncoder(b).Encode(alertmanagerPayload) | ||
|
||
if os.Getenv("DEBUG") == "true" { | ||
log.Printf("[DEBUG] : AlertManager's payload : %v\n", b) | ||
} | ||
|
||
resp, err := http.Post(os.Getenv("ALERTMANAGER_HOST_PORT")+alertmanagerURL, "application/json; charset=utf-8", b) | ||
if err != nil { | ||
log.Printf("[ERROR] : AlertManager - %v\n", err.Error()) | ||
} else if resp.StatusCode != 200 { | ||
log.Printf("[ERROR] : AlertManager - %v\n", resp) | ||
} else { | ||
log.Printf("[INFO] : AlertManager - Post sent successfully\n") | ||
} | ||
} |
Oops, something went wrong.