Prevent updates to refs/meta/group-names through push and submit
Change-Id: Iea92c2b120a96439b3fb1240af0ab484bf02a858
This commit is contained in:
@@ -778,7 +778,7 @@ public class CommitValidators {
|
||||
}
|
||||
}
|
||||
|
||||
/** Rejects updates to group branches. */
|
||||
/** Rejects updates to group branches (refs/groups/* and refs/meta/group-names). */
|
||||
public static class GroupCommitValidator implements CommitValidationListener {
|
||||
private final AllUsersName allUsers;
|
||||
|
||||
@@ -790,6 +790,7 @@ public class CommitValidators {
|
||||
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
|
||||
throws CommitValidationException {
|
||||
// Groups are stored inside 'refs/groups/' refs inside the 'All-Users' repository.
|
||||
// Group names are stored inside 'refs/meta/group-names' refs inside the 'All-Users' repository.
|
||||
if (!allUsers.equals(receiveEvent.project.getNameKey())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -800,7 +801,8 @@ public class CommitValidators {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (receiveEvent.command.getRefName().startsWith(RefNames.REFS_GROUPS)) {
|
||||
if (receiveEvent.command.getRefName().startsWith(RefNames.REFS_GROUPS)
|
||||
|| receiveEvent.command.getRefName().equals(RefNames.REFS_GROUPNAMES)) {
|
||||
throw new CommitValidationException("group update not allowed");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -319,8 +319,10 @@ public class MergeValidators {
|
||||
IdentifiedUser caller)
|
||||
throws MergeValidationException {
|
||||
// Groups are stored inside 'refs/groups/' refs inside the 'All-Users' repository.
|
||||
// Group names are stored inside 'refs/meta/group-names' inside the 'All-Users' repository.
|
||||
if (!allUsersName.equals(destProject.getNameKey())
|
||||
|| !destBranch.get().startsWith(RefNames.REFS_GROUPS)) {
|
||||
|| (!destBranch.get().startsWith(RefNames.REFS_GROUPS)
|
||||
&& !destBranch.get().equals(RefNames.REFS_GROUPNAMES))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user