mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-31 05:25:25 +00:00
[FIXED JENKINS-8802] Allow use of FilePath.validateFileMask and validateFilePath
from global level (not in a job config page). Require admin permission for this. Based on patch from bap.
This commit is contained in:
1 parent
e8971a5723
commit
ebf4146584
1 file changed
+15
-6
@@ -39,6 +39,7 @@ import hudson.remoting.Pipe;
|
||||
import hudson.remoting.RemoteOutputStream;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.remoting.RemoteInputStream;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.util.DirScanner;
|
||||
import hudson.util.IOException2;
|
||||
import hudson.util.HeadBufferingStream;
|
||||
@@ -1777,12 +1778,12 @@ public final class FilePath implements Serializable {
|
||||
|
||||
/**
|
||||
* Checks the GLOB-style file mask. See {@link #validateAntFileMask(String)}.
|
||||
* Requires configure permission on ancestor AbstractProject object in request.
|
||||
* Requires configure permission on ancestor AbstractProject object in request,
|
||||
* or admin permission if no such ancestor is found.
|
||||
* @since 1.294
|
||||
*/
|
||||
public FormValidation validateFileMask(String value, boolean errorIfNotExist) throws IOException {
|
||||
AbstractProject subject = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
|
||||
subject.checkPermission(Item.CONFIGURE);
|
||||
checkPermissionForValidate();
|
||||
|
||||
value = fixEmpty(value);
|
||||
if(value==null)
|
||||
@@ -1802,7 +1803,8 @@ public final class FilePath implements Serializable {
|
||||
|
||||
/**
|
||||
* Validates a relative file path from this {@link FilePath}.
|
||||
* Requires configure permission on ancestor AbstractProject object in request.
|
||||
* Requires configure permission on ancestor AbstractProject object in request,
|
||||
* or admin permission if no such ancestor is found.
|
||||
*
|
||||
* @param value
|
||||
* The relative path being validated.
|
||||
@@ -1813,8 +1815,7 @@ public final class FilePath implements Serializable {
|
||||
* Otherwise, the relative path is expected to be pointing to a directory.
|
||||
*/
|
||||
public FormValidation validateRelativePath(String value, boolean errorIfNotExist, boolean expectingFile) throws IOException {
|
||||
AbstractProject subject = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
|
||||
subject.checkPermission(Item.CONFIGURE);
|
||||
checkPermissionForValidate();
|
||||
|
||||
value = fixEmpty(value);
|
||||
|
||||
@@ -1852,6 +1853,14 @@ public final class FilePath implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkPermissionForValidate() {
|
||||
AccessControlled subject = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
|
||||
if (subject == null)
|
||||
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
|
||||
else
|
||||
subject.checkPermission(Item.CONFIGURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method over {@link #validateRelativePath(String, boolean, boolean)}.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user