-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-enable automatic approval of launch command if configured by admin #47
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import hudson.model.TaskListener; | ||
import hudson.util.FormValidation; | ||
import java.io.IOException; | ||
import jenkins.model.Jenkins; | ||
import org.jenkinsci.Symbol; | ||
import org.jenkinsci.plugins.command_launcher.Messages; | ||
import org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext; | ||
|
@@ -49,11 +50,11 @@ public class CommandConnector extends ComputerConnector { | |
public CommandConnector(String command) { | ||
this.command = command; | ||
// TODO add withKey if we can determine the Cloud.name being configured | ||
ScriptApproval.get().configuring(command, SystemCommandLanguage.get(), ApprovalContext.create().withCurrentUser()); | ||
ScriptApproval.get().configuring(command, SystemCommandLanguage.get(), ApprovalContext.create().withCurrentUser(), true); | ||
} | ||
|
||
private Object readResolve() { | ||
ScriptApproval.get().configuring(command, SystemCommandLanguage.get(), ApprovalContext.create()); | ||
ScriptApproval.get().configuring(command, SystemCommandLanguage.get(), ApprovalContext.create(), true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we would ever have an active user in this context, so maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I thought about this too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems this one has to stay as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, and it looks like both of those mechanisms of updating the configuration fully replace the existing content, so it seems ok to assume that admins always approve scripts in those cases. |
||
return this; | ||
} | ||
|
||
|
@@ -74,7 +75,7 @@ public FormValidation doCheckCommand(@QueryParameter String value) { | |
if (Util.fixEmptyAndTrim(value) == null) { | ||
return FormValidation.error(Messages.CommandLauncher_NoLaunchCommand()); | ||
} else { | ||
return ScriptApproval.get().checking(value, SystemCommandLanguage.get()); | ||
return ScriptApproval.get().checking(value, SystemCommandLanguage.get(), Jenkins.get().hasPermission(Jenkins.ADMINISTER)); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe? I was thinking we would need to have
oldCommand
get passed through the UI like withCpsFlowDefinition
, but I am not familiar with this plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if anyone other than admins can configure that, need to check.
If it's only admins who have permissions then I assume we're safe with
true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the relevant config page might only require Computer/Configure permission, but I'm not entirely sure. I guess if it always required administer permission then there would be no need for the plugin to integrate with
script-security
at all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the discussion: Computer/Configure is enough to access the page, that's why this plugin and the security fix preceding it were needed in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in c158b7b.