diff --git a/sqle/api/app.go b/sqle/api/app.go index f5213340e..5fe7a98f8 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -280,6 +280,8 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_id/sql_meta", v1.GetInstanceAuditPlanSQLMeta) v1ProjectRouter.POST("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_id/sql_data", v1.GetInstanceAuditPlanSQLData) v1ProjectRouter.POST("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_id/sql_export", v1.GetInstanceAuditPlanSQLExport) + v1ProjectRouter.POST("/:project_name/instance_audit_plans/:instance_audit_plan_id/audit_plans/:audit_plan_id/audit", v1.AuditPlanTriggerSqlAudit) + v1ProjectRouter.GET("/:project_name/instance_audit_plans/:instance_audit_plan_id/sqls/:id/analysis", v1.GetAuditPlanSqlAnalysisData) // sql manager v1ProjectRouter.GET("/:project_name/sql_manages", v1.GetSqlManageList) diff --git a/sqle/api/controller/v1/instance_audit_plan.go b/sqle/api/controller/v1/instance_audit_plan.go index 484b6ecf0..3f7f21768 100644 --- a/sqle/api/controller/v1/instance_audit_plan.go +++ b/sqle/api/controller/v1/instance_audit_plan.go @@ -1213,3 +1213,37 @@ func ConvertReqToAuditPlanFilter(fs []Filter) []auditplan.Filter { } return filters } + +// GetAuditPlanSqlAnalysisData get SQL explain and related table metadata for analysis +// @Summary 获取扫描任务相关的SQL执行计划和表元数据 +// @Description get SQL explain and related table metadata for analysis +// @Id getAuditPlanSqlAnalysisDataV1 +// @Tags instance_audit_plan +// @Param project_name path string true "project name" +// @Param instance_audit_plan_id path string true "instance audit plan id" +// @Param id path string true "audit plan sql id" +// @Security ApiKeyAuth +// @Success 200 {object} v1.GetSqlManageSqlAnalysisResp +// @router /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/sqls/{id}/analysis [get] +func GetAuditPlanSqlAnalysisData(c echo.Context) error { + + return c.JSON(http.StatusOK, &GetSqlManageSqlAnalysisResp{ + BaseRes: controller.NewBaseReq(nil), + Data: nil, + }) +} + +// @Summary 扫描任务触发sql审核 +// @Description audit plan trigger sql audit +// @Id auditPlanTriggerSqlAuditV1 +// @Tags instance_audit_plan +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param instance_audit_plan_id path string true "instance audit plan id" +// @Param audit_plan_id path string true "audit plan id" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/audit [post] +func AuditPlanTriggerSqlAudit(c echo.Context) error { + + return controller.JSONBaseErrorReq(c, nil) +} diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 1ff039273..93fa2e4e4 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -2528,6 +2528,52 @@ var doc = `{ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/audit": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "audit plan trigger sql audit", + "tags": [ + "instance_audit_plan" + ], + "summary": "扫描任务触发sql审核", + "operationId": "auditPlanTriggerSqlAuditV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan id", + "name": "audit_plan_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/sql_data": { "post": { "security": [ @@ -2744,6 +2790,52 @@ var doc = `{ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/sqls/{id}/analysis": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get SQL explain and related table metadata for analysis", + "tags": [ + "instance_audit_plan" + ], + "summary": "获取扫描任务相关的SQL执行计划和表元数据", + "operationId": "getAuditPlanSqlAnalysisDataV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan sql id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlManageSqlAnalysisResp" + } + } + } + } + }, "/v1/projects/{project_name}/instance_tips": { "get": { "security": [ @@ -3063,6 +3155,86 @@ var doc = `{ } } }, + "/v1/projects/{project_name}/report_push_configs": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get report push config list", + "tags": [ + "ReportPushConfig" + ], + "summary": "获取消息推送配置列表", + "operationId": "GetReportPushConfigList", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetReportPushConfigsListResV1" + } + } + } + } + }, + "/v1/projects/{project_name}/report_push_configs/{report_push_config_id}/": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update report push config", + "tags": [ + "ReportPushConfig" + ], + "summary": "更新消息推送配置", + "operationId": "UpdateReportPushConfig", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "report push config id", + "name": "report_push_config_id", + "in": "path", + "required": true + }, + { + "description": "update report push config request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.UpdateReportPushConfigReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/rule_template_tips": { "get": { "security": [ @@ -5556,7 +5728,7 @@ var doc = `{ "tags": [ "workflow" ], - "summary": "获取工单附件", + "summary": "获取工单的task附件", "operationId": "getWorkflowAttachment", "parameters": [ { @@ -11572,6 +11744,25 @@ var doc = `{ } } }, + "v1.GetReportPushConfigsListResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.ReportPushConfigList" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetRiskAuditPlanResV1": { "type": "object", "properties": { @@ -13110,6 +13301,46 @@ var doc = `{ } } }, + "v1.ReportPushConfigList": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "last_push_time": { + "type": "string" + }, + "push_frequency_cron": { + "type": "string" + }, + "push_user_Type": { + "type": "string", + "enum": [ + "fixed", + "permission_match" + ] + }, + "push_user_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "report_push_config_id": { + "type": "string" + }, + "trigger_type": { + "type": "string", + "enum": [ + "immediately", + "timing" + ] + }, + "type": { + "type": "string" + } + } + }, "v1.RewriteRule": { "type": "object", "properties": { @@ -14290,6 +14521,37 @@ var doc = `{ } } }, + "v1.UpdateReportPushConfigReqV1": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "push_frequency_cron": { + "type": "string" + }, + "push_user_Type": { + "type": "string", + "enum": [ + "fixed", + "permission_match" + ] + }, + "push_user_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "trigger_type": { + "type": "string", + "enum": [ + "immediately", + "timing" + ] + } + } + }, "v1.UpdateRuleKnowledgeReq": { "type": "object", "properties": { @@ -15784,6 +16046,9 @@ var doc = `{ "last_receive_timestamp": { "type": "string" }, + "priority": { + "type": "string" + }, "remark": { "type": "string" }, diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 08c38f524..4fbc44741 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -2512,6 +2512,52 @@ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/audit": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "audit plan trigger sql audit", + "tags": [ + "instance_audit_plan" + ], + "summary": "扫描任务触发sql审核", + "operationId": "auditPlanTriggerSqlAuditV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan id", + "name": "audit_plan_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/sql_data": { "post": { "security": [ @@ -2728,6 +2774,52 @@ } } }, + "/v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/sqls/{id}/analysis": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get SQL explain and related table metadata for analysis", + "tags": [ + "instance_audit_plan" + ], + "summary": "获取扫描任务相关的SQL执行计划和表元数据", + "operationId": "getAuditPlanSqlAnalysisDataV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance audit plan id", + "name": "instance_audit_plan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "audit plan sql id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlManageSqlAnalysisResp" + } + } + } + } + }, "/v1/projects/{project_name}/instance_tips": { "get": { "security": [ @@ -3047,6 +3139,86 @@ } } }, + "/v1/projects/{project_name}/report_push_configs": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Get report push config list", + "tags": [ + "ReportPushConfig" + ], + "summary": "获取消息推送配置列表", + "operationId": "GetReportPushConfigList", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetReportPushConfigsListResV1" + } + } + } + } + }, + "/v1/projects/{project_name}/report_push_configs/{report_push_config_id}/": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update report push config", + "tags": [ + "ReportPushConfig" + ], + "summary": "更新消息推送配置", + "operationId": "UpdateReportPushConfig", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "report push config id", + "name": "report_push_config_id", + "in": "path", + "required": true + }, + { + "description": "update report push config request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.UpdateReportPushConfigReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/rule_template_tips": { "get": { "security": [ @@ -5540,7 +5712,7 @@ "tags": [ "workflow" ], - "summary": "获取工单附件", + "summary": "获取工单的task附件", "operationId": "getWorkflowAttachment", "parameters": [ { @@ -11556,6 +11728,25 @@ } } }, + "v1.GetReportPushConfigsListResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.ReportPushConfigList" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetRiskAuditPlanResV1": { "type": "object", "properties": { @@ -13094,6 +13285,46 @@ } } }, + "v1.ReportPushConfigList": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "last_push_time": { + "type": "string" + }, + "push_frequency_cron": { + "type": "string" + }, + "push_user_Type": { + "type": "string", + "enum": [ + "fixed", + "permission_match" + ] + }, + "push_user_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "report_push_config_id": { + "type": "string" + }, + "trigger_type": { + "type": "string", + "enum": [ + "immediately", + "timing" + ] + }, + "type": { + "type": "string" + } + } + }, "v1.RewriteRule": { "type": "object", "properties": { @@ -14274,6 +14505,37 @@ } } }, + "v1.UpdateReportPushConfigReqV1": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "push_frequency_cron": { + "type": "string" + }, + "push_user_Type": { + "type": "string", + "enum": [ + "fixed", + "permission_match" + ] + }, + "push_user_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "trigger_type": { + "type": "string", + "enum": [ + "immediately", + "timing" + ] + } + } + }, "v1.UpdateRuleKnowledgeReq": { "type": "object", "properties": { @@ -15768,6 +16030,9 @@ "last_receive_timestamp": { "type": "string" }, + "priority": { + "type": "string" + }, "remark": { "type": "string" }, diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 774b5e114..8e798ba56 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -1648,6 +1648,19 @@ definitions: example: ok type: string type: object + v1.GetReportPushConfigsListResV1: + properties: + code: + example: 0 + type: integer + data: + items: + $ref: '#/definitions/v1.ReportPushConfigList' + type: array + message: + example: ok + type: string + type: object v1.GetRiskAuditPlanResV1: properties: code: @@ -2698,6 +2711,33 @@ definitions: reason: type: string type: object + v1.ReportPushConfigList: + properties: + enabled: + type: boolean + last_push_time: + type: string + push_frequency_cron: + type: string + push_user_Type: + enum: + - fixed + - permission_match + type: string + push_user_list: + items: + type: string + type: array + report_push_config_id: + type: string + trigger_type: + enum: + - immediately + - timing + type: string + type: + type: string + type: object v1.RewriteRule: properties: message: @@ -3493,6 +3533,27 @@ definitions: $ref: '#/definitions/v1.RuleReqV1' type: array type: object + v1.UpdateReportPushConfigReqV1: + properties: + enabled: + type: boolean + push_frequency_cron: + type: string + push_user_Type: + enum: + - fixed + - permission_match + type: string + push_user_list: + items: + type: string + type: array + trigger_type: + enum: + - immediately + - timing + type: string + type: object v1.UpdateRuleKnowledgeReq: properties: knowledge_content: @@ -4510,6 +4571,8 @@ definitions: type: string last_receive_timestamp: type: string + priority: + type: string remark: type: string schema_name: @@ -6274,6 +6337,36 @@ paths: summary: 更新扫描任务状态 tags: - instance_audit_plan + /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/audit: + post: + description: audit plan trigger sql audit + operationId: auditPlanTriggerSqlAuditV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: instance audit plan id + in: path + name: instance_audit_plan_id + required: true + type: string + - description: audit plan id + in: path + name: audit_plan_id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 扫描任务触发sql审核 + tags: + - instance_audit_plan /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/audit_plans/{audit_plan_id}/sql_data: post: description: get audit plan SQLs @@ -6416,6 +6509,36 @@ paths: summary: 获取指定扫描任务的SQLs信息 tags: - instance_audit_plan + /v1/projects/{project_name}/instance_audit_plans/{instance_audit_plan_id}/sqls/{id}/analysis: + get: + description: get SQL explain and related table metadata for analysis + operationId: getAuditPlanSqlAnalysisDataV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: instance audit plan id + in: path + name: instance_audit_plan_id + required: true + type: string + - description: audit plan sql id + in: path + name: id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetSqlManageSqlAnalysisResp' + security: + - ApiKeyAuth: [] + summary: 获取扫描任务相关的SQL执行计划和表元数据 + tags: + - instance_audit_plan /v1/projects/{project_name}/instance_tips: get: description: get instance tip list @@ -6623,6 +6746,57 @@ paths: summary: 批量测试实例连通性(实例提交后) tags: - instance + /v1/projects/{project_name}/report_push_configs: + get: + description: Get report push config list + operationId: GetReportPushConfigList + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetReportPushConfigsListResV1' + security: + - ApiKeyAuth: [] + summary: 获取消息推送配置列表 + tags: + - ReportPushConfig + /v1/projects/{project_name}/report_push_configs/{report_push_config_id}/: + put: + description: update report push config + operationId: UpdateReportPushConfig + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: report push config id + in: path + name: report_push_config_id + required: true + type: string + - description: update report push config request + in: body + name: req + required: true + schema: + $ref: '#/definitions/v1.UpdateReportPushConfigReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 更新消息推送配置 + tags: + - ReportPushConfig /v1/projects/{project_name}/rule_template_tips: get: description: get rule template tips in project @@ -8140,7 +8314,7 @@ paths: type: file security: - ApiKeyAuth: [] - summary: 获取工单附件 + summary: 获取工单的task附件 tags: - workflow /v1/projects/{project_name}/workflows/{workflow_id}/tasks/{task_id}/order_file: