diff --git a/.gitignore b/.gitignore index a1bb9b80..b3652cd1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ plugins/* build/* !build/build.md bin/* +swaggerdocs/* test/cacao/flatfile-db-example.json test/routes/__debug_bin2988553005 diff --git a/docs/docs.go b/docs/docs.go deleted file mode 100644 index 757e6b8d..00000000 --- a/docs/docs.go +++ /dev/null @@ -1,908 +0,0 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT -package docs - -import "github.com/swaggo/swag" - -const docTemplate = `{ - "schemes": {{ marshal .Schemes }}, - "swagger": "2.0", - "info": { - "description": "{{escape .Description}}", - "title": "{{.Title}}", - "contact": {}, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/playbook/": { - "get": { - "description": "return all stored playbooks default limit:100", - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "gets all the UUIDs for the stored playbooks", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - } - }, - "post": { - "description": "submit a new playbook api", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "submit playbook via the api", - "parameters": [ - { - "description": "playbook", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - } - }, - "/playbook/meta": { - "get": { - "description": "get playbook meta information for playbook", - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "gets all the meta information for the stored playbooks", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/api.PlaybookMeta" - } - } - } - } - } - }, - "/playbook/{id}": { - "get": { - "description": "get playbook by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "get CACAO playbook by its ID", - "parameters": [ - { - "type": "string", - "description": "playbook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - }, - "put": { - "description": "update playbook by Id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "update playbook", - "parameters": [ - { - "type": "string", - "description": "playbook Id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "playbook", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - }, - "delete": { - "description": "delete playbook by Id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "delete playbook by Id", - "parameters": [ - { - "type": "string", - "description": "playbook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/trigger/workflow": { - "post": { - "description": "trigger workflow", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "trigger" - ], - "summary": "trigger a workflow with via cacao payload", - "parameters": [ - { - "description": "execute playbook by payload", - "name": "playbook", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "{\"execution_id\":\"uuid\",\"payload\":\"playbook--uuid\"}" - } - } - } - } - }, - "definitions": { - "api.PlaybookMeta": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "string" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - } - } - }, - "cacao.AgentTarget": { - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "address": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "agent_target_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "authentication_info": { - "type": "string" - }, - "category": { - "type": "array", - "items": { - "type": "string" - } - }, - "contact": { - "$ref": "#/definitions/cacao.Contact" - }, - "description": { - "type": "string" - }, - "http_url": { - "type": "string" - }, - "id": { - "type": "string" - }, - "location": { - "$ref": "#/definitions/cacao.CivicLocation" - }, - "logical": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "port": { - "type": "string" - }, - "sector": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "cacao.AuthenticationInformation": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "string" - }, - "kms": { - "type": "boolean" - }, - "kms_key_identifier": { - "type": "string" - }, - "name": { - "type": "string" - }, - "oauth_header": { - "type": "string" - }, - "password": { - "type": "string" - }, - "private_key": { - "type": "string" - }, - "token": { - "type": "string" - }, - "type": { - "type": "string" - }, - "user_id": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "cacao.CivicLocation": { - "type": "object", - "properties": { - "administrative_area": { - "type": "string" - }, - "building_details": { - "type": "string" - }, - "city": { - "type": "string" - }, - "country": { - "type": "string" - }, - "description": { - "type": "string" - }, - "latitude": { - "type": "string" - }, - "longitude": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_details": { - "type": "string" - }, - "postal_code": { - "type": "string" - }, - "precision": { - "type": "string" - }, - "region": { - "type": "string" - }, - "street_address": { - "type": "string" - } - } - }, - "cacao.Command": { - "type": "object", - "required": [ - "command", - "type" - ], - "properties": { - "command": { - "type": "string" - }, - "command_b64": { - "type": "string" - }, - "content": { - "type": "string" - }, - "content_b64": { - "type": "string" - }, - "description": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "playbook_activity": { - "type": "string" - }, - "type": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "cacao.Contact": { - "type": "object", - "properties": { - "contact_details": { - "type": "string" - }, - "email": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "phone": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "cacao.DataMarking": { - "type": "object", - "required": [ - "created", - "created_by", - "id", - "type" - ], - "properties": { - "affected_party_notifications": { - "type": "string" - }, - "attribution": { - "type": "string" - }, - "created": { - "type": "string" - }, - "created_by": { - "type": "string" - }, - "description": { - "type": "string" - }, - "encrypt_in_transit": { - "type": "string" - }, - "end_date": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "iep_version": { - "type": "string" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "marking_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "name": { - "type": "string" - }, - "permitted_actions": { - "type": "string" - }, - "revoked": { - "type": "boolean" - }, - "start_date": { - "type": "string" - }, - "statement": { - "type": "string" - }, - "tlp": { - "type": "string" - }, - "tlpv2_level": { - "type": "string" - }, - "type": { - "type": "string" - }, - "unmodified_resale": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - } - } - }, - "cacao.ExtensionDefinition": { - "type": "object", - "required": [ - "created_by", - "schema", - "type", - "version" - ], - "properties": { - "created_by": { - "type": "string" - }, - "description": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "name": { - "type": "string" - }, - "schema": { - "type": "string" - }, - "type": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "cacao.Extensions": { - "type": "object", - "additionalProperties": true - }, - "cacao.ExternalReferences": { - "type": "object", - "required": [ - "description", - "name", - "source", - "url" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - }, - "source": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "cacao.Playbook": { - "type": "object", - "required": [ - "created", - "created_by", - "id", - "modified", - "name", - "spec_version", - "type", - "workflow", - "workflow_start" - ], - "properties": { - "agent_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AgentTarget" - } - }, - "authentication_info_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AuthenticationInformation" - } - }, - "created": { - "type": "string" - }, - "created_by": { - "type": "string" - }, - "data_marking_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.DataMarking" - } - }, - "derived_from": { - "type": "array", - "items": { - "type": "string" - } - }, - "description": { - "type": "string" - }, - "extension_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.ExtensionDefinition" - } - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "impact": { - "type": "integer" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "markings": { - "type": "array", - "items": { - "type": "string" - } - }, - "modified": { - "type": "string" - }, - "name": { - "type": "string" - }, - "playbook_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "playbook_types": { - "type": "array", - "items": { - "type": "string" - } - }, - "playbook_variables": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Variable" - } - }, - "priority": { - "type": "integer" - }, - "severity": { - "type": "integer" - }, - "spec_version": { - "type": "string" - }, - "target_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AgentTarget" - } - }, - "type": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - }, - "workflow": { - "$ref": "#/definitions/cacao.Workflow" - }, - "workflow_exception": { - "type": "string" - }, - "workflow_start": { - "type": "string" - } - } - }, - "cacao.Step": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "agent": { - "type": "string" - }, - "authentication_info": { - "type": "string" - }, - "cases": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "commands": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.Command" - } - }, - "condition": { - "type": "string" - }, - "delay": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "in_args": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "next_steps": { - "type": "array", - "items": { - "type": "string" - } - }, - "on_completion": { - "type": "string" - }, - "on_failure": { - "type": "string" - }, - "on_false": { - "type": "string" - }, - "on_success": { - "type": "string" - }, - "on_true": { - "type": "string" - }, - "out_args": { - "type": "array", - "items": { - "type": "string" - } - }, - "owner": { - "type": "string" - }, - "playbook_id": { - "type": "string" - }, - "playbook_version": { - "type": "string" - }, - "step_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "step_variables": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Variable" - } - }, - "switch": { - "type": "string" - }, - "targets": { - "type": "array", - "items": { - "type": "string" - } - }, - "timeout": { - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "cacao.Variable": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "constant": { - "type": "boolean" - }, - "description": { - "type": "string" - }, - "external": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "cacao.Workflow": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Step" - } - } - } -}` - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = &swag.Spec{ - Version: "", - Host: "", - BasePath: "", - Schemes: []string{}, - Title: "", - Description: "", - InfoInstanceName: "swagger", - SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", -} - -func init() { - swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) -} diff --git a/docs/swagger.json b/docs/swagger.json deleted file mode 100644 index 74f91832..00000000 --- a/docs/swagger.json +++ /dev/null @@ -1,879 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "contact": {} - }, - "paths": { - "/playbook/": { - "get": { - "description": "return all stored playbooks default limit:100", - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "gets all the UUIDs for the stored playbooks", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - } - }, - "post": { - "description": "submit a new playbook api", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "submit playbook via the api", - "parameters": [ - { - "description": "playbook", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - } - }, - "/playbook/meta": { - "get": { - "description": "get playbook meta information for playbook", - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "gets all the meta information for the stored playbooks", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/api.PlaybookMeta" - } - } - } - } - } - }, - "/playbook/{id}": { - "get": { - "description": "get playbook by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "get CACAO playbook by its ID", - "parameters": [ - { - "type": "string", - "description": "playbook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - }, - "put": { - "description": "update playbook by Id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "update playbook", - "parameters": [ - { - "type": "string", - "description": "playbook Id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "playbook", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - } - }, - "delete": { - "description": "delete playbook by Id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "playbook" - ], - "summary": "delete playbook by Id", - "parameters": [ - { - "type": "string", - "description": "playbook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/trigger/workflow": { - "post": { - "description": "trigger workflow", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "trigger" - ], - "summary": "trigger a workflow with via cacao payload", - "parameters": [ - { - "description": "execute playbook by payload", - "name": "playbook", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/cacao.Playbook" - } - } - ], - "responses": { - "200": { - "description": "{\"execution_id\":\"uuid\",\"payload\":\"playbook--uuid\"}" - } - } - } - } - }, - "definitions": { - "api.PlaybookMeta": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "string" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - } - } - }, - "cacao.AgentTarget": { - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "address": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "agent_target_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "authentication_info": { - "type": "string" - }, - "category": { - "type": "array", - "items": { - "type": "string" - } - }, - "contact": { - "$ref": "#/definitions/cacao.Contact" - }, - "description": { - "type": "string" - }, - "http_url": { - "type": "string" - }, - "id": { - "type": "string" - }, - "location": { - "$ref": "#/definitions/cacao.CivicLocation" - }, - "logical": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "port": { - "type": "string" - }, - "sector": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "cacao.AuthenticationInformation": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "string" - }, - "kms": { - "type": "boolean" - }, - "kms_key_identifier": { - "type": "string" - }, - "name": { - "type": "string" - }, - "oauth_header": { - "type": "string" - }, - "password": { - "type": "string" - }, - "private_key": { - "type": "string" - }, - "token": { - "type": "string" - }, - "type": { - "type": "string" - }, - "user_id": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "cacao.CivicLocation": { - "type": "object", - "properties": { - "administrative_area": { - "type": "string" - }, - "building_details": { - "type": "string" - }, - "city": { - "type": "string" - }, - "country": { - "type": "string" - }, - "description": { - "type": "string" - }, - "latitude": { - "type": "string" - }, - "longitude": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_details": { - "type": "string" - }, - "postal_code": { - "type": "string" - }, - "precision": { - "type": "string" - }, - "region": { - "type": "string" - }, - "street_address": { - "type": "string" - } - } - }, - "cacao.Command": { - "type": "object", - "required": [ - "command", - "type" - ], - "properties": { - "command": { - "type": "string" - }, - "command_b64": { - "type": "string" - }, - "content": { - "type": "string" - }, - "content_b64": { - "type": "string" - }, - "description": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "playbook_activity": { - "type": "string" - }, - "type": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "cacao.Contact": { - "type": "object", - "properties": { - "contact_details": { - "type": "string" - }, - "email": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "phone": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "cacao.DataMarking": { - "type": "object", - "required": [ - "created", - "created_by", - "id", - "type" - ], - "properties": { - "affected_party_notifications": { - "type": "string" - }, - "attribution": { - "type": "string" - }, - "created": { - "type": "string" - }, - "created_by": { - "type": "string" - }, - "description": { - "type": "string" - }, - "encrypt_in_transit": { - "type": "string" - }, - "end_date": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "iep_version": { - "type": "string" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "marking_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "name": { - "type": "string" - }, - "permitted_actions": { - "type": "string" - }, - "revoked": { - "type": "boolean" - }, - "start_date": { - "type": "string" - }, - "statement": { - "type": "string" - }, - "tlp": { - "type": "string" - }, - "tlpv2_level": { - "type": "string" - }, - "type": { - "type": "string" - }, - "unmodified_resale": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - } - } - }, - "cacao.ExtensionDefinition": { - "type": "object", - "required": [ - "created_by", - "schema", - "type", - "version" - ], - "properties": { - "created_by": { - "type": "string" - }, - "description": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "name": { - "type": "string" - }, - "schema": { - "type": "string" - }, - "type": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "cacao.Extensions": { - "type": "object", - "additionalProperties": true - }, - "cacao.ExternalReferences": { - "type": "object", - "required": [ - "description", - "name", - "source", - "url" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - }, - "source": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "cacao.Playbook": { - "type": "object", - "required": [ - "created", - "created_by", - "id", - "modified", - "name", - "spec_version", - "type", - "workflow", - "workflow_start" - ], - "properties": { - "agent_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AgentTarget" - } - }, - "authentication_info_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AuthenticationInformation" - } - }, - "created": { - "type": "string" - }, - "created_by": { - "type": "string" - }, - "data_marking_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.DataMarking" - } - }, - "derived_from": { - "type": "array", - "items": { - "type": "string" - } - }, - "description": { - "type": "string" - }, - "extension_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.ExtensionDefinition" - } - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "impact": { - "type": "integer" - }, - "labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "markings": { - "type": "array", - "items": { - "type": "string" - } - }, - "modified": { - "type": "string" - }, - "name": { - "type": "string" - }, - "playbook_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "playbook_types": { - "type": "array", - "items": { - "type": "string" - } - }, - "playbook_variables": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Variable" - } - }, - "priority": { - "type": "integer" - }, - "severity": { - "type": "integer" - }, - "spec_version": { - "type": "string" - }, - "target_definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.AgentTarget" - } - }, - "type": { - "type": "string" - }, - "valid_from": { - "type": "string" - }, - "valid_until": { - "type": "string" - }, - "workflow": { - "$ref": "#/definitions/cacao.Workflow" - }, - "workflow_exception": { - "type": "string" - }, - "workflow_start": { - "type": "string" - } - } - }, - "cacao.Step": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "agent": { - "type": "string" - }, - "authentication_info": { - "type": "string" - }, - "cases": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "commands": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.Command" - } - }, - "condition": { - "type": "string" - }, - "delay": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "external_references": { - "type": "array", - "items": { - "$ref": "#/definitions/cacao.ExternalReferences" - } - }, - "id": { - "type": "string" - }, - "in_args": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "next_steps": { - "type": "array", - "items": { - "type": "string" - } - }, - "on_completion": { - "type": "string" - }, - "on_failure": { - "type": "string" - }, - "on_false": { - "type": "string" - }, - "on_success": { - "type": "string" - }, - "on_true": { - "type": "string" - }, - "out_args": { - "type": "array", - "items": { - "type": "string" - } - }, - "owner": { - "type": "string" - }, - "playbook_id": { - "type": "string" - }, - "playbook_version": { - "type": "string" - }, - "step_extensions": { - "$ref": "#/definitions/cacao.Extensions" - }, - "step_variables": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Variable" - } - }, - "switch": { - "type": "string" - }, - "targets": { - "type": "array", - "items": { - "type": "string" - } - }, - "timeout": { - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "cacao.Variable": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "constant": { - "type": "boolean" - }, - "description": { - "type": "string" - }, - "external": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "cacao.Workflow": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/cacao.Step" - } - } - } -} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml deleted file mode 100644 index 1f2a72f1..00000000 --- a/docs/swagger.yaml +++ /dev/null @@ -1,585 +0,0 @@ -definitions: - api.PlaybookMeta: - properties: - description: - type: string - id: - type: string - labels: - items: - type: string - type: array - name: - type: string - valid_from: - type: string - valid_until: - type: string - type: object - cacao.AgentTarget: - properties: - address: - additionalProperties: - items: - type: string - type: array - type: object - agent_target_extensions: - $ref: '#/definitions/cacao.Extensions' - authentication_info: - type: string - category: - items: - type: string - type: array - contact: - $ref: '#/definitions/cacao.Contact' - description: - type: string - http_url: - type: string - id: - type: string - location: - $ref: '#/definitions/cacao.CivicLocation' - logical: - items: - type: string - type: array - name: - type: string - port: - type: string - sector: - type: string - type: - type: string - required: - - name - - type - type: object - cacao.AuthenticationInformation: - properties: - description: - type: string - id: - type: string - kms: - type: boolean - kms_key_identifier: - type: string - name: - type: string - oauth_header: - type: string - password: - type: string - private_key: - type: string - token: - type: string - type: - type: string - user_id: - type: string - username: - type: string - required: - - type - type: object - cacao.CivicLocation: - properties: - administrative_area: - type: string - building_details: - type: string - city: - type: string - country: - type: string - description: - type: string - latitude: - type: string - longitude: - type: string - name: - type: string - network_details: - type: string - postal_code: - type: string - precision: - type: string - region: - type: string - street_address: - type: string - type: object - cacao.Command: - properties: - command: - type: string - command_b64: - type: string - content: - type: string - content_b64: - type: string - description: - type: string - headers: - additionalProperties: - type: string - type: object - playbook_activity: - type: string - type: - type: string - version: - type: string - required: - - command - - type - type: object - cacao.Contact: - properties: - contact_details: - type: string - email: - additionalProperties: - type: string - type: object - phone: - additionalProperties: - type: string - type: object - type: object - cacao.DataMarking: - properties: - affected_party_notifications: - type: string - attribution: - type: string - created: - type: string - created_by: - type: string - description: - type: string - encrypt_in_transit: - type: string - end_date: - type: string - external_references: - items: - $ref: '#/definitions/cacao.ExternalReferences' - type: array - id: - type: string - iep_version: - type: string - labels: - items: - type: string - type: array - marking_extensions: - $ref: '#/definitions/cacao.Extensions' - name: - type: string - permitted_actions: - type: string - revoked: - type: boolean - start_date: - type: string - statement: - type: string - tlp: - type: string - tlpv2_level: - type: string - type: - type: string - unmodified_resale: - type: string - valid_from: - type: string - valid_until: - type: string - required: - - created - - created_by - - id - - type - type: object - cacao.ExtensionDefinition: - properties: - created_by: - type: string - description: - type: string - external_references: - items: - $ref: '#/definitions/cacao.ExternalReferences' - type: array - name: - type: string - schema: - type: string - type: - type: string - version: - type: string - required: - - created_by - - schema - - type - - version - type: object - cacao.Extensions: - additionalProperties: true - type: object - cacao.ExternalReferences: - properties: - description: - type: string - name: - type: string - source: - type: string - url: - type: string - required: - - description - - name - - source - - url - type: object - cacao.Playbook: - properties: - agent_definitions: - additionalProperties: - $ref: '#/definitions/cacao.AgentTarget' - type: object - authentication_info_definitions: - additionalProperties: - $ref: '#/definitions/cacao.AuthenticationInformation' - type: object - created: - type: string - created_by: - type: string - data_marking_definitions: - additionalProperties: - $ref: '#/definitions/cacao.DataMarking' - type: object - derived_from: - items: - type: string - type: array - description: - type: string - extension_definitions: - additionalProperties: - $ref: '#/definitions/cacao.ExtensionDefinition' - type: object - external_references: - items: - $ref: '#/definitions/cacao.ExternalReferences' - type: array - id: - type: string - impact: - type: integer - labels: - items: - type: string - type: array - markings: - items: - type: string - type: array - modified: - type: string - name: - type: string - playbook_extensions: - $ref: '#/definitions/cacao.Extensions' - playbook_types: - items: - type: string - type: array - playbook_variables: - additionalProperties: - $ref: '#/definitions/cacao.Variable' - type: object - priority: - type: integer - severity: - type: integer - spec_version: - type: string - target_definitions: - additionalProperties: - $ref: '#/definitions/cacao.AgentTarget' - type: object - type: - type: string - valid_from: - type: string - valid_until: - type: string - workflow: - $ref: '#/definitions/cacao.Workflow' - workflow_exception: - type: string - workflow_start: - type: string - required: - - created - - created_by - - id - - modified - - name - - spec_version - - type - - workflow - - workflow_start - type: object - cacao.Step: - properties: - agent: - type: string - authentication_info: - type: string - cases: - additionalProperties: - type: string - type: object - commands: - items: - $ref: '#/definitions/cacao.Command' - type: array - condition: - type: string - delay: - type: integer - description: - type: string - external_references: - items: - $ref: '#/definitions/cacao.ExternalReferences' - type: array - id: - type: string - in_args: - items: - type: string - type: array - name: - type: string - next_steps: - items: - type: string - type: array - on_completion: - type: string - on_failure: - type: string - on_false: - type: string - on_success: - type: string - on_true: - type: string - out_args: - items: - type: string - type: array - owner: - type: string - playbook_id: - type: string - playbook_version: - type: string - step_extensions: - $ref: '#/definitions/cacao.Extensions' - step_variables: - additionalProperties: - $ref: '#/definitions/cacao.Variable' - type: object - switch: - type: string - targets: - items: - type: string - type: array - timeout: - type: integer - type: - type: string - required: - - type - type: object - cacao.Variable: - properties: - constant: - type: boolean - description: - type: string - external: - type: boolean - name: - type: string - type: - type: string - value: - type: string - required: - - type - type: object - cacao.Workflow: - additionalProperties: - $ref: '#/definitions/cacao.Step' - type: object -info: - contact: {} -paths: - /playbook/: - get: - description: return all stored playbooks default limit:100 - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/cacao.Playbook' - type: array - summary: gets all the UUIDs for the stored playbooks - tags: - - playbook - post: - consumes: - - application/json - description: submit a new playbook api - parameters: - - description: playbook - in: body - name: data - required: true - schema: - $ref: '#/definitions/cacao.Playbook' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/cacao.Playbook' - summary: submit playbook via the api - tags: - - playbook - /playbook/{id}: - delete: - consumes: - - application/json - description: delete playbook by Id - parameters: - - description: playbook ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - summary: delete playbook by Id - tags: - - playbook - get: - consumes: - - application/json - description: get playbook by ID - parameters: - - description: playbook ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/cacao.Playbook' - summary: get CACAO playbook by its ID - tags: - - playbook - put: - consumes: - - application/json - description: update playbook by Id - parameters: - - description: playbook Id - in: path - name: id - required: true - type: string - - description: playbook - in: body - name: data - required: true - schema: - $ref: '#/definitions/cacao.Playbook' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/cacao.Playbook' - summary: update playbook - tags: - - playbook - /playbook/meta: - get: - description: get playbook meta information for playbook - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/api.PlaybookMeta' - type: array - summary: gets all the meta information for the stored playbooks - tags: - - playbook - /trigger/workflow: - post: - consumes: - - application/json - description: trigger workflow - parameters: - - description: execute playbook by payload - in: body - name: playbook - required: true - schema: - $ref: '#/definitions/cacao.Playbook' - produces: - - application/json - responses: - "200": - description: '{"execution_id":"uuid","payload":"playbook--uuid"}' - summary: trigger a workflow with via cacao payload - tags: - - trigger -swagger: "2.0" diff --git a/makefile b/makefile index 1b0e54b6..1d1689e3 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,8 @@ lint: golangci-lint run -v build: - swag init + mkdir -p swaggerdocs + swag init -o swaggerdocs CGO_ENABLED=0 go build -o ./build/soarca $(GOFLAGS) main.go test: @@ -31,7 +32,8 @@ clean: compile: echo "Compiling for every OS and Platform" - swag init + mkdir -p swaggerdocs + swag init -o swaggerdocs CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-${VERSION}-darwin-arm64 $(GOFLAGS) main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-windows-amd64 $(GOFLAGS) main.go @@ -44,7 +46,8 @@ sbom: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 cyclonedx-gomod app -json -licenses -output bin/${BINARY_NAME}-${VERSION}-windows-amd64.bom.json pre-docker-build: - swag init + mkdir -p swaggerdocs + swag init -o swaggerdocs GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go docker: pre-docker-build diff --git a/routes/swagger/swagger_endpoints.go b/routes/swagger/swagger_endpoints.go index e7ffb180..73f681d0 100644 --- a/routes/swagger/swagger_endpoints.go +++ b/routes/swagger/swagger_endpoints.go @@ -1,7 +1,7 @@ package swagger import ( - "soarca/docs" + "soarca/swaggerdocs" "github.com/gin-gonic/gin" swaggerfiles "github.com/swaggo/files" @@ -9,7 +9,7 @@ import ( ) func Routes(route *gin.Engine) { - docs.SwaggerInfo.BasePath = "/" + swaggerdocs.SwaggerInfo.BasePath = "/" swagger := route.Group("/swagger") { swagger.GET("/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))