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
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 @@ -529,6 +529,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 @@ -3126,6 +3186,12 @@ export interface IAuditTaskSQLResV2 {

audit_result?: IAuditResult[];

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

sql_fingerprint?: string;

audit_fingerprint?: string;

audit_status?: string;

description?: string;
Expand Down
5 changes: 5 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 @@ -26,6 +26,11 @@ export interface IGetInstanceTipListV1Params {

export interface IGetInstanceTipListV1Return extends IGetInstanceTipsResV1 {}

export interface IGetInstanceTipListV2Params
extends IGetInstanceTipListV1Params {}

export interface IGetInstanceTipListV2Return extends IGetInstanceTipsResV1 {}

export interface IBatchCheckInstanceIsConnectableByNameParams
extends IBatchCheckInstanceConnectionsReqV1 {
project_name: string;
Expand Down
17 changes: 17 additions & 0 deletions packages/shared/lib/api/sqle/service/instance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { AxiosRequestConfig } from 'axios';
import {
IGetInstanceTipListV1Params,
IGetInstanceTipListV1Return,
IGetInstanceTipListV2Params,
IGetInstanceTipListV2Return,
IBatchCheckInstanceIsConnectableByNameParams,
IBatchCheckInstanceIsConnectableByNameReturn,
ICheckInstanceIsConnectableByNameV1Params,
Expand Down Expand Up @@ -41,6 +43,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
Loading
Loading