Skip to content

Commit

Permalink
Add file path judgment
Browse files Browse the repository at this point in the history
  • Loading branch information
peacewong committed Mar 21, 2024
1 parent cf62b6b commit 72ac28d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
import org.apache.linkis.bml.client.BmlClientFactory;
import org.apache.linkis.bml.protocol.BmlResourceVersionsResponse;
import org.apache.linkis.bml.protocol.Version;
import org.apache.linkis.common.utils.SecurityUtils;
import org.apache.linkis.common.utils.ZipUtils;
import org.apache.linkis.engineplugin.server.dao.EngineConnBmlResourceDao;
import org.apache.linkis.engineplugin.server.entity.EngineConnBmlResource;
import org.apache.linkis.engineplugin.server.localize.DefaultEngineConnBmlResourceGenerator;
import org.apache.linkis.engineplugin.server.restful.EnginePluginRestful;
import org.apache.linkis.engineplugin.server.service.EnginePluginAdminService;
import org.apache.linkis.engineplugin.vo.EnginePluginBMLVo;
import org.apache.linkis.manager.am.exception.AMErrorCode;
import org.apache.linkis.manager.am.exception.AMErrorException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -37,6 +40,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.List;

import com.github.pagehelper.PageHelper;
Expand Down Expand Up @@ -79,6 +83,11 @@ public List<String> getTypeList() {
@Override
public void deleteEnginePluginBML(String ecType, String version, String username) {
List<EngineConnBmlResource> allEngineConnBmlResource = null;
if (ecType != null && SecurityUtils.containsRelativePath(ecType)) {
throw new AMErrorException(
AMErrorCode.EC_PLUGIN_ERROR.getErrorCode(),
MessageFormat.format(AMErrorCode.EC_PLUGIN_ERROR.getErrorDesc(), ecType));
}
try {
allEngineConnBmlResource =
engineConnBmlResourceDao.getAllEngineConnBmlResource(ecType, version);
Expand All @@ -88,7 +97,9 @@ public void deleteEnginePluginBML(String ecType, String version, String username
engineConnBmlResourceDao.delete(engineConnBmlResource);
});
String engineConnsHome = defaultEngineConnBmlResourceGenerator.getEngineConnsHome();

File file = new File(engineConnsHome + "/" + ecType);

if (file.exists()) {
deleteDir(file);
log.info("file {} delete success", ecType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public enum AMErrorCode implements LinkisErrorCode {

ASK_ENGINE_ERROR_RETRY(210005, "Ask engine error, retry(请求引擎失败,重试)"),

EC_OPERATE_ERROR(210006, "Failed to execute operation(引擎操作失败)");
EC_OPERATE_ERROR(210006, "Failed to execute operation(引擎操作失败)"),
EC_PLUGIN_ERROR(210007, "ECType {0} contains RelativePath");

private final int errorCode;

Expand Down

0 comments on commit 72ac28d

Please sign in to comment.