Browse Source

Merge pull request #5832 in DEC/decision-webui-dcm from final/11.0 to persist/11.0

* commit 'b0ea0877ceb04e830478ebb1f764997004877ae4':
  BI-112953 fix:jdbcResolve正则匹配trino
  BI-108526 BI-111537 feat:添加trino tdsql数据连接
  REPORT-77480 fix:SSRF漏洞处理
  REPORT-77480 fix:SSRF漏洞处理
  REPORT-75699 fix:处理控制台重复注册组件的报错
persist/11.0
superman 2 years ago
parent
commit
57721dabf7
  1. 2
      src/modules/app.provider.ts
  2. 2
      src/modules/components/file_upload/file_upload.ts
  3. 13
      src/modules/components/test_status/test_status.ts
  4. 11
      src/modules/components/test_status/tip_icon/tip_fail.ts
  5. 23
      src/modules/constants/constant.ts
  6. 4
      src/modules/pages/maintain/forms/form.server.ts
  7. 10
      src/modules/pages/maintain/forms/form.ts

2
src/modules/app.provider.ts

@ -25,7 +25,7 @@ BI.provider('dec.connection.provider.datebase', function() {
urlInfo: greenplumUrl[9], urlInfo: greenplumUrl[9],
}; };
} }
const result = url.match(/^jdbc:(mysql|sqlserver|db2|dm|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql|clickhouse):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(\/|;DatabaseName=)?([^]+)?(.*)/i); const result = url.match(/^jdbc:(mysql|sqlserver|db2|dm|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql|clickhouse|trino):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(\/|;DatabaseName=)?([^]+)?(.*)/i);
if (result) { if (result) {
return { return {
host: result[5], host: result[5],

2
src/modules/components/file_upload/file_upload.ts

@ -326,5 +326,3 @@ export class FileUpload extends BI.Widget {
this.store.setFileInfo(params); this.store.setFileInfo(params);
} }
} }
BI.shortcut("dec.dcm.components.file_upload", FileUpload);

13
src/modules/components/test_status/test_status.ts

@ -29,6 +29,7 @@ export class TestStatus extends BI.Widget {
failDriverMessage: Label; failDriverMessage: Label;
driverLink: FloatLeftLayout; driverLink: FloatLeftLayout;
detail: VerticalLayout; detail: VerticalLayout;
failMaskers:any;
watch = { watch = {
status: (status: string) => { status: (status: string) => {
@ -38,7 +39,7 @@ export class TestStatus extends BI.Widget {
render() { render() {
const { loadingCls, loadingText, successCls, successText, failCls, failText, retryText } = this.options; const { loadingCls, loadingText, successCls, successText, failCls, failText, retryText } = this.options;
var self=this;
return { return {
type: BI.CenterAdaptLayout.xtype, type: BI.CenterAdaptLayout.xtype,
cls: 'bi-z-index-mask', cls: 'bi-z-index-mask',
@ -51,7 +52,7 @@ export class TestStatus extends BI.Widget {
cls: 'bi-card', cls: 'bi-card',
width: 450, width: 450,
height: 250, height: 250,
single: true, // single: true,
showIndex: this.model.status, showIndex: this.model.status,
ref: (_ref: Tab) => { ref: (_ref: Tab) => {
this.tab = _ref; this.tab = _ref;
@ -70,6 +71,12 @@ export class TestStatus extends BI.Widget {
tipCls: failCls, tipCls: failCls,
tipText: failText, tipText: failText,
retryText, retryText,
ref:(_ref:any)=>{
self.failMaskers=_ref;
if(this.failMessage.getText()===''){
this.failMaskers.populateFail(BI.i18nText("Dec-Conn-ect-Failed"),false);
}
},
listeners: [ listeners: [
{ {
eventName: TipFail.EVENT_RELOAD, eventName: TipFail.EVENT_RELOAD,
@ -168,7 +175,7 @@ export class TestStatus extends BI.Widget {
this.store.setStatus(TEST_STATUS.SUCCESS); this.store.setStatus(TEST_STATUS.SUCCESS);
} }
setFail(message: string, driver = '', link = '') { setFail(message: string='', driver = '', link = '') {
this.store.setStatus(TEST_STATUS.FAIL); this.store.setStatus(TEST_STATUS.FAIL);
this.failMessage.setText(message); this.failMessage.setText(message);
this.failDriverMessage.setVisible(!!driver); this.failDriverMessage.setVisible(!!driver);

11
src/modules/components/test_status/tip_icon/tip_fail.ts

@ -1,5 +1,5 @@
import { shortcut, store } from '@core/core'; import { shortcut, store } from '@core/core';
import { Button } from '@fui/core'; import { Button, Label } from '@fui/core';
import { TipFailModel } from './tip_fail.model'; import { TipFailModel } from './tip_fail.model';
@shortcut() @shortcut()
@ -21,7 +21,7 @@ export class TipFail extends BI.Widget {
store: TipFailModel['store']; store: TipFailModel['store'];
detailButton: Button; detailButton: Button;
failText:Label;
watch = { watch = {
isCollapse: (isCollapse: boolean) => { isCollapse: (isCollapse: boolean) => {
this.detailButton.setText(isCollapse ? this.detailButton.setText(isCollapse ?
@ -29,6 +29,10 @@ export class TipFail extends BI.Widget {
BI.i18nText('Dec-Dcm_Connection_Detailed_Information')); BI.i18nText('Dec-Dcm_Connection_Detailed_Information'));
}, },
} }
populateFail(text:string,isVisible:boolean){
this.failText.setText(text);
this.detailButton.setVisible(isVisible);
}
render() { render() {
const { tipCls, tipText, retryText } = this.options; const { tipCls, tipText, retryText } = this.options;
@ -53,6 +57,9 @@ export class TipFail extends BI.Widget {
height: 14, height: 14,
bgap: 10, bgap: 10,
text: tipText, text: tipText,
ref:(_ref:Label)=>{
this.failText=_ref;
}
}, },
{ {
type: BI.VerticalAdaptLayout.xtype, type: BI.VerticalAdaptLayout.xtype,

23
src/modules/constants/constant.ts

@ -692,6 +692,29 @@ export const DATA_BASE_TYPES = [
'org.sqlite.JDBC': 'jdbc:sqlite:[PATH_TO_DB_FILES]', 'org.sqlite.JDBC': 'jdbc:sqlite:[PATH_TO_DB_FILES]',
}, },
}, },
{
text: 'trino',
databaseType: 'trino',
driver: 'io.trino.jdbc.TrinoDriver',
url: 'jdbc:trino://hostname:port/database',
commonly: false,
internal: true,
type: 'jdbc',
hasSchema: true,
kerberos: false,
},
{
text: BI.i18nText('Dec-Dcm_Connection_TDSQL'),
databaseType: 'tdsql',
driver: 'org.postgresql.Driver',
url: 'jdbc:postgresql://hostname:port/database',
commonly: false,
internal: true,
type: 'jdbc',
hasSchema: true,
kerberos: false,
fetchSize: 10000,
}
]; ];

4
src/modules/pages/maintain/forms/form.server.ts

@ -20,6 +20,10 @@ export function testConnection(value: Connection): Promise<string[]> {
const formValue = value; const formValue = value;
api.testConnection(formValue).then(re => { api.testConnection(formValue).then(re => {
if (re && re.errorCode) { if (re && re.errorCode) {
if(re.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED){
testStatus.setFail();
return;
}
// 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接 // 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
if (api.isDriverError(re.errorCode)) { if (api.isDriverError(re.errorCode)) {
if (formValue.connectionType === connectionType.JDBC) { if (formValue.connectionType === connectionType.JDBC) {

10
src/modules/pages/maintain/forms/form.ts

@ -38,6 +38,11 @@ export class MaintainForm extends BI.Widget {
value.creator = BI.get(this.getFormData(), 'creator'); value.creator = BI.get(this.getFormData(), 'creator');
this.store.updateConnection(this.connectionName, value).then(result => { this.store.updateConnection(this.connectionName, value).then(result => {
if (result.errorCode) { if (result.errorCode) {
if(result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED){
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"),{
level: "error",
});
}
this.showError(result); this.showError(result);
return; return;
@ -253,6 +258,11 @@ export class MaintainForm extends BI.Widget {
private addConnection(form: Connection) { private addConnection(form: Connection) {
this.store.addConnection(form).then(result => { this.store.addConnection(form).then(result => {
if (result.errorCode) { if (result.errorCode) {
if(result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED){
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"),{
level: "error",
});
}
if (result.errorCode === errorCode.DUPLICATE_NAMES) { if (result.errorCode === errorCode.DUPLICATE_NAMES) {
if (form.connectionType !== connectionType.JDBC && form.connectionType !== connectionType.JNDI) { if (form.connectionType !== connectionType.JDBC && form.connectionType !== connectionType.JNDI) {
// 如果不是jdbc或jndi,即如果是插件,名称重复的时候需要修改名字重新提交给后台 // 如果不是jdbc或jndi,即如果是插件,名称重复的时候需要修改名字重新提交给后台

Loading…
Cancel
Save