| |
@@ -199,20 +199,26 @@
|
| |
self.debug("SIG memberships: %s" % user_sigs)
|
| |
self.debug("RCM: %s" % is_rcm)
|
| |
|
| |
+ # Quick reminder about the protected_namespace: git.centos.org is
|
| |
+ # hosting in one pagure instance a "regular" git forge as well as
|
| |
+ # a dist-git instance. So they need to protect the dist-git
|
| |
+ # namespaces via the dist-git specific checks while the other
|
| |
+ # namespaces go via the regular checks.
|
| |
+
|
| |
# We have data, start the actual ACL checking
|
| |
if (
|
| |
repotype == "main"
|
| |
and not project.is_fork
|
| |
and project.namespace in self.protected_namespaces
|
| |
):
|
| |
- # In the protected namespace, we want to make sure we don't
|
| |
- # trample on blacklisted content.
|
| |
+ # In the protected namespace, we want to make sure that we block
|
| |
+ # blacklisted branches.
|
| |
for entry in self.blacklists:
|
| |
if entry.match(refname):
|
| |
self.info("Ref %s is blocked" % refname)
|
| |
return False
|
| |
|
| |
- # Allow RCM push
|
| |
+ # Allow RCM/releng to push regardless
|
| |
if is_rcm:
|
| |
for refre in self.rcm_branches:
|
| |
if refre.match(refname):
|
| |
@@ -228,37 +234,42 @@
|
| |
self.debug("SIG push")
|
| |
return True
|
| |
|
| |
- # For Fedora, allow supported branches
|
| |
+ # For Fedora, allow supported branches, these are the active
|
| |
+ # branches in PDC
|
| |
is_supported = self.is_supported_branch(project, refname)
|
| |
if is_supported is False:
|
| |
self.info("Branch %s is unsupported" % refname)
|
| |
return False
|
| |
elif is_supported is True:
|
| |
self.debug("Branch %s is supported" % refname)
|
| |
- return is_committer
|
| |
else:
|
| |
self.debug("No supported status available")
|
| |
|
| |
+ # This allows to block anything that is not allowed, so no
|
| |
+ # random branch creation.
|
| |
if self.block_unspecified:
|
| |
self.info(
|
| |
"Access to namespace %s is restricted" % project.namespace
|
| |
)
|
| |
return False
|
| |
|
| |
- # Block second level blacklists
|
| |
- for entry in self.unspecified_blacklist:
|
| |
- if entry.match(refname):
|
| |
- self.info("Unspecified ref %s is blocked" % refname)
|
| |
- return False
|
| |
+ # For branches that are not explicitely active in PDC, check
|
| |
+ # if the user is allowed to create/push to them.
|
| |
+ if not is_supported:
|
| |
+ for entry in self.unspecified_blacklist:
|
| |
+ if entry.match(refname):
|
| |
+ self.info("Unspecified ref %s is blocked" % refname)
|
| |
+ return False
|
| |
|
| |
# For unspecified refs, they can push if they're a committer
|
| |
self.debug("Unspecified branch push")
|
| |
- return is_committer
|
| |
|
| |
- # This is outside of the strongly protected namespaces
|
| |
- if repotype == "main":
|
| |
+ # This is applicable to all namespace, protected or not
|
| |
+
|
| |
+ if repotype == "main" and not is_rcm:
|
| |
# If this project has PRs only on, or PRs are globally enforced and
|
| |
# this is not a fork, only allow pushing if this is a PR merge.
|
| |
+ # However, RCM/releng is allowed to by-pass the PR only model
|
| |
pr_only = project.settings.get("pull_request_access_only", False)
|
| |
if (
|
| |
pr_only or (self.global_pr_only and not project.is_fork)
|
| |
@@ -266,9 +277,9 @@
|
| |
self.info("A pull request is required for this branch")
|
| |
return False
|
| |
|
| |
- # This is an unprotected namespace, let's allow committers
|
| |
+ # Allow committers to commit
|
| |
if is_committer:
|
| |
- self.debug("Committer push to unprotected")
|
| |
+ self.debug("Committer push")
|
| |
return True
|
| |
|
| |
# If all else fails, deny
|
| |
Basically, we were returning True before we had a chance to check if
the project allowed to direct commits vs enforcing a PR only workflow.
RCM and releng are not concerned by this though.
Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr