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