Improve create alerts input (#493)

* check decisions start_ip & end_ip fields
This commit is contained in:
erenJag 2020-12-01 14:42:53 +01:00 committed by GitHub
parent a16fb1475d
commit 71325d9134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,6 +121,12 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
for _, alert := range input {
if len(alert.Decisions) > 0 {
log.Debugf("alert %s already has decisions, don't apply profiles", *alert.Message)
for _, decision := range alert.Decisions {
if decision.EndIP != 0 && decision.StartIP != 0 && decision.EndIP < decision.StartIP {
gctx.JSON(http.StatusBadRequest, gin.H{"message": "'start_ip' must be lower than or equal to 'end_ip' in decisions"})
return
}
}
} else {
decisions, err := csprofiles.EvaluateProfiles(c.Profiles, alert)
if err != nil {