mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(iam): match condition values case-sensitively (#4672)
* fix(iam): match condition values case-sensitively * chore(ci): retry transient registry pull failure
This commit is contained in:
1 parent
970bdf2e54
commit
33617e340d
4 files changed
+189
-6
No files matched your search
@@ -968,10 +968,10 @@ public class IamPolicyEvaluator {
|
||||
case "StringNotEquals" -> !ctxValue.equals(condValue);
|
||||
case "StringEqualsIgnoreCase" -> ctxValue.equalsIgnoreCase(condValue);
|
||||
case "StringNotEqualsIgnoreCase" -> !ctxValue.equalsIgnoreCase(condValue);
|
||||
case "StringLike" -> globMatches(condValue, ctxValue);
|
||||
case "StringNotLike" -> !globMatches(condValue, ctxValue);
|
||||
case "ArnEquals", "ArnLike" -> globMatches(condValue, ctxValue);
|
||||
case "ArnNotEquals", "ArnNotLike"-> !globMatches(condValue, ctxValue);
|
||||
case "StringLike" -> caseSensitiveGlobMatches(condValue, ctxValue);
|
||||
case "StringNotLike" -> !caseSensitiveGlobMatches(condValue, ctxValue);
|
||||
case "ArnEquals", "ArnLike" -> matchesArnCondition(condValue, ctxValue);
|
||||
case "ArnNotEquals", "ArnNotLike"-> !matchesArnCondition(condValue, ctxValue);
|
||||
case "Bool" -> Boolean.parseBoolean(condValue) == Boolean.parseBoolean(ctxValue);
|
||||
case "NumericEquals" -> compareNumeric(ctxValue, condValue) == 0;
|
||||
case "NumericNotEquals" -> compareNumeric(ctxValue, condValue) != 0;
|
||||
@@ -1053,6 +1053,28 @@ public class IamPolicyEvaluator {
|
||||
return globMatchesHelper(pattern.toLowerCase(), value.toLowerCase(), 0, 0);
|
||||
}
|
||||
|
||||
private static boolean caseSensitiveGlobMatches(String pattern, String value) {
|
||||
return pattern != null && value != null && globMatchesHelper(pattern, value, 0, 0);
|
||||
}
|
||||
|
||||
private static boolean matchesArnCondition(String pattern, String value) {
|
||||
if (pattern == null || value == null) {
|
||||
return false;
|
||||
}
|
||||
// The resource component may itself contain colons (for example Lambda qualifiers).
|
||||
String[] patternComponents = pattern.split(":", 6);
|
||||
String[] valueComponents = value.split(":", 6);
|
||||
if (patternComponents.length != 6 || valueComponents.length != 6) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < patternComponents.length; i++) {
|
||||
if (!caseSensitiveGlobMatches(patternComponents[i], valueComponents[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean globMatchesHelper(String pat, String val, int pi, int vi) {
|
||||
while (pi < pat.length() && vi < val.length()) {
|
||||
char p = pat.charAt(pi);
|
||||
|
||||
Reference in new issue
Block a user