mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
add cscli decisions import (#1038)
* add cscli decisions import Co-authored-by: Sebastien Blot <sebastien@crowdsec.net> Co-authored-by: bui <thibault@crowdsec.net>
This commit is contained in:
parent
6e272d3f88
commit
88d06260d7
6 changed files with 254 additions and 22 deletions
|
@ -125,7 +125,7 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
|||
c.HandleDBErrors(gctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
stopFlush := false
|
||||
for _, alert := range input {
|
||||
alert.MachineID = machineID
|
||||
if len(alert.Decisions) != 0 {
|
||||
|
@ -143,6 +143,10 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
|||
break
|
||||
}
|
||||
}
|
||||
decision := alert.Decisions[0]
|
||||
if decision.Origin != nil && *decision.Origin == "cscli-import" {
|
||||
stopFlush = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -164,7 +168,13 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
if stopFlush {
|
||||
c.DBClient.CanFlush = false
|
||||
}
|
||||
|
||||
alerts, err := c.DBClient.CreateAlert(machineID, input)
|
||||
c.DBClient.CanFlush = true
|
||||
|
||||
if err != nil {
|
||||
c.HandleDBErrors(gctx, err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue