mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-07 07:42:45 +01:00
24
test/data.go
24
test/data.go
@@ -6,13 +6,13 @@ import (
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/database"
|
||||
"github.com/SecurityBrewery/catalyst/database/migrations"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
"github.com/SecurityBrewery/catalyst/pointer"
|
||||
)
|
||||
|
||||
var bobSetting = &models.UserData{Email: pointer.String("bob@example.org"), Name: pointer.String("Bob Bad")}
|
||||
var bobForm = &models.UserForm{ID: "bob", Blocked: false, Roles: []string{"admin"}}
|
||||
var Bob = &models.UserResponse{ID: "bob", Blocked: false, Roles: []string{"admin"}}
|
||||
var bobSetting = &model.UserData{Email: pointer.String("bob@example.org"), Name: pointer.String("Bob Bad")}
|
||||
var bobForm = &model.UserForm{ID: "bob", Blocked: false, Roles: []string{"admin"}}
|
||||
var Bob = &model.UserResponse{ID: "bob", Blocked: false, Roles: []string{"admin"}}
|
||||
|
||||
func SetupTestData(ctx context.Context, db *database.Database) error {
|
||||
if err := db.UserDataCreate(ctx, "bob", bobSetting); err != nil {
|
||||
@@ -22,18 +22,18 @@ func SetupTestData(ctx context.Context, db *database.Database) error {
|
||||
if _, err := db.UserCreate(ctx, bobForm); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := db.UserCreate(ctx, &models.UserForm{ID: "script", Roles: []string{"engineer"}, Apikey: true}); err != nil {
|
||||
if _, err := db.UserCreate(ctx, &model.UserForm{ID: "script", Roles: []string{"engineer"}, Apikey: true}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := db.TicketBatchCreate(ctx, []*models.TicketForm{
|
||||
if _, err := db.TicketBatchCreate(ctx, []*model.TicketForm{
|
||||
{
|
||||
ID: pointer.Int64(8125),
|
||||
Created: parse("2021-10-02T18:04:59.078186+02:00"),
|
||||
Modified: parse("2021-10-02T18:04:59.078186+02:00"),
|
||||
Name: "phishing from selenafadel@von.com detected",
|
||||
Owner: pointer.String("demo"),
|
||||
References: []*models.Reference{{Href: "https://www.seniorleading-edge.name/users/efficient", Name: "recovery"}, {Href: "http://www.dynamicseamless.com/clicks-and-mortar", Name: "force"}, {Href: "http://www.leadscalable.biz/envisioneer", Name: "fund"}},
|
||||
References: []*model.Reference{{Href: "https://www.seniorleading-edge.name/users/efficient", Name: "recovery"}, {Href: "http://www.dynamicseamless.com/clicks-and-mortar", Name: "force"}, {Href: "http://www.leadscalable.biz/envisioneer", Name: "fund"}},
|
||||
Schema: pointer.String("{}"),
|
||||
Status: "closed",
|
||||
Type: "alert",
|
||||
@@ -43,7 +43,7 @@ func SetupTestData(ctx context.Context, db *database.Database) error {
|
||||
Modified: parse("2021-10-02T18:04:59.078186+02:00"),
|
||||
Name: "Surfaceintroduce virus detected",
|
||||
Owner: pointer.String("demo"),
|
||||
References: []*models.Reference{{Href: "http://www.centralworld-class.io/synthesize", Name: "university"}, {Href: "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", Name: "goal"}, {Href: "http://www.chiefsyndicate.io/action-items", Name: "unemployment"}},
|
||||
References: []*model.Reference{{Href: "http://www.centralworld-class.io/synthesize", Name: "university"}, {Href: "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", Name: "goal"}, {Href: "http://www.chiefsyndicate.io/action-items", Name: "unemployment"}},
|
||||
Schema: pointer.String("{}"),
|
||||
Status: "closed",
|
||||
Type: "alert",
|
||||
@@ -51,18 +51,18 @@ func SetupTestData(ctx context.Context, db *database.Database) error {
|
||||
ID: pointer.Int64(8123),
|
||||
Created: parse("2021-10-02T18:04:59.078206+02:00"),
|
||||
Modified: parse("2021-10-02T18:04:59.078206+02:00"),
|
||||
Artifacts: []*models.Artifact{
|
||||
Artifacts: []*model.Artifact{
|
||||
{Name: "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", Status: pointer.String("unknown")},
|
||||
{Name: "http://www.customerviral.io/scalable/vertical/killer", Status: pointer.String("clean")},
|
||||
{Name: "leadreintermediate.io", Status: pointer.String("malicious")},
|
||||
},
|
||||
Name: "live zebra",
|
||||
Owner: pointer.String("demo"),
|
||||
References: []*models.Reference{{Href: "https://www.leadmaximize.net/e-services/back-end", Name: "performance"}, {Href: "http://www.corporateinteractive.name/rich", Name: "autumn"}, {Href: "https://www.corporateintuitive.org/intuitive/platforms/integrate", Name: "suggest"}},
|
||||
References: []*model.Reference{{Href: "https://www.leadmaximize.net/e-services/back-end", Name: "performance"}, {Href: "http://www.corporateinteractive.name/rich", Name: "autumn"}, {Href: "https://www.corporateintuitive.org/intuitive/platforms/integrate", Name: "suggest"}},
|
||||
Schema: pointer.String("{\n \"definitions\": {},\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://example.com/object1618746510.json\",\n \"title\": \"Event\",\n \"type\": \"object\",\n \"required\": [\n \"severity\",\n \"description\",\n \"tlp\"\n ],\n \"properties\": {\n \"severity\": {\n \"$id\": \"#root/severity\",\n \"title\": \"Severity\",\n \"type\": \"string\",\n \"default\": \"Medium\",\n \"nx-enum\": [\n \"Low\",\n \"Medium\",\n \"High\"\n ],\n \"x-cols\": 6,\n \"x-class\": \"pr-2\",\n \"x-display\": \"icon\",\n \"x-itemIcon\": \"icon\",\n \"oneOf\": [\n {\n \"const\": \"Low\",\n \"title\": \"Low\",\n \"icon\": \"mdi-chevron-up\"\n },\n {\n \"const\": \"Medium\",\n \"title\": \"Medium\",\n \"icon\": \"mdi-chevron-double-up\"\n },\n {\n \"const\": \"High\",\n \"title\": \"High\",\n \"icon\": \"mdi-chevron-triple-up\"\n }\n ]\n },\n \"tlp\": {\n \"$id\": \"#root/tlp\",\n \"title\": \"TLP\",\n \"type\": \"string\",\n \"nx-enum\": [\n \"White\",\n \"Green\",\n \"Amber\",\n \"Red\"\n ],\n \"x-cols\": 6,\n \"x-class\": \"pr-2\",\n \"x-display\": \"icon\",\n \"x-itemIcon\": \"icon\",\n \"oneOf\": [\n {\n \"const\": \"White\",\n \"title\": \"White\",\n \"icon\": \"mdi-alpha-w\"\n },\n {\n \"const\": \"Green\",\n \"title\": \"Green\",\n \"icon\": \"mdi-alpha-g\"\n },\n {\n \"const\": \"Amber\",\n \"title\": \"Amber\",\n \"icon\": \"mdi-alpha-a\"\n },\n {\n \"const\": \"Red\",\n \"title\": \"Red\",\n \"icon\": \"mdi-alpha-r\"\n }\n ]\n },\n \"description\": {\n \"$id\": \"#root/description\",\n \"title\": \"Description\",\n \"type\": \"string\",\n \"x-display\": \"textarea\",\n \"x-class\": \"pr-2\"\n }\n }\n}\n"),
|
||||
Status: "closed",
|
||||
Type: "incident",
|
||||
Playbooks: []*models.PlaybookTemplateForm{
|
||||
Playbooks: []*model.PlaybookTemplateForm{
|
||||
{Yaml: migrations.PhishingPlaybook},
|
||||
},
|
||||
},
|
||||
@@ -73,7 +73,7 @@ func SetupTestData(ctx context.Context, db *database.Database) error {
|
||||
if err := db.RelatedCreate(ctx, 8125, 8126); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := db.PlaybookCreate(ctx, &models.PlaybookTemplateForm{Yaml: "name: Simple\ntasks:\n input:\n name: Enter something to hash\n type: input\n schema:\n title: Something\n type: object\n properties:\n something:\n type: string\n title: Something\n default: \"\"\n next:\n hash: \"something != ''\"\n\n hash:\n name: Hash the something\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['something']\"\n next:\n comment: \"hash != ''\"\n\n comment:\n name: Comment the hash\n type: automation\n automation: comment\n payload:\n default: \"playbook.tasks['hash'].data['hash']\"\n next:\n done: \"done\"\n\n done:\n name: You can close this case now\n type: task\n"}); err != nil {
|
||||
if _, err := db.PlaybookCreate(ctx, &model.PlaybookTemplateForm{Yaml: "name: Simple\ntasks:\n input:\n name: Enter something to hash\n type: input\n schema:\n title: Something\n type: object\n properties:\n something:\n type: string\n title: Something\n default: \"\"\n next:\n hash: \"something != ''\"\n\n hash:\n name: Hash the something\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['something']\"\n next:\n comment: \"hash != ''\"\n\n comment:\n name: Comment the hash\n type: automation\n automation: comment\n payload:\n default: \"playbook.tasks['hash'].data['hash']\"\n next:\n done: \"done\"\n\n done:\n name: You can close this case now\n type: task\n"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user