Skip to content
Open
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: 1 addition & 1 deletion packages/base/src/scripts/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const UI_VERSION = 'sync/data-masking 417b194dd';
export const UI_VERSION = 'dev/rule-exc a32b5993';
47 changes: 46 additions & 1 deletion packages/shared/lib/api/sqle/service/audit_whitelist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import {
IGetAuditWhitelistResV1,
ICreateAuditWhitelistReqV1,
IBaseRes,
IUpdateAuditWhitelistReqV1
IUpdateAuditWhitelistReqV1,
ISQLRuleExceptionResV1,
ICreateSQLRuleExceptionReqV1,
IGetSQLRuleExceptionResV1
} from '../common.d';

export interface IGetAuditWhitelistV1Params {
Expand Down Expand Up @@ -42,3 +45,45 @@ export interface IUpdateAuditWhitelistByIdV1Params
}

export interface IUpdateAuditWhitelistByIdV1Return extends IBaseRes {}

export interface ICreateSQLRuleExceptionV1Params
extends ICreateSQLRuleExceptionReqV1 {
project_name: string;
}

export interface ICreateSQLRuleExceptionV1Return extends IBaseRes {
data?: ISQLRuleExceptionResV1;
}

export interface IGetSQLRuleExceptionV1Params {
project_name: string;

fuzzy_search_value?: string;

filter_instance_id?: string;

filter_rule_name?: string;

filter_created_by?: string;

filter_created_time_from?: string;

filter_created_time_to?: string;

filter_sql_fingerprint?: string;

page_index: string;

page_size: string;
}

export interface IGetSQLRuleExceptionV1Return
extends IGetSQLRuleExceptionResV1 {}

export interface IDeleteSQLRuleExceptionV1Params {
project_name: string;

sql_rule_exception_id: string;
}

export interface IDeleteSQLRuleExceptionV1Return extends IBaseRes {}
75 changes: 74 additions & 1 deletion packages/shared/lib/api/sqle/service/audit_whitelist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
IDeleteAuditWhitelistByIdV1Params,
IDeleteAuditWhitelistByIdV1Return,
IUpdateAuditWhitelistByIdV1Params,
IUpdateAuditWhitelistByIdV1Return
IUpdateAuditWhitelistByIdV1Return,
ICreateSQLRuleExceptionV1Params,
ICreateSQLRuleExceptionV1Return,
IDeleteSQLRuleExceptionV1Params,
IDeleteSQLRuleExceptionV1Return,
IGetSQLRuleExceptionV1Params,
IGetSQLRuleExceptionV1Return
} from './index.d';

class AuditWhitelistService extends ServiceBase {
Expand Down Expand Up @@ -48,6 +54,73 @@ class AuditWhitelistService extends ServiceBase {
);
}

public createSQLRuleExceptionV1(
params: ICreateSQLRuleExceptionV1Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

const config = options || {};
const headers = config.headers ? config.headers : {};
config.headers = {
...headers,
'Content-Type': 'application/json'
};
config.transformRequest = [
(data) =>
`{"instance_id":${data.instance_id},"sql_fingerprint":${JSON.stringify(
data.sql_fingerprint ?? ''
)},"rule_name":${JSON.stringify(
data.rule_name ?? ''
)},"rule_desc":${JSON.stringify(
data.rule_desc ?? ''
)},"rule_level":${JSON.stringify(
data.rule_level ?? ''
)},"reason":${JSON.stringify(data.reason ?? '')}}`
];

return this.post<ICreateSQLRuleExceptionV1Return>(
`/v1/projects/${project_name}/audit_whitelist/rule_exceptions`,
paramsData,
config
);
}

public getSQLRuleExceptionV1(
params: IGetSQLRuleExceptionV1Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

return this.get<IGetSQLRuleExceptionV1Return>(
`/v1/projects/${project_name}/audit_whitelist/rule_exceptions`,
paramsData,
options
);
}

public deleteSQLRuleExceptionV1(
params: IDeleteSQLRuleExceptionV1Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

const sql_rule_exception_id = paramsData.sql_rule_exception_id;
delete paramsData.sql_rule_exception_id;

return this.delete<IDeleteSQLRuleExceptionV1Return>(
`/v1/projects/${project_name}/audit_whitelist/rule_exceptions/${sql_rule_exception_id}`,
paramsData,
options
);
}

public deleteAuditWhitelistByIdV1(
params: IDeleteAuditWhitelistByIdV1Params,
options?: AxiosRequestConfig
Expand Down
66 changes: 66 additions & 0 deletions packages/shared/lib/api/sqle/service/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,66 @@ export interface ICreateAuditWhitelistReqV1 {
value?: string;
}

export interface ICreateSQLRuleExceptionReqV1 {
instance_id?: string;

sql_fingerprint?: string;

rule_name?: string;

rule_desc?: string;

rule_level?: string;

reason?: string;
}

export interface ISQLRuleExceptionResV1 {
sql_rule_exception_id?: number;

project_name?: string;

project_id?: string;

instance_id?: string;

instance_name?: string;

sql_fingerprint?: string;

rule_name?: string;

rule_desc?: string;

rule_level?: string;

reason?: string;

created_by?: string;

created_at?: string;

hit_count?: number;

last_match_time?: string;

matched_count?: number;

match_info?: string;

hit_info?: string;
}

export interface IGetSQLRuleExceptionResV1 {
code?: number;

data?: ISQLRuleExceptionResV1[];

message?: string;

total_nums?: number;
}

export interface ICreateBlacklistReqV1 {
content?: string;

Expand Down Expand Up @@ -4619,6 +4679,12 @@ export interface IAuditTaskSQLResV2 {

audit_result?: IAuditResult[];

skipped_audit_result?: (IAuditResult & Partial<ISQLRuleExceptionResV1>)[];

sql_fingerprint?: string;

audit_fingerprint?: string;

audit_status?: string;

backup_result?: string;
Expand Down
14 changes: 14 additions & 0 deletions packages/shared/lib/api/sqle/service/instance/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ export interface IGetInstanceTipListV1Params {

export interface IGetInstanceTipListV1Return extends IGetInstanceTipsResV1 {}

export interface IGetInstanceTipListV2Params {
project_name: string;

filter_db_type?: string;

filter_by_business?: string;

filter_workflow_template_id?: string;

functional_module?: getInstanceTipListV2FunctionalModuleEnum;
}

export interface IGetInstanceTipListV2Return extends IGetInstanceTipsResV2 {}

export interface IBatchCheckInstanceIsConnectableByNameParams
extends IBatchCheckInstanceConnectionsReqV1 {
project_name: string;
Expand Down
34 changes: 17 additions & 17 deletions packages/shared/lib/api/sqle/service/instance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
IGetDatabaseDriverOptionsReturn,
IGetInstanceTipListV1Params,
IGetInstanceTipListV1Return,
IGetInstanceTipListV2Params,
IGetInstanceTipListV2Return,
IBatchCheckInstanceIsConnectableByNameParams,
IBatchCheckInstanceIsConnectableByNameReturn,
ICheckInstanceIsConnectableByNameV1Params,
Expand All @@ -24,8 +26,6 @@ import {
IListTableBySchemaReturn,
IGetTableMetadataParams,
IGetTableMetadataReturn,
IGetInstanceTipListV2Params,
IGetInstanceTipListV2Return,
IGetInstanceV2Params,
IGetInstanceV2Return
} from './index.d';
Expand Down Expand Up @@ -66,6 +66,21 @@ class InstanceService extends ServiceBase {
);
}

public getInstanceTipListV2(
params: IGetInstanceTipListV2Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

return this.get<IGetInstanceTipListV2Return>(
`/v2/projects/${project_name}/instance_tips`,
paramsData,
options
);
}

public batchCheckInstanceIsConnectableByName(
params: IBatchCheckInstanceIsConnectableByNameParams,
options?: AxiosRequestConfig
Expand Down Expand Up @@ -180,21 +195,6 @@ class InstanceService extends ServiceBase {
);
}

public getInstanceTipListV2(
params: IGetInstanceTipListV2Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

return this.get<IGetInstanceTipListV2Return>(
`/v2/projects/${project_name}/instance_tips`,
paramsData,
options
);
}

public getInstanceV2(
params: IGetInstanceV2Params,
options?: AxiosRequestConfig
Expand Down
23 changes: 22 additions & 1 deletion packages/shared/lib/testUtil/mockApi/sqle/auditWhiteList/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { IAuditWhitelistResV1 } from '../../../../api/sqle/service/common';
import {
IAuditWhitelistResV1,
ISQLRuleExceptionResV1
} from '../../../../api/sqle/service/common.d';
import { CreateAuditWhitelistReqV1MatchTypeEnum } from '../../../../api/sqle/service/common.enum';

export const auditWhiteListMockData: IAuditWhitelistResV1[] = [
Expand Down Expand Up @@ -30,3 +33,21 @@ export const auditWhiteListMockData: IAuditWhitelistResV1[] = [
desc: 'test4'
}
];

export const sqlRuleExceptionMockData: ISQLRuleExceptionResV1[] = [
{
sql_rule_exception_id: 11,
project_name: 'default',
instance_id: '1739531854064652288',
instance_name: 'mysql_local_sqle',
sql_fingerprint: 'create table rule_exc_management (id int)',
rule_name: 'ddl_check_pk_not_exist',
rule_desc: '建表语句必须包含主键',
rule_level: 'error',
reason: '标准管理页回归验证',
created_by: 'admin',
created_at: '2026-06-19T02:40:00+00:00',
matched_count: 2,
last_match_time: '2026-06-19T02:50:00+00:00'
}
];
22 changes: 20 additions & 2 deletions packages/shared/lib/testUtil/mockApi/sqle/auditWhiteList/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import audit_whitelist from '../../../../api/sqle/service/audit_whitelist';
import { MockSpyApy, createSpySuccessResponse } from '../../common';
import { auditWhiteListMockData } from './data';
import { MockSpyApy, createSpySuccessResponse } from '../../index';
import { auditWhiteListMockData, sqlRuleExceptionMockData } from './data';

class AuditWhiteList implements MockSpyApy {
public mockAllApi(): void {
this.getAuditWhitelist();
this.deleteAuthWhitelist();
this.addAuthWhitelist();
this.getSQLRuleException();
this.deleteSQLRuleException();
}

public getAuditWhitelist() {
Expand Down Expand Up @@ -36,6 +38,22 @@ class AuditWhiteList implements MockSpyApy {
spy.mockImplementation(() => createSpySuccessResponse({}));
return spy;
}

public getSQLRuleException() {
const spy = jest.spyOn(audit_whitelist, 'getSQLRuleExceptionV1');
spy.mockImplementation(() =>
createSpySuccessResponse({
data: sqlRuleExceptionMockData
})
);
return spy;
}

public deleteSQLRuleException() {
const spy = jest.spyOn(audit_whitelist, 'deleteSQLRuleExceptionV1');
spy.mockImplementation(() => createSpySuccessResponse({}));
return spy;
}
}

export default new AuditWhiteList();
Loading
Loading