From 2f7d57deac0a082940cf6ee1eaf64986e18eefff Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Mon, 15 Feb 2021 14:43:36 +0100 Subject: [PATCH] If no `project` is given, fall back to global permission. See https://issues.jenkins.io/browse/JENKINS-64872 for details. --- src/main/java/io/jenkins/plugins/util/JenkinsFacade.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/util/JenkinsFacade.java b/src/main/java/io/jenkins/plugins/util/JenkinsFacade.java index 086eeed..61f6e3d 100644 --- a/src/main/java/io/jenkins/plugins/util/JenkinsFacade.java +++ b/src/main/java/io/jenkins/plugins/util/JenkinsFacade.java @@ -8,6 +8,8 @@ import org.apache.commons.lang3.StringUtils; +import edu.umd.cs.findbugs.annotations.CheckForNull; + import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; import hudson.DescriptorExtensionList; @@ -86,7 +88,10 @@ public boolean hasPermission(final Permission permission) { * * @return {@code false} if the user doesn't have the permission */ - public boolean hasPermission(final Permission permission, final Job project) { + public boolean hasPermission(final Permission permission, @CheckForNull final Job project) { + if (project == null) { + return hasPermission(permission); + } return getJenkins().getAuthorizationStrategy().getACL(project).hasPermission(permission); }