Skip to content

Commit

Permalink
feat: group parameter check (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
masaimu authored Oct 30, 2023
1 parent 70800fe commit b91bd39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public EventInfo eval(ComputeContext context,
} catch (Throwable ex) {
RecordSucOrFailNotify.alertNotifyProcess("AlertTaskCompute Exception: " + ex,
ALERT_TASK_COMPUTE, "alert task compute", inspectConfig.getAlertNotifyRecord());
logger.error("fail to eval inspectConfig {}, traceId: {} ", G.get().toJson(inspectConfig),
traceId, ex);
logger.error("ALERT_EXCEPTION_MONITOR inspectConfig {}, traceId: {} ",
inspectConfig.getUniqueId(), traceId, ex);
}
return events;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public JsonResult<Long> create(@RequestBody AlarmGroupDTO alarmGroup) {
return jsonResult;
}

return save(alarmGroup);
return save(alarmGroup, true);
}

public JsonResult<Long> save(AlarmGroupDTO alarmGroup) {
public JsonResult<Long> save(AlarmGroupDTO alarmGroup, boolean needCheckUser) {
final JsonResult<Long> result = new JsonResult<>();
facadeTemplate.manage(result, new ManageCallback() {
@Override
Expand All @@ -114,7 +114,7 @@ public void checkParameter() {
"invalid groupName, please use a-z A-Z 0-9 Chinese - _ , . spaces");
List<String> persons = alarmGroup.getUserList();
MonitorUser mu = RequestContext.getContext().mu;
if (!CollectionUtils.isEmpty(persons)) {
if (!CollectionUtils.isEmpty(persons) && needCheckUser) {
for (String person : persons) {
ParaCheckUtil.checkParaBoolean(
parameterSecurityService.checkUserTenantAndWorkspace(person, mu),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public void checkParameter() {
}
if (!CollectionUtils.isEmpty(alarmSubscribeDTO.getAlarmSubscribe())) {
for (AlarmSubscribeInfo alarmSubscribeInfo : alarmSubscribeDTO.getAlarmSubscribe()) {
if (StringUtils.isNotEmpty(alarmSubscribeInfo.getUniqueId())) {
ParaCheckUtil.checkParaBoolean(
parameterSecurityService.checkRuleTenantAndWorkspace(
alarmSubscribeInfo.getUniqueId(), ms.getTenant(), ms.getWorkspace()),
"uniqueId do not belong to this tenant or workspace");
}
if (CollectionUtils.isEmpty(alarmSubscribeInfo.getNoticeType())) {
continue;
}
Expand Down

0 comments on commit b91bd39

Please sign in to comment.