diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index a1398d86eb..517e9ae764 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -114,9 +114,13 @@ public class ApiAutomationService { Map map = d.getEnvironmentMap(); if (map != null) { if (map.isEmpty()) { - List ids = (List) JSONPath.read(definition, "$..projectId"); - if (CollectionUtils.isNotEmpty(ids)) { - idList.addAll(new HashSet<>(ids)); + try { + List ids = (List) JSONPath.read(definition, "$..projectId"); + if (CollectionUtils.isNotEmpty(ids)) { + idList.addAll(new HashSet<>(ids)); + } + } catch (Exception e) { + LogUtil.error("JSONPath.read projectId fail."); } } else { Set set = d.getEnvironmentMap().keySet(); diff --git a/backend/src/main/java/io/metersphere/security/CsrfFilter.java b/backend/src/main/java/io/metersphere/security/CsrfFilter.java index 66ef15689e..59442dc61d 100644 --- a/backend/src/main/java/io/metersphere/security/CsrfFilter.java +++ b/backend/src/main/java/io/metersphere/security/CsrfFilter.java @@ -7,7 +7,6 @@ import io.metersphere.commons.utils.SessionUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.ExpiredCredentialsException; import org.apache.shiro.web.filter.authc.AnonymousFilter; import org.apache.shiro.web.util.WebUtils; import org.springframework.core.env.Environment; @@ -42,12 +41,7 @@ public class CsrfFilter extends AnonymousFilter { // 请求头取出的token value String csrfToken = httpServletRequest.getHeader(TOKEN_NAME); // 校验 token - try { - validateToken(csrfToken); - } catch (ExpiredCredentialsException e) { - ((HttpServletResponse) response).setHeader("Authentication-Status", "invalid"); - return true; - } + validateToken(csrfToken); // 校验 referer validateReferer(httpServletRequest); return true; @@ -80,18 +74,6 @@ public class CsrfFilter extends AnonymousFilter { if (signatureArray.length != 3) { throw new RuntimeException("invalid token"); } - - long signatureTime; - try { - signatureTime = Long.parseLong(signatureArray[2]); - } catch (Exception e) { - throw new RuntimeException(e); - } - Environment env = CommonBeanFactory.getBean(Environment.class); - long timeout = env.getProperty("session.timeout", Long.class, 43200L); - if (Math.abs(System.currentTimeMillis() - signatureTime) > timeout * 1000) { - throw new ExpiredCredentialsException("expired token"); - } if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) { throw new RuntimeException("Please check csrf token."); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index e7b8089ea5..c7c1fed489 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -206,7 +206,7 @@ public class TestPlanService { } else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name - i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新 + i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新 } if (!StringUtils.isBlank(testPlan.getStatus())) { BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index d6e72ddfd4..95a3ab2f8b 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -70,7 +70,6 @@ import {getUUID, downloadFile, checkoutTestManagerOrTestUser} from "@/common/js/utils"; import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule"; import MsEditApiScenario from "./scenario/EditApiScenario"; - import {getCurrentProjectID} from "../../../../common/js/utils"; export default { name: "ApiAutomation", @@ -96,7 +95,10 @@ }, isReadOnly() { return !checkoutTestManagerOrTestUser(); - } + }, + projectId() { + return this.$store.state.projectId + }, }, data() { return { @@ -145,7 +147,7 @@ let selectParamArr = redirectParam.split("edit:"); if (selectParamArr.length == 2) { let scenarioId = selectParamArr[1]; - let projectId = getCurrentProjectID(); + let projectId = this.projectId; //查找单条数据,跳转修改页面 let url = "/api/automation/list/" + 1 + "/" + 1; this.$post(url, {id: scenarioId, projectId: projectId}, response => { @@ -176,7 +178,7 @@ } }, addTab(tab) { - if (!getCurrentProjectID()) { + if (!this.projectId) { this.$warning(this.$t('commons.check_project_tip')); return; } diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index c0624d9ffd..2fb0c281f8 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -45,7 +45,7 @@ import MsApiReportExport from "./ApiReportExport"; import MsApiReportViewHeader from "./ApiReportViewHeader"; import {RequestFactory} from "../../definition/model/ApiTestModel"; - import {windowPrint, getCurrentProjectID} from "@/common/js/utils"; + import {windowPrint} from "@/common/js/utils"; export default { name: "MsApiReport", @@ -211,7 +211,7 @@ return; } this.loading = true; - this.report.projectId = getCurrentProjectID(); + this.report.projectId = this.projectId; let url = "/api/scenario/report/update"; this.result = this.$post(url, this.report, response => { this.$success(this.$t('commons.save_success')); @@ -236,7 +236,10 @@ }, isNotRunning() { return "Running" !== this.report.status; - } + }, + projectId() { + return this.$store.state.projectId + }, } } diff --git a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue index 96110380f6..ae28794b28 100644 --- a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue @@ -58,7 +58,7 @@