Skip to content

Commit 1da9ed2

Browse files
committed
fix(systray): Distinguish between behaviour and YARA notifications
The notification area text and title are rendered depending on whether the alert is generated by the behaviour or YARA rule engine.
1 parent 24a3158 commit 1da9ed2

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

cmd/systray/main_windows.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/rabbitstack/fibratus/pkg/sys"
3636
"github.com/rabbitstack/fibratus/pkg/util/log"
3737
"github.com/rabbitstack/fibratus/pkg/util/signals"
38+
yconfig "github.com/rabbitstack/fibratus/pkg/yara/config"
3839
"github.com/sirupsen/logrus"
3940
"golang.org/x/sys/windows"
4041
)
@@ -49,8 +50,8 @@ const (
4950
)
5051

5152
var (
52-
className = windows.StringToUTF16Ptr("fibratus")
53-
alertTitle = "Malicious Activity Detected"
53+
className = windows.StringToUTF16Ptr("fibratus")
54+
defaultSystrayTitle = "Malicious Activity Detected"
5455
)
5556

5657
// Msg represents the data exchanged between systray client/server.
@@ -77,6 +78,24 @@ func (m Msg) decode(output any) error {
7778
return decoder.Decode(m.Data)
7879
}
7980

81+
func systrayTitle(alert alertsender.Alert) string {
82+
switch alert.Title {
83+
case yconfig.MemoryThreatAlertTitle, yconfig.FileThreatAlertTitle:
84+
return alert.Title
85+
default:
86+
return defaultSystrayTitle
87+
}
88+
}
89+
90+
func systrayText(alert alertsender.Alert) string {
91+
switch alert.Title {
92+
case yconfig.MemoryThreatAlertTitle, yconfig.FileThreatAlertTitle:
93+
return alert.Text
94+
default:
95+
return alert.Title
96+
}
97+
}
98+
8099
type Systray struct {
81100
systrayIcon *sys.SystrayIcon
82101
window sys.Hwnd
@@ -222,7 +241,7 @@ func (s *Systray) handleMessage(m Msg) error {
222241
logrus.Errorf("unable to decode alert: %v", err)
223242
return err
224243
}
225-
return s.systrayIcon.ShowBalloonNotification(alertTitle, alert.Title, s.config.Sound, s.config.QuietMode)
244+
return s.systrayIcon.ShowBalloonNotification(systrayTitle(alert), systrayText(alert), s.config.Sound, s.config.QuietMode)
226245
}
227246
return nil
228247
}

0 commit comments

Comments
 (0)