Skip to content

Commit

Permalink
fix(frontend): webconsole use语句正则校验 TencentBlueKing#7488
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 22282
  • Loading branch information
JustaCattt authored and hLinx committed Oct 30, 2024
1 parent e2f8423 commit 71e277f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
}
// 校验语句
cmd = cmd.substring(inputPlaceholder.length);
if (consoleConfig.value.validate) {
const validateResult = consoleConfig.value.validate(cmd);
if (validateResult) {
Expand All @@ -202,7 +203,6 @@
// 开始请求
try {
loading.value = true;
cmd = cmd.substring(inputPlaceholder.length);
if (typeof props.raw === 'boolean') {
baseParams = {
...baseParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
export const validate = (cmd: string) => {
if (cmd.includes('use')) {
if (/^\s*use\s+.*$/.test(cmd)) {
return t('暂不支持 use 语句,请使用 db.table 指定 database');
}
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
queryResult: string;
commandInputs: string[];
}) => {
if (/select/i.test(cmd) && queryResult === 'OK') {
if (/^\s*select\s+.*$/.test(cmd) && queryResult === 'OK') {
const newDbIndex = Number(cmd.substring('select '.length));
setDbIndexByClusterId(clusterId, newDbIndex);
const newCommandInputs = commandInputs.map((item) => item.replace(/\[(\d+)\]/, `[${newDbIndex}]`));
Expand Down

0 comments on commit 71e277f

Please sign in to comment.