mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-10 17:23:05 +01:00
Release catalyst
This commit is contained in:
38
automation/result.go
Normal file
38
automation/result.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package automation
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/database"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
)
|
||||
|
||||
func resultAutomation(catalystBus *bus.Bus, db *database.Database) error {
|
||||
return catalystBus.SubscribeResult(func(resultMsg *bus.ResultMsg) {
|
||||
if resultMsg.Target != nil {
|
||||
ctx := jobContext()
|
||||
switch {
|
||||
case resultMsg.Target.TaskOrigin != nil:
|
||||
if _, err := db.TaskComplete(
|
||||
ctx,
|
||||
resultMsg.Target.TaskOrigin.TicketId,
|
||||
resultMsg.Target.TaskOrigin.PlaybookId,
|
||||
resultMsg.Target.TaskOrigin.TaskId,
|
||||
resultMsg.Data,
|
||||
); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
case resultMsg.Target.ArtifactOrigin != nil:
|
||||
enrichment := &models.EnrichmentForm{
|
||||
Data: resultMsg.Data,
|
||||
Name: resultMsg.Automation,
|
||||
}
|
||||
_, err := db.EnrichArtifact(ctx, resultMsg.Target.ArtifactOrigin.TicketId, resultMsg.Target.ArtifactOrigin.Artifact, enrichment)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user