diff --git a/server/home/home-common/src/main/java/io/holoinsight/server/home/common/service/query/KeyResult.java b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/service/query/KeyResult.java index 8eb1d26c0..7d1cdd828 100644 --- a/server/home/home-common/src/main/java/io/holoinsight/server/home/common/service/query/KeyResult.java +++ b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/service/query/KeyResult.java @@ -16,4 +16,5 @@ public class KeyResult { private String metric; private List tags; + private String unit; } diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java index b94c458c4..d5c14b94a 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java @@ -67,6 +67,7 @@ public void doManage() { if (null != mu) { alarmDingDingRobotDTO.setCreator(mu.getLoginName()); } + alarmDingDingRobotDTO.setModifier(null); if (null != ms && !StringUtils.isEmpty(ms.tenant)) { alarmDingDingRobotDTO.setTenant(ms.tenant); } diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java index b85588108..19dc0fa4a 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java @@ -107,7 +107,7 @@ public void doManage() { String tenant = tenant(); String workspace = workspace(); MonitorUser mu = RequestContext.getContext().mu; - if (null != mu && StringUtils.isBlank(alarmRuleDTO.getCreator())) { + if (null != mu) { alarmRuleDTO.setCreator(mu.getLoginName()); } if (StringUtils.isNotEmpty(tenant)) { diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java index 008681433..1b8cdb93a 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java @@ -68,11 +68,13 @@ public class FolderFacadeImpl extends BaseFacade { @PostMapping("/update") @ResponseBody @MonitorScopeAuth(targetType = AuthTargetType.TENANT, needPower = PowerConstants.EDIT) - public JsonResult update(@RequestBody Folder folder) { + public JsonResult update(@RequestBody Folder folder) { final JsonResult result = new JsonResult<>(); facadeTemplate.manage(result, new ManageCallback() { @Override public void checkParameter() { + + log.info("update Folder req {}", J.toJson(folder)); MonitorScope ms = RequestContext.getContext().ms; ParaCheckUtil.checkParaNotNull(folder.id, "id"); ParaCheckUtil.checkParaNotNull(folder.parentFolderId, "parentFolderId"); @@ -112,6 +114,7 @@ public void doManage() { } update.setGmtModified(new Date()); folderService.updateById(update); + result.setData(update); assert mu != null; userOpLogService.append("folder", folder.getId(), OpType.UPDATE, mu.getLoginName(), @@ -120,7 +123,7 @@ public void doManage() { } }); - return JsonResult.createSuccessResult(true); + return result; } @PostMapping("/create") @@ -131,6 +134,7 @@ public JsonResult create(@RequestBody Folder folder) { facadeTemplate.manage(result, new ManageCallback() { @Override public void checkParameter() { + log.info("create Folder req {}", J.toJson(folder)); ParaCheckUtil.checkParaNotNull(folder.parentFolderId, "parentFolderId"); ParaCheckUtil.checkParaNotBlank(folder.name, "name"); ParaCheckUtil.checkParaId(folder.getId()); diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java index 4daf5a818..82f530807 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java @@ -283,6 +283,7 @@ public void doManage() { if (metricInfo != null) { List tags = metricInfo.getTags(); KeyResult keyResult = new KeyResult(); + keyResult.setUnit(metricInfo.getUnit()); keyResult.setMetric(metric); keyResult.setTags(tags); result.setData(keyResult); diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/ParameterSecurityService.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/ParameterSecurityService.java index cbde0007e..92e9b0b0d 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/ParameterSecurityService.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/ParameterSecurityService.java @@ -38,4 +38,6 @@ boolean checkFilterTenantAndWorkspace(String metricTable, Map(Arrays.asList("custom", "cloudbase", "log", "hosting_system", "hosting_port", "hosting_tbase", "hosting_spanner", "hosting_ob", "hosting_apm_ai", "hosting_spanner_ai", "hosting_ob_ai", "hosting_tbase_ai", "hosting_system_ai", "hosting_disk", "iot", - "miniapp", "antiTemplate", "template", "hosting")); + "miniapp", "antiTemplate", "template", "hosting", "template_default", "template_update")); private static final Set silenceModes = new HashSet<>(Arrays.asList("default", "gradual", "fixed")); @@ -347,9 +352,21 @@ private LevelAuthorizationCheckResult checkAlarmRuleDTO(String methodName, return failCheckResult("invalid alertTemplateUuid %s", alarmRuleDTO.getAlertTemplateUuid()); } + if (alarmRuleDTO.getSourceId() != null && !checkSourceId(alarmRuleDTO.getSourceId(), + alarmRuleDTO.getSourceType(), tenant, workspace)) { + return failCheckResult("invalid source id %s", String.valueOf(alarmRuleDTO.getSourceId())); + } + return successCheckResult(); } + private boolean checkSourceId(Long sourceId, String sourceType, String tenant, String workspace) { + if (StringUtils.isEmpty(sourceType)) { + return false; + } + return this.parameterSecurityService.checkSourceId(sourceId, sourceType, tenant, workspace); + } + private LevelAuthorizationCheckResult checkRule(Map ruleMap, String tenant, String workspace) { AlarmRuleConf alarmRuleConf = J.fromJson(J.toJson(ruleMap), AlarmRuleConf.class); diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/FolderFacadeIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/FolderFacadeIT.java index c55c93f41..299b0814b 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/FolderFacadeIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/FolderFacadeIT.java @@ -26,7 +26,8 @@ public class FolderFacadeIT extends BaseIT { Supplier queryById = () -> given() // .pathParam("id", id) // .when() // - .get("/webapi/folder/query/{id}"); // + .get("/webapi/folder/query/{id}") // + .prettyPeek(); // Supplier queryByParentFolderId = () -> given() // .pathParam("parentFolderId", parentFolderId) // @@ -80,7 +81,7 @@ public void test_folder_create() { public void test_folder_update() { name = name + "_v02"; Folder item = new Folder(); - parentFolderId = Long.valueOf(2); + parentFolderId = (long) -1; item.setId(id); item.setName(name); item.setTenant(tenant); @@ -90,9 +91,9 @@ public void test_folder_update() { .body(new JSONObject(J.toMap(J.toJson(item)))) // .when() // .post("/webapi/folder/update") // + .prettyPeek() // .then() // - .body("success", IS_TRUE) // - .body("data", IS_TRUE); // + .body("success", IS_TRUE); // Response response = queryById.get(); System.out.println(response.body().print()); response // diff --git a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/LogMonitoringFolderIT.java b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/LogMonitoringFolderIT.java index bf407400a..e78a4ee2d 100644 --- a/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/LogMonitoringFolderIT.java +++ b/test/server-e2e-test/src/main/java/io/holoinsight/server/test/it/LogMonitoringFolderIT.java @@ -118,6 +118,7 @@ public void test_folder_rename() { .put("tenant", tenant)) // .when() // .post("/webapi/folder/update") // + .prettyPeek() // .then() // .body("success", IS_TRUE); //