Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +81,9 @@

@DataBoundSetter
public void setResourceSelectStrategy(String resourceSelectStrategy) {
this.resourceSelectStrategy = resourceSelectStrategy;
if (resourceSelectStrategy != null && !resourceSelectStrategy.isEmpty()) {

Check warning on line 84 in src/main/java/org/jenkins/plugins/lockableresources/LockStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 84 is only partially covered, 2 branches are missing
Copy link
Contributor

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.

this.resourceSelectStrategy = resourceSelectStrategy;
}
}

@DataBoundSetter
Expand Down Expand Up @@ -142,6 +145,15 @@
return RequiredResourcesProperty.DescriptorImpl.doAutoCompleteResourceNames(value, item);
}

@RequirePOST
public ListBoxModel doFillResourceSelectStrategyItems() {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doFillResourceSelectStrategyItems
Copy link
Author

Choose a reason for hiding this comment

The 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

// check permission, security first
if (item != null) {
item.checkPermission(Item.CONFIGURE);
} else {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
}
but not sure why

Copy link
Contributor

Choose a reason for hiding this comment

The 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;

Check warning on line 154 in src/main/java/org/jenkins/plugins/lockableresources/LockStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 150-154 are not covered by tests
}

@RequirePOST
public static FormValidation doCheckLabel(
@QueryParameter String value, @QueryParameter String resource, @AncestorInPath Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<f:checkbox title="${%entry.skipIfLocked.title}"/>
</f:entry>
<f:entry title="${%entry.resourceSelectStrategy.title}" field="resourceSelectStrategy">
<f:textbox/>
<f:select/>
</f:entry>
<f:entry title="${%entry.priority.title}" field="priority">
<f:number/>
Expand Down
Loading