Skip to content
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 updating credentials ID #366

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

yaroslavafenkin
Copy link
Contributor

See JENKINS-72611.

Proposed changelog entries

  • Forbid updating credentials ID

Submitter checklist

  • JIRA issue is well described
  • Changelog entry appropriate for the audience affected by the change (users or developer, depending on the change).
    * Use the Internal: prefix if the change has no user-visible impact (API, test frameworks, etc.)
  • Appropriate autotests or explanation to why this change has no tests

@yaroslavafenkin yaroslavafenkin requested a review from a team as a code owner January 25, 2024 19:19
@jglick
Copy link
Member

jglick commented Jan 25, 2024

complementing jenkinsci/credentials-plugin#502

@jglick jglick added the bug label Jan 25, 2024
@jglick jglick enabled auto-merge January 25, 2024 19:35
@jglick jglick merged commit ce8ab43 into jenkinsci:master Jan 25, 2024
14 of 15 checks passed
@jtnord
Copy link
Member

jtnord commented Jan 26, 2024

most likely needs to be reverted due to exactly the same reason as jenkinsci/credentials-plugin#502

// 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.
if (!current.equals(replacement)) {
throw new IllegalArgumentException("Credentials' IDs do not match, will not update.");
Copy link
Member

@jtnord jtnord Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no no and more no. you must handle credentials that are not IDCredentials
reverted in #368

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about int index = list.indexOf(current) 6 lines below though? It will rely on equals under the hood, won't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does.
But why do you think that matters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If credential isn't an IdCredential, would that indexOf correctly find a credential to be updated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If credential isn't an IdCredential, would that indexOf correctly find a credential to be updated?

Under what conditions would it fail to find current in a list of Credentials?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.equals.
I've tested locally with the loadfocus plugin, and updating indeed works there. I'm surprised that object reference is that same. I don't know why I assumed it wouldn't be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants