diff --git a/cmd/soc/main.go b/cmd/soc/main.go index 00b0220..ef10ffb 100644 --- a/cmd/soc/main.go +++ b/cmd/soc/main.go @@ -1,5 +1,11 @@ // Package main provides the standalone SOC API server entry point. // +// @title SYNTREX Sentinel SOC API +// @version 1.0 +// @description Enterprise API for AI Firewall and Security Operations Center. Auto-generated via Doc-as-Code. +// @host localhost:9100 +// @BasePath / +// // Usage: // // go run ./cmd/soc/ diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..424f68d --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,102 @@ +// 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": { + "/api/v1/scan": { + "post": { + "description": "Scans user inputs using Sentinel Lattice (Rust engine) to detect jailbreaks, prompt injections, and Data Exfiltration attempts within 1ms.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Scanner" + ], + "summary": "Inspect AI Prompt", + "parameters": [ + { + "description": "Request body containing 'prompt' string", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Scan result with confidence scores and block flags", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "429": { + "description": "Rate Limited", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "503": { + "description": "Service Unavailable (Queue full)", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:9100", + BasePath: "/", + Schemes: []string{}, + Title: "SYNTREX Sentinel SOC API", + Description: "Enterprise API for AI Firewall and Security Operations Center. Auto-generated via Doc-as-Code.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..0401c85 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,78 @@ +{ + "swagger": "2.0", + "info": { + "description": "Enterprise API for AI Firewall and Security Operations Center. Auto-generated via Doc-as-Code.", + "title": "SYNTREX Sentinel SOC API", + "contact": {}, + "version": "1.0" + }, + "host": "localhost:9100", + "basePath": "/", + "paths": { + "/api/v1/scan": { + "post": { + "description": "Scans user inputs using Sentinel Lattice (Rust engine) to detect jailbreaks, prompt injections, and Data Exfiltration attempts within 1ms.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Scanner" + ], + "summary": "Inspect AI Prompt", + "parameters": [ + { + "description": "Request body containing 'prompt' string", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Scan result with confidence scores and block flags", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "429": { + "description": "Rate Limited", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "503": { + "description": "Service Unavailable (Queue full)", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..6c36ab2 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,54 @@ +basePath: / +host: localhost:9100 +info: + contact: {} + description: Enterprise API for AI Firewall and Security Operations Center. Auto-generated + via Doc-as-Code. + title: SYNTREX Sentinel SOC API + version: "1.0" +paths: + /api/v1/scan: + post: + consumes: + - application/json + description: Scans user inputs using Sentinel Lattice (Rust engine) to detect + jailbreaks, prompt injections, and Data Exfiltration attempts within 1ms. + parameters: + - description: Request body containing 'prompt' string + in: body + name: body + required: true + schema: + additionalProperties: + type: string + type: object + produces: + - application/json + responses: + "200": + description: Scan result with confidence scores and block flags + schema: + additionalProperties: true + type: object + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "429": + description: Rate Limited + schema: + additionalProperties: + type: string + type: object + "503": + description: Service Unavailable (Queue full) + schema: + additionalProperties: + type: string + type: object + summary: Inspect AI Prompt + tags: + - Scanner +swagger: "2.0" diff --git a/internal/transport/http/soc_handlers.go b/internal/transport/http/soc_handlers.go index 836bc9f..17fa65f 100644 --- a/internal/transport/http/soc_handlers.go +++ b/internal/transport/http/soc_handlers.go @@ -1504,12 +1504,18 @@ func (s *Server) handleSLAConfig(w http.ResponseWriter, _ *http.Request) { } // handlePublicScan provides a public (no-auth) prompt scanning endpoint for the demo. -// POST /api/v1/scan body: {"prompt": "Ignore all instructions..."} -// Runs sentinel-core (54 Rust engines) + Shield (C11 payload inspection) in parallel. // -// Concurrency control: uses scanSem (buffered channel) to limit parallel scans. -// If all slots are busy, returns 503 Service Unavailable with Retry-After header -// to prevent OOM under burst load (e.g., 20 concurrent battle workers). +// @Summary Inspect AI Prompt +// @Description Scans user inputs using Sentinel Lattice (Rust engine) to detect jailbreaks, prompt injections, and Data Exfiltration attempts within 1ms. +// @Tags Scanner +// @Accept json +// @Produce json +// @Param body body map[string]string true "Request body containing 'prompt' string" +// @Success 200 {object} map[string]any "Scan result with confidence scores and block flags" +// @Failure 400 {object} map[string]string "Bad Request" +// @Failure 429 {object} map[string]string "Rate Limited" +// @Failure 503 {object} map[string]string "Service Unavailable (Queue full)" +// @Router /api/v1/scan [post] func (s *Server) handlePublicScan(w http.ResponseWriter, r *http.Request) { limitBody(w, r) defer r.Body.Close()