Skip to content

Commit

Permalink
[feature]: Support fast SQL auditing
Browse files Browse the repository at this point in the history
  • Loading branch information
LZS911 committed Sep 12, 2023
1 parent 9b663b4 commit 6af2630
Show file tree
Hide file tree
Showing 33 changed files with 2,135 additions and 83 deletions.
2 changes: 1 addition & 1 deletion craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = {
const res = {};
for (let i = 0; i < 10; i++) {
res[`/v${i}`] = {
target: 'http://10.186.60.56:10001',
target: 'http://124.70.158.246:8889',
secure: false,
changeOrigin: true,
ws: true,
Expand Down
114 changes: 111 additions & 3 deletions src/api/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ export interface ICreateRuleTemplateReqV1 {
rule_template_name?: string;
}

export interface ICreateSQLAuditRecordResV1 {
code?: number;

data?: ISQLAuditRecordResData;

message?: string;
}

export interface ICreateSyncInstanceTaskReqV1 {
db_type: string;

Expand Down Expand Up @@ -1229,6 +1237,32 @@ export interface IGetSQLAnalysisDataResItemV1 {
table_metas?: ITableMeta[];
}

export interface IGetSQLAuditRecordResV1 {
code?: number;

data?: ISQLAuditRecord;

message?: string;
}

export interface IGetSQLAuditRecordTagTipsResV1 {
code?: number;

data?: string[];

message?: string;
}

export interface IGetSQLAuditRecordsResV1 {
code?: number;

data?: ISQLAuditRecord[];

message?: string;

total_nums?: number;
}

export interface IGetSQLEInfoResDataV1 {
logo_url?: string;

Expand Down Expand Up @@ -1275,6 +1309,16 @@ export interface IGetSqlExecutionFailPercentResV1 {
message?: string;
}

export interface IGetSqlManageListResp {
code?: number;

data?: ISqlManage[];

message?: string;

total_nums?: number;
}

export interface IGetSyncInstanceTaskListResV1 {
code?: number;

Expand Down Expand Up @@ -2091,6 +2135,32 @@ export interface ISMTPConfigurationResV1 {
smtp_username?: string;
}

export interface ISQLAuditRecord {
creator?: string;

instance?: ISQLAuditRecordInstance;

sql_audit_record_id?: number;

sql_audit_status?: string;

tags?: string[];

task?: IAuditTaskResV1;
}

export interface ISQLAuditRecordInstance {
db_host?: string;

db_port?: string;
}

export interface ISQLAuditRecordResData {
sql_audit_record_id?: string;

task?: IAuditTaskResV1;
}

export interface ISQLExplain {
classic_result?: IExplainClassicResult;

Expand Down Expand Up @@ -2141,6 +2211,38 @@ export interface ISqlExecutionFailPercent {
percent?: number;
}

export interface ISqlManage {
appear_num?: number;

assignee?: string;

audit_result?: string;

first_appear_time?: string;

id?: number;

instance?: string;

last_appear_time?: string;

remark?: string;

source?: string;

sql?: string;

sql_fingerprint?: string;

sql_manage_bad_num?: number;

sql_manage_optimized_num?: number;

sql_manage_total_num?: number;

status?: string;
}

export interface IStatisticAuditPlanResV1 {
code?: number;

Expand Down Expand Up @@ -2424,11 +2526,11 @@ export interface IUpdateDingTalkConfigurationReqV1 {
}

export interface IUpdateFeishuConfigurationReqV1 {
app_id?: string;
app_id: string;

app_secret?: string;
app_secret: string;

is_feishu_notification_enabled?: boolean;
is_feishu_notification_enabled: boolean;
}

export interface IUpdateInstanceReqV1 {
Expand Down Expand Up @@ -2507,6 +2609,12 @@ export interface IUpdateSMTPConfigurationReqV1 {
smtp_username?: string;
}

export interface IUpdateSQLAuditRecordReqV1 {
sql_audit_record_id?: string;

tags?: string[];
}

export interface IUpdateSyncInstanceTaskReqV1 {
global_rule_template?: string;

Expand Down
4 changes: 3 additions & 1 deletion src/api/instance/index.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
export enum getInstanceTipListV1FunctionalModuleEnum {
'create_audit_plan' = 'create_audit_plan',

'create_workflow' = 'create_workflow'
'create_workflow' = 'create_workflow',

'sql_manage' = 'sql_manage'
}
73 changes: 73 additions & 0 deletions src/api/sql_audit_record/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { getSQLAuditRecordsV1FilterSqlAuditStatusEnum } from './index.enum';

import {
IGetSQLAuditRecordsResV1,
ICreateSQLAuditRecordResV1,
IGetSQLAuditRecordTagTipsResV1,
IGetSQLAuditRecordResV1,
IUpdateSQLAuditRecordReqV1,
IBaseRes
} from '../common.d';

export interface IGetSQLAuditRecordsV1Params {
fuzzy_search_tags?: string;

filter_sql_audit_status?: getSQLAuditRecordsV1FilterSqlAuditStatusEnum;

filter_instance_name?: string;

filter_create_time_from?: string;

filter_create_time_to?: string;

page_index: number;

page_size: number;

project_name: string;
}

export interface IGetSQLAuditRecordsV1Return extends IGetSQLAuditRecordsResV1 {}

export interface ICreateSQLAuditRecordV1Params {
project_name: string;

instance_name?: string;

instance_schema?: string;

db_type?: string;

sql?: string;

input_sql_file?: any;

input_mybatis_xml_file?: any;

input_zip_file?: any;
}

export interface ICreateSQLAuditRecordV1Return
extends ICreateSQLAuditRecordResV1 {}

export interface IGetSQLAuditRecordTagTipsV1Params {
project_name: string;
}

export interface IGetSQLAuditRecordTagTipsV1Return
extends IGetSQLAuditRecordTagTipsResV1 {}

export interface IGetSQLAuditRecordV1Params {
project_name: string;

sql_audit_record_id: string;
}

export interface IGetSQLAuditRecordV1Return extends IGetSQLAuditRecordResV1 {}

export interface IUpdateSQLAuditRecordV1Params
extends IUpdateSQLAuditRecordReqV1 {
project_name: string;
}

export interface IUpdateSQLAuditRecordV1Return extends IBaseRes {}
7 changes: 7 additions & 0 deletions src/api/sql_audit_record/index.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* tslint:disable no-duplicate-string */

export enum getSQLAuditRecordsV1FilterSqlAuditStatusEnum {
'auditing' = 'auditing',

'successfully' = 'successfully'
}
Loading

0 comments on commit 6af2630

Please sign in to comment.