Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit plan sqls api #2537

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 34 additions & 0 deletions sqle/api/controller/v1/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
267 changes: 266 additions & 1 deletion sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -5556,7 +5728,7 @@ var doc = `{
"tags": [
"workflow"
],
"summary": "获取工单附件",
"summary": "获取工单的task附件",
"operationId": "getWorkflowAttachment",
"parameters": [
{
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -15784,6 +16046,9 @@ var doc = `{
"last_receive_timestamp": {
"type": "string"
},
"priority": {
"type": "string"
},
"remark": {
"type": "string"
},
Expand Down
Loading
Loading