Skip to content

Commit

Permalink
Fix tag based evaluation for Create
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilbonte21 committed Dec 4, 2023
1 parent c779b6a commit deccfbe
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,23 @@ private static boolean validateResourcesForCreateEntity(List<RangerPolicy> resou

//for tag based policy
if ("tag".equals(resource)) {
if (entity.getClassifications() != null && !entity.getClassifications().isEmpty()) {
List<String> assetTags = entity.getClassifications().stream().map(x -> x.getTypeName()).collect(Collectors.toList());
if (entity.getClassifications() == null || entity.getClassifications().isEmpty()) {
//since entity does not have tags at all, it should not pass this evaluation
resourcesMatched = false;
break;
}

for (String assetTag : assetTags) {
Optional<String> match = values.stream().filter(x -> assetTag.matches(x.replace("*", ".*"))).findFirst();
List<String> assetTags = entity.getClassifications().stream().map(x -> x.getTypeName()).collect(Collectors.toList());

if (!match.isPresent()) {
resourcesMatched = false;
break;
}
for (String assetTag : assetTags) {
Optional<String> match = values.stream().filter(x -> assetTag.matches(x.replace("*", ".*"))).findFirst();

if (!match.isPresent()) {
resourcesMatched = false;
break;
}
}

}
}

Expand Down

0 comments on commit deccfbe

Please sign in to comment.