Change code generator (#4)

* Change code generator
* Remove gin
This commit is contained in:
Jonas Plum authored and GitHub committed 2022-01-08 00:48:44 +01:00
1 parent b5dd0cfacd
commit 8333ea88a8
148 files changed
+3077 -23976

No files matched your search

+1094
View File
File diff suppressed because it is too large. Load diff
+587
View File
@@ -0,0 +1,587 @@
package api
import "time"
type Args struct {
Method string
URL string
Data interface{}
}
type Want struct {
Status int
Body interface{}
}
var Tests = []struct {
Name string
Args Args
Want Want
}{
{
Name: "ListAutomations",
Args: Args{Method: "Get", URL: "/automations"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"id": "comment", "image": "docker.io/python:3", "script": "", "type": []interface{}{"playbook"}}, map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "", "type": []interface{}{"global", "artifact", "playbook"}}, map[string]interface{}{"id": "thehive", "image": "docker.io/python:3", "schema": "{\"title\":\"TheHive credentials\",\"type\":\"object\",\"properties\":{\"thehiveurl\":{\"type\":\"string\",\"title\":\"TheHive URL (e.g. 'https://thehive.example.org')\"},\"thehivekey\":{\"type\":\"string\",\"title\":\"TheHive API Key\"},\"skip_files\":{\"type\":\"boolean\", \"default\": true, \"title\":\"Skip Files (much faster)\"},\"keep_ids\":{\"type\":\"boolean\", \"default\": true, \"title\":\"Keep IDs and overwrite existing IDs\"}},\"required\":[\"thehiveurl\", \"thehivekey\", \"skip_files\", \"keep_ids\"]}", "script": "", "type": []interface{}{"global"}}, map[string]interface{}{"id": "vt.hash", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "", "type": []interface{}{"global", "artifact", "playbook"}}},
},
},
{
Name: "CreateAutomation",
Args: Args{Method: "Post", URL: "/automations", Data: map[string]interface{}{"id": "hash-sha-256", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha256 = hashlib.sha256(msg['payload']['default'].encode('utf-8'))\n return {'hash': sha256.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "hash-sha-256", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha256 = hashlib.sha256(msg['payload']['default'].encode('utf-8'))\n return {'hash': sha256.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global"}},
},
},
{
Name: "GetAutomation",
Args: Args{Method: "Get", URL: "/automations/hash.sha1"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "#!/usr/bin/env python\n\nimport sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload']['default'].encode('utf-8'))\n return {\"hash\": sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}},
},
},
{
Name: "UpdateAutomation",
Args: Args{Method: "Put", URL: "/automations/hash.sha1", Data: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload'].encode('utf-8'))\n return {'hash': sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload'].encode('utf-8'))\n return {'hash': sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}},
},
},
{
Name: "DeleteAutomation",
Args: Args{Method: "Delete", URL: "/automations/hash.sha1"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "CurrentUser",
Args: Args{Method: "Get", URL: "/currentuser"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
Name: "CurrentUserData",
Args: Args{Method: "Get", URL: "/currentuserdata"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
Name: "UpdateCurrentUserData",
Args: Args{Method: "Put", URL: "/currentuserdata", Data: map[string]interface{}{"email": "bob@example.org", "name": "Bob Bad"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
Name: "ListJobs",
Args: Args{Method: "Get", URL: "/jobs"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "created"}},
},
},
{
Name: "RunJob",
Args: Args{Method: "Post", URL: "/jobs", Data: map[string]interface{}{"automation": "hash.sha1", "message": map[string]interface{}{"payload": "test"}}},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "GetJob",
Args: Args{Method: "Get", URL: "/jobs/99cd67131b48"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "created"},
},
},
{
Name: "UpdateJob",
Args: Args{Method: "Put", URL: "/jobs/99cd67131b48", Data: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "failed"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "failed"},
},
},
{
Name: "GetLogs",
Args: Args{Method: "Get", URL: "/logs/tickets%252F294511"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "creator": "bob", "message": "Fail run account resist lend solve incident centre priority temperature. Cause change distribution examine location technique shape partner milk customer. Rail tea plate soil report cook railway interpretation breath action. Exercise dream accept park conclusion addition shoot assistance may answer. Gold writer link stop combine hear power name commitment operation. Determine lifespan support grow degree henry exclude detail set religion. Direct library policy convention chain retain discover ride walk student. Gather proposal select march aspect play noise avoid encourage employ. Assessment preserve transport combine wish influence income guess run stand. Charge limit crime ignore statement foundation study issue stop claim.", "reference": "tickets/294511", "type": "manual"}},
},
},
{
Name: "ListPlaybooks",
Args: Args{Method: "Get", URL: "/playbooks"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"id": "malware", "name": "Malware", "yaml": "name: Malware\ntasks:\n file-or-hash:\n name: Do you have the file or the hash?\n type: input\n schema:\n title: Malware\n type: object\n properties:\n file:\n type: string\n title: \"I have the\"\n enum: [ \"File\", \"Hash\" ]\n next:\n enter-hash: \"file == 'Hash'\"\n upload: \"file == 'File'\"\n\n enter-hash:\n name: Please enter the hash\n type: input\n schema:\n title: Malware\n type: object\n properties:\n hash:\n type: string\n title: Please enter the hash value\n minlength: 32\n next:\n virustotal: \"hash != ''\"\n\n upload:\n name: Upload the malware\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: object\n x-display: file\n title: Please upload the malware\n next:\n hash: \"malware\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['upload'].data['malware']\"\n next:\n virustotal:\n\n virustotal:\n name: Send hash to VirusTotal\n type: automation\n automation: vt.hash\n args:\n hash: \"playbook.tasks['enter-hash'].data['hash'] || playbook.tasks['hash'].data['hash']\"\n # next:\n # known-malware: \"score > 5\"\n # sandbox: \"score < 6\" # unknown-malware\n"}, map[string]interface{}{"id": "phishing", "name": "Phishing", "yaml": "name: Phishing\ntasks:\n board:\n name: Board Involvement?\n description: Is a board member involved?\n type: input\n schema:\n properties:\n boardInvolved:\n default: false\n title: A board member is involved.\n type: boolean\n required:\n - boardInvolved\n title: Board Involvement?\n type: object\n next:\n escalate: \"boardInvolved == true\"\n mail-available: \"boardInvolved == false\"\n\n escalate:\n name: Escalate to CISO\n description: Please escalate the task to the CISO\n type: task\n\n mail-available:\n name: Mail available\n type: input\n schema:\n oneOf:\n - properties:\n mail:\n title: Mail\n type: string\n x-display: textarea\n schemaKey:\n const: 'yes'\n type: string\n required:\n - mail\n title: 'Yes'\n - properties:\n schemaKey:\n const: 'no'\n type: string\n title: 'No'\n title: Mail available\n type: object\n next:\n block-sender: \"schemaKey == 'yes'\"\n extract-iocs: \"schemaKey == 'yes'\"\n search-email-gateway: \"schemaKey == 'no'\"\n\n search-email-gateway:\n name: Search email gateway\n description: Please search email-gateway for the phishing mail.\n type: task\n next:\n extract-iocs:\n\n block-sender:\n name: Block sender\n type: task\n next:\n extract-iocs:\n\n extract-iocs:\n name: Extract IOCs\n description: Please insert the IOCs\n type: input\n schema:\n properties:\n iocs:\n items:\n type: string\n title: IOCs\n type: array\n title: Extract IOCs\n type: object\n next:\n block-iocs:\n\n block-iocs:\n name: Block IOCs\n type: task\n"}, map[string]interface{}{"id": "simple", "name": "Simple", "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"}},
},
},
{
Name: "CreatePlaybook",
Args: Args{Method: "Post", URL: "/playbooks", Data: map[string]interface{}{"yaml": "name: Simple2\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "simple-2", "name": "Simple2", "yaml": "name: Simple2\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"},
},
},
{
Name: "GetPlaybook",
Args: Args{Method: "Get", URL: "/playbooks/simple"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "simple", "name": "Simple", "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"},
},
},
{
Name: "UpdatePlaybook",
Args: Args{Method: "Put", URL: "/playbooks/simple", Data: map[string]interface{}{"yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "simple", "name": "Simple", "yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"},
},
},
{
Name: "DeletePlaybook",
Args: Args{Method: "Delete", URL: "/playbooks/simple"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "GetSettings",
Args: Args{Method: "Get", URL: "/settings"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
},
},
{
Name: "GetStatistics",
Args: Args{Method: "Get", URL: "/statistics"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"open_tickets_per_user": map[string]interface{}{}, "tickets_per_type": map[string]interface{}{"alert": 2, "incident": 1}, "tickets_per_week": map[string]interface{}{"2021-39": 3}, "unassigned": 0},
},
},
{
Name: "ListTasks",
Args: Args{Method: "Get", URL: "/tasks"},
Want: Want{
Status: 200,
Body: nil,
},
},
{
Name: "ListTemplates",
Args: Args{Method: "Get", URL: "/templates"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"id": "default", "name": "Default", "schema": "{\n \"definitions\": {},\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://example.com/object1618746510.json\",\n \"title\": \"Default\",\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 \"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 \"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"}},
},
},
{
Name: "CreateTemplate",
Args: Args{Method: "Post", URL: "/templates", Data: map[string]interface{}{"name": "My Template", "schema": "{\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"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "my-template", "name": "My Template", "schema": "{\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"},
},
},
{
Name: "GetTemplate",
Args: Args{Method: "Get", URL: "/templates/default"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "default", "name": "Default", "schema": "{\n \"definitions\": {},\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://example.com/object1618746510.json\",\n \"title\": \"Default\",\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 \"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 \"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"},
},
},
{
Name: "UpdateTemplate",
Args: Args{Method: "Put", URL: "/templates/default", Data: map[string]interface{}{"name": "My Template", "schema": "{\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"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "default", "name": "My Template", "schema": "{\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"},
},
},
{
Name: "DeleteTemplate",
Args: Args{Method: "Delete", URL: "/templates/default"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "ListTickets",
Args: Args{Method: "Get", URL: "/tickets"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"count": 3, "tickets": []interface{}{map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "type": "task"}, "block-sender": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}, "board": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "type": "task"}, "extract-iocs": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\Line truncated
},
},
{
Name: "CreateTicket",
Args: Args{Method: "Post", URL: "/tickets", Data: map[string]interface{}{"id": 123, "name": "Wannacry infection", "owner": "bob", "status": "open", "type": "incident"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "id": 123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "Wannacry infection", "owner": "bob", "schema": "{}", "status": "open", "type": "incident"},
},
},
{
Name: "CreateTicketBatch",
Args: Args{Method: "Post", URL: "/tickets/batch", Data: []interface{}{map[string]interface{}{"id": 123, "name": "Wannacry infection", "owner": "bob", "status": "open", "type": "incident"}}},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "GetTicket",
Args: Args{Method: "Get", URL: "/tickets/8125"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8125, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "UpdateTicket",
Args: Args{Method: "Put", URL: "/tickets/8125", Data: map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.org detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "type": "alert"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "id": 8125, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.org detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "DeleteTicket",
Args: Args{Method: "Delete", URL: "/tickets/8125"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "AddArtifact",
Args: Args{Method: "Post", URL: "/tickets/8123/artifacts", Data: map[string]interface{}{"name": "2.2.2.2"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}, map[string]interface{}{"name": "2.2.2.2", "status": "unknown", "type": "ip"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\":Line truncated
},
},
{
Name: "GetArtifact",
Args: Args{Method: "Get", URL: "/tickets/8123/artifacts/leadreintermediate.io"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"},
},
},
{
Name: "SetArtifact",
Args: Args{Method: "Put", URL: "/tickets/8123/artifacts/leadreintermediate.io", Data: map[string]interface{}{"name": "leadreintermediate.io", "status": "clean"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "clean"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 \Line truncated
},
},
{
Name: "RemoveArtifact",
Args: Args{Method: "Delete", URL: "/tickets/8123/artifacts/leadreintermediate.io"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\",\Line truncated
},
},
{
Name: "EnrichArtifact",
Args: Args{Method: "Post", URL: "/tickets/8123/artifacts/leadreintermediate.io/enrich", Data: map[string]interface{}{"data": map[string]interface{}{"hash": "b7a067a742c20d07a7456646de89bc2d408a1153"}, "name": "hash.sha1"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"enrichments": map[string]interface{}{"hash.sha1": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "data": map[string]interface{}{"hash": "b7a067a742c20d07a7456646de89bc2d408a1153"}, "name": "hash.sha1"}}, "name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 Line truncated
},
},
{
Name: "RunArtifact",
Args: Args{Method: "Post", URL: "/tickets/8123/artifacts/leadreintermediate.io/run/hash.sha1"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "AddComment",
Args: Args{Method: "Post", URL: "/tickets/8125/comments", Data: map[string]interface{}{"message": "My first comment"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"comments": []interface{}{map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "creator": "bob", "message": "My first comment"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8125, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "RemoveComment",
Args: Args{Method: "Delete", URL: "/tickets/8123/comments/0"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 Line truncated
},
},
{
Name: "LinkFiles",
Args: Args{Method: "Put", URL: "/tickets/8125/files", Data: []interface{}{map[string]interface{}{"key": "myfile", "name": "document.doc"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "files": []interface{}{map[string]interface{}{"key": "myfile", "name": "document.doc"}}, "id": 8125, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "AddTicketPlaybook",
Args: Args{Method: "Post", URL: "/tickets/8125/playbooks", Data: map[string]interface{}{"yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8125, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "playbooks": map[string]interface{}{"simple": map[string]interface{}{"name": "Simple", "tasks": map[string]interface{}{"escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to malware team", "order": 2, "type": "task"}, "hash": map[string]interface{}{"active": false, "automation": "hash.sha1", "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Hash the malware", "next": map[string]interface{}{"escalate": ""}, "order": 1, "payload": map[string]interface{}{"default": "playbook.tasks['input'].data['malware']"}, "type": "automation"}, "input": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Upload malware if possible", "next": map[string]interface{}{"hash": "malware != ''"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"malware": map[string]interface{}{"default": "", "title": "Select malware", "type": "string"}}, "title": "Malware", "type": "object"}, "type": "input"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "RemoveTicketPlaybook",
Args: Args{Method: "Delete", URL: "/tickets/8123/playbooks/phishing"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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"},
},
},
{
Name: "SetTask",
Args: Args{Method: "Put", URL: "/tickets/8123/playbooks/phishing/task/board", Data: map[string]interface{}{"active": true, "data": map[string]interface{}{"boardInvolved": true}, "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "data": map[string]interface{}{"boardInvolved": true}, "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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-uLine truncated
},
},
{
Name: "CompleteTask",
Args: Args{Method: "Put", URL: "/tickets/8123/playbooks/phishing/task/board/complete", Data: map[string]interface{}{"boardInvolved": true}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": false, "closed": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "data": map[string]interface{}{"boardInvolved": true}, "done": true, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": true, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 Line truncated
},
},
{
Name: "RunTask",
Args: Args{Method: "Post", URL: "/tickets/8123/playbooks/phishing/task/board/run"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "SetReferences",
Args: Args{Method: "Put", URL: "/tickets/8125/references", Data: []interface{}{map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8125, "modified": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "SetSchema",
Args: Args{Method: "Put", URL: "/tickets/8125/schema", Data: "{}"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8125, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
Name: "LinkTicket",
Args: Args{Method: "Patch", URL: "/tickets/8126/tickets", Data: 8123},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "id": 8123, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78206000, time.UTC), "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block IOCs", "type": "task"}, "block-sender": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}, "board": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Escalate to CISO", "type": "task"}, "extract-iocs": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"created": time.Date(2021, time.December, 12, 12, 12, 12, 12, time.UTC), "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\Line truncated
},
},
{
Name: "UnlinkTicket",
Args: Args{Method: "Delete", URL: "/tickets/8126/tickets", Data: 8125},
Want: Want{
Status: 200,
Body: map[string]interface{}{"created": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "id": 8126, "modified": time.Date(2021, time.October, 2, 16, 4, 59, 78186000, time.UTC), "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"},
},
},
{
Name: "ListTicketTypes",
Args: Args{Method: "Get", URL: "/tickettypes"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}},
},
},
{
Name: "CreateTicketType",
Args: Args{Method: "Post", URL: "/tickettypes", Data: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-newspaper-variant-outline", "name": "TI Tickets"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-newspaper-variant-outline", "id": "ti-tickets", "name": "TI Tickets"},
},
},
{
Name: "GetTicketType",
Args: Args{Method: "Get", URL: "/tickettypes/alert"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"},
},
},
{
Name: "UpdateTicketType",
Args: Args{Method: "Put", URL: "/tickettypes/alert", Data: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-bell", "id": "alert", "name": "Alerts"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-bell", "id": "alert", "name": "Alerts"},
},
},
{
Name: "DeleteTicketType",
Args: Args{Method: "Delete", URL: "/tickettypes/alert"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "ListUserData",
Args: Args{Method: "Get", URL: "/userdata"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"}},
},
},
{
Name: "GetUserData",
Args: Args{Method: "Get", URL: "/userdata/bob"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
Name: "UpdateUserData",
Args: Args{Method: "Put", URL: "/userdata/bob", Data: map[string]interface{}{"blocked": false, "email": "bob@example.org", "name": "Bob Bad"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
Name: "ListUsers",
Args: Args{Method: "Get", URL: "/users"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}, map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}},
},
},
{
Name: "CreateUser",
Args: Args{Method: "Post", URL: "/users", Data: map[string]interface{}{"id": "syncscript", "roles": []interface{}{"analyst"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"blocked": false, "id": "syncscript", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read"}, "secret": "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"},
},
},
{
Name: "GetUser",
Args: Args{Method: "Get", URL: "/users/script"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
Name: "UpdateUser",
Args: Args{Method: "Put", URL: "/users/bob", Data: map[string]interface{}{"roles": []interface{}{"analyst", "admin"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
Name: "DeleteUser",
Args: Args{Method: "Delete", URL: "/users/script"},
Want: Want{
Status: 204,
Body: nil,
},
},
}
+23 -24
View File
@@ -795,10 +795,7 @@
"content" : {
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/PlaybookTemplateResponse"
},
"type" : "array"
"$ref" : "#/components/schemas/PlaybookTemplateResponse"
}
},
"test" : {
@@ -1245,7 +1242,7 @@
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/TaskResponse"
"$ref" : "#/components/schemas/TaskWithContext"
},
"type" : "array"
}
@@ -1805,7 +1802,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -1889,7 +1886,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -1976,7 +1973,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2187,7 +2184,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2443,7 +2440,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2660,7 +2657,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Artifact"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2922,7 +2919,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3013,7 +3010,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3226,7 +3223,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3317,7 +3314,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3418,6 +3415,9 @@
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "ticket:write" ]
} ],
"summary" : "Add a new ticket playbook",
"tags" : [ "tickets" ],
"x-codegen-request-body-name" : "playbook"
@@ -3451,7 +3451,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3545,7 +3545,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3776,7 +3776,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -4038,7 +4038,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -4112,14 +4112,14 @@
}
},
"description" : "New ticket schema",
"required" : false
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -4207,7 +4207,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -4273,7 +4273,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -5433,7 +5433,6 @@
"$ref" : "#/components/schemas/Context"
},
"payload" : {
"properties" : { },
"type" : "object"
},
"secrets" : {
+24 -23
View File
@@ -325,8 +325,7 @@ definitions:
properties:
context:
$ref: '#/definitions/Context'
payload:
type: object
payload: {}
secrets:
additionalProperties:
type: string
@@ -2251,9 +2250,7 @@ paths:
name: Escalate to malware team
type: task
schema:
items:
$ref: '#/definitions/PlaybookTemplateResponse'
type: array
$ref: '#/definitions/PlaybookTemplateResponse'
security:
- roles:
- playbook:write
@@ -2687,7 +2684,7 @@ paths:
test: []
schema:
items:
$ref: '#/definitions/TaskResponse'
$ref: '#/definitions/TaskWithContext'
type: array
security:
- roles:
@@ -3726,7 +3723,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:read
@@ -3801,7 +3798,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4053,7 +4050,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4297,7 +4294,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4580,7 +4577,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4841,7 +4838,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/Artifact'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4938,7 +4935,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5186,7 +5183,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5257,7 +5254,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5388,7 +5385,10 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
summary: Add a new ticket playbook
tags:
- tickets
@@ -5527,7 +5527,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5809,7 +5809,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6073,7 +6073,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6167,7 +6167,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6188,6 +6188,7 @@ paths:
- description: New ticket schema
in: body
name: schema
required: true
schema:
type: string
x-example: '{}'
@@ -6228,7 +6229,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6275,7 +6276,7 @@ paths:
status: closed
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6540,7 +6541,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
+23 -24
View File
@@ -563,10 +563,7 @@
"content" : {
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/PlaybookTemplateResponse"
},
"type" : "array"
"$ref" : "#/components/schemas/PlaybookTemplateResponse"
}
},
"test" : {
@@ -815,7 +812,7 @@
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/TaskResponse"
"$ref" : "#/components/schemas/TaskWithContext"
},
"type" : "array"
}
@@ -1375,7 +1372,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -1459,7 +1456,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -1546,7 +1543,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -1757,7 +1754,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2013,7 +2010,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2230,7 +2227,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Artifact"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2492,7 +2489,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2583,7 +2580,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2796,7 +2793,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2887,7 +2884,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -2988,6 +2985,9 @@
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "ticket:write" ]
} ],
"summary" : "Add a new ticket playbook",
"tags" : [ "tickets" ],
"x-codegen-request-body-name" : "playbook"
@@ -3021,7 +3021,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3115,7 +3115,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3346,7 +3346,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3608,7 +3608,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3682,14 +3682,14 @@
}
},
"description" : "New ticket schema",
"required" : false
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3777,7 +3777,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -3843,7 +3843,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/TicketResponse"
"$ref" : "#/components/schemas/TicketWithTickets"
}
},
"test" : {
@@ -4920,7 +4920,6 @@
"$ref" : "#/components/schemas/Context"
},
"payload" : {
"properties" : { },
"type" : "object"
},
"secrets" : {
+24 -23
View File
@@ -260,8 +260,7 @@ definitions:
properties:
context:
$ref: '#/definitions/Context'
payload:
type: object
payload: {}
secrets:
additionalProperties:
type: string
@@ -1980,9 +1979,7 @@ paths:
name: Escalate to malware team
type: task
schema:
items:
$ref: '#/definitions/PlaybookTemplateResponse'
type: array
$ref: '#/definitions/PlaybookTemplateResponse'
security:
- roles:
- playbook:write
@@ -2275,7 +2272,7 @@ paths:
test: []
schema:
items:
$ref: '#/definitions/TaskResponse'
$ref: '#/definitions/TaskWithContext'
type: array
security:
- roles:
@@ -3314,7 +3311,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:read
@@ -3389,7 +3386,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -3641,7 +3638,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -3885,7 +3882,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4168,7 +4165,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4429,7 +4426,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/Artifact'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4526,7 +4523,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4774,7 +4771,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4845,7 +4842,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -4976,7 +4973,10 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
summary: Add a new ticket playbook
tags:
- tickets
@@ -5115,7 +5115,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5397,7 +5397,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5661,7 +5661,7 @@ paths:
status: closed
type: incident
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5755,7 +5755,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5776,6 +5776,7 @@ paths:
- description: New ticket schema
in: body
name: schema
required: true
schema:
type: string
x-example: '{}'
@@ -5816,7 +5817,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -5863,7 +5864,7 @@ paths:
status: closed
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -6128,7 +6129,7 @@ paths:
type: alert
type: alert
schema:
$ref: '#/definitions/TicketResponse'
$ref: '#/definitions/TicketWithTickets'
security:
- roles:
- ticket:write
@@ -1,4 +1,4 @@
package models
package model
import (
"fmt"
@@ -78,7 +78,7 @@ func init() {
gojsonschema.NewStringLoader(`{"type":"object","required":["automation"],"x-embed":"","properties":{"automation":{"type":"string"},"origin":{"$ref":"#/definitions/Origin"},"payload":{}},"$id":"#/definitions/JobForm"}`),
gojsonschema.NewStringLoader(`{"type":"object","required":["id","automation","status"],"x-embed":"","properties":{"automation":{"type":"string"},"container":{"type":"string"},"id":{"type":"string"},"log":{"type":"string"},"origin":{"$ref":"#/definitions/Origin"},"output":{"type":"object"},"payload":{},"status":{"type":"string"}},"$id":"#/definitions/JobResponse"}`),
gojsonschema.NewStringLoader(`{"type":"object","required":["type","reference","creator","created","message"],"x-embed":"","properties":{"created":{"format":"date-time","type":"string"},"creator":{"type":"string"},"message":{"type":"string"},"reference":{"type":"string"},"type":{"type":"string"}},"$id":"#/definitions/LogEntry"}`),
gojsonschema.NewStringLoader(`{"type":"object","x-embed":"","properties":{"context":{"$ref":"#/definitions/Context"},"payload":{"type":"object"},"secrets":{"type":"object","additionalProperties":{"type":"string"}}},"$id":"#/definitions/Message"}`),
gojsonschema.NewStringLoader(`{"type":"object","x-embed":"","properties":{"context":{"$ref":"#/definitions/Context"},"payload":{},"secrets":{"type":"object","additionalProperties":{"type":"string"}}},"$id":"#/definitions/Message"}`),
gojsonschema.NewStringLoader(`{"type":"object","required":["id","blocked","roles"],"x-embed":"","properties":{"blocked":{"type":"boolean"},"id":{"type":"string"},"roles":{"items":{"type":"string"},"type":"array"},"secret":{"type":"string"}},"$id":"#/definitions/NewUserResponse"}`),
gojsonschema.NewStringLoader(`{"type":"object","x-embed":"","properties":{"artifact_origin":{"$ref":"#/definitions/ArtifactOrigin"},"task_origin":{"$ref":"#/definitions/TaskOrigin"}},"$id":"#/definitions/Origin"}`),
gojsonschema.NewStringLoader(`{"type":"object","required":["name","tasks"],"x-embed":"","properties":{"name":{"type":"string"},"tasks":{"type":"object","additionalProperties":{"$ref":"#/definitions/Task"}}},"$id":"#/definitions/Playbook"}`),
@@ -223,14 +223,14 @@ type Context struct {
}
type Enrichment struct {
Created time.Time `json:"created"`
Data interface{} `json:"data"`
Name string `json:"name"`
Created time.Time `json:"created"`
Data map[string]interface{} `json:"data"`
Name string `json:"name"`
}
type EnrichmentForm struct {
Data interface{} `json:"data"`
Name string `json:"name"`
Data map[string]interface{} `json:"data"`
Name string `json:"name"`
}
type File struct {
@@ -239,14 +239,14 @@ type File struct {
}
type Job struct {
Automation string `json:"automation"`
Container *string `json:"container,omitempty"`
Log *string `json:"log,omitempty"`
Origin *Origin `json:"origin,omitempty"`
Output interface{} `json:"output,omitempty"`
Payload interface{} `json:"payload,omitempty"`
Running bool `json:"running"`
Status string `json:"status"`
Automation string `json:"automation"`
Container *string `json:"container,omitempty"`
Log *string `json:"log,omitempty"`
Origin *Origin `json:"origin,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`
Payload interface{} `json:"payload,omitempty"`
Running bool `json:"running"`
Status string `json:"status"`
}
type JobForm struct {
@@ -256,14 +256,14 @@ type JobForm struct {
}
type JobResponse struct {
Automation string `json:"automation"`
Container *string `json:"container,omitempty"`
ID string `json:"id"`
Log *string `json:"log,omitempty"`
Origin *Origin `json:"origin,omitempty"`
Output interface{} `json:"output,omitempty"`
Payload interface{} `json:"payload,omitempty"`
Status string `json:"status"`
Automation string `json:"automation"`
Container *string `json:"container,omitempty"`
ID string `json:"id"`
Log *string `json:"log,omitempty"`
Origin *Origin `json:"origin,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`
Payload interface{} `json:"payload,omitempty"`
Status string `json:"status"`
}
type LogEntry struct {
@@ -340,33 +340,33 @@ type Statistics struct {
}
type Task struct {
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created time.Time `json:"created"`
Data interface{} `json:"data,omitempty"`
Done bool `json:"done"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema interface{} `json:"schema,omitempty"`
Type string `json:"type"`
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created time.Time `json:"created"`
Data map[string]interface{} `json:"data,omitempty"`
Done bool `json:"done"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
Type string `json:"type"`
}
type TaskForm struct {
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created *time.Time `json:"created,omitempty"`
Data interface{} `json:"data,omitempty"`
Done *bool `json:"done,omitempty"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema interface{} `json:"schema,omitempty"`
Type string `json:"type"`
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created *time.Time `json:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
Done *bool `json:"done,omitempty"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
Type string `json:"type"`
}
type TaskOrigin struct {
@@ -376,54 +376,54 @@ type TaskOrigin struct {
}
type TaskResponse struct {
Active bool `json:"active"`
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created time.Time `json:"created"`
Data interface{} `json:"data,omitempty"`
Done bool `json:"done"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Order int64 `json:"order"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema interface{} `json:"schema,omitempty"`
Type string `json:"type"`
Active bool `json:"active"`
Automation *string `json:"automation,omitempty"`
Closed *time.Time `json:"closed,omitempty"`
Created time.Time `json:"created"`
Data map[string]interface{} `json:"data,omitempty"`
Done bool `json:"done"`
Join *bool `json:"join,omitempty"`
Name string `json:"name"`
Next map[string]string `json:"next,omitempty"`
Order int64 `json:"order"`
Owner *string `json:"owner,omitempty"`
Payload map[string]string `json:"payload,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
Type string `json:"type"`
}
type TaskWithContext struct {
PlaybookId string `json:"playbook_id"`
PlaybookName string `json:"playbook_name"`
Task TaskResponse `json:"task"`
TaskId string `json:"task_id"`
TicketId int64 `json:"ticket_id"`
TicketName string `json:"ticket_name"`
PlaybookId string `json:"playbook_id"`
PlaybookName string `json:"playbook_name"`
Task *TaskResponse `json:"task"`
TaskId string `json:"task_id"`
TicketId int64 `json:"ticket_id"`
TicketName string `json:"ticket_name"`
}
type Ticket struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
Modified time.Time `json:"modified"`
Name string `json:"name"`
Owner *string `json:"owner,omitempty"`
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
Read []string `json:"read,omitempty"`
References []*Reference `json:"references,omitempty"`
Schema string `json:"schema"`
Status string `json:"status"`
Type string `json:"type"`
Write []string `json:"write,omitempty"`
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details map[string]interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
Modified time.Time `json:"modified"`
Name string `json:"name"`
Owner *string `json:"owner,omitempty"`
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
Read []string `json:"read,omitempty"`
References []*Reference `json:"references,omitempty"`
Schema string `json:"schema"`
Status string `json:"status"`
Type string `json:"type"`
Write []string `json:"write,omitempty"`
}
type TicketForm struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created *time.Time `json:"created,omitempty"`
Details interface{} `json:"details,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
ID *int64 `json:"id,omitempty"`
Modified *time.Time `json:"modified,omitempty"`
@@ -447,7 +447,7 @@ type TicketResponse struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details interface{} `json:"details,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
ID int64 `json:"id"`
Modified time.Time `json:"modified"`
@@ -463,22 +463,22 @@ type TicketResponse struct {
}
type TicketSimpleResponse struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
ID int64 `json:"id"`
Modified time.Time `json:"modified"`
Name string `json:"name"`
Owner *string `json:"owner,omitempty"`
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
Read []string `json:"read,omitempty"`
References []*Reference `json:"references,omitempty"`
Schema string `json:"schema"`
Status string `json:"status"`
Type string `json:"type"`
Write []string `json:"write,omitempty"`
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details map[string]interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
ID int64 `json:"id"`
Modified time.Time `json:"modified"`
Name string `json:"name"`
Owner *string `json:"owner,omitempty"`
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
Read []string `json:"read,omitempty"`
References []*Reference `json:"references,omitempty"`
Schema string `json:"schema"`
Status string `json:"status"`
Type string `json:"type"`
Write []string `json:"write,omitempty"`
}
type TicketTemplate struct {
@@ -528,7 +528,7 @@ type TicketWithTickets struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Created time.Time `json:"created"`
Details interface{} `json:"details,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
Files []*File `json:"files,omitempty"`
ID int64 `json:"id"`
Logs []*LogEntry `json:"logs,omitempty"`
-252
View File
@@ -1,252 +0,0 @@
package restapi
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/gin-gonic/gin"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/automations"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/jobs"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/logs"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/playbooks"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/settings"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/statistics"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/tasks"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/templates"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/tickets"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/tickettypes"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/userdata"
"github.com/SecurityBrewery/catalyst/generated/restapi/operations/users"
"github.com/SecurityBrewery/catalyst/role"
)
// Service is the interface that must be implemented in order to provide
// business logic for the Server service.
type Service interface {
AddArtifact(ctx context.Context, params *tickets.AddArtifactParams) *api.Response
AddComment(ctx context.Context, params *tickets.AddCommentParams) *api.Response
AddTicketPlaybook(ctx context.Context, params *tickets.AddTicketPlaybookParams) *api.Response
CompleteTask(ctx context.Context, params *tickets.CompleteTaskParams) *api.Response
CreateAutomation(ctx context.Context, params *automations.CreateAutomationParams) *api.Response
CreatePlaybook(ctx context.Context, params *playbooks.CreatePlaybookParams) *api.Response
CreateTemplate(ctx context.Context, params *templates.CreateTemplateParams) *api.Response
CreateTicket(ctx context.Context, params *tickets.CreateTicketParams) *api.Response
CreateTicketBatch(ctx context.Context, params *tickets.CreateTicketBatchParams) *api.Response
CreateTicketType(ctx context.Context, params *tickettypes.CreateTicketTypeParams) *api.Response
CreateUser(ctx context.Context, params *users.CreateUserParams) *api.Response
CurrentUser(ctx context.Context) *api.Response
CurrentUserData(ctx context.Context) *api.Response
DeleteAutomation(ctx context.Context, params *automations.DeleteAutomationParams) *api.Response
DeletePlaybook(ctx context.Context, params *playbooks.DeletePlaybookParams) *api.Response
DeleteTemplate(ctx context.Context, params *templates.DeleteTemplateParams) *api.Response
DeleteTicket(ctx context.Context, params *tickets.DeleteTicketParams) *api.Response
DeleteTicketType(ctx context.Context, params *tickettypes.DeleteTicketTypeParams) *api.Response
DeleteUser(ctx context.Context, params *users.DeleteUserParams) *api.Response
EnrichArtifact(ctx context.Context, params *tickets.EnrichArtifactParams) *api.Response
GetArtifact(ctx context.Context, params *tickets.GetArtifactParams) *api.Response
GetAutomation(ctx context.Context, params *automations.GetAutomationParams) *api.Response
GetJob(ctx context.Context, params *jobs.GetJobParams) *api.Response
GetLogs(ctx context.Context, params *logs.GetLogsParams) *api.Response
GetPlaybook(ctx context.Context, params *playbooks.GetPlaybookParams) *api.Response
GetSettings(ctx context.Context) *api.Response
GetStatistics(ctx context.Context) *api.Response
GetTemplate(ctx context.Context, params *templates.GetTemplateParams) *api.Response
GetTicket(ctx context.Context, params *tickets.GetTicketParams) *api.Response
GetTicketType(ctx context.Context, params *tickettypes.GetTicketTypeParams) *api.Response
GetUser(ctx context.Context, params *users.GetUserParams) *api.Response
GetUserData(ctx context.Context, params *userdata.GetUserDataParams) *api.Response
LinkFiles(ctx context.Context, params *tickets.LinkFilesParams) *api.Response
LinkTicket(ctx context.Context, params *tickets.LinkTicketParams) *api.Response
ListAutomations(ctx context.Context) *api.Response
ListJobs(ctx context.Context) *api.Response
ListPlaybooks(ctx context.Context) *api.Response
ListTasks(ctx context.Context) *api.Response
ListTemplates(ctx context.Context) *api.Response
ListTicketTypes(ctx context.Context) *api.Response
ListTickets(ctx context.Context, params *tickets.ListTicketsParams) *api.Response
ListUserData(ctx context.Context) *api.Response
ListUsers(ctx context.Context) *api.Response
RemoveArtifact(ctx context.Context, params *tickets.RemoveArtifactParams) *api.Response
RemoveComment(ctx context.Context, params *tickets.RemoveCommentParams) *api.Response
RemoveTicketPlaybook(ctx context.Context, params *tickets.RemoveTicketPlaybookParams) *api.Response
RunArtifact(ctx context.Context, params *tickets.RunArtifactParams) *api.Response
RunJob(ctx context.Context, params *jobs.RunJobParams) *api.Response
RunTask(ctx context.Context, params *tickets.RunTaskParams) *api.Response
SetArtifact(ctx context.Context, params *tickets.SetArtifactParams) *api.Response
SetReferences(ctx context.Context, params *tickets.SetReferencesParams) *api.Response
SetSchema(ctx context.Context, params *tickets.SetSchemaParams) *api.Response
SetTask(ctx context.Context, params *tickets.SetTaskParams) *api.Response
UnlinkTicket(ctx context.Context, params *tickets.UnlinkTicketParams) *api.Response
UpdateAutomation(ctx context.Context, params *automations.UpdateAutomationParams) *api.Response
UpdateCurrentUserData(ctx context.Context, params *userdata.UpdateCurrentUserDataParams) *api.Response
UpdateJob(ctx context.Context, params *jobs.UpdateJobParams) *api.Response
UpdatePlaybook(ctx context.Context, params *playbooks.UpdatePlaybookParams) *api.Response
UpdateTemplate(ctx context.Context, params *templates.UpdateTemplateParams) *api.Response
UpdateTicket(ctx context.Context, params *tickets.UpdateTicketParams) *api.Response
UpdateTicketType(ctx context.Context, params *tickettypes.UpdateTicketTypeParams) *api.Response
UpdateUser(ctx context.Context, params *users.UpdateUserParams) *api.Response
UpdateUserData(ctx context.Context, params *userdata.UpdateUserDataParams) *api.Response
}
// Config defines the config options for the API server.
type Config struct {
Address string
InsecureHTTP bool
TLSCertFile string
TLSKeyFile string
}
// Server defines the Server service.
type Server struct {
*gin.Engine
config *Config
server *http.Server
service Service
ApiGroup *gin.RouterGroup
RoleAuth func([]role.Role) gin.HandlerFunc
}
// New initializes a new Server service.
func New(svc Service, config *Config) *Server {
engine := gin.New()
engine.Use(gin.Recovery())
return &Server{
Engine: engine,
service: svc,
config: config,
server: &http.Server{
Addr: config.Address,
Handler: engine,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
},
ApiGroup: engine.Group("/api"),
RoleAuth: func(i []role.Role) gin.HandlerFunc { return func(c *gin.Context) { c.Next() } },
}
}
// ConfigureRoutes configures the routes for the Server service.
// Configuring of routes includes setting up Auth if it is enabled.
func (s *Server) ConfigureRoutes() {
s.ApiGroup.POST("/tickets/:id/artifacts", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.AddArtifactEndpoint(s.service.AddArtifact))
s.ApiGroup.POST("/tickets/:id/comments", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.AddCommentEndpoint(s.service.AddComment))
s.ApiGroup.POST("/tickets/:id/playbooks", s.RoleAuth([]role.Role{}), tickets.AddTicketPlaybookEndpoint(s.service.AddTicketPlaybook))
s.ApiGroup.PUT("/tickets/:id/playbooks/:playbookID/task/:taskID/complete", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.CompleteTaskEndpoint(s.service.CompleteTask))
s.ApiGroup.POST("/automations", s.RoleAuth([]role.Role{role.AutomationWrite}), automations.CreateAutomationEndpoint(s.service.CreateAutomation))
s.ApiGroup.POST("/playbooks", s.RoleAuth([]role.Role{role.PlaybookWrite}), playbooks.CreatePlaybookEndpoint(s.service.CreatePlaybook))
s.ApiGroup.POST("/templates", s.RoleAuth([]role.Role{role.TemplateWrite}), templates.CreateTemplateEndpoint(s.service.CreateTemplate))
s.ApiGroup.POST("/tickets", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.CreateTicketEndpoint(s.service.CreateTicket))
s.ApiGroup.POST("/tickets/batch", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.CreateTicketBatchEndpoint(s.service.CreateTicketBatch))
s.ApiGroup.POST("/tickettypes", s.RoleAuth([]role.Role{role.TickettypeWrite}), tickettypes.CreateTicketTypeEndpoint(s.service.CreateTicketType))
s.ApiGroup.POST("/users", s.RoleAuth([]role.Role{role.UserWrite}), users.CreateUserEndpoint(s.service.CreateUser))
s.ApiGroup.GET("/currentuser", s.RoleAuth([]role.Role{role.CurrentuserRead}), users.CurrentUserEndpoint(s.service.CurrentUser))
s.ApiGroup.GET("/currentuserdata", s.RoleAuth([]role.Role{role.CurrentuserdataRead}), userdata.CurrentUserDataEndpoint(s.service.CurrentUserData))
s.ApiGroup.DELETE("/automations/:id", s.RoleAuth([]role.Role{role.AutomationWrite}), automations.DeleteAutomationEndpoint(s.service.DeleteAutomation))
s.ApiGroup.DELETE("/playbooks/:id", s.RoleAuth([]role.Role{role.PlaybookWrite}), playbooks.DeletePlaybookEndpoint(s.service.DeletePlaybook))
s.ApiGroup.DELETE("/templates/:id", s.RoleAuth([]role.Role{role.TemplateWrite}), templates.DeleteTemplateEndpoint(s.service.DeleteTemplate))
s.ApiGroup.DELETE("/tickets/:id", s.RoleAuth([]role.Role{role.TicketDelete}), tickets.DeleteTicketEndpoint(s.service.DeleteTicket))
s.ApiGroup.DELETE("/tickettypes/:id", s.RoleAuth([]role.Role{role.TickettypeWrite}), tickettypes.DeleteTicketTypeEndpoint(s.service.DeleteTicketType))
s.ApiGroup.DELETE("/users/:id", s.RoleAuth([]role.Role{role.UserWrite}), users.DeleteUserEndpoint(s.service.DeleteUser))
s.ApiGroup.POST("/tickets/:id/artifacts/:name/enrich", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.EnrichArtifactEndpoint(s.service.EnrichArtifact))
s.ApiGroup.GET("/tickets/:id/artifacts/:name", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.GetArtifactEndpoint(s.service.GetArtifact))
s.ApiGroup.GET("/automations/:id", s.RoleAuth([]role.Role{role.AutomationRead}), automations.GetAutomationEndpoint(s.service.GetAutomation))
s.ApiGroup.GET("/jobs/:id", s.RoleAuth([]role.Role{role.JobRead}), jobs.GetJobEndpoint(s.service.GetJob))
s.ApiGroup.GET("/logs/:reference", s.RoleAuth([]role.Role{role.LogRead}), logs.GetLogsEndpoint(s.service.GetLogs))
s.ApiGroup.GET("/playbooks/:id", s.RoleAuth([]role.Role{role.PlaybookRead}), playbooks.GetPlaybookEndpoint(s.service.GetPlaybook))
s.ApiGroup.GET("/settings", s.RoleAuth([]role.Role{role.SettingsRead}), settings.GetSettingsEndpoint(s.service.GetSettings))
s.ApiGroup.GET("/statistics", s.RoleAuth([]role.Role{role.TicketRead}), statistics.GetStatisticsEndpoint(s.service.GetStatistics))
s.ApiGroup.GET("/templates/:id", s.RoleAuth([]role.Role{role.TemplateRead}), templates.GetTemplateEndpoint(s.service.GetTemplate))
s.ApiGroup.GET("/tickets/:id", s.RoleAuth([]role.Role{role.TicketRead}), tickets.GetTicketEndpoint(s.service.GetTicket))
s.ApiGroup.GET("/tickettypes/:id", s.RoleAuth([]role.Role{role.TickettypeRead}), tickettypes.GetTicketTypeEndpoint(s.service.GetTicketType))
s.ApiGroup.GET("/users/:id", s.RoleAuth([]role.Role{role.UserRead}), users.GetUserEndpoint(s.service.GetUser))
s.ApiGroup.GET("/userdata/:id", s.RoleAuth([]role.Role{role.UserdataRead}), userdata.GetUserDataEndpoint(s.service.GetUserData))
s.ApiGroup.PUT("/tickets/:id/files", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.LinkFilesEndpoint(s.service.LinkFiles))
s.ApiGroup.PATCH("/tickets/:id/tickets", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.LinkTicketEndpoint(s.service.LinkTicket))
s.ApiGroup.GET("/automations", s.RoleAuth([]role.Role{role.AutomationRead}), automations.ListAutomationsEndpoint(s.service.ListAutomations))
s.ApiGroup.GET("/jobs", s.RoleAuth([]role.Role{role.JobRead}), jobs.ListJobsEndpoint(s.service.ListJobs))
s.ApiGroup.GET("/playbooks", s.RoleAuth([]role.Role{role.PlaybookRead}), playbooks.ListPlaybooksEndpoint(s.service.ListPlaybooks))
s.ApiGroup.GET("/tasks", s.RoleAuth([]role.Role{role.TicketRead}), tasks.ListTasksEndpoint(s.service.ListTasks))
s.ApiGroup.GET("/templates", s.RoleAuth([]role.Role{role.TemplateRead}), templates.ListTemplatesEndpoint(s.service.ListTemplates))
s.ApiGroup.GET("/tickettypes", s.RoleAuth([]role.Role{role.TickettypeRead}), tickettypes.ListTicketTypesEndpoint(s.service.ListTicketTypes))
s.ApiGroup.GET("/tickets", s.RoleAuth([]role.Role{role.TicketRead}), tickets.ListTicketsEndpoint(s.service.ListTickets))
s.ApiGroup.GET("/userdata", s.RoleAuth([]role.Role{role.UserdataRead}), userdata.ListUserDataEndpoint(s.service.ListUserData))
s.ApiGroup.GET("/users", s.RoleAuth([]role.Role{role.UserRead}), users.ListUsersEndpoint(s.service.ListUsers))
s.ApiGroup.DELETE("/tickets/:id/artifacts/:name", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.RemoveArtifactEndpoint(s.service.RemoveArtifact))
s.ApiGroup.DELETE("/tickets/:id/comments/:commentID", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.RemoveCommentEndpoint(s.service.RemoveComment))
s.ApiGroup.DELETE("/tickets/:id/playbooks/:playbookID", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.RemoveTicketPlaybookEndpoint(s.service.RemoveTicketPlaybook))
s.ApiGroup.POST("/tickets/:id/artifacts/:name/run/:automation", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.RunArtifactEndpoint(s.service.RunArtifact))
s.ApiGroup.POST("/jobs", s.RoleAuth([]role.Role{role.JobWrite}), jobs.RunJobEndpoint(s.service.RunJob))
s.ApiGroup.POST("/tickets/:id/playbooks/:playbookID/task/:taskID/run", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.RunTaskEndpoint(s.service.RunTask))
s.ApiGroup.PUT("/tickets/:id/artifacts/:name", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.SetArtifactEndpoint(s.service.SetArtifact))
s.ApiGroup.PUT("/tickets/:id/references", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.SetReferencesEndpoint(s.service.SetReferences))
s.ApiGroup.PUT("/tickets/:id/schema", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.SetSchemaEndpoint(s.service.SetSchema))
s.ApiGroup.PUT("/tickets/:id/playbooks/:playbookID/task/:taskID", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.SetTaskEndpoint(s.service.SetTask))
s.ApiGroup.DELETE("/tickets/:id/tickets", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.UnlinkTicketEndpoint(s.service.UnlinkTicket))
s.ApiGroup.PUT("/automations/:id", s.RoleAuth([]role.Role{role.AutomationWrite}), automations.UpdateAutomationEndpoint(s.service.UpdateAutomation))
s.ApiGroup.PUT("/currentuserdata", s.RoleAuth([]role.Role{role.CurrentuserdataWrite}), userdata.UpdateCurrentUserDataEndpoint(s.service.UpdateCurrentUserData))
s.ApiGroup.PUT("/jobs/:id", s.RoleAuth([]role.Role{role.JobWrite}), jobs.UpdateJobEndpoint(s.service.UpdateJob))
s.ApiGroup.PUT("/playbooks/:id", s.RoleAuth([]role.Role{role.PlaybookWrite}), playbooks.UpdatePlaybookEndpoint(s.service.UpdatePlaybook))
s.ApiGroup.PUT("/templates/:id", s.RoleAuth([]role.Role{role.TemplateWrite}), templates.UpdateTemplateEndpoint(s.service.UpdateTemplate))
s.ApiGroup.PUT("/tickets/:id", s.RoleAuth([]role.Role{role.TicketWrite}), tickets.UpdateTicketEndpoint(s.service.UpdateTicket))
s.ApiGroup.PUT("/tickettypes/:id", s.RoleAuth([]role.Role{role.TickettypeWrite}), tickettypes.UpdateTicketTypeEndpoint(s.service.UpdateTicketType))
s.ApiGroup.PUT("/users/:id", s.RoleAuth([]role.Role{role.UserWrite}), users.UpdateUserEndpoint(s.service.UpdateUser))
s.ApiGroup.PUT("/userdata/:id", s.RoleAuth([]role.Role{role.UserdataWrite}), userdata.UpdateUserDataEndpoint(s.service.UpdateUserData))
}
// run the Server. It will listen on either HTTP or HTTPS depending on the
// config passed to NewServer.
func (s *Server) run() error {
log.Printf("Serving on address %s\n", s.server.Addr)
if s.config.InsecureHTTP {
return s.server.ListenAndServe()
}
return s.server.ListenAndServeTLS(s.config.TLSCertFile, s.config.TLSKeyFile)
}
// Shutdown will gracefully shutdown the Server.
func (s *Server) Shutdown() error {
return s.server.Shutdown(context.Background())
}
// RunWithSigHandler runs the Server with SIGTERM handling automatically
// enabled. The server will listen for a SIGTERM signal and gracefully shutdown
// the web server.
// It's possible to optionally pass any number shutdown functions which will
// execute one by one after the webserver has been shutdown successfully.
func (s *Server) RunWithSigHandler(shutdown ...func() error) error {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigCh
s.Shutdown()
}()
err := s.run()
if err != nil {
if err != http.ErrServerClosed {
return err
}
}
for _, fn := range shutdown {
err := fn()
if err != nil {
return err
}
}
return nil
}
-6
View File
@@ -1,6 +0,0 @@
package api
type Response struct {
Code int
Body interface{}
}
File diff suppressed because it is too large. Load diff
@@ -1,90 +0,0 @@
package automations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateAutomationEndpoint executes the core logic of the related
// route endpoint.
func CreateAutomationEndpoint(handler func(ctx context.Context, params *CreateAutomationParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateAutomationParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateAutomationParams creates a new CreateAutomationParams object
// with the default values initialized.
func NewCreateAutomationParams() *CreateAutomationParams {
var ()
return &CreateAutomationParams{}
}
// CreateAutomationParams contains all the bound params for the create automation operation
// typically these are obtained from a http.Request
//
// swagger:parameters createAutomation
type CreateAutomationParams struct {
/*New automation
Required: true
In: body
*/
Automation *models.AutomationForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateAutomationParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.AutomationForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("automation", "body", ""))
} else {
res = append(res, errors.NewParseError("automation", "body", "", err))
}
} else {
o.Automation = &body
}
} else {
res = append(res, errors.Required("automation", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package automations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeleteAutomationEndpoint executes the core logic of the related
// route endpoint.
func DeleteAutomationEndpoint(handler func(ctx context.Context, params *DeleteAutomationParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeleteAutomationParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeleteAutomationParams creates a new DeleteAutomationParams object
// with the default values initialized.
func NewDeleteAutomationParams() *DeleteAutomationParams {
var ()
return &DeleteAutomationParams{}
}
// DeleteAutomationParams contains all the bound params for the delete automation operation
// typically these are obtained from a http.Request
//
// swagger:parameters deleteAutomation
type DeleteAutomationParams struct {
/*Automation ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeleteAutomationParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeleteAutomationParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package automations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetAutomationEndpoint executes the core logic of the related
// route endpoint.
func GetAutomationEndpoint(handler func(ctx context.Context, params *GetAutomationParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetAutomationParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetAutomationParams creates a new GetAutomationParams object
// with the default values initialized.
func NewGetAutomationParams() *GetAutomationParams {
var ()
return &GetAutomationParams{}
}
// GetAutomationParams contains all the bound params for the get automation operation
// typically these are obtained from a http.Request
//
// swagger:parameters getAutomation
type GetAutomationParams struct {
/*Automation ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetAutomationParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetAutomationParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package automations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListAutomationsEndpoint executes the core logic of the related
// route endpoint.
func ListAutomationsEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListAutomationsParams creates a new ListAutomationsParams object
// with the default values initialized.
func NewListAutomationsParams() *ListAutomationsParams {
var ()
return &ListAutomationsParams{}
}
// ListAutomationsParams contains all the bound params for the list automations operation
// typically these are obtained from a http.Request
//
// swagger:parameters listAutomations
type ListAutomationsParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListAutomationsParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package automations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateAutomationEndpoint executes the core logic of the related
// route endpoint.
func UpdateAutomationEndpoint(handler func(ctx context.Context, params *UpdateAutomationParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateAutomationParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateAutomationParams creates a new UpdateAutomationParams object
// with the default values initialized.
func NewUpdateAutomationParams() *UpdateAutomationParams {
var ()
return &UpdateAutomationParams{}
}
// UpdateAutomationParams contains all the bound params for the update automation operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateAutomation
type UpdateAutomationParams struct {
/*Automation object that needs to be added
Required: true
In: body
*/
Automation *models.AutomationForm
/*Automation ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateAutomationParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.AutomationForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("automation", "body", ""))
} else {
res = append(res, errors.NewParseError("automation", "body", "", err))
}
} else {
o.Automation = &body
}
} else {
res = append(res, errors.Required("automation", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateAutomationParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package jobs
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetJobEndpoint executes the core logic of the related
// route endpoint.
func GetJobEndpoint(handler func(ctx context.Context, params *GetJobParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetJobParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetJobParams creates a new GetJobParams object
// with the default values initialized.
func NewGetJobParams() *GetJobParams {
var ()
return &GetJobParams{}
}
// GetJobParams contains all the bound params for the get job operation
// typically these are obtained from a http.Request
//
// swagger:parameters getJob
type GetJobParams struct {
/*Job ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetJobParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetJobParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package jobs
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListJobsEndpoint executes the core logic of the related
// route endpoint.
func ListJobsEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListJobsParams creates a new ListJobsParams object
// with the default values initialized.
func NewListJobsParams() *ListJobsParams {
var ()
return &ListJobsParams{}
}
// ListJobsParams contains all the bound params for the list jobs operation
// typically these are obtained from a http.Request
//
// swagger:parameters listJobs
type ListJobsParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListJobsParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,90 +0,0 @@
package jobs
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RunJobEndpoint executes the core logic of the related
// route endpoint.
func RunJobEndpoint(handler func(ctx context.Context, params *RunJobParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRunJobParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRunJobParams creates a new RunJobParams object
// with the default values initialized.
func NewRunJobParams() *RunJobParams {
var ()
return &RunJobParams{}
}
// RunJobParams contains all the bound params for the run job operation
// typically these are obtained from a http.Request
//
// swagger:parameters runJob
type RunJobParams struct {
/*New job
Required: true
In: body
*/
Job *models.JobForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RunJobParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.JobForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("job", "body", ""))
} else {
res = append(res, errors.NewParseError("job", "body", "", err))
}
} else {
o.Job = &body
}
} else {
res = append(res, errors.Required("job", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package jobs
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateJobEndpoint executes the core logic of the related
// route endpoint.
func UpdateJobEndpoint(handler func(ctx context.Context, params *UpdateJobParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateJobParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateJobParams creates a new UpdateJobParams object
// with the default values initialized.
func NewUpdateJobParams() *UpdateJobParams {
var ()
return &UpdateJobParams{}
}
// UpdateJobParams contains all the bound params for the update job operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateJob
type UpdateJobParams struct {
/*Job ID
Required: true
In: path
*/
ID string
/*Job object that needs to be added
Required: true
In: body
*/
Job *models.Job
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateJobParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.Job
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("job", "body", ""))
} else {
res = append(res, errors.NewParseError("job", "body", "", err))
}
} else {
o.Job = &body
}
} else {
res = append(res, errors.Required("job", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateJobParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package logs
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetLogsEndpoint executes the core logic of the related
// route endpoint.
func GetLogsEndpoint(handler func(ctx context.Context, params *GetLogsParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetLogsParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetLogsParams creates a new GetLogsParams object
// with the default values initialized.
func NewGetLogsParams() *GetLogsParams {
var ()
return &GetLogsParams{}
}
// GetLogsParams contains all the bound params for the get logs operation
// typically these are obtained from a http.Request
//
// swagger:parameters getLogs
type GetLogsParams struct {
/*Reference
Required: true
In: path
*/
Reference string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetLogsParams) ReadRequest(ctx *gin.Context) error {
var res []error
rReference := []string{ctx.Param("reference")}
if err := o.bindReference(rReference, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetLogsParams) bindReference(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Reference = raw
return nil
}
@@ -1,90 +0,0 @@
package playbooks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreatePlaybookEndpoint executes the core logic of the related
// route endpoint.
func CreatePlaybookEndpoint(handler func(ctx context.Context, params *CreatePlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreatePlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreatePlaybookParams creates a new CreatePlaybookParams object
// with the default values initialized.
func NewCreatePlaybookParams() *CreatePlaybookParams {
var ()
return &CreatePlaybookParams{}
}
// CreatePlaybookParams contains all the bound params for the create playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters createPlaybook
type CreatePlaybookParams struct {
/*New playbook
Required: true
In: body
*/
Playbook *models.PlaybookTemplateForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreatePlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.PlaybookTemplateForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("playbook", "body", ""))
} else {
res = append(res, errors.NewParseError("playbook", "body", "", err))
}
} else {
o.Playbook = &body
}
} else {
res = append(res, errors.Required("playbook", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package playbooks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeletePlaybookEndpoint executes the core logic of the related
// route endpoint.
func DeletePlaybookEndpoint(handler func(ctx context.Context, params *DeletePlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeletePlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeletePlaybookParams creates a new DeletePlaybookParams object
// with the default values initialized.
func NewDeletePlaybookParams() *DeletePlaybookParams {
var ()
return &DeletePlaybookParams{}
}
// DeletePlaybookParams contains all the bound params for the delete playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters deletePlaybook
type DeletePlaybookParams struct {
/*Playbook name
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeletePlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeletePlaybookParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package playbooks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetPlaybookEndpoint executes the core logic of the related
// route endpoint.
func GetPlaybookEndpoint(handler func(ctx context.Context, params *GetPlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetPlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetPlaybookParams creates a new GetPlaybookParams object
// with the default values initialized.
func NewGetPlaybookParams() *GetPlaybookParams {
var ()
return &GetPlaybookParams{}
}
// GetPlaybookParams contains all the bound params for the get playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters getPlaybook
type GetPlaybookParams struct {
/*Playbook name
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetPlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetPlaybookParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package playbooks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListPlaybooksEndpoint executes the core logic of the related
// route endpoint.
func ListPlaybooksEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListPlaybooksParams creates a new ListPlaybooksParams object
// with the default values initialized.
func NewListPlaybooksParams() *ListPlaybooksParams {
var ()
return &ListPlaybooksParams{}
}
// ListPlaybooksParams contains all the bound params for the list playbooks operation
// typically these are obtained from a http.Request
//
// swagger:parameters listPlaybooks
type ListPlaybooksParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListPlaybooksParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package playbooks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdatePlaybookEndpoint executes the core logic of the related
// route endpoint.
func UpdatePlaybookEndpoint(handler func(ctx context.Context, params *UpdatePlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdatePlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdatePlaybookParams creates a new UpdatePlaybookParams object
// with the default values initialized.
func NewUpdatePlaybookParams() *UpdatePlaybookParams {
var ()
return &UpdatePlaybookParams{}
}
// UpdatePlaybookParams contains all the bound params for the update playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters updatePlaybook
type UpdatePlaybookParams struct {
/*Playbook ID
Required: true
In: path
*/
ID string
/*Updated playbook
Required: true
In: body
*/
Playbook *models.PlaybookTemplateForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdatePlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.PlaybookTemplateForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("playbook", "body", ""))
} else {
res = append(res, errors.NewParseError("playbook", "body", "", err))
}
} else {
o.Playbook = &body
}
} else {
res = append(res, errors.Required("playbook", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdatePlaybookParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package settings
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetSettingsEndpoint executes the core logic of the related
// route endpoint.
func GetSettingsEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetSettingsParams creates a new GetSettingsParams object
// with the default values initialized.
func NewGetSettingsParams() *GetSettingsParams {
var ()
return &GetSettingsParams{}
}
// GetSettingsParams contains all the bound params for the get settings operation
// typically these are obtained from a http.Request
//
// swagger:parameters getSettings
type GetSettingsParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetSettingsParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,55 +0,0 @@
package statistics
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetStatisticsEndpoint executes the core logic of the related
// route endpoint.
func GetStatisticsEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetStatisticsParams creates a new GetStatisticsParams object
// with the default values initialized.
func NewGetStatisticsParams() *GetStatisticsParams {
var ()
return &GetStatisticsParams{}
}
// GetStatisticsParams contains all the bound params for the get statistics operation
// typically these are obtained from a http.Request
//
// swagger:parameters getStatistics
type GetStatisticsParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetStatisticsParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,55 +0,0 @@
package tasks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListTasksEndpoint executes the core logic of the related
// route endpoint.
func ListTasksEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListTasksParams creates a new ListTasksParams object
// with the default values initialized.
func NewListTasksParams() *ListTasksParams {
var ()
return &ListTasksParams{}
}
// ListTasksParams contains all the bound params for the list tasks operation
// typically these are obtained from a http.Request
//
// swagger:parameters listTasks
type ListTasksParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListTasksParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,90 +0,0 @@
package templates
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateTemplateEndpoint executes the core logic of the related
// route endpoint.
func CreateTemplateEndpoint(handler func(ctx context.Context, params *CreateTemplateParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateTemplateParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateTemplateParams creates a new CreateTemplateParams object
// with the default values initialized.
func NewCreateTemplateParams() *CreateTemplateParams {
var ()
return &CreateTemplateParams{}
}
// CreateTemplateParams contains all the bound params for the create template operation
// typically these are obtained from a http.Request
//
// swagger:parameters createTemplate
type CreateTemplateParams struct {
/*New template
Required: true
In: body
*/
Template *models.TicketTemplateForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateTemplateParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.TicketTemplateForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("template", "body", ""))
} else {
res = append(res, errors.NewParseError("template", "body", "", err))
}
} else {
o.Template = &body
}
} else {
res = append(res, errors.Required("template", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package templates
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeleteTemplateEndpoint executes the core logic of the related
// route endpoint.
func DeleteTemplateEndpoint(handler func(ctx context.Context, params *DeleteTemplateParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeleteTemplateParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeleteTemplateParams creates a new DeleteTemplateParams object
// with the default values initialized.
func NewDeleteTemplateParams() *DeleteTemplateParams {
var ()
return &DeleteTemplateParams{}
}
// DeleteTemplateParams contains all the bound params for the delete template operation
// typically these are obtained from a http.Request
//
// swagger:parameters deleteTemplate
type DeleteTemplateParams struct {
/*Template ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeleteTemplateParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeleteTemplateParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package templates
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetTemplateEndpoint executes the core logic of the related
// route endpoint.
func GetTemplateEndpoint(handler func(ctx context.Context, params *GetTemplateParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetTemplateParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetTemplateParams creates a new GetTemplateParams object
// with the default values initialized.
func NewGetTemplateParams() *GetTemplateParams {
var ()
return &GetTemplateParams{}
}
// GetTemplateParams contains all the bound params for the get template operation
// typically these are obtained from a http.Request
//
// swagger:parameters getTemplate
type GetTemplateParams struct {
/*Template ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetTemplateParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetTemplateParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package templates
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListTemplatesEndpoint executes the core logic of the related
// route endpoint.
func ListTemplatesEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListTemplatesParams creates a new ListTemplatesParams object
// with the default values initialized.
func NewListTemplatesParams() *ListTemplatesParams {
var ()
return &ListTemplatesParams{}
}
// ListTemplatesParams contains all the bound params for the list templates operation
// typically these are obtained from a http.Request
//
// swagger:parameters listTemplates
type ListTemplatesParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListTemplatesParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package templates
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateTemplateEndpoint executes the core logic of the related
// route endpoint.
func UpdateTemplateEndpoint(handler func(ctx context.Context, params *UpdateTemplateParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateTemplateParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateTemplateParams creates a new UpdateTemplateParams object
// with the default values initialized.
func NewUpdateTemplateParams() *UpdateTemplateParams {
var ()
return &UpdateTemplateParams{}
}
// UpdateTemplateParams contains all the bound params for the update template operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateTemplate
type UpdateTemplateParams struct {
/*Template ID
Required: true
In: path
*/
ID string
/*Template object that needs to be added
Required: true
In: body
*/
Template *models.TicketTemplateForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateTemplateParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.TicketTemplateForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("template", "body", ""))
} else {
res = append(res, errors.NewParseError("template", "body", "", err))
}
} else {
o.Template = &body
}
} else {
res = append(res, errors.Required("template", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateTemplateParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// AddArtifactEndpoint executes the core logic of the related
// route endpoint.
func AddArtifactEndpoint(handler func(ctx context.Context, params *AddArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewAddArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewAddArtifactParams creates a new AddArtifactParams object
// with the default values initialized.
func NewAddArtifactParams() *AddArtifactParams {
var ()
return &AddArtifactParams{}
}
// AddArtifactParams contains all the bound params for the add artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters addArtifact
type AddArtifactParams struct {
/*Artifact object that needs to be added
Required: true
In: body
*/
Artifact *models.Artifact
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *AddArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.Artifact
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("artifact", "body", ""))
} else {
res = append(res, errors.NewParseError("artifact", "body", "", err))
}
} else {
o.Artifact = &body
}
} else {
res = append(res, errors.Required("artifact", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *AddArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// AddCommentEndpoint executes the core logic of the related
// route endpoint.
func AddCommentEndpoint(handler func(ctx context.Context, params *AddCommentParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewAddCommentParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewAddCommentParams creates a new AddCommentParams object
// with the default values initialized.
func NewAddCommentParams() *AddCommentParams {
var ()
return &AddCommentParams{}
}
// AddCommentParams contains all the bound params for the add comment operation
// typically these are obtained from a http.Request
//
// swagger:parameters addComment
type AddCommentParams struct {
/*Ticket comment
Required: true
In: body
*/
Comment *models.CommentForm
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *AddCommentParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.CommentForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("comment", "body", ""))
} else {
res = append(res, errors.NewParseError("comment", "body", "", err))
}
} else {
o.Comment = &body
}
} else {
res = append(res, errors.Required("comment", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *AddCommentParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// AddTicketPlaybookEndpoint executes the core logic of the related
// route endpoint.
func AddTicketPlaybookEndpoint(handler func(ctx context.Context, params *AddTicketPlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewAddTicketPlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewAddTicketPlaybookParams creates a new AddTicketPlaybookParams object
// with the default values initialized.
func NewAddTicketPlaybookParams() *AddTicketPlaybookParams {
var ()
return &AddTicketPlaybookParams{}
}
// AddTicketPlaybookParams contains all the bound params for the add ticket playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters addTicketPlaybook
type AddTicketPlaybookParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Ticket playbook object that needs to be added
Required: true
In: body
*/
Playbook *models.PlaybookTemplateForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *AddTicketPlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.PlaybookTemplateForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("playbook", "body", ""))
} else {
res = append(res, errors.NewParseError("playbook", "body", "", err))
}
} else {
o.Playbook = &body
}
} else {
res = append(res, errors.Required("playbook", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *AddTicketPlaybookParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,157 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CompleteTaskEndpoint executes the core logic of the related
// route endpoint.
func CompleteTaskEndpoint(handler func(ctx context.Context, params *CompleteTaskParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCompleteTaskParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCompleteTaskParams creates a new CompleteTaskParams object
// with the default values initialized.
func NewCompleteTaskParams() *CompleteTaskParams {
var ()
return &CompleteTaskParams{}
}
// CompleteTaskParams contains all the bound params for the complete task operation
// typically these are obtained from a http.Request
//
// swagger:parameters completeTask
type CompleteTaskParams struct {
/*Ticket playbook object that needs to be added
Required: true
In: body
*/
Data interface{}
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Playbook ID
Required: true
In: path
*/
PlaybookID string
/*Task ID
Required: true
In: path
*/
TaskID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CompleteTaskParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body interface{}
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("data", "body", ""))
} else {
res = append(res, errors.NewParseError("data", "body", "", err))
}
} else {
o.Data = body
}
} else {
res = append(res, errors.Required("data", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rPlaybookID := []string{ctx.Param("playbookID")}
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
res = append(res, err)
}
rTaskID := []string{ctx.Param("taskID")}
if err := o.bindTaskID(rTaskID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *CompleteTaskParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *CompleteTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.PlaybookID = raw
return nil
}
func (o *CompleteTaskParams) bindTaskID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.TaskID = raw
return nil
}
@@ -1,90 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateTicketBatchEndpoint executes the core logic of the related
// route endpoint.
func CreateTicketBatchEndpoint(handler func(ctx context.Context, params *CreateTicketBatchParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateTicketBatchParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateTicketBatchParams creates a new CreateTicketBatchParams object
// with the default values initialized.
func NewCreateTicketBatchParams() *CreateTicketBatchParams {
var ()
return &CreateTicketBatchParams{}
}
// CreateTicketBatchParams contains all the bound params for the create ticket batch operation
// typically these are obtained from a http.Request
//
// swagger:parameters createTicketBatch
type CreateTicketBatchParams struct {
/*New ticket
Required: true
In: body
*/
Ticket []*models.TicketForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateTicketBatchParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body []*models.TicketForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("ticket", "body", ""))
} else {
res = append(res, errors.NewParseError("ticket", "body", "", err))
}
} else {
o.Ticket = body
}
} else {
res = append(res, errors.Required("ticket", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,90 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateTicketEndpoint executes the core logic of the related
// route endpoint.
func CreateTicketEndpoint(handler func(ctx context.Context, params *CreateTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateTicketParams creates a new CreateTicketParams object
// with the default values initialized.
func NewCreateTicketParams() *CreateTicketParams {
var ()
return &CreateTicketParams{}
}
// CreateTicketParams contains all the bound params for the create ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters createTicket
type CreateTicketParams struct {
/*New ticket
Required: true
In: body
*/
Ticket *models.TicketForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.TicketForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("ticket", "body", ""))
} else {
res = append(res, errors.NewParseError("ticket", "body", "", err))
}
} else {
o.Ticket = &body
}
} else {
res = append(res, errors.Required("ticket", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,92 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeleteTicketEndpoint executes the core logic of the related
// route endpoint.
func DeleteTicketEndpoint(handler func(ctx context.Context, params *DeleteTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeleteTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeleteTicketParams creates a new DeleteTicketParams object
// with the default values initialized.
func NewDeleteTicketParams() *DeleteTicketParams {
var ()
return &DeleteTicketParams{}
}
// DeleteTicketParams contains all the bound params for the delete ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters deleteTicket
type DeleteTicketParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeleteTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeleteTicketParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,137 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// EnrichArtifactEndpoint executes the core logic of the related
// route endpoint.
func EnrichArtifactEndpoint(handler func(ctx context.Context, params *EnrichArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewEnrichArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewEnrichArtifactParams creates a new EnrichArtifactParams object
// with the default values initialized.
func NewEnrichArtifactParams() *EnrichArtifactParams {
var ()
return &EnrichArtifactParams{}
}
// EnrichArtifactParams contains all the bound params for the enrich artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters enrichArtifact
type EnrichArtifactParams struct {
/*
Required: true
In: body
*/
Data *models.EnrichmentForm
/*Ticket ID
Required: true
In: path
*/
ID int64
/*
Required: true
In: path
*/
Name string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *EnrichArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.EnrichmentForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("data", "body", ""))
} else {
res = append(res, errors.NewParseError("data", "body", "", err))
}
} else {
o.Data = &body
}
} else {
res = append(res, errors.Required("data", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rName := []string{ctx.Param("name")}
if err := o.bindName(rName, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *EnrichArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *EnrichArtifactParams) bindName(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Name = raw
return nil
}
@@ -1,113 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetArtifactEndpoint executes the core logic of the related
// route endpoint.
func GetArtifactEndpoint(handler func(ctx context.Context, params *GetArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetArtifactParams creates a new GetArtifactParams object
// with the default values initialized.
func NewGetArtifactParams() *GetArtifactParams {
var ()
return &GetArtifactParams{}
}
// GetArtifactParams contains all the bound params for the get artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters getArtifact
type GetArtifactParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*
Required: true
In: path
*/
Name string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rName := []string{ctx.Param("name")}
if err := o.bindName(rName, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *GetArtifactParams) bindName(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Name = raw
return nil
}
@@ -1,92 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetTicketEndpoint executes the core logic of the related
// route endpoint.
func GetTicketEndpoint(handler func(ctx context.Context, params *GetTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetTicketParams creates a new GetTicketParams object
// with the default values initialized.
func NewGetTicketParams() *GetTicketParams {
var ()
return &GetTicketParams{}
}
// GetTicketParams contains all the bound params for the get ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters getTicket
type GetTicketParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetTicketParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// LinkFilesEndpoint executes the core logic of the related
// route endpoint.
func LinkFilesEndpoint(handler func(ctx context.Context, params *LinkFilesParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewLinkFilesParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewLinkFilesParams creates a new LinkFilesParams object
// with the default values initialized.
func NewLinkFilesParams() *LinkFilesParams {
var ()
return &LinkFilesParams{}
}
// LinkFilesParams contains all the bound params for the link files operation
// typically these are obtained from a http.Request
//
// swagger:parameters linkFiles
type LinkFilesParams struct {
/*Added files
Required: true
In: body
*/
Files []*models.File
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *LinkFilesParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body []*models.File
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("files", "body", ""))
} else {
res = append(res, errors.NewParseError("files", "body", "", err))
}
} else {
o.Files = body
}
} else {
res = append(res, errors.Required("files", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *LinkFilesParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,115 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// LinkTicketEndpoint executes the core logic of the related
// route endpoint.
func LinkTicketEndpoint(handler func(ctx context.Context, params *LinkTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewLinkTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewLinkTicketParams creates a new LinkTicketParams object
// with the default values initialized.
func NewLinkTicketParams() *LinkTicketParams {
var ()
return &LinkTicketParams{}
}
// LinkTicketParams contains all the bound params for the link ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters linkTicket
type LinkTicketParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Added ticket ID
Required: true
In: body
*/
LinkedID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *LinkTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body int64
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("linkedId", "body", ""))
} else {
res = append(res, errors.NewParseError("linkedId", "body", "", err))
}
} else {
o.LinkedID = body
}
} else {
res = append(res, errors.Required("linkedId", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *LinkTicketParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,269 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListTicketsEndpoint executes the core logic of the related
// route endpoint.
func ListTicketsEndpoint(handler func(ctx context.Context, params *ListTicketsParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewListTicketsParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListTicketsParams creates a new ListTicketsParams object
// with the default values initialized.
func NewListTicketsParams() *ListTicketsParams {
var (
countDefault = int64(25)
offsetDefault = int64(0)
)
return &ListTicketsParams{
Count: &countDefault,
Offset: &offsetDefault,
}
}
// ListTicketsParams contains all the bound params for the list tickets operation
// typically these are obtained from a http.Request
//
// swagger:parameters listTickets
type ListTicketsParams struct {
/*Number of tickets
Maximum: 100
In: query
Default: 25
*/
Count *int64
/*Sort descending
In: query
*/
Desc []bool
/*Offset of the list
In: query
Default: 0
*/
Offset *int64
/*Search query
In: query
*/
Query *string
/*Sort columns
In: query
*/
Sort []string
/*Ticket Type
In: query
*/
Type *string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListTicketsParams) ReadRequest(ctx *gin.Context) error {
var res []error
qs := runtime.Values(ctx.Request.URL.Query())
qCount, qhkCount, _ := qs.GetOK("count")
if err := o.bindCount(qCount, qhkCount); err != nil {
res = append(res, err)
}
qDesc, qhkDesc, _ := qs.GetOK("desc")
if err := o.bindDesc(qDesc, qhkDesc); err != nil {
res = append(res, err)
}
qOffset, qhkOffset, _ := qs.GetOK("offset")
if err := o.bindOffset(qOffset, qhkOffset); err != nil {
res = append(res, err)
}
qQuery, qhkQuery, _ := qs.GetOK("query")
if err := o.bindQuery(qQuery, qhkQuery); err != nil {
res = append(res, err)
}
qSort, qhkSort, _ := qs.GetOK("sort")
if err := o.bindSort(qSort, qhkSort); err != nil {
res = append(res, err)
}
qType, qhkType, _ := qs.GetOK("type")
if err := o.bindType(qType, qhkType); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *ListTicketsParams) bindCount(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
if raw == "" { // empty values pass all other validations
var countDefault int64 = int64(25)
o.Count = &countDefault
return nil
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("count", "query", "int64", raw)
}
o.Count = &value
if err := o.validateCount(); err != nil {
return err
}
return nil
}
func (o *ListTicketsParams) validateCount() error {
if err := validate.MaximumInt("count", "query", int64(*o.Count), 100, false); err != nil {
return err
}
return nil
}
func (o *ListTicketsParams) bindDesc(rawData []string, hasKey bool) error {
var qvDesc string
if len(rawData) > 0 {
qvDesc = rawData[len(rawData)-1]
}
descIC := swag.SplitByFormat(qvDesc, "")
if len(descIC) == 0 {
return nil
}
var descIR []bool
for i, descIV := range descIC {
descI, err := swag.ConvertBool(descIV)
if err != nil {
return errors.InvalidType(fmt.Sprintf("%s.%v", "desc", i), "query", "bool", descI)
}
descIR = append(descIR, descI)
}
o.Desc = descIR
return nil
}
func (o *ListTicketsParams) bindOffset(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
if raw == "" { // empty values pass all other validations
var offsetDefault int64 = int64(0)
o.Offset = &offsetDefault
return nil
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("offset", "query", "int64", raw)
}
o.Offset = &value
return nil
}
func (o *ListTicketsParams) bindQuery(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
if raw == "" { // empty values pass all other validations
return nil
}
o.Query = &raw
return nil
}
func (o *ListTicketsParams) bindSort(rawData []string, hasKey bool) error {
var qvSort string
if len(rawData) > 0 {
qvSort = rawData[len(rawData)-1]
}
sortIC := swag.SplitByFormat(qvSort, "")
if len(sortIC) == 0 {
return nil
}
var sortIR []string
for _, sortIV := range sortIC {
sortI := sortIV
sortIR = append(sortIR, sortI)
}
o.Sort = sortIR
return nil
}
func (o *ListTicketsParams) bindType(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
if raw == "" { // empty values pass all other validations
return nil
}
o.Type = &raw
return nil
}
@@ -1,113 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RemoveArtifactEndpoint executes the core logic of the related
// route endpoint.
func RemoveArtifactEndpoint(handler func(ctx context.Context, params *RemoveArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRemoveArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRemoveArtifactParams creates a new RemoveArtifactParams object
// with the default values initialized.
func NewRemoveArtifactParams() *RemoveArtifactParams {
var ()
return &RemoveArtifactParams{}
}
// RemoveArtifactParams contains all the bound params for the remove artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters removeArtifact
type RemoveArtifactParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*
Required: true
In: path
*/
Name string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RemoveArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rName := []string{ctx.Param("name")}
if err := o.bindName(rName, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *RemoveArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *RemoveArtifactParams) bindName(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Name = raw
return nil
}
@@ -1,117 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RemoveCommentEndpoint executes the core logic of the related
// route endpoint.
func RemoveCommentEndpoint(handler func(ctx context.Context, params *RemoveCommentParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRemoveCommentParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRemoveCommentParams creates a new RemoveCommentParams object
// with the default values initialized.
func NewRemoveCommentParams() *RemoveCommentParams {
var ()
return &RemoveCommentParams{}
}
// RemoveCommentParams contains all the bound params for the remove comment operation
// typically these are obtained from a http.Request
//
// swagger:parameters removeComment
type RemoveCommentParams struct {
/*Comment ID to remove
Required: true
In: path
*/
CommentID int64
/*Ticket ID
Required: true
In: path
*/
ID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RemoveCommentParams) ReadRequest(ctx *gin.Context) error {
var res []error
rCommentID := []string{ctx.Param("commentID")}
if err := o.bindCommentID(rCommentID, true); err != nil {
res = append(res, err)
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *RemoveCommentParams) bindCommentID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("commentID", "path", "int64", raw)
}
o.CommentID = value
return nil
}
func (o *RemoveCommentParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,113 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RemoveTicketPlaybookEndpoint executes the core logic of the related
// route endpoint.
func RemoveTicketPlaybookEndpoint(handler func(ctx context.Context, params *RemoveTicketPlaybookParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRemoveTicketPlaybookParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRemoveTicketPlaybookParams creates a new RemoveTicketPlaybookParams object
// with the default values initialized.
func NewRemoveTicketPlaybookParams() *RemoveTicketPlaybookParams {
var ()
return &RemoveTicketPlaybookParams{}
}
// RemoveTicketPlaybookParams contains all the bound params for the remove ticket playbook operation
// typically these are obtained from a http.Request
//
// swagger:parameters removeTicketPlaybook
type RemoveTicketPlaybookParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Playbook ID
Required: true
In: path
*/
PlaybookID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RemoveTicketPlaybookParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rPlaybookID := []string{ctx.Param("playbookID")}
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *RemoveTicketPlaybookParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *RemoveTicketPlaybookParams) bindPlaybookID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.PlaybookID = raw
return nil
}
@@ -1,134 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RunArtifactEndpoint executes the core logic of the related
// route endpoint.
func RunArtifactEndpoint(handler func(ctx context.Context, params *RunArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRunArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRunArtifactParams creates a new RunArtifactParams object
// with the default values initialized.
func NewRunArtifactParams() *RunArtifactParams {
var ()
return &RunArtifactParams{}
}
// RunArtifactParams contains all the bound params for the run artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters runArtifact
type RunArtifactParams struct {
/*
Required: true
In: path
*/
Automation string
/*Ticket ID
Required: true
In: path
*/
ID int64
/*
Required: true
In: path
*/
Name string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RunArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
rAutomation := []string{ctx.Param("automation")}
if err := o.bindAutomation(rAutomation, true); err != nil {
res = append(res, err)
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rName := []string{ctx.Param("name")}
if err := o.bindName(rName, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *RunArtifactParams) bindAutomation(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Automation = raw
return nil
}
func (o *RunArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *RunArtifactParams) bindName(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Name = raw
return nil
}
@@ -1,134 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// RunTaskEndpoint executes the core logic of the related
// route endpoint.
func RunTaskEndpoint(handler func(ctx context.Context, params *RunTaskParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewRunTaskParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewRunTaskParams creates a new RunTaskParams object
// with the default values initialized.
func NewRunTaskParams() *RunTaskParams {
var ()
return &RunTaskParams{}
}
// RunTaskParams contains all the bound params for the run task operation
// typically these are obtained from a http.Request
//
// swagger:parameters runTask
type RunTaskParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Playbook ID
Required: true
In: path
*/
PlaybookID string
/*Task ID
Required: true
In: path
*/
TaskID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *RunTaskParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rPlaybookID := []string{ctx.Param("playbookID")}
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
res = append(res, err)
}
rTaskID := []string{ctx.Param("taskID")}
if err := o.bindTaskID(rTaskID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *RunTaskParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *RunTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.PlaybookID = raw
return nil
}
func (o *RunTaskParams) bindTaskID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.TaskID = raw
return nil
}
@@ -1,137 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// SetArtifactEndpoint executes the core logic of the related
// route endpoint.
func SetArtifactEndpoint(handler func(ctx context.Context, params *SetArtifactParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewSetArtifactParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewSetArtifactParams creates a new SetArtifactParams object
// with the default values initialized.
func NewSetArtifactParams() *SetArtifactParams {
var ()
return &SetArtifactParams{}
}
// SetArtifactParams contains all the bound params for the set artifact operation
// typically these are obtained from a http.Request
//
// swagger:parameters setArtifact
type SetArtifactParams struct {
/*
Required: true
In: body
*/
Artifact *models.Artifact
/*Ticket ID
Required: true
In: path
*/
ID int64
/*
Required: true
In: path
*/
Name string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *SetArtifactParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.Artifact
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("artifact", "body", ""))
} else {
res = append(res, errors.NewParseError("artifact", "body", "", err))
}
} else {
o.Artifact = &body
}
} else {
res = append(res, errors.Required("artifact", "body", ""))
}
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rName := []string{ctx.Param("name")}
if err := o.bindName(rName, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *SetArtifactParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *SetArtifactParams) bindName(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.Name = raw
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// SetReferencesEndpoint executes the core logic of the related
// route endpoint.
func SetReferencesEndpoint(handler func(ctx context.Context, params *SetReferencesParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewSetReferencesParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewSetReferencesParams creates a new SetReferencesParams object
// with the default values initialized.
func NewSetReferencesParams() *SetReferencesParams {
var ()
return &SetReferencesParams{}
}
// SetReferencesParams contains all the bound params for the set references operation
// typically these are obtained from a http.Request
//
// swagger:parameters setReferences
type SetReferencesParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*All ticket references
Required: true
In: body
*/
References []*models.Reference
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *SetReferencesParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body []*models.Reference
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("references", "body", ""))
} else {
res = append(res, errors.NewParseError("references", "body", "", err))
}
} else {
o.References = body
}
} else {
res = append(res, errors.Required("references", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *SetReferencesParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,106 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// SetSchemaEndpoint executes the core logic of the related
// route endpoint.
func SetSchemaEndpoint(handler func(ctx context.Context, params *SetSchemaParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewSetSchemaParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewSetSchemaParams creates a new SetSchemaParams object
// with the default values initialized.
func NewSetSchemaParams() *SetSchemaParams {
var ()
return &SetSchemaParams{}
}
// SetSchemaParams contains all the bound params for the set schema operation
// typically these are obtained from a http.Request
//
// swagger:parameters setSchema
type SetSchemaParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*New ticket schema
In: body
*/
Schema string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *SetSchemaParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body string
if err := ctx.BindJSON(&body); err != nil {
res = append(res, errors.NewParseError("schema", "body", "", err))
} else {
o.Schema = body
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *SetSchemaParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,158 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// SetTaskEndpoint executes the core logic of the related
// route endpoint.
func SetTaskEndpoint(handler func(ctx context.Context, params *SetTaskParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewSetTaskParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewSetTaskParams creates a new SetTaskParams object
// with the default values initialized.
func NewSetTaskParams() *SetTaskParams {
var ()
return &SetTaskParams{}
}
// SetTaskParams contains all the bound params for the set task operation
// typically these are obtained from a http.Request
//
// swagger:parameters setTask
type SetTaskParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Playbook ID
Required: true
In: path
*/
PlaybookID string
/*Task
Required: true
In: body
*/
Task *models.Task
/*Task ID
Required: true
In: path
*/
TaskID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *SetTaskParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
rPlaybookID := []string{ctx.Param("playbookID")}
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.Task
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("task", "body", ""))
} else {
res = append(res, errors.NewParseError("task", "body", "", err))
}
} else {
o.Task = &body
}
} else {
res = append(res, errors.Required("task", "body", ""))
}
rTaskID := []string{ctx.Param("taskID")}
if err := o.bindTaskID(rTaskID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *SetTaskParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
func (o *SetTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.PlaybookID = raw
return nil
}
func (o *SetTaskParams) bindTaskID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.TaskID = raw
return nil
}
@@ -1,115 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UnlinkTicketEndpoint executes the core logic of the related
// route endpoint.
func UnlinkTicketEndpoint(handler func(ctx context.Context, params *UnlinkTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUnlinkTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUnlinkTicketParams creates a new UnlinkTicketParams object
// with the default values initialized.
func NewUnlinkTicketParams() *UnlinkTicketParams {
var ()
return &UnlinkTicketParams{}
}
// UnlinkTicketParams contains all the bound params for the unlink ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters unlinkTicket
type UnlinkTicketParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Added ticket ID
Required: true
In: body
*/
LinkedID int64
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UnlinkTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body int64
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("linkedId", "body", ""))
} else {
res = append(res, errors.NewParseError("linkedId", "body", "", err))
}
} else {
o.LinkedID = body
}
} else {
res = append(res, errors.Required("linkedId", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UnlinkTicketParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,116 +0,0 @@
package tickets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/swag"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateTicketEndpoint executes the core logic of the related
// route endpoint.
func UpdateTicketEndpoint(handler func(ctx context.Context, params *UpdateTicketParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateTicketParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateTicketParams creates a new UpdateTicketParams object
// with the default values initialized.
func NewUpdateTicketParams() *UpdateTicketParams {
var ()
return &UpdateTicketParams{}
}
// UpdateTicketParams contains all the bound params for the update ticket operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateTicket
type UpdateTicketParams struct {
/*Ticket ID
Required: true
In: path
*/
ID int64
/*Updated ticket
Required: true
In: body
*/
Ticket *models.Ticket
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateTicketParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.Ticket
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("ticket", "body", ""))
} else {
res = append(res, errors.NewParseError("ticket", "body", "", err))
}
} else {
o.Ticket = &body
}
} else {
res = append(res, errors.Required("ticket", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateTicketParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
value, err := swag.ConvertInt64(raw)
if err != nil {
return errors.InvalidType("id", "path", "int64", raw)
}
o.ID = value
return nil
}
@@ -1,90 +0,0 @@
package tickettypes
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateTicketTypeEndpoint executes the core logic of the related
// route endpoint.
func CreateTicketTypeEndpoint(handler func(ctx context.Context, params *CreateTicketTypeParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateTicketTypeParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateTicketTypeParams creates a new CreateTicketTypeParams object
// with the default values initialized.
func NewCreateTicketTypeParams() *CreateTicketTypeParams {
var ()
return &CreateTicketTypeParams{}
}
// CreateTicketTypeParams contains all the bound params for the create ticket type operation
// typically these are obtained from a http.Request
//
// swagger:parameters createTicketType
type CreateTicketTypeParams struct {
/*New tickettype
Required: true
In: body
*/
Tickettype *models.TicketTypeForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateTicketTypeParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.TicketTypeForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("tickettype", "body", ""))
} else {
res = append(res, errors.NewParseError("tickettype", "body", "", err))
}
} else {
o.Tickettype = &body
}
} else {
res = append(res, errors.Required("tickettype", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package tickettypes
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeleteTicketTypeEndpoint executes the core logic of the related
// route endpoint.
func DeleteTicketTypeEndpoint(handler func(ctx context.Context, params *DeleteTicketTypeParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeleteTicketTypeParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeleteTicketTypeParams creates a new DeleteTicketTypeParams object
// with the default values initialized.
func NewDeleteTicketTypeParams() *DeleteTicketTypeParams {
var ()
return &DeleteTicketTypeParams{}
}
// DeleteTicketTypeParams contains all the bound params for the delete ticket type operation
// typically these are obtained from a http.Request
//
// swagger:parameters deleteTicketType
type DeleteTicketTypeParams struct {
/*TicketType ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeleteTicketTypeParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeleteTicketTypeParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package tickettypes
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetTicketTypeEndpoint executes the core logic of the related
// route endpoint.
func GetTicketTypeEndpoint(handler func(ctx context.Context, params *GetTicketTypeParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetTicketTypeParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetTicketTypeParams creates a new GetTicketTypeParams object
// with the default values initialized.
func NewGetTicketTypeParams() *GetTicketTypeParams {
var ()
return &GetTicketTypeParams{}
}
// GetTicketTypeParams contains all the bound params for the get ticket type operation
// typically these are obtained from a http.Request
//
// swagger:parameters getTicketType
type GetTicketTypeParams struct {
/*TicketType ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetTicketTypeParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetTicketTypeParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package tickettypes
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListTicketTypesEndpoint executes the core logic of the related
// route endpoint.
func ListTicketTypesEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListTicketTypesParams creates a new ListTicketTypesParams object
// with the default values initialized.
func NewListTicketTypesParams() *ListTicketTypesParams {
var ()
return &ListTicketTypesParams{}
}
// ListTicketTypesParams contains all the bound params for the list ticket types operation
// typically these are obtained from a http.Request
//
// swagger:parameters listTicketTypes
type ListTicketTypesParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListTicketTypesParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package tickettypes
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateTicketTypeEndpoint executes the core logic of the related
// route endpoint.
func UpdateTicketTypeEndpoint(handler func(ctx context.Context, params *UpdateTicketTypeParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateTicketTypeParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateTicketTypeParams creates a new UpdateTicketTypeParams object
// with the default values initialized.
func NewUpdateTicketTypeParams() *UpdateTicketTypeParams {
var ()
return &UpdateTicketTypeParams{}
}
// UpdateTicketTypeParams contains all the bound params for the update ticket type operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateTicketType
type UpdateTicketTypeParams struct {
/*TicketType ID
Required: true
In: path
*/
ID string
/*TicketType object that needs to be added
Required: true
In: body
*/
Tickettype *models.TicketTypeForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateTicketTypeParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.TicketTypeForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("tickettype", "body", ""))
} else {
res = append(res, errors.NewParseError("tickettype", "body", "", err))
}
} else {
o.Tickettype = &body
}
} else {
res = append(res, errors.Required("tickettype", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateTicketTypeParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package userdata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CurrentUserDataEndpoint executes the core logic of the related
// route endpoint.
func CurrentUserDataEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCurrentUserDataParams creates a new CurrentUserDataParams object
// with the default values initialized.
func NewCurrentUserDataParams() *CurrentUserDataParams {
var ()
return &CurrentUserDataParams{}
}
// CurrentUserDataParams contains all the bound params for the current user data operation
// typically these are obtained from a http.Request
//
// swagger:parameters currentUserData
type CurrentUserDataParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CurrentUserDataParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package userdata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetUserDataEndpoint executes the core logic of the related
// route endpoint.
func GetUserDataEndpoint(handler func(ctx context.Context, params *GetUserDataParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetUserDataParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetUserDataParams creates a new GetUserDataParams object
// with the default values initialized.
func NewGetUserDataParams() *GetUserDataParams {
var ()
return &GetUserDataParams{}
}
// GetUserDataParams contains all the bound params for the get user data operation
// typically these are obtained from a http.Request
//
// swagger:parameters getUserData
type GetUserDataParams struct {
/*User Data ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetUserDataParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetUserDataParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package userdata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListUserDataEndpoint executes the core logic of the related
// route endpoint.
func ListUserDataEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListUserDataParams creates a new ListUserDataParams object
// with the default values initialized.
func NewListUserDataParams() *ListUserDataParams {
var ()
return &ListUserDataParams{}
}
// ListUserDataParams contains all the bound params for the list user data operation
// typically these are obtained from a http.Request
//
// swagger:parameters listUserData
type ListUserDataParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListUserDataParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,90 +0,0 @@
package userdata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateCurrentUserDataEndpoint executes the core logic of the related
// route endpoint.
func UpdateCurrentUserDataEndpoint(handler func(ctx context.Context, params *UpdateCurrentUserDataParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateCurrentUserDataParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateCurrentUserDataParams creates a new UpdateCurrentUserDataParams object
// with the default values initialized.
func NewUpdateCurrentUserDataParams() *UpdateCurrentUserDataParams {
var ()
return &UpdateCurrentUserDataParams{}
}
// UpdateCurrentUserDataParams contains all the bound params for the update current user data operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateCurrentUserData
type UpdateCurrentUserDataParams struct {
/*User data object that needs to be added
Required: true
In: body
*/
Userdata *models.UserData
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateCurrentUserDataParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.UserData
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("userdata", "body", ""))
} else {
res = append(res, errors.NewParseError("userdata", "body", "", err))
}
} else {
o.Userdata = &body
}
} else {
res = append(res, errors.Required("userdata", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package userdata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateUserDataEndpoint executes the core logic of the related
// route endpoint.
func UpdateUserDataEndpoint(handler func(ctx context.Context, params *UpdateUserDataParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateUserDataParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateUserDataParams creates a new UpdateUserDataParams object
// with the default values initialized.
func NewUpdateUserDataParams() *UpdateUserDataParams {
var ()
return &UpdateUserDataParams{}
}
// UpdateUserDataParams contains all the bound params for the update user data operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateUserData
type UpdateUserDataParams struct {
/*User Data ID
Required: true
In: path
*/
ID string
/*User data object that needs to be added
Required: true
In: body
*/
Userdata *models.UserData
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateUserDataParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.UserData
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("userdata", "body", ""))
} else {
res = append(res, errors.NewParseError("userdata", "body", "", err))
}
} else {
o.Userdata = &body
}
} else {
res = append(res, errors.Required("userdata", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateUserDataParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,90 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CreateUserEndpoint executes the core logic of the related
// route endpoint.
func CreateUserEndpoint(handler func(ctx context.Context, params *CreateUserParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewCreateUserParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCreateUserParams creates a new CreateUserParams object
// with the default values initialized.
func NewCreateUserParams() *CreateUserParams {
var ()
return &CreateUserParams{}
}
// CreateUserParams contains all the bound params for the create user operation
// typically these are obtained from a http.Request
//
// swagger:parameters createUser
type CreateUserParams struct {
/*user object that needs to be added
Required: true
In: body
*/
User *models.UserForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CreateUserParams) ReadRequest(ctx *gin.Context) error {
var res []error
if runtime.HasBody(ctx.Request) {
var body models.UserForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("user", "body", ""))
} else {
res = append(res, errors.NewParseError("user", "body", "", err))
}
} else {
o.User = &body
}
} else {
res = append(res, errors.Required("user", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,55 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// CurrentUserEndpoint executes the core logic of the related
// route endpoint.
func CurrentUserEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewCurrentUserParams creates a new CurrentUserParams object
// with the default values initialized.
func NewCurrentUserParams() *CurrentUserParams {
var ()
return &CurrentUserParams{}
}
// CurrentUserParams contains all the bound params for the current user operation
// typically these are obtained from a http.Request
//
// swagger:parameters currentUser
type CurrentUserParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *CurrentUserParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,87 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// DeleteUserEndpoint executes the core logic of the related
// route endpoint.
func DeleteUserEndpoint(handler func(ctx context.Context, params *DeleteUserParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewDeleteUserParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewDeleteUserParams creates a new DeleteUserParams object
// with the default values initialized.
func NewDeleteUserParams() *DeleteUserParams {
var ()
return &DeleteUserParams{}
}
// DeleteUserParams contains all the bound params for the delete user operation
// typically these are obtained from a http.Request
//
// swagger:parameters deleteUser
type DeleteUserParams struct {
/*user ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *DeleteUserParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *DeleteUserParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,87 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// GetUserEndpoint executes the core logic of the related
// route endpoint.
func GetUserEndpoint(handler func(ctx context.Context, params *GetUserParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewGetUserParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewGetUserParams creates a new GetUserParams object
// with the default values initialized.
func NewGetUserParams() *GetUserParams {
var ()
return &GetUserParams{}
}
// GetUserParams contains all the bound params for the get user operation
// typically these are obtained from a http.Request
//
// swagger:parameters getUser
type GetUserParams struct {
/*user ID
Required: true
In: path
*/
ID string
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *GetUserParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetUserParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
@@ -1,55 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// ListUsersEndpoint executes the core logic of the related
// route endpoint.
func ListUsersEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
resp := handler(ctx)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewListUsersParams creates a new ListUsersParams object
// with the default values initialized.
func NewListUsersParams() *ListUsersParams {
var ()
return &ListUsersParams{}
}
// ListUsersParams contains all the bound params for the list users operation
// typically these are obtained from a http.Request
//
// swagger:parameters listUsers
type ListUsersParams struct {
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *ListUsersParams) ReadRequest(ctx *gin.Context) error {
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
@@ -1,111 +0,0 @@
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/SecurityBrewery/catalyst/generated/models"
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
)
// UpdateUserEndpoint executes the core logic of the related
// route endpoint.
func UpdateUserEndpoint(handler func(ctx context.Context, params *UpdateUserParams) *api.Response) gin.HandlerFunc {
return func(ctx *gin.Context) {
// generate params from request
params := NewUpdateUserParams()
err := params.ReadRequest(ctx)
if err != nil {
errObj := err.(*errors.CompositeError)
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
return
}
resp := handler(ctx, params)
switch resp.Code {
case http.StatusNoContent:
ctx.AbortWithStatus(resp.Code)
default:
ctx.JSON(resp.Code, resp.Body)
}
}
}
// NewUpdateUserParams creates a new UpdateUserParams object
// with the default values initialized.
func NewUpdateUserParams() *UpdateUserParams {
var ()
return &UpdateUserParams{}
}
// UpdateUserParams contains all the bound params for the update user operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateUser
type UpdateUserParams struct {
/*Template ID
Required: true
In: path
*/
ID string
/*user object that needs to be added
Required: true
In: body
*/
User *models.UserForm
}
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdateUserParams) ReadRequest(ctx *gin.Context) error {
var res []error
rID := []string{ctx.Param("id")}
if err := o.bindID(rID, true); err != nil {
res = append(res, err)
}
if runtime.HasBody(ctx.Request) {
var body models.UserForm
if err := ctx.BindJSON(&body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("user", "body", ""))
} else {
res = append(res, errors.NewParseError("user", "body", "", err))
}
} else {
o.User = &body
}
} else {
res = append(res, errors.Required("user", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *UpdateUserParams) bindID(rawData []string, hasKey bool) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}
-638
View File
@@ -1,638 +0,0 @@
package test
import (
"bytes"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
"github.com/SecurityBrewery/catalyst/database/busdb"
"github.com/SecurityBrewery/catalyst/test"
ctime "github.com/SecurityBrewery/catalyst/time"
)
type testClock struct{}
func (testClock) Now() time.Time {
return time.Date(2021, 12, 12, 12, 12, 12, 12, time.UTC)
}
func TestService(t *testing.T) {
gin.SetMode(gin.TestMode)
ctime.DefaultClock = testClock{}
type args struct {
method string
url string
data interface{}
}
type want struct {
status int
body interface{}
}
tests := []struct {
name string
args args
want want
}{
{
name: "AddArtifact",
args: args{method: "POST", url: "/api/tickets/8123/artifacts", data: map[string]interface{}{"name": "2.2.2.2"}},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}, map[string]interface{}{"name": "2.2.2.2", "status": "unknown", "type": "ip"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\"\Line truncated
},
},
{
name: "AddComment",
args: args{method: "POST", url: "/api/tickets/8125/comments", data: map[string]interface{}{"message": "My first comment"}},
want: want{
status: 200,
body: map[string]interface{}{"comments": []interface{}{map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "creator": "bob", "message": "My first comment"}}, "created": "2021-10-02T16:04:59.078186Z", "id": 8125, "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "AddTicketPlaybook",
args: args{method: "POST", url: "/api/tickets/8125/playbooks", data: map[string]interface{}{"yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8125, "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "playbooks": map[string]interface{}{"simple": map[string]interface{}{"name": "Simple", "tasks": map[string]interface{}{"escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to malware team", "order": 2, "type": "task"}, "hash": map[string]interface{}{"active": false, "automation": "hash.sha1", "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Hash the malware", "next": map[string]interface{}{"escalate": ""}, "order": 1, "payload": map[string]interface{}{"default": "playbook.tasks['input'].data['malware']"}, "type": "automation"}, "input": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Upload malware if possible", "next": map[string]interface{}{"hash": "malware != ''"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"malware": map[string]interface{}{"default": "", "title": "Select malware", "type": "string"}}, "title": "Malware", "type": "object"}, "type": "input"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "CompleteTask",
args: args{method: "PUT", url: "/api/tickets/8123/playbooks/phishing/task/board/complete", data: map[string]interface{}{"boardInvolved": true}},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": false, "closed": "2021-12-12T12:12:12.000000012Z", "created": "2021-12-12T12:12:12.000000012Z", "data": map[string]interface{}{"boardInvolved": true}, "done": true, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\Line truncated
},
},
{
name: "CreateAutomation",
args: args{method: "POST", url: "/api/automations", data: map[string]interface{}{"id": "hash-sha-256", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha256 = hashlib.sha256(msg['payload']['default'].encode('utf-8'))\n return {'hash': sha256.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global"}}},
want: want{
status: 200,
body: map[string]interface{}{"id": "hash-sha-256", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha256 = hashlib.sha256(msg['payload']['default'].encode('utf-8'))\n return {'hash': sha256.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global"}},
},
},
{
name: "CreatePlaybook",
args: args{method: "POST", url: "/api/playbooks", data: map[string]interface{}{"yaml": "name: Simple2\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
want: want{
status: 200,
body: map[string]interface{}{"id": "simple-2", "name": "Simple2", "yaml": "name: Simple2\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"},
},
},
{
name: "CreateTemplate",
args: args{method: "POST", url: "/api/templates", data: map[string]interface{}{"name": "My Template", "schema": "{\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"}},
want: want{
status: 200,
body: map[string]interface{}{"id": "my-template", "name": "My Template", "schema": "{\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"},
},
},
{
name: "CreateTicket",
args: args{method: "POST", url: "/api/tickets", data: map[string]interface{}{"id": 123, "name": "Wannacry infection", "owner": "bob", "status": "open", "type": "incident"}},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "id": 123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "Wannacry infection", "owner": "bob", "schema": "{}", "status": "open", "type": "incident"},
},
},
{
name: "CreateTicketBatch",
args: args{method: "POST", url: "/api/tickets/batch", data: []interface{}{map[string]interface{}{"id": 123, "name": "Wannacry infection", "owner": "bob", "status": "open", "type": "incident"}}},
want: want{
status: 204,
body: nil,
},
},
{
name: "CreateTicketType",
args: args{method: "POST", url: "/api/tickettypes", data: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-newspaper-variant-outline", "name": "TI Tickets"}},
want: want{
status: 200,
body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-newspaper-variant-outline", "id": "ti-tickets", "name": "TI Tickets"},
},
},
{
name: "CreateUser",
args: args{method: "POST", url: "/api/users", data: map[string]interface{}{"id": "syncscript", "roles": []interface{}{"analyst"}}},
want: want{
status: 200,
body: map[string]interface{}{"blocked": false, "id": "syncscript", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read"}, "secret": "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"},
},
},
{
name: "CurrentUser",
args: args{method: "GET", url: "/api/currentuser"},
want: want{
status: 200,
body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
name: "CurrentUserData",
args: args{method: "GET", url: "/api/currentuserdata"},
want: want{
status: 200,
body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
name: "DeleteAutomation",
args: args{method: "DELETE", url: "/api/automations/hash.sha1"},
want: want{
status: 204,
body: nil,
},
},
{
name: "DeletePlaybook",
args: args{method: "DELETE", url: "/api/playbooks/simple"},
want: want{
status: 204,
body: nil,
},
},
{
name: "DeleteTemplate",
args: args{method: "DELETE", url: "/api/templates/default"},
want: want{
status: 204,
body: nil,
},
},
{
name: "DeleteTicket",
args: args{method: "DELETE", url: "/api/tickets/8125"},
want: want{
status: 204,
body: nil,
},
},
{
name: "DeleteTicketType",
args: args{method: "DELETE", url: "/api/tickettypes/alert"},
want: want{
status: 204,
body: nil,
},
},
{
name: "DeleteUser",
args: args{method: "DELETE", url: "/api/users/script"},
want: want{
status: 204,
body: nil,
},
},
{
name: "EnrichArtifact",
args: args{method: "POST", url: "/api/tickets/8123/artifacts/leadreintermediate.io/enrich", data: map[string]interface{}{"data": map[string]interface{}{"hash": "b7a067a742c20d07a7456646de89bc2d408a1153"}, "name": "hash.sha1"}},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"enrichments": map[string]interface{}{"hash.sha1": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "data": map[string]interface{}{"hash": "b7a067a742c20d07a7456646de89bc2d408a1153"}, "name": "hash.sha1"}}, "name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-10-02T16:04:59.078206Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 \"tLine truncated
},
},
{
name: "GetArtifact",
args: args{method: "GET", url: "/api/tickets/8123/artifacts/leadreintermediate.io"},
want: want{
status: 200,
body: map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"},
},
},
{
name: "GetAutomation",
args: args{method: "GET", url: "/api/automations/hash.sha1"},
want: want{
status: 200,
body: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "#!/usr/bin/env python\n\nimport sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload']['default'].encode('utf-8'))\n return {\"hash\": sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}},
},
},
{
name: "GetJob",
args: args{method: "GET", url: "/api/jobs/99cd67131b48"},
want: want{
status: 200,
body: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "created"},
},
},
{
name: "GetLogs",
args: args{method: "GET", url: "/api/logs/tickets%252F294511"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "creator": "bob", "message": "Fail run account resist lend solve incident centre priority temperature. Cause change distribution examine location technique shape partner milk customer. Rail tea plate soil report cook railway interpretation breath action. Exercise dream accept park conclusion addition shoot assistance may answer. Gold writer link stop combine hear power name commitment operation. Determine lifespan support grow degree henry exclude detail set religion. Direct library policy convention chain retain discover ride walk student. Gather proposal select march aspect play noise avoid encourage employ. Assessment preserve transport combine wish influence income guess run stand. Charge limit crime ignore statement foundation study issue stop claim.", "reference": "tickets/294511", "type": "manual"}},
},
},
{
name: "GetPlaybook",
args: args{method: "GET", url: "/api/playbooks/simple"},
want: want{
status: 200,
body: map[string]interface{}{"id": "simple", "name": "Simple", "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"},
},
},
{
name: "GetSettings",
args: args{method: "GET", url: "/api/settings"},
want: want{
status: 200,
body: map[string]interface{}{"artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
},
},
{
name: "GetStatistics",
args: args{method: "GET", url: "/api/statistics"},
want: want{
status: 200,
body: map[string]interface{}{"open_tickets_per_user": map[string]interface{}{}, "tickets_per_type": map[string]interface{}{"alert": 2, "incident": 1}, "tickets_per_week": map[string]interface{}{"2021-39": 3}, "unassigned": 0},
},
},
{
name: "GetTemplate",
args: args{method: "GET", url: "/api/templates/default"},
want: want{
status: 200,
body: map[string]interface{}{"id": "default", "name": "Default", "schema": "{\n \"definitions\": {},\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://example.com/object1618746510.json\",\n \"title\": \"Default\",\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 \"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 \"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"},
},
},
{
name: "GetTicket",
args: args{method: "GET", url: "/api/tickets/8125"},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8125, "modified": "2021-10-02T16:04:59.078186Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "GetTicketType",
args: args{method: "GET", url: "/api/tickettypes/alert"},
want: want{
status: 200,
body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"},
},
},
{
name: "GetUser",
args: args{method: "GET", url: "/api/users/script"},
want: want{
status: 200,
body: map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
name: "GetUserData",
args: args{method: "GET", url: "/api/userdata/bob"},
want: want{
status: 200,
body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
name: "LinkFiles",
args: args{method: "PUT", url: "/api/tickets/8125/files", data: []interface{}{map[string]interface{}{"key": "myfile", "name": "document.doc"}}},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "files": []interface{}{map[string]interface{}{"key": "myfile", "name": "document.doc"}}, "id": 8125, "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "LinkTicket",
args: args{method: "PATCH", url: "/api/tickets/8126/tickets", data: 8123},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-10-02T16:04:59.078206Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "type": "task"}, "block-sender": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}, "board": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "type": "task"}, "extract-iocs": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 Line truncated
},
},
{
name: "ListAutomations",
args: args{method: "GET", url: "/api/automations"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"id": "comment", "image": "docker.io/python:3", "script": "", "type": []interface{}{"playbook"}}, map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "", "type": []interface{}{"global", "artifact", "playbook"}}, map[string]interface{}{"id": "thehive", "image": "docker.io/python:3", "schema": "{\"title\":\"TheHive credentials\",\"type\":\"object\",\"properties\":{\"thehiveurl\":{\"type\":\"string\",\"title\":\"TheHive URL (e.g. 'https://thehive.example.org')\"},\"thehivekey\":{\"type\":\"string\",\"title\":\"TheHive API Key\"},\"skip_files\":{\"type\":\"boolean\", \"default\": true, \"title\":\"Skip Files (much faster)\"},\"keep_ids\":{\"type\":\"boolean\", \"default\": true, \"title\":\"Keep IDs and overwrite existing IDs\"}},\"required\":[\"thehiveurl\", \"thehivekey\", \"skip_files\", \"keep_ids\"]}", "script": "", "type": []interface{}{"global"}}, map[string]interface{}{"id": "vt.hash", "image": "docker.io/python:3", "schema": "{\"title\":\"Input\",\"type\":\"object\",\"properties\":{\"default\":{\"type\":\"string\",\"title\":\"Value\"}},\"required\":[\"default\"]}", "script": "", "type": []interface{}{"global", "artifact", "playbook"}}},
},
},
{
name: "ListJobs",
args: args{method: "GET", url: "/api/jobs"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "created"}},
},
},
{
name: "ListPlaybooks",
args: args{method: "GET", url: "/api/playbooks"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"id": "malware", "name": "Malware", "yaml": "name: Malware\ntasks:\n file-or-hash:\n name: Do you have the file or the hash?\n type: input\n schema:\n title: Malware\n type: object\n properties:\n file:\n type: string\n title: \"I have the\"\n enum: [ \"File\", \"Hash\" ]\n next:\n enter-hash: \"file == 'Hash'\"\n upload: \"file == 'File'\"\n\n enter-hash:\n name: Please enter the hash\n type: input\n schema:\n title: Malware\n type: object\n properties:\n hash:\n type: string\n title: Please enter the hash value\n minlength: 32\n next:\n virustotal: \"hash != ''\"\n\n upload:\n name: Upload the malware\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: object\n x-display: file\n title: Please upload the malware\n next:\n hash: \"malware\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['upload'].data['malware']\"\n next:\n virustotal:\n\n virustotal:\n name: Send hash to VirusTotal\n type: automation\n automation: vt.hash\n args:\n hash: \"playbook.tasks['enter-hash'].data['hash'] || playbook.tasks['hash'].data['hash']\"\n # next:\n # known-malware: \"score > 5\"\n # sandbox: \"score < 6\" # unknown-malware\n"}, map[string]interface{}{"id": "phishing", "name": "Phishing", "yaml": "name: Phishing\ntasks:\n board:\n name: Board Involvement?\n description: Is a board member involved?\n type: input\n schema:\n properties:\n boardInvolved:\n default: false\n title: A board member is involved.\n type: boolean\n required:\n - boardInvolved\n title: Board Involvement?\n type: object\n next:\n escalate: \"boardInvolved == true\"\n mail-available: \"boardInvolved == false\"\n\n escalate:\n name: Escalate to CISO\n description: Please escalate the task to the CISO\n type: task\n\n mail-available:\n name: Mail available\n type: input\n schema:\n oneOf:\n - properties:\n mail:\n title: Mail\n type: string\n x-display: textarea\n schemaKey:\n const: 'yes'\n type: string\n required:\n - mail\n title: 'Yes'\n - properties:\n schemaKey:\n const: 'no'\n type: string\n title: 'No'\n title: Mail available\n type: object\n next:\n block-sender: \"schemaKey == 'yes'\"\n extract-iocs: \"schemaKey == 'yes'\"\n search-email-gateway: \"schemaKey == 'no'\"\n\n search-email-gateway:\n name: Search email gateway\n description: Please search email-gateway for the phishing mail.\n type: task\n next:\n extract-iocs:\n\n block-sender:\n name: Block sender\n type: task\n next:\n extract-iocs:\n\n extract-iocs:\n name: Extract IOCs\n description: Please insert the IOCs\n type: input\n schema:\n properties:\n iocs:\n items:\n type: string\n title: IOCs\n type: array\n title: Extract IOCs\n type: object\n next:\n block-iocs:\n\n block-iocs:\n name: Block IOCs\n type: task\n"}, map[string]interface{}{"id": "simple", "name": "Simple", "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"}},
},
},
{
name: "ListTasks",
args: args{method: "GET", url: "/api/tasks"},
want: want{
status: 200,
body: []interface{}{},
},
},
{
name: "ListTemplates",
args: args{method: "GET", url: "/api/templates"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"id": "default", "name": "Default", "schema": "{\n \"definitions\": {},\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://example.com/object1618746510.json\",\n \"title\": \"Default\",\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 \"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 \"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"}},
},
},
{
name: "ListTicketTypes",
args: args{method: "GET", url: "/api/tickettypes"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}},
},
},
{
name: "ListTickets",
args: args{method: "GET", url: "/api/tickets"},
want: want{
status: 200,
body: map[string]interface{}{"count": 3, "tickets": []interface{}{map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-10-02T16:04:59.078206Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "type": "task"}, "block-sender": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}, "board": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "type": "task"}, "extract-iocs": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\",Line truncated
},
},
{
name: "ListUserData",
args: args{method: "GET", url: "/api/userdata"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"}},
},
},
{
name: "ListUsers",
args: args{method: "GET", url: "/api/users"},
want: want{
status: 200,
body: []interface{}{map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}, map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}},
},
},
{
name: "RemoveArtifact",
args: args{method: "DELETE", url: "/api/tickets/8123/artifacts/leadreintermediate.io"},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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 {\Line truncated
},
},
{
name: "RemoveComment",
args: args{method: "DELETE", url: "/api/tickets/8123/comments/0"},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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-displLine truncated
},
},
{
name: "RemoveTicketPlaybook",
args: args{method: "DELETE", url: "/api/tickets/8123/playbooks/phishing"},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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"},
},
},
{
name: "RunArtifact",
args: args{method: "POST", url: "/api/tickets/8123/artifacts/leadreintermediate.io/run/hash.sha1"},
want: want{
status: 204,
body: nil,
},
},
{
name: "RunJob",
args: args{method: "POST", url: "/api/jobs", data: map[string]interface{}{"automation": "hash.sha1", "message": map[string]interface{}{"payload": "test"}}},
want: want{
status: 204,
body: nil,
},
},
{
name: "RunTask",
args: args{method: "POST", url: "/api/tickets/8123/playbooks/phishing/task/board/run"},
want: want{
status: 204,
body: nil,
},
},
{
name: "SetArtifact",
args: args{method: "PUT", url: "/api/tickets/8123/artifacts/leadreintermediate.io", data: map[string]interface{}{"name": "leadreintermediate.io", "status": "clean"}},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "clean"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-10-02T16:04:59.078206Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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\": \Line truncated
},
},
{
name: "SetReferences",
args: args{method: "PUT", url: "/api/tickets/8125/references", data: []interface{}{map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8125, "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "SetSchema",
args: args{method: "PUT", url: "/api/tickets/8125/schema", data: "{}"},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8125, "modified": "2021-10-02T16:04:59.078186Z", "name": "phishing from selenafadel@von.com detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "SetTask",
args: args{method: "PUT", url: "/api/tickets/8123/playbooks/phishing/task/board", data: map[string]interface{}{"active": true, "data": map[string]interface{}{"boardInvolved": true}, "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}},
want: want{
status: 200,
body: map[string]interface{}{"artifacts": []interface{}{map[string]interface{}{"name": "94d5cab6f5fe3422a447ab15436e7a672bc0c09a", "status": "unknown"}, map[string]interface{}{"name": "http://www.customerviral.io/scalable/vertical/killer", "status": "clean"}, map[string]interface{}{"name": "leadreintermediate.io", "status": "malicious"}}, "created": "2021-10-02T16:04:59.078206Z", "id": 8123, "modified": "2021-12-12T12:12:12.000000012Z", "name": "live zebra", "owner": "demo", "playbooks": map[string]interface{}{"phishing": map[string]interface{}{"name": "Phishing", "tasks": map[string]interface{}{"block-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block IOCs", "order": 6, "type": "task"}, "block-sender": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Block sender", "next": map[string]interface{}{"extract-iocs": ""}, "order": 3, "type": "task"}, "board": map[string]interface{}{"active": true, "created": "2021-12-12T12:12:12.000000012Z", "data": map[string]interface{}{"boardInvolved": true}, "done": false, "name": "Board Involvement?", "next": map[string]interface{}{"escalate": "boardInvolved == true", "mail-available": "boardInvolved == false"}, "order": 0, "schema": map[string]interface{}{"properties": map[string]interface{}{"boardInvolved": map[string]interface{}{"default": false, "title": "A board member is involved.", "type": "boolean"}}, "required": []interface{}{"boardInvolved"}, "title": "Board Involvement?", "type": "object"}, "type": "input"}, "escalate": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Escalate to CISO", "order": 1, "type": "task"}, "extract-iocs": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Extract IOCs", "next": map[string]interface{}{"block-iocs": ""}, "order": 5, "schema": map[string]interface{}{"properties": map[string]interface{}{"iocs": map[string]interface{}{"items": map[string]interface{}{"type": "string"}, "title": "IOCs", "type": "array"}}, "title": "Extract IOCs", "type": "object"}, "type": "input"}, "mail-available": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Mail available", "next": map[string]interface{}{"block-sender": "schemaKey == 'yes'", "extract-iocs": "schemaKey == 'yes'", "search-email-gateway": "schemaKey == 'no'"}, "order": 2, "schema": map[string]interface{}{"oneOf": []interface{}{map[string]interface{}{"properties": map[string]interface{}{"mail": map[string]interface{}{"title": "Mail", "type": "string", "x-display": "textarea"}, "schemaKey": map[string]interface{}{"const": "yes", "type": "string"}}, "required": []interface{}{"mail"}, "title": "Yes"}, map[string]interface{}{"properties": map[string]interface{}{"schemaKey": map[string]interface{}{"const": "no", "type": "string"}}, "title": "No"}}, "title": "Mail available", "type": "object"}, "type": "input"}, "search-email-gateway": map[string]interface{}{"active": false, "created": "2021-12-12T12:12:12.000000012Z", "done": false, "name": "Search email gateway", "next": map[string]interface{}{"extract-iocs": ""}, "order": 4, "type": "task"}}}}, "references": []interface{}{map[string]interface{}{"href": "https://www.leadmaximize.net/e-services/back-end", "name": "performance"}, map[string]interface{}{"href": "http://www.corporateinteractive.name/rich", "name": "autumn"}, map[string]interface{}{"href": "https://www.corporateintuitive.org/intuitive/platforms/integrate", "name": "suggest"}}, "schema": "{\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-coLine truncated
},
},
{
name: "UnlinkTicket",
args: args{method: "DELETE", url: "/api/tickets/8126/tickets", data: 8125},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"},
},
},
{
name: "UpdateAutomation",
args: args{method: "PUT", url: "/api/automations/hash.sha1", data: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload'].encode('utf-8'))\n return {'hash': sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}}},
want: want{
status: 200,
body: map[string]interface{}{"id": "hash.sha1", "image": "docker.io/python:3", "script": "import sys\nimport json\nimport hashlib\n\n\ndef run(msg):\n sha1 = hashlib.sha1(msg['payload'].encode('utf-8'))\n return {'hash': sha1.hexdigest()}\n\n\nprint(json.dumps(run(json.loads(sys.argv[1]))))\n", "type": []interface{}{"global", "artifact", "playbook"}},
},
},
{
name: "UpdateCurrentUserData",
args: args{method: "PUT", url: "/api/currentuserdata", data: map[string]interface{}{"email": "bob@example.org", "name": "Bob Bad"}},
want: want{
status: 200,
body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
{
name: "UpdateJob",
args: args{method: "PUT", url: "/api/jobs/99cd67131b48", data: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "failed"}},
want: want{
status: 200,
body: map[string]interface{}{"automation": "hash.sha1", "id": "99cd67131b48", "payload": "test", "status": "failed"},
},
},
{
name: "UpdatePlaybook",
args: args{method: "PUT", url: "/api/playbooks/simple", data: map[string]interface{}{"yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"}},
want: want{
status: 200,
body: map[string]interface{}{"id": "simple", "name": "Simple", "yaml": "name: Simple\ntasks:\n input:\n name: Upload malware if possible\n type: input\n schema:\n title: Malware\n type: object\n properties:\n malware:\n type: string\n title: Select malware\n default: \"\"\n next:\n hash: \"malware != ''\"\n\n hash:\n name: Hash the malware\n type: automation\n automation: hash.sha1\n payload:\n default: \"playbook.tasks['input'].data['malware']\"\n next:\n escalate:\n\n escalate:\n name: Escalate to malware team\n type: task\n"},
},
},
{
name: "UpdateTemplate",
args: args{method: "PUT", url: "/api/templates/default", data: map[string]interface{}{"name": "My Template", "schema": "{\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"}},
want: want{
status: 200,
body: map[string]interface{}{"id": "default", "name": "My Template", "schema": "{\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"},
},
},
{
name: "UpdateTicket",
args: args{method: "PUT", url: "/api/tickets/8125", data: map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.org detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "type": "alert"}},
want: want{
status: 200,
body: map[string]interface{}{"created": "2021-12-12T12:12:12.000000012Z", "id": 8125, "modified": "2021-12-12T12:12:12.000000012Z", "name": "phishing from selenafadel@von.org detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "https://www.seniorleading-edge.name/users/efficient", "name": "recovery"}, map[string]interface{}{"href": "http://www.dynamicseamless.com/clicks-and-mortar", "name": "force"}, map[string]interface{}{"href": "http://www.leadscalable.biz/envisioneer", "name": "fund"}}, "schema": "{}", "status": "closed", "tickets": []interface{}{map[string]interface{}{"created": "2021-10-02T16:04:59.078186Z", "id": 8126, "modified": "2021-10-02T16:04:59.078186Z", "name": "Surfaceintroduce virus detected", "owner": "demo", "references": []interface{}{map[string]interface{}{"href": "http://www.centralworld-class.io/synthesize", "name": "university"}, map[string]interface{}{"href": "https://www.futurevirtual.org/supply-chains/markets/sticky/iterate", "name": "goal"}, map[string]interface{}{"href": "http://www.chiefsyndicate.io/action-items", "name": "unemployment"}}, "schema": "{}", "status": "closed", "type": "alert"}}, "type": "alert"},
},
},
{
name: "UpdateTicketType",
args: args{method: "PUT", url: "/api/tickettypes/alert", data: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-bell", "id": "alert", "name": "Alerts"}},
want: want{
status: 200,
body: map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-bell", "id": "alert", "name": "Alerts"},
},
},
{
name: "UpdateUser",
args: args{method: "PUT", url: "/api/users/bob", data: map[string]interface{}{"roles": []interface{}{"analyst", "admin"}}},
want: want{
status: 200,
body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
{
name: "UpdateUserData",
args: args{method: "PUT", url: "/api/userdata/bob", data: map[string]interface{}{"blocked": false, "email": "bob@example.org", "name": "Bob Bad"}},
want: want{
status: 200,
body: map[string]interface{}{"email": "bob@example.org", "id": "bob", "name": "Bob Bad"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx, _, _, _, _, db, _, server, cleanup, err := test.Server(t)
if err != nil {
t.Fatal(err)
}
defer cleanup()
if err := test.SetupTestData(ctx, db); err != nil {
t.Fatal(err)
}
setUser := func(context *gin.Context) {
busdb.SetContext(context, test.Bob)
}
server.ApiGroup.Use(setUser)
server.ConfigureRoutes()
w := httptest.NewRecorder()
// setup request
var req *http.Request
if tt.args.data != nil {
b, err := json.Marshal(tt.args.data)
if err != nil {
t.Fatal(err)
}
req = httptest.NewRequest(tt.args.method, tt.args.url, bytes.NewBuffer(b))
req.Header.Set("Content-Type", "application/json")
} else {
req = httptest.NewRequest(tt.args.method, tt.args.url, nil)
}
// run request
server.ServeHTTP(w, req)
result := w.Result()
// assert results
if result.StatusCode != tt.want.status {
msg, _ := io.ReadAll(result.Body)
t.Fatalf("Status got = %v, want %v: %s", result.Status, tt.want.status, msg)
}
if tt.want.status != http.StatusNoContent {
jsonEqual(t, result.Body, tt.want.body)
}
})
}
}
func jsonEqual(t *testing.T, got io.Reader, want interface{}) {
var gotObject, wantObject interface{}
// load bytes
wantBytes, err := json.Marshal(want)
if err != nil {
t.Fatal(err)
}
gotBytes, err := io.ReadAll(got)
if err != nil {
t.Fatal(err)
}
fields := []string{"secret"}
for _, field := range fields {
gField := gjson.GetBytes(wantBytes, field)
if gField.Exists() && gjson.GetBytes(gotBytes, field).Exists() {
gotBytes, err = sjson.SetBytes(gotBytes, field, gField.Value())
if err != nil {
t.Fatal(err)
}
}
}
// normalize bytes
if err = json.Unmarshal(wantBytes, &wantObject); err != nil {
t.Fatal(err)
}
if err := json.Unmarshal(gotBytes, &gotObject); err != nil {
t.Fatal(string(gotBytes), err)
}
// compare
assert.Equal(t, wantObject, gotObject)
}