-
Notifications
You must be signed in to change notification settings - Fork 234
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
[JENKINS-72611] Forbid editing credentials ID #502
Changes from all commits
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 |
---|---|---|
|
@@ -323,6 +323,14 @@ private synchronized boolean removeCredentials(@NonNull Domain domain, @NonNull | |
private synchronized boolean updateCredentials(@NonNull Domain domain, @NonNull Credentials current, | ||
@NonNull Credentials replacement) throws IOException { | ||
checkPermission(CredentialsProvider.UPDATE); | ||
|
||
// See IdCredentials.Helper#equals. | ||
// Note: We probably should not assume that all credentials are IdCredentials. We also do this a few lines below in list.indexOf(current) call. | ||
// If this one breaks, that one breaks as well. | ||
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. how so - the list is of type |
||
if (!current.equals(replacement)) { | ||
throw new IllegalArgumentException("Credentials' IDs do not match, will not update."); | ||
} | ||
|
||
Map<Domain, List<Credentials>> domainCredentialsMap = getDomainCredentialsMap(); | ||
if (domainCredentialsMap.containsKey(domain)) { | ||
List<Credentials> list = domainCredentialsMap.get(domain); | ||
|
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.
FTR
credentials-plugin/src/main/java/com/cloudbees/plugins/credentials/common/IdCredentials.java
Lines 50 to 85 in cf0a900
credentials-plugin/src/main/java/com/cloudbees/plugins/credentials/impl/BaseStandardCredentials.java
Lines 116 to 130 in cf0a900