mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-23 23:43:12 +01:00
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/database"
|
||||
"github.com/SecurityBrewery/catalyst/database/busdb"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
"github.com/SecurityBrewery/catalyst/role"
|
||||
"github.com/SecurityBrewery/catalyst/time"
|
||||
)
|
||||
@@ -19,9 +19,9 @@ type busService struct {
|
||||
catalystBus *bus.Bus
|
||||
}
|
||||
|
||||
func New(apiurl, apikey string, catalystBus *bus.Bus, db *database.Database) error {
|
||||
func New(apiURL, apikey string, catalystBus *bus.Bus, db *database.Database) error {
|
||||
|
||||
h := &busService{db: db, apiURL: apiurl, apiKey: apikey, catalystBus: catalystBus}
|
||||
h := &busService{db: db, apiURL: apiURL, apiKey: apikey, catalystBus: catalystBus}
|
||||
|
||||
if err := catalystBus.SubscribeRequest(h.logRequest); err != nil {
|
||||
return err
|
||||
@@ -38,14 +38,14 @@ func New(apiurl, apikey string, catalystBus *bus.Bus, db *database.Database) err
|
||||
|
||||
func busContext() context.Context {
|
||||
// TODO: change roles?
|
||||
bot := &models.UserResponse{ID: "bot", Roles: []string{role.Admin}}
|
||||
bot := &model.UserResponse{ID: "bot", Roles: []string{role.Admin}}
|
||||
return busdb.UserContext(context.Background(), bot)
|
||||
}
|
||||
|
||||
func (h *busService) logRequest(msg *bus.RequestMsg) {
|
||||
var logEntries []*models.LogEntry
|
||||
var logEntries []*model.LogEntry
|
||||
for _, i := range msg.IDs {
|
||||
logEntries = append(logEntries, &models.LogEntry{
|
||||
logEntries = append(logEntries, &model.LogEntry{
|
||||
Type: bus.ChannelRequest,
|
||||
Reference: i.String(),
|
||||
Creator: msg.User,
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
)
|
||||
|
||||
func (h *busService) handleJob(automationMsg *bus.JobMsg) {
|
||||
ctx := busContext()
|
||||
|
||||
job, err := h.db.JobCreate(ctx, automationMsg.ID, &models.JobForm{
|
||||
job, err := h.db.JobCreate(ctx, automationMsg.ID, &model.JobForm{
|
||||
Automation: automationMsg.Automation,
|
||||
Payload: automationMsg.Message.Payload,
|
||||
Origin: automationMsg.Origin,
|
||||
@@ -47,7 +47,7 @@ func (h *busService) handleJob(automationMsg *bus.JobMsg) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := h.db.JobUpdate(ctx, automationMsg.ID, &models.Job{
|
||||
if _, err := h.db.JobUpdate(ctx, automationMsg.ID, &model.Job{
|
||||
Automation: job.Automation,
|
||||
Container: &containerID,
|
||||
Origin: job.Origin,
|
||||
@@ -85,7 +85,7 @@ func (h *busService) handleJob(automationMsg *bus.JobMsg) {
|
||||
}
|
||||
|
||||
/*
|
||||
func getAutomation(automationID string, config *Config) (*models.AutomationResponse, error) {
|
||||
func getAutomation(automationID string, config *Config) (*model.AutomationResponse, error) {
|
||||
req, err := http.NewRequest(http.MethodGet, config.CatalystAPIUrl+"/automations/"+automationID, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -104,7 +104,7 @@ func getAutomation(automationID string, config *Config) (*models.AutomationRespo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var automation models.AutomationResponse
|
||||
var automation model.AutomationResponse
|
||||
if err := json.Unmarshal(b, &automation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
)
|
||||
|
||||
func (h *busService) handleResult(resultMsg *bus.ResultMsg) {
|
||||
@@ -22,7 +22,7 @@ func (h *busService) handleResult(resultMsg *bus.ResultMsg) {
|
||||
log.Println(err)
|
||||
}
|
||||
case resultMsg.Target.ArtifactOrigin != nil:
|
||||
enrichment := &models.EnrichmentForm{
|
||||
enrichment := &model.EnrichmentForm{
|
||||
Data: resultMsg.Data,
|
||||
Name: resultMsg.Automation,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user