diff --git a/wazuh-notify-go/log/log.go b/wazuh-notify-go/log/log.go index 5561aca..dfa3a10 100644 --- a/wazuh-notify-go/log/log.go +++ b/wazuh-notify-go/log/log.go @@ -29,7 +29,7 @@ func CloseLogFile() { if err != nil { panic(err) } - logFile.Close() + logFile.Close() } func Log(message string) { diff --git a/wazuh-notify-go/notification/discord.go b/wazuh-notify-go/notification/discord.go index db70f4e..910a405 100644 --- a/wazuh-notify-go/notification/discord.go +++ b/wazuh-notify-go/notification/discord.go @@ -6,7 +6,6 @@ import ( "log" "net/http" "os" - "strconv" "wazuh-notify/services" "wazuh-notify/types" ) @@ -14,7 +13,6 @@ import ( func SendDiscord(params types.Params) { embedDescription := services.BuildMessage(params, "discord", params.MarkdownEmphasis.Discord) + - "**Priority:** " + strconv.Itoa(params.Priority) + "\n" + "**Tags:** " + params.Tags + "\n\n" + params.General.Click diff --git a/wazuh-notify-go/notification/ntfy.go b/wazuh-notify-go/notification/ntfy.go index 7103143..f8332e9 100644 --- a/wazuh-notify-go/notification/ntfy.go +++ b/wazuh-notify-go/notification/ntfy.go @@ -14,7 +14,7 @@ func SendNtfy(params types.Params) { req, _ := http.NewRequest( "POST", os.Getenv("NTFY_URL"), - strings.NewReader(services.BuildMessage(params, "ntfy", params.MarkdownEmphasis.Ntfy))) + strings.NewReader(" "+services.BuildMessage(params, "ntfy", params.MarkdownEmphasis.Ntfy))) req.Header.Set("Content-Type", "text/markdown") diff --git a/wazuh-notify-go/notification/slack.go b/wazuh-notify-go/notification/slack.go index 98603cf..524e4de 100644 --- a/wazuh-notify-go/notification/slack.go +++ b/wazuh-notify-go/notification/slack.go @@ -6,7 +6,6 @@ import ( "log" "net/http" "os" - "strconv" "wazuh-notify/services" "wazuh-notify/types" ) @@ -15,7 +14,6 @@ func SendSlack(params types.Params) { message := types.SlackMessage{ Text: services.BuildMessage(params, "slack", params.MarkdownEmphasis.Slack) + - "*Priority:* " + strconv.Itoa(params.Priority) + "\n" + "*Tags:* " + params.Tags + "\n\n" + params.General.Click, } diff --git a/wazuh-notify-go/services/init.go b/wazuh-notify-go/services/init.go index b29416c..c7ed975 100644 --- a/wazuh-notify-go/services/init.go +++ b/wazuh-notify-go/services/init.go @@ -80,7 +80,7 @@ func wazuhInput() { inputParams.WazuhMessage = wazuhData - for i, _ := range configParams.PriorityMap { + for i := range configParams.PriorityMap { if slices.Contains(configParams.PriorityMap[i].ThreatMap, wazuhData.Parameters.Alert.Rule.Level) { if inputParams.WazuhMessage.Parameters.Alert.Rule.Firedtimes%inputParams.PriorityMap[i].NotifyThreshold != 0 { os.Exit(0) diff --git a/wazuh-notify-go/services/messageBuilder.go b/wazuh-notify-go/services/messageBuilder.go index 7fb94db..5c129b6 100644 --- a/wazuh-notify-go/services/messageBuilder.go +++ b/wazuh-notify-go/services/messageBuilder.go @@ -33,7 +33,8 @@ func BuildMessage(params types.Params, target string, emphasis string) string { fmt.Sprintf("%sDescription:%s ", emphasis, emphasis) + params.WazuhMessage.Parameters.Alert.FullLog + "\n" + fmt.Sprintf("%sThreat level:%s ", emphasis, emphasis) + strconv.Itoa(params.WazuhMessage.Parameters.Alert.Rule.Level) + "\n" + fmt.Sprintf("%sTimes fired:%s ", emphasis, emphasis) + strconv.Itoa(params.WazuhMessage.Parameters.Alert.Rule.Firedtimes) + - "\n\n" + "\n\n" + + fmt.Sprintf("%sPriority:%s ", emphasis, emphasis) + strconv.Itoa(params.Priority) + "\n" } } diff --git a/wazuh-notify-go/types/discord.go b/wazuh-notify-go/types/discord.go new file mode 100644 index 0000000..cd3f1fb --- /dev/null +++ b/wazuh-notify-go/types/discord.go @@ -0,0 +1,14 @@ +package types + +type DiscordMessage struct { + Username string `json:"username,omitempty"` + AvatarUrl string `json:"avatar_url,omitempty"` + Content string `json:"content,omitempty"` + Embeds []Embed `json:"embeds,omitempty"` +} + +type Embed struct { + Title string `json:"title,omitempty"` + Description string `json:"description,omitempty"` + Color int `json:"color,omitempty"` +} diff --git a/wazuh-notify-go/types/ntfy.go b/wazuh-notify-go/types/ntfy.go new file mode 100644 index 0000000..ab1254f --- /dev/null +++ b/wazuh-notify-go/types/ntfy.go @@ -0,0 +1 @@ +package types diff --git a/wazuh-notify-go/types/slack.go b/wazuh-notify-go/types/slack.go new file mode 100644 index 0000000..c986f98 --- /dev/null +++ b/wazuh-notify-go/types/slack.go @@ -0,0 +1,5 @@ +package types + +type SlackMessage struct { + Text string `json:"text,omitempty"` +} diff --git a/wazuh-notify-go/types/types.go b/wazuh-notify-go/types/types.go index de951a9..186dabd 100644 --- a/wazuh-notify-go/types/types.go +++ b/wazuh-notify-go/types/types.go @@ -31,22 +31,3 @@ type MarkdownEmphasis struct { Ntfy string `toml:"ntfy"` Discord string `toml:"discord"` } - -// Discord -type DiscordMessage struct { - Username string `json:"username,omitempty"` - AvatarUrl string `json:"avatar_url,omitempty"` - Content string `json:"content,omitempty"` - Embeds []Embed `json:"embeds,omitempty"` -} - -type Embed struct { - Title string `json:"title,omitempty"` - Description string `json:"description,omitempty"` - Color int `json:"color,omitempty"` -} - -// slack -type SlackMessage struct { - Text string `json:"text,omitempty"` -}