Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
b97583e
fix: update page history bug
lu-yg Dec 26, 2024
d30877c
fix: format code and fix style issue
lu-yg Jan 7, 2025
33316bf
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 7, 2025
7fc6507
fix: modify page histiry entity
lu-yg Jan 7, 2025
64be7b4
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
24474b8
feat: add code submission rules
lu-yg Jan 9, 2025
9745b66
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
239c624
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
b77f2f4
fix: modify app schema for test
lu-yg Jan 9, 2025
feeb8f7
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
7d52937
fix: modify block group
lu-yg Jan 22, 2025
6559bec
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
2a7fc44
Merge branch 'opentiny:develop' into develop
lu-yg Jan 22, 2025
656a4a1
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
9de10c5
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 22, 2025
e9aa592
fix: modify block update api
lu-yg Jan 23, 2025
aff95bb
Merge branch 'opentiny:develop' into develop
lu-yg Jan 23, 2025
02607e4
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 23, 2025
ed7483d
fix: Modify code format
lu-yg Jan 23, 2025
48267d6
fix: Modify code format
lu-yg Jan 23, 2025
cabb309
fix: Modify code format
lu-yg Jan 23, 2025
83cb48a
fix: Modify code format
lu-yg Jan 24, 2025
486944b
fix: Modify code format
lu-yg Jan 24, 2025
751f331
Merge branch 'opentiny:develop' into develop
lu-yg Jan 26, 2025
48645e1
fix: modify block group api
lu-yg Jan 26, 2025
d2f2406
fix: modify block group mapper
lu-yg Jan 26, 2025
e24d0ec
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 26, 2025
ee8219f
fix: modify workflows
lu-yg Jan 26, 2025
efad29b
fix: Update checkstyle.yml
lu-yg Jan 26, 2025
6868add
fix: modify workflows
lu-yg Jan 26, 2025
2e131ff
fix: Modify block create and update api
lu-yg Jan 27, 2025
9c1225a
Merge branch 'opentiny:develop' into develop
lu-yg Jan 27, 2025
8cc8ca5
fix: Modify code format
lu-yg Jan 27, 2025
4ba0818
fix: Modify code format
lu-yg Jan 27, 2025
6d978f1
fix: Modify block group
lu-yg Feb 6, 2025
b3f35a0
fix: Modify block group
lu-yg Feb 6, 2025
9717200
fix: Modify block group
lu-yg Feb 6, 2025
e757b29
fix: Modify block group
lu-yg Feb 6, 2025
7d90c86
fix: Modify block group api
lu-yg Feb 13, 2025
d6856ba
Merge branch 'opentiny:develop' into develop
lu-yg Feb 13, 2025
8a89475
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Feb 13, 2025
baa4eeb
fix: Modify block group api
lu-yg Feb 13, 2025
654da8b
fix: Modify block group api
lu-yg Feb 13, 2025
a230c24
feat: add code check
lu-yg Feb 27, 2025
6966946
Merge branch 'opentiny:develop' into develop
lu-yg Feb 27, 2025
d503c96
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Feb 27, 2025
7f9b378
feat: add code check
lu-yg Feb 27, 2025
2bdf54c
feat: add code check
lu-yg Feb 27, 2025
bef4adc
Merge branch 'opentiny:develop' into develop
lu-yg Feb 28, 2025
88dec60
feat: add code check
lu-yg Feb 28, 2025
63efa3c
Merge branch 'opentiny:develop' into develop
lu-yg Feb 28, 2025
f05a3ef
fix: Fix code check
lu-yg Feb 28, 2025
dbc910c
Merge branch 'opentiny:develop' into develop
lu-yg Mar 6, 2025
8a4041c
fix: Cross domain configuration
lu-yg Mar 6, 2025
57fd35a
fix: Cross domain configuration
lu-yg Mar 6, 2025
bff62cc
fix: i18n file upload
lu-yg Mar 7, 2025
ededae7
fix: i18n file upload
lu-yg Mar 7, 2025
1fa284b
Merge branch 'opentiny:develop' into develop
lu-yg Mar 20, 2025
7f17fb7
fix: page update api
lu-yg Mar 20, 2025
934130f
fix: page update api
lu-yg Mar 20, 2025
a920283
feat: material history api
lu-yg Apr 1, 2025
b1e0f83
feat: component library api
lu-yg Apr 2, 2025
5d244ba
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 2, 2025
05f4473
feat: component library api
lu-yg Apr 7, 2025
58ed56b
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 7, 2025
6a5269d
feat: component library api
lu-yg Apr 7, 2025
2f31f88
feat: component library api
lu-yg Apr 7, 2025
9ee1ef1
feat: component library api
lu-yg Apr 7, 2025
59c6ddc
feat: component library api
lu-yg Apr 7, 2025
8373484
feat: component library api
lu-yg Apr 7, 2025
fb123c6
feat: component library api
lu-yg Apr 7, 2025
0875559
feat: component library api
lu-yg Apr 7, 2025
4082626
fix: Mock data is changed to be obtained from loginUserContext
lu-yg Apr 7, 2025
b70579e
Merge branch 'opentiny:develop' into develop
lu-yg Apr 7, 2025
a25abab
Merge branch 'opentiny:develop' into develop
lu-yg Apr 10, 2025
72539c5
fix: Component library mapper
lu-yg Apr 10, 2025
a98b503
fix:Update t_component index
lu-yg Apr 11, 2025
9c82702
Merge branch 'opentiny:develop' into develop
lu-yg Apr 11, 2025
e1e1ef4
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 11, 2025
8005656
fix:Update t_component index
lu-yg Apr 11, 2025
898e66d
Merge branch 'opentiny:develop' into develop
lu-yg Apr 16, 2025
3c66527
fix: Component and component library mapper
lu-yg Apr 16, 2025
267f667
fix: App v1 service
lu-yg Apr 16, 2025
75f0be1
fix: App v1 service
lu-yg Apr 16, 2025
40e6829
Merge branch 'opentiny:develop' into develop
lu-yg Apr 17, 2025
e7071e7
fix: Modify code format
lu-yg Apr 17, 2025
9a4e612
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 17, 2025
0993e94
Merge branch 'opentiny:develop' into develop
lu-yg Apr 21, 2025
7d88f1c
fix: Modify mapper
lu-yg Apr 21, 2025
2265f07
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 21, 2025
c35445f
Merge branch 'opentiny:develop' into develop
lu-yg Apr 23, 2025
cabc129
fix: Modify bundle split
lu-yg Apr 23, 2025
958c7b6
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Apr 23, 2025
7e33a5d
Merge branch 'opentiny:develop' into develop
lu-yg Apr 27, 2025
2c60fa1
fix: format code and fix style issue
lu-yg Apr 27, 2025
e7e4be5
Merge branch 'opentiny:develop' into develop
lu-yg Apr 27, 2025
1a380b6
fix: fix getSchemaComponentsTree function bug
lu-yg Apr 30, 2025
15c6e8f
fix: Fix folder hierarchy restrictions and add AI models
lu-yg May 7, 2025
4ab18bd
Merge branch 'opentiny:develop' into develop
lu-yg May 8, 2025
243d8f9
fix: block lock issue
lu-yg May 8, 2025
818986d
Merge branch 'opentiny:develop' into develop
lu-yg May 9, 2025
b98e193
fead: platform API
lu-yg May 9, 2025
4ac65e2
feat: platform API
lu-yg May 9, 2025
16ad90d
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg May 13, 2025
7f875ce
feat: platform API
lu-yg May 13, 2025
091ed5e
feat: Add inspection file
lu-yg May 13, 2025
3438b96
feat: Add inspection file
lu-yg May 13, 2025
68b329a
feat: Add inspection file
lu-yg May 13, 2025
37e06a9
feat: Add inspection file
lu-yg May 13, 2025
2df5550
feat: Add inspection file
lu-yg May 13, 2025
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
4 changes: 2 additions & 2 deletions app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ create table `t_platform_history`
`ref_id` int not null comment '关联主表id',
`version` varchar(255) not null comment '版本',
`name` varchar(255) not null comment '名称',
`publish_url` varchar(255) not null comment '设计器静态资源托管地址',
`publish_url` varchar(255) comment '设计器静态资源托管地址',
`description` varchar(2000) comment '描述',
`vscode_url` varchar(255) comment '设计预留字段',
`material_history_id` int not null comment '关联物料包历史id',
`sub_count` int not null comment '设计预留字段',
`sub_count` int comment '设计预留字段',
`material_pkg_name` varchar(255) comment '物料包名称',
`material_version` varchar(255) comment '物料包版本',
`image_url` varchar(255) comment '封面图地址',
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/resources/sql/h2/update_all_tables_ddl.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
ALTER TABLE t_component DROP INDEX u_idx_component;
ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id);
ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id);

ALTER TABLE t_datasource DROP INDEX u_idx_datasource;
ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`);

ALTER TABLE t_platform_history MODIFY sub_count int NULL;
ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ create table `t_platform_history`
`ref_id` int not null comment '关联主表id',
`version` varchar(255) not null comment '版本',
`name` varchar(255) not null comment '名称',
`publish_url` varchar(255) not null comment '设计器静态资源托管地址',
`publish_url` varchar(255) comment '设计器静态资源托管地址',
`description` varchar(2000) comment '描述',
`vscode_url` varchar(255) comment '设计预留字段',
`vscode_url` varchar(255) comment '设计预留字段',
`material_history_id` int not null comment '关联物料包历史id',
`sub_count` int not null comment '设计预留字段',
`sub_count` int comment '设计预留字段',
`material_pkg_name` varchar(255) comment '物料包名称',
`material_version` varchar(255) comment '物料包版本',
`image_url` varchar(255) comment '封面图地址',
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/resources/sql/mysql/update_all_tables_ddl.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
ALTER TABLE t_component DROP INDEX u_idx_component;
ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id);
ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id);

ALTER TABLE t_datasource DROP INDEX u_idx_datasource;
ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`);

ALTER TABLE t_platform_history MODIFY sub_count int NULL;
ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,22 @@ public enum ExceptionEnum implements IBaseError {
/**
* Cm 322 exception enum.
*/
CM322("CM322", "调用接口失败");
CM322("CM322", "调用接口失败"),

/**
* Cm 323 exception enum.
*/
CM323("CM323", "文件名长度范围为1-100,以数字或字母开头"),

/**
* Cm 324 exception enum.
*/
CM324("CM324","文件名或路径无效"),

/**
* Cm 325 exception enum.
*/
CM325("CM325","文件校验失败");

/**
* 错误码
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*/

package com.tinyengine.it.common.utils;

import cn.hutool.core.util.ObjectUtil;
import com.tinyengine.it.common.exception.ExceptionEnum;
import com.tinyengine.it.common.exception.ServiceException;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;

/**
* The file check Utils.
*
* @since 2025-05-13
*/
public class SecurityFileCheckUtil {

private static final String REGX_FILE_NAME = "^[a-z0-9A-Z][^\\\\/:*<>|]+$";
private static final Pattern PATTERN_FILE_NAME = Pattern.compile(REGX_FILE_NAME);

/**
* Determine whether the file has cross path connections.
*
* @param dirOrFileName the dirOrFileName
* @return true or false
*/
public static boolean checkPathHasCrossDir(String dirOrFileName) {
if (!dirOrFileName.contains("../") && !dirOrFileName.contains("/..")) {
if (!dirOrFileName.contains("..\\") && !dirOrFileName.contains("\\..")) {
return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\") || dirOrFileName.contains("%00");
} else {
return true;
}
} else {
return true;
}
}

/**
* Type of inspection document.
*
* @param file the file
* @param fileTypeMap the fileTypeMap
* @return true or false
*/
public static boolean checkFileType(MultipartFile file, Map<String, String> fileTypeMap) {
if (Objects.isNull(file) || fileTypeMap.isEmpty()) {
throw new ServiceException(ExceptionEnum.CM307.getResultCode(), ExceptionEnum.CM307.getResultMsg());
}
String originalFileName = file.getOriginalFilename();
for (Map.Entry<String, String> entry : fileTypeMap.entrySet()) {
if (originalFileName.endsWith(entry.getKey())) {
return checkFileType(file, entry.getKey(), entry.getValue());
}
}
return false;
}

/**
* Type of inspection document.
*
* @param file the file
* @param fileNameEnd the fileNameEnd
* @param fileType the fileType
* @return true or false
*/
public static boolean checkFileType(MultipartFile file, String fileNameEnd, String fileType) {
String originalFileName = file.getOriginalFilename();
String contentType = file.getContentType();
if (ObjectUtil.isEmpty(originalFileName) || ObjectUtil.isEmpty(contentType)) {
return false;
}
if (!originalFileName.endsWith(fileNameEnd)) {
return false;
}
if (!contentType.equalsIgnoreCase(fileType)) {
return false;
}
return true;
}

/**
* Inspection file name.
*
* @param fileName the fileName
*/
public static void validFileName(String fileName) {
if (!StringUtils.hasText(fileName)) {
throw new ServiceException(ExceptionEnum.CM320.getResultCode(), ExceptionEnum.CM320.getResultMsg());
}
if (!checkFileNameLength(fileName, 1, 100)) {
throw new ServiceException(ExceptionEnum.CM323.getResultCode(), ExceptionEnum.CM323.getResultMsg());
}
if (!filePathIsValid(fileName)) {
throw new ServiceException(ExceptionEnum.CM324.getResultCode(), ExceptionEnum.CM324.getResultMsg());
}
String fullFileName = getFileName(fileName);
if (!PATTERN_FILE_NAME.matcher(fullFileName).matches()) {
throw new ServiceException(ExceptionEnum.CM324.getResultCode(), ExceptionEnum.CM324.getResultMsg());
}
}

/**
* Check if the file name length is within the specified range.
*
* @param fileName the fileName
* @param min the min
* @param max the max
* @return true or false
*/
public static boolean checkFileNameLength(String fileName, int min, int max) {
if (!StringUtils.hasText(fileName)) {
return min <= 0;
}
String temp = fileName.replaceAll("[^\\x00-\\xff]", "**");
return temp.length() <= max;
}

/**
* Verify file path.
*
* @param fileName the fileName
* @return true or false
*/
public static boolean filePathIsValid(String fileName) {
if (fileName == null || fileName.trim().isEmpty()) {
return false;
}

// 获取当前操作系统的名称
String os = System.getProperty("os.name").toLowerCase();

// 定义通用的非法字符
String illegalChars = "";

if (os.contains("win")) {
// 针对Windows的非法字符
illegalChars = "[<>:\"/\\|?*]";
} else if (os.contains("nix") || os.contains("nux") || os.contains("mac")) {
// 针对Linux和macOS的非法字符(一般来说,Linux和macOS对文件名的限制较少,但有一些常见的非法字符)
illegalChars = "[/]"; // Linux和macOS的路径不能包含斜杠 '/'
}
// 检查路径中是否包含非法字符
if (fileName.matches(".*" + illegalChars + ".*")) {
return false;
}
// 检查路径是否超过文件系统允许的最大长度(例如,Windows上的路径限制通常为260个字符)
if (fileName.length() > 260) {
return false;
}

// 检查路径中是否包含空格或其他特殊字符,视需要进行定制
// 如果需要你也可以根据不同操作系统做不同的检查

return true;
}

private static String getFileName(String filePath) {
File file = new File(filePath);
return file.getName();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.tinyengine.it.common.base.Result;
import com.tinyengine.it.common.exception.ExceptionEnum;
import com.tinyengine.it.common.log.SystemControllerLog;
import com.tinyengine.it.common.utils.SecurityFileCheckUtil;
import com.tinyengine.it.model.dto.BundleResultDto;
import com.tinyengine.it.model.dto.CustComponentDto;
import com.tinyengine.it.model.dto.FileResult;
Expand Down Expand Up @@ -71,6 +72,7 @@ public Result<FileResult> bundleCreateComponent(@RequestParam MultipartFile file
if (file.isEmpty()) {
return Result.failed(ExceptionEnum.CM307);
}
SecurityFileCheckUtil.validFileName(file.getOriginalFilename());
// 返回插入和更新的条数
return componentService.readFileAndBulkCreate(file);
}
Expand All @@ -92,6 +94,7 @@ public Result<BundleResultDto> bundleSplit(@RequestParam MultipartFile file) {
if (file.isEmpty()) {
return Result.failed(ExceptionEnum.CM307);
}
SecurityFileCheckUtil.validFileName(file.getOriginalFilename());
return componentService.bundleSplit(file);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.tinyengine.it.common.exception.ExceptionEnum;
import com.tinyengine.it.common.exception.ServiceException;
import com.tinyengine.it.common.log.SystemControllerLog;
import com.tinyengine.it.common.utils.SecurityFileCheckUtil;
import com.tinyengine.it.model.dto.DeleteI18nEntry;
import com.tinyengine.it.model.dto.FileResult;
import com.tinyengine.it.model.dto.I18nEntryDto;
Expand Down Expand Up @@ -234,10 +235,10 @@ public Result<FileResult> updateI18nSingleFile(
for (Map.Entry<String, MultipartFile> entry : filesMap.entrySet()) {
// 获取对应的文件
MultipartFile file = entry.getValue();

if (file.isEmpty()) {
return Result.failed(ExceptionEnum.CM307);
}
SecurityFileCheckUtil.validFileName(file.getOriginalFilename());
// 返回插入和更新的条数
result = i18nEntryService.readSingleFileAndBulkCreate(file, id);
}
Expand Down Expand Up @@ -274,10 +275,10 @@ public Result<FileResult> updateI18nMultiFile(
for (Map.Entry<String, MultipartFile> entry : filesMap.entrySet()) {
String key = entry.getKey(); // 获取动态的参数名
MultipartFile file = entry.getValue(); // 获取对应的文件

if (file.isEmpty()) {
return Result.failed(ExceptionEnum.CM307);
}
SecurityFileCheckUtil.validFileName(file.getOriginalFilename());
// 返回插入和更新的条数
result = i18nEntryService.readFilesAndbulkCreate(key, file, id);
}
Expand Down
Loading
Loading