-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: k0rventen <[email protected]>
- Loading branch information
Showing
10 changed files
with
139 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Webex | ||
|
||
- **Category**: Chat/Messaging | ||
- **Website**: https://webex.com | ||
|
||
## Table of content | ||
|
||
- [Teams](#teams) | ||
- [Table of content](#table-of-content) | ||
- [Configuration](#configuration) | ||
- [Example of config.yaml](#example-of-configyaml) | ||
- [Screenshots](#screenshots) | ||
|
||
## Configuration | ||
|
||
| Setting | Env var | Default value | Description | | ||
| ----------------------- | ----------------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | ||
| `webex.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 ""` | | ||
|
||
|
||
> [!NOTE] | ||
The Env var values override the settings from yaml file. | ||
|
||
## Example of config.yaml | ||
|
||
```yaml | ||
webex: | ||
webhookurl: "" # Webex WebhookURL, if not empty, Webex output is enabled | ||
# minimumpriority: "debug" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default) | ||
``` | ||
## Screenshots | ||
|
||
 | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
package outputs | ||
|
||
import ( | ||
"bytes" | ||
"log" | ||
"text/template" | ||
|
||
"github.com/falcosecurity/falcosidekick/types" | ||
) | ||
|
||
var md string = `# Falco Rule '{{ .Rule }}' | ||
### {{ .Output }} | ||
Additional informations: | ||
* Hostname: {{ .Hostname }} | ||
* Source: {{ .Source }} | ||
* Priority: {{ .Priority }} | ||
* Tags: | ||
{{ range $t := .Tags }} | ||
* {{ $t }} | ||
{{ end }} | ||
* Fields: | ||
{{ range $key, $value := .OutputFields }} | ||
* {{ $key }}: {{ $value }} | ||
{{ end }} | ||
` | ||
|
||
// 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 | ||
|
||
if err := webexTmpl.Execute(&tpl, falcopayload); err != nil { | ||
log.Printf("[ERROR] : Webex Template - %v\n", err) | ||
|
||
} | ||
t := webexPayload{ | ||
Markdown: tpl.String(), | ||
} | ||
|
||
return t | ||
} | ||
|
||
// WebexPost sends event to a Webex Room through a Webhook | ||
func (c *Client) WebexPost(falcopayload types.FalcoPayload) { | ||
c.Stats.Webex.Add(Total, 1) | ||
|
||
err := c.Post(newWebexPayload(falcopayload)) | ||
|
||
if err != nil { | ||
go c.CountMetric(Outputs, 1, []string{"output:webex", "status:error"}) | ||
c.Stats.Webhook.Add(Error, 1) | ||
c.PromStats.Outputs.With(map[string]string{"destination": "webex", "status": Error}).Inc() | ||
log.Printf("[ERROR] : Webex - %v\n", err.Error()) | ||
return | ||
} | ||
|
||
// Setting the success status | ||
go c.CountMetric(Outputs, 1, []string{"output:webex", "status:ok"}) | ||
c.Stats.Webhook.Add(OK, 1) | ||
c.PromStats.Outputs.With(map[string]string{"destination": "webex", "status": OK}).Inc() | ||
} |
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