empty body email notifications

When I try to create an email notification template that pulls an IP address, then I trigger the email notification (Not using notifications test) I get an email with an empty body. The strange thing is when I use notifications test I can see everything is being filled correctly so the issue shouldn't be a config issue. I tried using the example notification template and the result is still the same:
<html><body>
{{range . -}}
{{$alert := . -}}
{{range .Decisions -}}
<p><a href="https://www.whois.com/whois/{{.Value}}">{{.Value}}</a> will get <b>{{.Type}}</b> for next <b>{{.Duration}}</b> for triggering <b>{{.Scenario}}</b> on machine <b>{{$alert.MachineID}}</b>.</p> <p><a href="https://app.crowdsec.net/cti/{{.Value}}">CrowdSec CTI</a></p>
{{end -}}
{{end -}}
</body></html>
<html><body>
{{range . -}}
{{$alert := . -}}
{{range .Decisions -}}
<p><a href="https://www.whois.com/whois/{{.Value}}">{{.Value}}</a> will get <b>{{.Type}}</b> for next <b>{{.Duration}}</b> for triggering <b>{{.Scenario}}</b> on machine <b>{{$alert.MachineID}}</b>.</p> <p><a href="https://app.crowdsec.net/cti/{{.Value}}">CrowdSec CTI</a></p>
{{end -}}
{{end -}}
</body></html>
I'm testing the notification by triggering a modsec rule. OS: Ubuntu 24.04 CrowdSec Version: 1.7.2
12 Replies
CrowdSec
CrowdSec2mo ago
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type /unresolve
© Created By WhyAydan for CrowdSec ❤️
Loz
Loz2mo ago
I'm testing the notification by triggering a modsec rule.
Do you mean the modsec scenario, or the appsec rules? becuase appsec doesnt make decisions so the range .Decisions will be empty
GNU Plus Windows User
the modsec scenario, I don't use AppSec I wrote a custom scenario to trigger on the CRS webshell rules specifically, and have a notification set up for that scenario
Loz
Loz2mo ago
But are you filtering on a profile that has no decisions?
GNU Plus Windows User
No decisions, I had issues triggering the notification with both a decision and email notification so I started testing without any decisions.
Loz
Loz2mo ago
thats why the email is blank from the template shown as the range .Decisions has no elements so it will skip and write an empty email
GNU Plus Windows User
I actually had a few other issues but I want to fix this first btw does the ordering of decisions and notifications matter, do I need to have the email notification before or after a decision within a profile?
Loz
Loz2mo ago
Yes order matters, as it top down so if it matches the first and continue to the second the decision will only be applied after
GNU Plus Windows User
so that means I need to place the email notification above the decisions block?
Loz
Loz2mo ago
well it depends on what information you want. if you want to send an email with meta information then you just need to alter the template. if you want to send an email with decision information then either your profile needs a decision or you have to change the default "on_sucess: break" to continue but then it gets really messy
GNU Plus Windows User
I just tested it and it's working fine now even with the decisions. weird issue is definitely fixed, I'll open another ticket on other problems I found.
CrowdSec
CrowdSec2mo ago
Resolving empty body email notifications This has now been resolved. If you think this is a mistake please run /unresolve

Did you find this page helpful?