Skip to content

Commit

Permalink
fix: typo and docs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
k0rventen committed Sep 2, 2024
1 parent 30d6e24 commit 0db1a5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docs/outputs/webex.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Webex


- **Category**: Chat/Messaging
- **Website**: https://webex.com

Expand All @@ -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 ""` |


Expand Down
12 changes: 7 additions & 5 deletions outputs/webex.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/falcosecurity/falcosidekick/types"
)

var md string = `# Falco Rule {{ .Rule }}
var md string = `# Falco Rule '{{ .Rule }}'
### {{ .Output }}
Expand All @@ -28,16 +28,18 @@ 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"`
}

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)

}
Expand All @@ -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)

Expand Down

0 comments on commit 0db1a5f

Please sign in to comment.