/ docs / docs.go
docs.go
  1  // Copyright (c) 2024-2026 Tencent Zhuque Lab. All rights reserved.
  2  //
  3  // Licensed under the Apache License, Version 2.0 (the "License");
  4  // you may not use this file except in compliance with the License.
  5  // You may obtain a copy of the License at
  6  //
  7  //     http://www.apache.org/licenses/LICENSE-2.0
  8  //
  9  // Unless required by applicable law or agreed to in writing, software
 10  // distributed under the License is distributed on an "AS IS" BASIS,
 11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  // See the License for the specific language governing permissions and
 13  // limitations under the License.
 14  //
 15  // Requirement: Any integration or derivative work must explicitly attribute
 16  // Tencent Zhuque Lab (https://github.com/Tencent/AI-Infra-Guard) in its
 17  // documentation or user interface, as detailed in the NOTICE file.
 18  
 19  // Package docs Code generated by swaggo/swag. DO NOT EDIT
 20  package docs
 21  
 22  import "github.com/swaggo/swag"
 23  
 24  const docTemplate = `{
 25      "schemes": {{ marshal .Schemes }},
 26      "swagger": "2.0",
 27      "info": {
 28          "description": "{{escape .Description}}",
 29          "title": "{{.Title}}",
 30          "contact": {},
 31          "version": "{{.Version}}"
 32      },
 33      "host": "{{.Host}}",
 34      "basePath": "{{.BasePath}}",
 35      "paths": {
 36          "/api/v1/app/taskapi/result/{id}": {
 37              "get": {
 38                  "description": "Retrieve the final result of a completed task. Returns detailed scan results, vulnerabilities found, and security assessment data.",
 39                  "produces": [
 40                      "application/json"
 41                  ],
 42                  "tags": [
 43                      "taskapi"
 44                  ],
 45                  "summary": "Get task result",
 46                  "parameters": [
 47                      {
 48                          "type": "string",
 49                          "description": "Task Session ID",
 50                          "name": "id",
 51                          "in": "path",
 52                          "required": true
 53                      }
 54                  ],
 55                  "responses": {
 56                      "200": {
 57                          "description": "Task result retrieved successfully. Data contains scan results, vulnerabilities, and security findings",
 58                          "schema": {
 59                              "$ref": "#/definitions/websocket.APIResponse"
 60                          }
 61                      },
 62                      "400": {
 63                          "description": "Invalid session ID format",
 64                          "schema": {
 65                              "$ref": "#/definitions/websocket.APIResponse"
 66                          }
 67                      },
 68                      "404": {
 69                          "description": "Task not found or not completed",
 70                          "schema": {
 71                              "$ref": "#/definitions/websocket.APIResponse"
 72                          }
 73                      },
 74                      "500": {
 75                          "description": "Internal server error",
 76                          "schema": {
 77                              "$ref": "#/definitions/websocket.APIResponse"
 78                          }
 79                      }
 80                  }
 81              }
 82          },
 83          "/api/v1/app/taskapi/status/{id}": {
 84              "get": {
 85                  "description": "Retrieve the current status and logs of a task by session ID. Returns task metadata and execution logs.",
 86                  "produces": [
 87                      "application/json"
 88                  ],
 89                  "tags": [
 90                      "taskapi"
 91                  ],
 92                  "summary": "Get task status",
 93                  "parameters": [
 94                      {
 95                          "type": "string",
 96                          "description": "Task Session ID",
 97                          "name": "id",
 98                          "in": "path",
 99                          "required": true
100                      }
101                  ],
102                  "responses": {
103                      "200": {
104                          "description": "Task status retrieved successfully",
105                          "schema": {
106                              "allOf": [
107                                  {
108                                      "$ref": "#/definitions/websocket.APIResponse"
109                                  },
110                                  {
111                                      "type": "object",
112                                      "properties": {
113                                          "data": {
114                                              "$ref": "#/definitions/websocket.TaskStatusResponse"
115                                          }
116                                      }
117                                  }
118                              ]
119                          }
120                      },
121                      "400": {
122                          "description": "Invalid session ID format",
123                          "schema": {
124                              "$ref": "#/definitions/websocket.APIResponse"
125                          }
126                      },
127                      "404": {
128                          "description": "Task not found",
129                          "schema": {
130                              "$ref": "#/definitions/websocket.APIResponse"
131                          }
132                      },
133                      "500": {
134                          "description": "Internal server error",
135                          "schema": {
136                              "$ref": "#/definitions/websocket.APIResponse"
137                          }
138                      }
139                  }
140              }
141          },
142          "/api/v1/app/taskapi/tasks": {
143              "post": {
144                  "description": "Submit a new task for processing. Supports three types of tasks:\n1. MCP Scan (mcp_scan): Model Context Protocol security scanning\n2. AI Infra Scan (ai_infra_scan): AI infrastructure security scanning\n3. Model Redteam Report (model_redteam_report): AI model red team testing\n\nRequest Body Examples:\n\nMCP Scan Task:\n{\n\"type\": \"mcp_scan\",\n\"content\": {\n\"prompt\": \"Custom prompt for scan\",\n\"model\": {\n\"model\": \"gpt-4\",\n\"token\": \"sk-xxx\",\n\"base_url\": \"https://api.openai.com/v1\"\n},\n\"thread\": 4,\n\"language\": \"zh\",\n\"attachments\": \"file.zip\",\n\"headers\": {\n\"Authorization\": \"Bearer token\"\n}\n}\n}\n\nAI Infra Scan Task:\n{\n\"type\": \"ai_infra_scan\",\n\"content\": {\n\"target\": [\"https://example.com\"],\n\"headers\": {\n\"Authorization\": \"Bearer token\"\n},\n\"timeout\": 30,\n\"model\": {\n\"model\": \"gpt-4\",\n\"token\": \"sk-xxx\",\n\"base_url\": \"https://api.openai.com/v1\"\n}\n}\n}\n\nModel Redteam Task:\n{\n\"type\": \"model_redteam_report\",\n\"content\": {\n\"model\": [{\n\"model\": \"gpt-4\",\n\"token\": \"sk-xxx\",\n\"base_url\": \"https://api.openai.com/v1\"\n}],\n\"eval_model\": {\n\"model\": \"gpt-4\",\n\"token\": \"sk-xxx\"\n},\n\"dataset\": {\n\"dataFile\": [\"JailBench-Tiny\", \"JailbreakPrompts-Tiny\"],\n\"numPrompts\": 100,\n\"randomSeed\": 42\n},\n\"prompt\": \"How to make a bomb?\",\n\"techniques\": [\"\"]\n}\n}",
145                  "consumes": [
146                      "application/json"
147                  ],
148                  "produces": [
149                      "application/json"
150                  ],
151                  "tags": [
152                      "taskapi"
153                  ],
154                  "summary": "Create a new task",
155                  "parameters": [
156                      {
157                          "description": "Task request body. Content should be JSON object containing task-specific parameters based on type",
158                          "name": "request",
159                          "in": "body",
160                          "required": true,
161                          "schema": {
162                              "type": "object",
163                              "properties": {
164                                  "content": {
165                                      "type": "object"
166                                  },
167                                  "type": {
168                                      "type": "string"
169                                  }
170                              }
171                          }
172                      }
173                  ],
174                  "responses": {
175                      "200": {
176                          "description": "Task created successfully",
177                          "schema": {
178                              "allOf": [
179                                  {
180                                      "$ref": "#/definitions/websocket.APIResponse"
181                                  },
182                                  {
183                                      "type": "object",
184                                      "properties": {
185                                          "data": {
186                                              "$ref": "#/definitions/websocket.TaskCreateResponse"
187                                          }
188                                      }
189                                  }
190                              ]
191                          }
192                      },
193                      "400": {
194                          "description": "Invalid request parameters",
195                          "schema": {
196                              "$ref": "#/definitions/websocket.APIResponse"
197                          }
198                      },
199                      "500": {
200                          "description": "Internal server error",
201                          "schema": {
202                              "$ref": "#/definitions/websocket.APIResponse"
203                          }
204                      }
205                  }
206              }
207          },
208          "/api/v1/app/taskapi/upload": {
209              "post": {
210                  "description": "Upload a file for task processing. Supports various file formats including zip, json, txt, etc.\nThe uploaded file will be stored securely and can be referenced in task creation.",
211                  "consumes": [
212                      "multipart/form-data"
213                  ],
214                  "produces": [
215                      "application/json"
216                  ],
217                  "tags": [
218                      "taskapi"
219                  ],
220                  "summary": "Upload file",
221                  "parameters": [
222                      {
223                          "type": "file",
224                          "description": "File to upload",
225                          "name": "file",
226                          "in": "formData",
227                          "required": true
228                      }
229                  ],
230                  "responses": {
231                      "200": {
232                          "description": "File uploaded successfully",
233                          "schema": {
234                              "type": "object",
235                              "properties": {
236                                  "data": {
237                                      "type": "object",
238                                      "properties": {
239                                          "fileUrl": {
240                                              "type": "string"
241                                          },
242                                          "filename": {
243                                              "type": "string"
244                                          },
245                                          "size": {
246                                              "type": "integer"
247                                          }
248                                      }
249                                  },
250                                  "message": {
251                                      "type": "string"
252                                  },
253                                  "status": {
254                                      "type": "integer"
255                                  }
256                              }
257                          }
258                      },
259                      "400": {
260                          "description": "Invalid file or upload parameters",
261                          "schema": {
262                              "type": "object",
263                              "properties": {
264                                  "data": {
265                                      "type": "object"
266                                  },
267                                  "message": {
268                                      "type": "string"
269                                  },
270                                  "status": {
271                                      "type": "integer"
272                                  }
273                              }
274                          }
275                      },
276                      "500": {
277                          "description": "Internal server error",
278                          "schema": {
279                              "type": "object",
280                              "properties": {
281                                  "data": {
282                                      "type": "object"
283                                  },
284                                  "message": {
285                                      "type": "string"
286                                  },
287                                  "status": {
288                                      "type": "integer"
289                                  }
290                              }
291                          }
292                      }
293                  }
294              }
295          }
296      },
297      "definitions": {
298          "websocket.APIResponse": {
299              "type": "object",
300              "properties": {
301                  "data": {
302                      "description": "响应数据"
303                  },
304                  "message": {
305                      "description": "响应消息",
306                      "type": "string",
307                      "example": "操作成功"
308                  },
309                  "status": {
310                      "description": "状态码: 0=成功, 1=失败",
311                      "type": "integer",
312                      "example": 0
313                  }
314              }
315          },
316          "websocket.TaskCreateResponse": {
317              "type": "object",
318              "properties": {
319                  "session_id": {
320                      "description": "任务会话ID",
321                      "type": "string",
322                      "example": "550e8400-e29b-41d4-a716-446655440000"
323                  }
324              }
325          },
326          "websocket.TaskStatusResponse": {
327              "type": "object",
328              "properties": {
329                  "created_at": {
330                      "description": "创建时间戳(毫秒)",
331                      "type": "integer",
332                      "example": 1640995200000
333                  },
334                  "log": {
335                      "description": "任务执行日志",
336                      "type": "string",
337                      "example": "任务执行日志..."
338                  },
339                  "session_id": {
340                      "description": "任务会话ID",
341                      "type": "string",
342                      "example": "550e8400-e29b-41d4-a716-446655440000"
343                  },
344                  "status": {
345                      "description": "任务状态: pending, running, completed, failed",
346                      "type": "string",
347                      "example": "running"
348                  },
349                  "title": {
350                      "description": "任务标题",
351                      "type": "string",
352                      "example": "MCP安全扫描任务"
353                  },
354                  "updated_at": {
355                      "description": "更新时间戳(毫秒)",
356                      "type": "integer",
357                      "example": 1640995200000
358                  }
359              }
360          }
361      }
362  }`
363  
364  // SwaggerInfo holds exported Swagger Info so clients can modify it
365  var SwaggerInfo = &swag.Spec{
366  	Version:          "1.0",
367  	Host:             "",
368  	BasePath:         "/",
369  	Schemes:          []string{},
370  	Title:            "AI-Infra-Guard 任务API",
371  	Description:      "API for managing AI security scanning tasks",
372  	InfoInstanceName: "swagger",
373  	SwaggerTemplate:  docTemplate,
374  	LeftDelim:        "{{",
375  	RightDelim:       "}}",
376  }
377  
378  func init() {
379  	swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
380  }