-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| import hudson.markup.MarkupFormatter; | ||
| import hudson.markup.RawHtmlMarkupFormatter; | ||
| import hudson.model.*; | ||
| import hudson.security.AccessControlled; | ||
| import hudson.security.Permission; | ||
| import jenkins.model.Jenkins; | ||
| import org.apache.commons.fileupload.FileItem; | ||
|
|
@@ -637,8 +638,13 @@ private String[] resolveSlaveNames(String nameAlias) { | |
| * @throws IOException | ||
|
Check warning on line 638 in src/main/java/org/jenkinsci/plugins/scriptler/ScriptlerManagement.java
|
||
| * @throws ServletException | ||
|
Check warning on line 639 in src/main/java/org/jenkinsci/plugins/scriptler/ScriptlerManagement.java
|
||
| */ | ||
| public void doShowScript(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id") String id) throws IOException, ServletException { | ||
| // action directly accessible to any people configuring job, so no permission check | ||
| public void doShowScript(StaplerRequest req, StaplerResponse rsp, @AncestorInPath Item item, @QueryParameter("id") String id) throws IOException, ServletException { | ||
| // action directly accessible to any people configuring job, so use a more lenient permission check | ||
| Jenkins jenkins = Jenkins.get(); | ||
| if (!jenkins.hasAnyPermission(ScriptlerPermissions.RUN_SCRIPTS, ScriptlerPermissions.CONFIGURE)) { | ||
| AccessControlled parent = item == null ? jenkins : item; | ||
| parent.checkPermission(Item.CONFIGURE); | ||
| } | ||
| Script script = ScriptHelper.getScript(id, true); | ||
| req.setAttribute("script", script); | ||
| req.getView(this, "show.jelly").forward(req, rsp); | ||
|
|
||
33 changes: 33 additions & 0 deletions
33
src/main/java/org/jenkinsci/plugins/scriptler/TransientActionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.jenkinsci.plugins.scriptler; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
| import hudson.Extension; | ||
| import hudson.model.Action; | ||
| import hudson.model.Job; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import jenkins.model.TransientActionFactory; | ||
|
|
||
| @Extension | ||
| public class TransientActionProvider extends TransientActionFactory<Job> { | ||
| @Override | ||
| public Class<Job> type() { | ||
| return Job.class; | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public Collection<? extends Action> createFor(@NonNull Job target) { | ||
| return Collections.singleton(new ScriptlerManagement() { | ||
| @Override | ||
| public String getIconFileName() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDisplayName() { | ||
| return null; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters