From 0db1a5f7161495d9add6329a1af75968d1b23a35 Mon Sep 17 00:00:00 2001 From: k0rventen <49311792+k0rventen@users.noreply.github.com> Date: Mon, 2 Sep 2024 21:05:15 +0200 Subject: [PATCH] fix: typo and docs fix: typo fix: bad doc fix: better variable name fix: remove empty line fix: improved template & better template loading fix: typo in webex doc Signed-off-by: k0rventen <49311792+k0rventen@users.noreply.github.com> --- config_example.yaml | 4 ++-- docs/outputs/webex.md | 3 +-- outputs/webex.go | 12 +++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config_example.yaml b/config_example.yaml index d732440a4..c77416731 100644 --- a/config_example.yaml +++ b/config_example.yaml @@ -66,8 +66,8 @@ teams: minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default) webex: - #webhookurl: "" # Webex WebhookURL, if not empty, Teams Webex is enabled - #minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default) + # webhookurl: "" # Webex WebhookURL, if not empty, Teams Webex is enabled + # minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default) datadog: # apikey: "" # Datadog API Key, if not empty, Datadog output is enabled diff --git a/docs/outputs/webex.md b/docs/outputs/webex.md index 3728f79c7..088bb5d0c 100644 --- a/docs/outputs/webex.md +++ b/docs/outputs/webex.md @@ -1,6 +1,5 @@ # Webex - - **Category**: Chat/Messaging - **Website**: https://webex.com @@ -16,7 +15,7 @@ | Setting | Env var | Default value | Description | | ----------------------- | ----------------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| `teams.webhookurl` | `TEAMS_WEBHOOKURL` | | Teams WebhookURL, if not empty, Teams output is **enabled** | +| `wexeb.webhookurl` | `WEBEX_WEBHOOKURL` | | Teams WebhookURL, if not empty, Webex output is **enabled** | | `webex.minimumpriority` | `WEBEX_MINIMUMPRIORITY` | `""` (= `debug`) | Minimum priority of event for using this output, order is `emergency,alert,critical,error,warning,notice,informational,debug or ""` | diff --git a/outputs/webex.go b/outputs/webex.go index 5a605b139..4c17fda0e 100644 --- a/outputs/webex.go +++ b/outputs/webex.go @@ -10,7 +10,7 @@ import ( "github.com/falcosecurity/falcosidekick/types" ) -var md string = `# Falco Rule {{ .Rule }} +var md string = `# Falco Rule '{{ .Rule }}' ### {{ .Output }} @@ -28,7 +28,10 @@ Additional informations: {{ end }} ` -// Payload +// Load the md template +var webexTmpl, _ = template.New("markdown").Parse(md) + +// the format is {"markdown":"..."} type webexPayload struct { Markdown string `json:"markdown"` } @@ -36,8 +39,7 @@ type webexPayload struct { func newWebexPayload(falcopayload types.FalcoPayload) webexPayload { var tpl bytes.Buffer - tmpl, _ := template.New("markdown").Parse(md) - if err := tmpl.Execute(&tpl, falcopayload); err != nil { + if err := webexTmpl.Execute(&tpl, falcopayload); err != nil { log.Printf("[ERROR] : Webex Template - %v\n", err) } @@ -48,7 +50,7 @@ func newWebexPayload(falcopayload types.FalcoPayload) webexPayload { return t } -// WebhookPost posts event to an URL +// WebexPost sends event to a Webex Room through a Webhook func (c *Client) WebexPost(falcopayload types.FalcoPayload) { c.Stats.Webex.Add(Total, 1)