From ef5e2b3aaf8f0f1da80785ab493c4bc7a561ff7a Mon Sep 17 00:00:00 2001 From: Thomas Labarussias Date: Thu, 8 Sep 2022 15:48:54 +0200 Subject: [PATCH] allow to set Slack channel Signed-off-by: Thomas Labarussias --- README.md | 4 ++-- config.go | 1 + config_example.yaml | 1 + outputs/slack.go | 5 +++++ types/types.go | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 556f91a10..665daf3f2 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ mutualtlsfilespath: "/etc/certs" # folder which will used to store client.crt, c slack: webhookurl: "" # Slack WebhookURL (ex: https://hooks.slack.com/services/XXXX/YYYY/ZZZZ), if not empty, Slack output is enabled + #channel: "" # Slack channel (optionnal) #footer: "" # Slack footer #icon: "" # Slack icon (avatar) #username: "" # Slack username (default: Falcosidekick) @@ -545,8 +546,7 @@ care of lower/uppercases**) : `yaml: a.b --> envvar: A_B` : events, syntax is "key:value,key:value" **MUTUALTLSFILESPATH**: path which will be used to stored certs and key for mutual tls authentication (default: "/etc/certs") - **SLACK_WEBHOOKURL** : Slack Webhook URL (ex: - https://hooks.slack.com/services/XXXX/YYYY/ZZZZ), if not `empty`, Slack output - is _enabled_ +- **SLACK_CHANNEL** : Slack Channel (optionnal) - **SLACK_FOOTER** : Slack footer - **SLACK_ICON** : Slack icon (avatar) - **SLACK_USERNAME** : Slack username (default: `Falcosidekick`) diff --git a/config.go b/config.go index 06b9d6415..885c066c8 100644 --- a/config.go +++ b/config.go @@ -44,6 +44,7 @@ func getConfig() *types.Configuration { v.SetDefault("Slack.WebhookURL", "") v.SetDefault("Slack.Footer", "https://github.com/falcosecurity/falcosidekick") v.SetDefault("Slack.Username", "Falcosidekick") + v.SetDefault("Slack.Channel", "") v.SetDefault("Slack.Icon", "https://raw.githubusercontent.com/falcosecurity/falcosidekick/master/imgs/falcosidekick_color.png") v.SetDefault("Slack.OutputFormat", "all") v.SetDefault("Slack.MessageFormat", "") diff --git a/config_example.yaml b/config_example.yaml index 4f8665b67..a52c46d3a 100644 --- a/config_example.yaml +++ b/config_example.yaml @@ -11,6 +11,7 @@ mutualtlsfilespath: "/etc/certs" # folder which will used to store client.crt, c slack: webhookurl: "" # Slack WebhookURL (ex: https://hooks.slack.com/services/XXXX/YYYY/ZZZZ), if not empty, Slack output is enabled + #channel: "" # Slack channel (optionnal) #footer: "" # Slack footer #icon: "" # Slack icon (avatar) #username: "" # Slack username (default: Falcosidekick) diff --git a/outputs/slack.go b/outputs/slack.go index 3b44cfbab..e6adec11f 100644 --- a/outputs/slack.go +++ b/outputs/slack.go @@ -30,6 +30,7 @@ type slackPayload struct { Text string `json:"text,omitempty"` Username string `json:"username,omitempty"` IconURL string `json:"icon_url,omitempty"` + Channel string `json:"channel,omitempty"` Attachments []slackAttachment `json:"attachments,omitempty"` } @@ -127,6 +128,10 @@ func newSlackPayload(falcopayload types.FalcoPayload, config *types.Configuratio IconURL: config.Slack.Icon, Attachments: attachments} + if config.Slack.Channel != "" { + s.Channel = config.Slack.Channel + } + return s } diff --git a/types/types.go b/types/types.go index 5c28d8b88..2c222a44b 100644 --- a/types/types.go +++ b/types/types.go @@ -80,6 +80,7 @@ type Configuration struct { // SlackOutputConfig represents parameters for Slack type SlackOutputConfig struct { WebhookURL string + Channel string Footer string Icon string Username string