openapi: 3.0.3 info: title: AegisDAST API version: 0.1.0 description: | REST API cho hệ thống DAST tích hợp AI. Tất cả endpoint (trừ auth) yêu cầu `Authorization: Bearer `. servers: - url: http://localhost:8000/api/v1 tags: - name: Auth - name: Targets - name: Scans - name: Vulnerabilities - name: Reports - name: Stats components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: Error: type: object properties: detail: { type: string } UserRegister: type: object required: [email, username, password] properties: email: { type: string, format: email } username: { type: string, minLength: 3, maxLength: 32 } password: { type: string, minLength: 8 } UserLogin: type: object required: [username, password] properties: username: { type: string } password: { type: string } TokenPair: type: object properties: access_token: { type: string } refresh_token: { type: string } token_type: { type: string, example: bearer } Target: type: object properties: id: { type: string } name: { type: string } base_url: { type: string } scope_regex: { type: string } auth: type: object properties: type: { type: string, enum: [none, basic, form, bearer] } tags: { type: array, items: { type: string } } verified_ownership: { type: boolean } created_at: { type: string, format: date-time } TargetCreate: type: object required: [name, base_url, verified_ownership] properties: name: { type: string } base_url: { type: string } scope_regex: { type: string } auth: type: object properties: type: { type: string, enum: [none, basic, form, bearer] } credentials: { type: object, additionalProperties: true } tags: { type: array, items: { type: string } } verified_ownership: { type: boolean } ScanConfig: type: object properties: max_depth: { type: integer, default: 3 } max_urls: { type: integer, default: 500 } concurrency: { type: integer, default: 10 } use_playwright: { type: boolean, default: false } ai_enabled: { type: boolean, default: true } modules: type: array items: type: string enum: [sqli, xss, cmdi, path_traversal, misconfig, exposure] ScanCreate: type: object required: [target_id] properties: target_id: { type: string } profile: { type: string, enum: [quick, full, custom], default: quick } config: { $ref: '#/components/schemas/ScanConfig' } Scan: type: object properties: id: { type: string } target_id: { type: string } profile: { type: string } status: type: string enum: [queued, crawling, scanning, analyzing, reporting, completed, failed, cancelled] progress: { type: object, additionalProperties: true } stats: { type: object, additionalProperties: true } started_at: { type: string, format: date-time } completed_at: { type: string, format: date-time, nullable: true } Vulnerability: type: object properties: id: { type: string } scan_id: { type: string } target_id: { type: string } vuln_type: { type: string } subtype: { type: string } title: { type: string } severity: { type: string, enum: [critical, high, medium, low, info] } confidence: { type: number } cwe: { type: string } owasp: { type: string } endpoint: { type: object, additionalProperties: true } payload: { type: string } evidence: { type: object, additionalProperties: true } request: { type: object, additionalProperties: true } response: { type: object, additionalProperties: true } ai_analysis: { type: object, nullable: true, additionalProperties: true } status: { type: string, enum: [open, false_positive, fixed, accepted_risk] } security: - bearerAuth: [] paths: /auth/register: post: tags: [Auth] security: [] summary: Đăng ký user mới requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/UserRegister' } responses: '201': { description: Created } '409': { description: Email/username exists } /auth/login: post: tags: [Auth] security: [] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/UserLogin' } responses: '200': description: OK content: application/json: schema: { $ref: '#/components/schemas/TokenPair' } '401': { description: Invalid credentials } /auth/refresh: post: tags: [Auth] summary: Đổi refresh token lấy access token mới responses: '200': { description: OK } /auth/me: get: tags: [Auth] responses: '200': { description: Current user info } /targets: get: tags: [Targets] parameters: - in: query name: q schema: { type: string } responses: '200': description: List content: application/json: schema: type: array items: { $ref: '#/components/schemas/Target' } post: tags: [Targets] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/TargetCreate' } responses: '201': description: Created content: application/json: schema: { $ref: '#/components/schemas/Target' } /targets/{id}: parameters: - in: path name: id required: true schema: { type: string } get: tags: [Targets] responses: '200': description: OK content: application/json: schema: { $ref: '#/components/schemas/Target' } patch: tags: [Targets] requestBody: content: application/json: schema: { $ref: '#/components/schemas/TargetCreate' } responses: '200': { description: OK } delete: tags: [Targets] responses: '204': { description: No Content } /scans: get: tags: [Scans] parameters: - in: query name: target_id schema: { type: string } - in: query name: status schema: { type: string } - in: query name: limit schema: { type: integer, default: 20 } responses: '200': description: List content: application/json: schema: type: array items: { $ref: '#/components/schemas/Scan' } post: tags: [Scans] summary: Tạo & enqueue scan requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/ScanCreate' } responses: '202': description: Accepted (queued) content: application/json: schema: { $ref: '#/components/schemas/Scan' } /scans/{id}: parameters: - in: path name: id required: true schema: { type: string } get: tags: [Scans] responses: '200': description: OK content: application/json: schema: { $ref: '#/components/schemas/Scan' } /scans/{id}/cancel: parameters: - { in: path, name: id, required: true, schema: { type: string } } post: tags: [Scans] responses: { '200': { description: OK } } /scans/{id}/vulnerabilities: parameters: - { in: path, name: id, required: true, schema: { type: string } } get: tags: [Vulnerabilities] responses: '200': description: List content: application/json: schema: type: array items: { $ref: '#/components/schemas/Vulnerability' } /vulnerabilities/{id}: parameters: - { in: path, name: id, required: true, schema: { type: string } } get: tags: [Vulnerabilities] responses: '200': description: OK content: application/json: schema: { $ref: '#/components/schemas/Vulnerability' } patch: tags: [Vulnerabilities] summary: Cập nhật trạng thái (mark FP, fixed,…) requestBody: content: application/json: schema: type: object properties: status: { type: string } user_notes: { type: string } responses: { '200': { description: OK } } /scans/{id}/report: parameters: - { in: path, name: id, required: true, schema: { type: string } } post: tags: [Reports] summary: Sinh report (HTML/PDF) requestBody: content: application/json: schema: type: object properties: format: { type: string, enum: [html, pdf], default: pdf } responses: '200': { description: Report metadata } /reports/{id}/download: parameters: - { in: path, name: id, required: true, schema: { type: string } } get: tags: [Reports] responses: '200': description: File content: application/pdf: {} text/html: {} /stats/dashboard: get: tags: [Stats] responses: '200': description: Aggregated stats cho dashboard content: application/json: schema: type: object properties: total_targets: { type: integer } total_scans: { type: integer } total_vulns_by_severity: { type: object } recent_scans: type: array items: { $ref: '#/components/schemas/Scan' }