/ docs / swagger.json
swagger.json
  1  {
  2      "swagger": "2.0",
  3      "info": {
  4          "description": "API for managing AI security scanning tasks",
  5          "title": "AI-Infra-Guard 任务API",
  6          "contact": {},
  7          "version": "1.0"
  8      },
  9      "basePath": "/",
 10      "paths": {
 11          "/api/v1/app/taskapi/result/{id}": {
 12              "get": {
 13                  "description": "Retrieve the final result of a completed task. Returns detailed scan results, vulnerabilities found, and security assessment data.",
 14                  "produces": [
 15                      "application/json"
 16                  ],
 17                  "tags": [
 18                      "taskapi"
 19                  ],
 20                  "summary": "Get task result",
 21                  "parameters": [
 22                      {
 23                          "type": "string",
 24                          "description": "Task Session ID",
 25                          "name": "id",
 26                          "in": "path",
 27                          "required": true
 28                      }
 29                  ],
 30                  "responses": {
 31                      "200": {
 32                          "description": "Task result retrieved successfully. Data contains scan results, vulnerabilities, and security findings",
 33                          "schema": {
 34                              "$ref": "#/definitions/websocket.APIResponse"
 35                          }
 36                      },
 37                      "400": {
 38                          "description": "Invalid session ID format",
 39                          "schema": {
 40                              "$ref": "#/definitions/websocket.APIResponse"
 41                          }
 42                      },
 43                      "404": {
 44                          "description": "Task not found or not completed",
 45                          "schema": {
 46                              "$ref": "#/definitions/websocket.APIResponse"
 47                          }
 48                      },
 49                      "500": {
 50                          "description": "Internal server error",
 51                          "schema": {
 52                              "$ref": "#/definitions/websocket.APIResponse"
 53                          }
 54                      }
 55                  }
 56              }
 57          },
 58          "/api/v1/app/taskapi/status/{id}": {
 59              "get": {
 60                  "description": "Retrieve the current status and logs of a task by session ID. Returns task metadata and execution logs.",
 61                  "produces": [
 62                      "application/json"
 63                  ],
 64                  "tags": [
 65                      "taskapi"
 66                  ],
 67                  "summary": "Get task status",
 68                  "parameters": [
 69                      {
 70                          "type": "string",
 71                          "description": "Task Session ID",
 72                          "name": "id",
 73                          "in": "path",
 74                          "required": true
 75                      }
 76                  ],
 77                  "responses": {
 78                      "200": {
 79                          "description": "Task status retrieved successfully",
 80                          "schema": {
 81                              "allOf": [
 82                                  {
 83                                      "$ref": "#/definitions/websocket.APIResponse"
 84                                  },
 85                                  {
 86                                      "type": "object",
 87                                      "properties": {
 88                                          "data": {
 89                                              "$ref": "#/definitions/websocket.TaskStatusResponse"
 90                                          }
 91                                      }
 92                                  }
 93                              ]
 94                          }
 95                      },
 96                      "400": {
 97                          "description": "Invalid session ID format",
 98                          "schema": {
 99                              "$ref": "#/definitions/websocket.APIResponse"
100                          }
101                      },
102                      "404": {
103                          "description": "Task not found",
104                          "schema": {
105                              "$ref": "#/definitions/websocket.APIResponse"
106                          }
107                      },
108                      "500": {
109                          "description": "Internal server error",
110                          "schema": {
111                              "$ref": "#/definitions/websocket.APIResponse"
112                          }
113                      }
114                  }
115              }
116          },
117          "/api/v1/app/taskapi/tasks": {
118              "post": {
119                  "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}",
120                  "consumes": [
121                      "application/json"
122                  ],
123                  "produces": [
124                      "application/json"
125                  ],
126                  "tags": [
127                      "taskapi"
128                  ],
129                  "summary": "Create a new task",
130                  "parameters": [
131                      {
132                          "description": "Task request body. Content should be JSON object containing task-specific parameters based on type",
133                          "name": "request",
134                          "in": "body",
135                          "required": true,
136                          "schema": {
137                              "type": "object",
138                              "properties": {
139                                  "content": {
140                                      "type": "object"
141                                  },
142                                  "type": {
143                                      "type": "string"
144                                  }
145                              }
146                          }
147                      }
148                  ],
149                  "responses": {
150                      "200": {
151                          "description": "Task created successfully",
152                          "schema": {
153                              "allOf": [
154                                  {
155                                      "$ref": "#/definitions/websocket.APIResponse"
156                                  },
157                                  {
158                                      "type": "object",
159                                      "properties": {
160                                          "data": {
161                                              "$ref": "#/definitions/websocket.TaskCreateResponse"
162                                          }
163                                      }
164                                  }
165                              ]
166                          }
167                      },
168                      "400": {
169                          "description": "Invalid request parameters",
170                          "schema": {
171                              "$ref": "#/definitions/websocket.APIResponse"
172                          }
173                      },
174                      "500": {
175                          "description": "Internal server error",
176                          "schema": {
177                              "$ref": "#/definitions/websocket.APIResponse"
178                          }
179                      }
180                  }
181              }
182          },
183          "/api/v1/app/taskapi/upload": {
184              "post": {
185                  "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.",
186                  "consumes": [
187                      "multipart/form-data"
188                  ],
189                  "produces": [
190                      "application/json"
191                  ],
192                  "tags": [
193                      "taskapi"
194                  ],
195                  "summary": "Upload file",
196                  "parameters": [
197                      {
198                          "type": "file",
199                          "description": "File to upload",
200                          "name": "file",
201                          "in": "formData",
202                          "required": true
203                      }
204                  ],
205                  "responses": {
206                      "200": {
207                          "description": "File uploaded successfully",
208                          "schema": {
209                              "type": "object",
210                              "properties": {
211                                  "data": {
212                                      "type": "object",
213                                      "properties": {
214                                          "fileUrl": {
215                                              "type": "string"
216                                          },
217                                          "filename": {
218                                              "type": "string"
219                                          },
220                                          "size": {
221                                              "type": "integer"
222                                          }
223                                      }
224                                  },
225                                  "message": {
226                                      "type": "string"
227                                  },
228                                  "status": {
229                                      "type": "integer"
230                                  }
231                              }
232                          }
233                      },
234                      "400": {
235                          "description": "Invalid file or upload parameters",
236                          "schema": {
237                              "type": "object",
238                              "properties": {
239                                  "data": {
240                                      "type": "object"
241                                  },
242                                  "message": {
243                                      "type": "string"
244                                  },
245                                  "status": {
246                                      "type": "integer"
247                                  }
248                              }
249                          }
250                      },
251                      "500": {
252                          "description": "Internal server error",
253                          "schema": {
254                              "type": "object",
255                              "properties": {
256                                  "data": {
257                                      "type": "object"
258                                  },
259                                  "message": {
260                                      "type": "string"
261                                  },
262                                  "status": {
263                                      "type": "integer"
264                                  }
265                              }
266                          }
267                      }
268                  }
269              }
270          }
271      },
272      "definitions": {
273          "websocket.APIResponse": {
274              "type": "object",
275              "properties": {
276                  "data": {
277                      "description": "响应数据"
278                  },
279                  "message": {
280                      "description": "响应消息",
281                      "type": "string",
282                      "example": "操作成功"
283                  },
284                  "status": {
285                      "description": "状态码: 0=成功, 1=失败",
286                      "type": "integer",
287                      "example": 0
288                  }
289              }
290          },
291          "websocket.TaskCreateResponse": {
292              "type": "object",
293              "properties": {
294                  "session_id": {
295                      "description": "任务会话ID",
296                      "type": "string",
297                      "example": "550e8400-e29b-41d4-a716-446655440000"
298                  }
299              }
300          },
301          "websocket.TaskStatusResponse": {
302              "type": "object",
303              "properties": {
304                  "created_at": {
305                      "description": "创建时间戳(毫秒)",
306                      "type": "integer",
307                      "example": 1640995200000
308                  },
309                  "log": {
310                      "description": "任务执行日志",
311                      "type": "string",
312                      "example": "任务执行日志..."
313                  },
314                  "session_id": {
315                      "description": "任务会话ID",
316                      "type": "string",
317                      "example": "550e8400-e29b-41d4-a716-446655440000"
318                  },
319                  "status": {
320                      "description": "任务状态: pending, running, completed, failed",
321                      "type": "string",
322                      "example": "running"
323                  },
324                  "title": {
325                      "description": "任务标题",
326                      "type": "string",
327                      "example": "MCP安全扫描任务"
328                  },
329                  "updated_at": {
330                      "description": "更新时间戳(毫秒)",
331                      "type": "integer",
332                      "example": 1640995200000
333                  }
334              }
335          }
336      }
337  }