-
Notifications
You must be signed in to change notification settings - Fork 196
feat: add dropdown for resource select strategies and fix empty resource strategy in pipeline syntax #767
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
base: master
Are you sure you want to change the base?
feat: add dropdown for resource select strategies and fix empty resource strategy in pipeline syntax #767
Changes from 3 commits
4030359
dfa555d
4382a11
c95023b
b725c52
227a171
7d8b048
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |||||||||||||
| import hudson.model.Item; | ||||||||||||||
| import hudson.model.TaskListener; | ||||||||||||||
| import hudson.util.FormValidation; | ||||||||||||||
| import hudson.util.ListBoxModel; | ||||||||||||||
| import java.io.Serializable; | ||||||||||||||
| import java.util.ArrayList; | ||||||||||||||
| import java.util.Arrays; | ||||||||||||||
|
|
@@ -80,7 +81,9 @@ | |||||||||||||
|
|
||||||||||||||
| @DataBoundSetter | ||||||||||||||
| public void setResourceSelectStrategy(String resourceSelectStrategy) { | ||||||||||||||
| this.resourceSelectStrategy = resourceSelectStrategy; | ||||||||||||||
| if (resourceSelectStrategy != null && !resourceSelectStrategy.isEmpty()) { | ||||||||||||||
| this.resourceSelectStrategy = resourceSelectStrategy; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @DataBoundSetter | ||||||||||||||
|
|
@@ -142,6 +145,15 @@ | |||||||||||||
| return RequiredResourcesProperty.DescriptorImpl.doAutoCompleteResourceNames(value, item); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @RequirePOST | ||||||||||||||
| public ListBoxModel doFillResourceSelectStrategyItems() { | ||||||||||||||
Check warningCode scanning / Jenkins Security Scan Stapler: Missing permission check Warning
Potential missing permission check in DescriptorImpl#doFillResourceSelectStrategyItems
Author
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. From my understanding this is a false positive since the resource strategy is available regardless of permissions? However, I see that there is a permission check in lockable-resources-plugin/src/main/java/org/jenkins/plugins/lockableresources/LockStep.java Lines 172 to 177 in 4030359
Contributor
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. because of security. Just add the same check like in other dSomething actions and every body will be happy.
|
||||||||||||||
| ListBoxModel items = new ListBoxModel(); | ||||||||||||||
| for (ResourceSelectStrategy resSelStrategy : ResourceSelectStrategy.values()) { | ||||||||||||||
| items.add(resSelStrategy.name()); | ||||||||||||||
| } | ||||||||||||||
| return items; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @RequirePOST | ||||||||||||||
| public static FormValidation doCheckLabel( | ||||||||||||||
| @QueryParameter String value, @QueryParameter String resource, @AncestorInPath Item item) { | ||||||||||||||
|
|
||||||||||||||
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 think, it will be better to thrown some exceptuion here. Because, like in ouir example, empty string is still not valid. The code will do some default things, and nobody will catch the developer failure.