Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 1.9.0 bug fix #637

Merged
merged 14 commits into from
Nov 5, 2024
Next Next commit
Code optimization
“v_kkhuang” committed Oct 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 82fcf60cae799a20f9ff12b399b48b436009c137
Original file line number Diff line number Diff line change
@@ -311,14 +311,12 @@ public Message saveFullTree(HttpServletRequest req, @RequestBody JsonNode json)
configKeyValue.setConfigValue(sparkConf);
}
if (AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()
&& (configKeyValue.getKey().equals("linkis.nebula.password")
|| configKeyValue.getKey().equals("wds.linkis.jdbc.password"))
&& configKeyValue.getKey().equals("linkis.nebula.password")
&& StringUtils.isNotBlank(configKeyValue.getConfigValue())) {
List<ConfigKeyValue> configByLabelIds =
configurationService.getConfigByLabelId(configKeyValue.getConfigLabelId(), null);
for (ConfigKeyValue configByLabelId : configByLabelIds) {
if ((configByLabelId.getKey().equals("linkis.nebula.password")
|| configByLabelId.getKey().equals("wds.linkis.jdbc.password"))
if (configByLabelId.getKey().equals("linkis.nebula.password")
&& !configByLabelId.getConfigValue().equals(configKeyValue.getConfigValue())) {
configKeyValue.setConfigValue(
AESUtils.encrypt(
Original file line number Diff line number Diff line change
@@ -389,9 +389,7 @@ public Message getInfoByDataSourceId(
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
// Decrypt
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
return Message.ok().data("info", dataSource);
},
"Fail to access data source[获取数据源信息失败]");
@@ -427,9 +425,8 @@ public Message getInfoByDataSourceName(
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
// Decrypt
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());

return Message.ok().data("info", dataSource);
},
"Fail to access data source[获取数据源信息失败]");
@@ -464,9 +461,8 @@ public Message getPublishedInfoByDataSourceName(
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
// Decrypt
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());

return Message.ok().data("info", dataSource);
},
"Fail to access data source[获取数据源信息失败]");
@@ -510,9 +506,7 @@ public Message getInfoByDataSourceIdAndVersion(
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
// Decrypt
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, dataSource.getConnectParams());
return Message.ok().data("info", dataSource);
},
"Fail to access data source[获取数据源信息失败]");
@@ -550,7 +544,7 @@ public Message getVersionList(
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
// Decrypt
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue() && null != versions) {
if (null != versions) {
versions.forEach(
version -> {
RestfulApiHelper.decryptPasswordKey(
@@ -700,9 +694,7 @@ public Message getConnectParams(
Map<String, Object> connectParams = dataSource.getConnectParams();
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, connectParams);
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, connectParams);
return Message.ok().data("connectParams", connectParams);
},
"Fail to connect data source[连接数据源失败]");
@@ -738,9 +730,7 @@ public Message getConnectParams(

List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(dataSource.getDataSourceTypeId());
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, connectParams);
}
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, connectParams);
return Message.ok().data("connectParams", connectParams);
},
"Fail to connect data source[连接数据源失败]");
Original file line number Diff line number Diff line change
@@ -74,11 +74,12 @@ public static void encryptPasswordKey(
Object password = connectParams.get(keyDefinition.getKey());
if (null != password) {
String passwordStr = String.valueOf(password);
if (AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()
&& !connectParams.containsKey("isEncrypt")) {
passwordStr =
AESUtils.encrypt(passwordStr, AESUtils.LINKIS_DATASOURCE_AES_KEY.getValue());
connectParams.put("isEncrypt", "1");
if (AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
if (!connectParams.containsKey("isEncrypt")) {
passwordStr =
AESUtils.encrypt(passwordStr, AESUtils.LINKIS_DATASOURCE_AES_KEY.getValue());
connectParams.put("isEncrypt", "1");
}
} else {
passwordStr = CryptoUtils.object2String(passwordStr);
}
@@ -106,7 +107,7 @@ public static void decryptPasswordKey(
passwordStr =
AESUtils.decrypt(passwordStr, AESUtils.LINKIS_DATASOURCE_AES_KEY.getValue());
} else {
passwordStr = CryptoUtils.object2String(passwordStr);
passwordStr = String.valueOf(CryptoUtils.string2Object(passwordStr));
}
connectParams.put(keyDefinition.getKey(), passwordStr);
}
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ public static String checkModuleFile(MultipartFile file, String username) throws
Utils.exec(
(new String[] {
"python",
Configuration.getLinkisHome() + "/admin/" + "check_python_module.py",
Configuration.getLinkisHome() + "/admin/" + "check_modules.py",
module
}));
return !Boolean.parseBoolean(exec);
Original file line number Diff line number Diff line change
@@ -1286,9 +1286,9 @@ public Message pythonFileExist(
if (org.apache.commons.lang3.StringUtils.isBlank(fileName)) {
return Message.error("参数fileName不能为空");
}
String fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."));
if (!fileNameWithoutExtension.matches("^[a-zA-Z][a-zA-Z0-9_.-]{0,49}$")) {
return Message.error("只支持数字字母下划线,且以字母开头,长度最大50");
String fileNameWithoutExtension = fileName.split("\\.")[0];
if (!fileNameWithoutExtension.matches("^[a-zA-Z][a-zA-Z0-9_-]{0,49}$")) {
return Message.error("只支持数字字母下划线,中划线,且以字母开头,长度最大50");
}

// 封装PythonModuleInfo对象并查询数据库