Skip to content

Commit

Permalink
fix: fix AlarmRuleLevelAuthorizationChecker (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1001de authored Apr 9, 2024
1 parent 043ecaa commit 453c399
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
*/
package io.holoinsight.server.home.web.security.custom;

import io.holoinsight.server.home.web.security.LevelAuthorizationCheck;
import io.holoinsight.server.home.web.security.LevelAuthorizationCheckResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

Expand All @@ -21,8 +19,12 @@
public interface AbstractResourceChecker {

default LevelAuthorizationCheckResult checkIdNotNull(List<String> parameters) {
if (CollectionUtils.isEmpty(parameters) || !StringUtils.isNumeric(parameters.get(0))) {
return failCheckResult("parameters %s is empty or is not numeric.", parameters);
if (CollectionUtils.isEmpty(parameters)) {
return failCheckResult("parameters %s is empty.", parameters);
}

if (!StringUtils.isNumeric(parameters.get(0))) {
return failCheckResult("parameters %s is not numeric.", parameters.get(0));
}
return successCheckResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private LevelAuthorizationCheckResult checkSelfBool(String methodName, List<Stri

private LevelAuthorizationCheckResult checkIdsExists(List<String> parameters, String tenant,
String workspace) {
String[] idArray = StringUtils.split(parameters.get(0), ",");
String st = parameters.get(0);
String[] idArray = StringUtils.split(st.substring(1, st.length() - 1), ",");
for (String id : idArray) {
LevelAuthorizationCheckResult checkResult =
checkIdExists(Collections.singletonList(id), tenant, workspace);
Expand Down

0 comments on commit 453c399

Please sign in to comment.