Avoid magic meaning of Integer.MIN_VALUE during access evaluation
As part of the security review, Julien Tinnes identified the use of a magic value that controlled whether or not the inherited rules are to be applied to a project. Using a magic value for security related things isn't a recommended practice. Replace the magic meaning of Integer.MIN_VALUE with a boolean, removing the risk that a RefRight object has used the same magic value. Change-Id: Iea8359afae62aa74f3b81f16668f83dc5e2f3cb5 Suggested-by: Julien Tinnes Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -154,14 +154,16 @@ public class ProjectControl {
|
||||
short requireValue) {
|
||||
final Set<AccountGroup.Id> groups = user.getEffectiveGroups();
|
||||
int val = Integer.MIN_VALUE;
|
||||
boolean local = false;
|
||||
|
||||
for (final RefRight pr : state.getLocalRights(actionId)) {
|
||||
if (groups.contains(pr.getAccountGroupId())) {
|
||||
val = Math.max(pr.getMaxValue(), val);
|
||||
local = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (val == Integer.MIN_VALUE && actionId.canInheritFromWildProject()) {
|
||||
if (!local && actionId.canInheritFromWildProject()) {
|
||||
for (final RefRight pr : state.getInheritedRights(actionId)) {
|
||||
if (groups.contains(pr.getAccountGroupId())) {
|
||||
val = Math.max(pr.getMaxValue(), val);
|
||||
|
||||
Reference in New Issue
Block a user