Skip to content

Commit f87b078

Browse files
authored
Fix warnings (#208)
1 parent e690cd1 commit f87b078

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/main/java/hudson/plugins/throttleconcurrents/ThrottleJobProperty.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
4646
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
4747
import org.jenkinsci.plugins.workflow.graph.FlowNode;
48+
import org.kohsuke.stapler.AncestorInPath;
4849
import org.kohsuke.stapler.DataBoundConstructor;
4950
import org.kohsuke.stapler.QueryParameter;
5051
import org.kohsuke.stapler.StaplerRequest;
@@ -426,6 +427,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
426427
return true;
427428
}
428429

430+
@SuppressWarnings({"lgtm[jenkins/csrf]", "lgtm[jenkins/no-permission-check]"})
429431
public FormValidation doCheckCategoryName(@QueryParameter String value) {
430432
if (Util.fixEmptyAndTrim(value) == null) {
431433
return FormValidation.error("Empty category names are not allowed.");
@@ -434,6 +436,7 @@ public FormValidation doCheckCategoryName(@QueryParameter String value) {
434436
}
435437
}
436438

439+
@SuppressWarnings({"lgtm[jenkins/csrf]", "lgtm[jenkins/no-permission-check]"})
437440
public FormValidation doCheckMaxConcurrentPerNode(@QueryParameter String value) {
438441
return checkNullOrInt(value);
439442
}
@@ -448,6 +451,7 @@ private FormValidation checkNullOrInt(String value) {
448451
}
449452
}
450453

454+
@SuppressWarnings({"lgtm[jenkins/csrf]", "lgtm[jenkins/no-permission-check]"})
451455
public FormValidation doCheckMaxConcurrentTotal(@QueryParameter String value) {
452456
return checkNullOrInt(value);
453457
}
@@ -479,7 +483,14 @@ public List<ThrottleCategory> getCategories() {
479483
return categories;
480484
}
481485

482-
public ListBoxModel doFillCategoryItems() {
486+
@SuppressWarnings("lgtm[jenkins/csrf]")
487+
public ListBoxModel doFillCategoryItems(@AncestorInPath Item item) {
488+
if (item != null) {
489+
item.checkPermission(Item.CONFIGURE);
490+
} else {
491+
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
492+
}
493+
483494
ListBoxModel m = new ListBoxModel();
484495

485496
m.add("(none)", "");

src/main/java/hudson/plugins/throttleconcurrents/pipeline/ThrottleStep.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hudson.plugins.throttleconcurrents.pipeline;
22

33
import hudson.Extension;
4+
import hudson.model.Item;
45
import hudson.model.TaskListener;
56
import hudson.plugins.throttleconcurrents.ThrottleJobProperty;
67
import hudson.util.FormValidation;
@@ -14,6 +15,7 @@
1415
import org.jenkinsci.plugins.workflow.steps.StepContext;
1516
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
1617
import org.jenkinsci.plugins.workflow.steps.StepExecution;
18+
import org.kohsuke.stapler.AncestorInPath;
1719
import org.kohsuke.stapler.DataBoundConstructor;
1820
import org.kohsuke.stapler.QueryParameter;
1921

@@ -59,6 +61,7 @@ public Set<? extends Class<?>> getRequiredContext() {
5961
return Collections.singleton(TaskListener.class);
6062
}
6163

64+
@SuppressWarnings({"lgtm[jenkins/csrf]", "lgtm[jenkins/no-permission-check]"})
6265
public FormValidation doCheckCategoryName(@QueryParameter String value) {
6366
return ThrottleJobProperty.fetchDescriptor().doCheckCategoryName(value);
6467
}
@@ -67,8 +70,9 @@ public List<ThrottleJobProperty.ThrottleCategory> getCategories() {
6770
return ThrottleJobProperty.fetchDescriptor().getCategories();
6871
}
6972

70-
public ListBoxModel doFillCategoryItems() {
71-
return ThrottleJobProperty.fetchDescriptor().doFillCategoryItems();
73+
@SuppressWarnings("lgtm[jenkins/csrf]")
74+
public ListBoxModel doFillCategoryItems(@AncestorInPath Item item) {
75+
return ThrottleJobProperty.fetchDescriptor().doFillCategoryItems(item);
7276
}
7377
}
7478

0 commit comments

Comments
 (0)