This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new d4972f7f3 RANGER-4403: security-zone validation updated to prevent
duplicate resource entries - #2
d4972f7f3 is described below
commit d4972f7f388819149fcc0a408ca988e54a50741d
Author: Madhan Neethiraj <[email protected]>
AuthorDate: Wed Sep 13 10:36:01 2023 -0700
RANGER-4403: security-zone validation updated to prevent duplicate resource
entries - #2
---
.../ranger/plugin/model/RangerPolicyResourceSignature.java | 9 +++++++--
.../plugin/model/validation/RangerSecurityZoneValidator.java | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPolicyResourceSignature.java
b/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPolicyResourceSignature.java
index cc7713fca..bcdc86779 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPolicyResourceSignature.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPolicyResourceSignature.java
@@ -57,8 +57,13 @@ public class RangerPolicyResourceSignature {
}
}
- public RangerPolicyResourceSignature(Map<String, List<String>>
resources) {
- this(toSignatureString(toPolicyResources(resources)));
+ public RangerPolicyResourceSignature(Map<String, RangerPolicyResource>
resources) {
+ this(toSignatureString(resources));
+ }
+
+ // alternate to constructor that takes Map<String, List<String>>
+ public static RangerPolicyResourceSignature from(Map<String,
List<String>> resources) {
+ return new
RangerPolicyResourceSignature(toPolicyResources(resources));
}
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerSecurityZoneValidator.java
b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerSecurityZoneValidator.java
index 2a1adb397..360426198 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerSecurityZoneValidator.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerSecurityZoneValidator.java
@@ -507,7 +507,7 @@ public class RangerSecurityZoneValidator extends
RangerValidator {
}
}
- RangerPolicyResourceSignature resourceSignature = new
RangerPolicyResourceSignature(resource);
+ RangerPolicyResourceSignature resourceSignature =
RangerPolicyResourceSignature.from(resource);
if
(!resourceSignatures.add(resourceSignature.getSignature())) {
ValidationErrorCode error =
ValidationErrorCode.SECURITY_ZONE_VALIDATION_ERR_DUPLICATE_RESOURCE_ENTRY;