Skip to content

Commit

Permalink
fix(接口测试): 修复用例附件被直接删除漏洞
Browse files Browse the repository at this point in the history
  • Loading branch information
fit2-zhao committed Dec 7, 2022
1 parent ec7282f commit b5b4c51
Showing 1 changed file with 5 additions and 9 deletions.
Expand Up @@ -333,10 +333,14 @@ public void delete(String testId) {
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
apiTestCaseMapper.deleteByPrimaryKey(testId);
esbApiParamService.deleteByResourceId(testId);
deleteBodyFiles(testId);
// 删除附件关系
extFileAssociationService.deleteByResourceId(testId);
deleteFollows(testId);
ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(testId);
if (apiTestCase != null) {
String filePath = StringUtils.join(BODY_FILE_DIR, File.separator, apiTestCase.getId());
FileUtil.deleteContents(new File(filePath));
}
}

private void deleteFollows(String testId) {
Expand All @@ -362,14 +366,6 @@ public void deleteTestCase(String apiId) {
}
}

public void deleteBodyFiles(String testId) {
File file = new File(BODY_FILE_DIR + "/" + testId);
FileUtil.deleteContents(file);
if (file.exists()) {
file.delete();
}
}

public void checkNameExist(SaveApiTestCaseRequest request) {
if (hasSameCase(request)) {
MSException.throwException(Translator.get("case_name_is_already_exist") + ": " + request.getName());
Expand Down

0 comments on commit b5b4c51

Please sign in to comment.