Skip to content

Commit

Permalink
[SECURITY-2753]
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Apr 29, 2022
1 parent 989ad1e commit 37e48ca
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dabsquared.gitlabjenkins.connection;


import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
Expand Down Expand Up @@ -125,6 +126,15 @@ public ListBoxModel doFillGitLabConnectionItems() {
public ListBoxModel doFillJobCredentialIdItems(@AncestorInPath Item item, @QueryParameter String url,
@QueryParameter String jobCredentialId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(jobCredentialId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(jobCredentialId);
}
}
return result.includeEmptyValue()
.includeMatchingAs(ACL.SYSTEM, item, StandardCredentials.class,
URIRequirementBuilder.fromUri(url).build(), new GitLabCredentialMatcher())
Expand Down

0 comments on commit 37e48ca

Please sign in to comment.