Skip to content

[JENKINS-74917] Fix adjunct script to validate the passphrase when the SSH private key is entered directly#231

Merged
fcojfernandez merged 1 commit intojenkinsci:masterfrom
fcojfernandez:JENKINS-74917
Nov 26, 2024
Merged

[JENKINS-74917] Fix adjunct script to validate the passphrase when the SSH private key is entered directly#231
fcojfernandez merged 1 commit intojenkinsci:masterfrom
fcojfernandez:JENKINS-74917

Conversation

@fcojfernandez
Copy link
Member

this script relies on a secretTextarea having an specific class, but that's not supported in the taglib. Therefore, there was a javascript error preventing the form validations from being updated. The plugin is behaving as expected, and this issue is merely a UX issue.

Note 1: Although this was detected working on FIPS mode, this is not a real FIPS issue
Note 2: This issue is not blocking, the page still works. Simply it's a bit annoying to see that the form validation messages are not updated

Testing done

  1. Open the javascript console
  2. Go to Manage Jenkins > Credentials
  3. Select a Domain
  4. Click on Add Credentials
  5. Select SSH Username with private key
  6. Click on Enter directly
  7. Enter a ciphered private key
  8. Enter the passphrase

With the code in master you'll see an error in the javascript console
With the fix, the javascript error isn't there.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@fcojfernandez fcojfernandez requested a review from a team as a code owner November 26, 2024 09:55
var newEvent = new Event("change")
const privateKeyElements = document.getElementsByClassName('sshCredentials_privateKey');
if (passphraseElements.length > 0) {
var newEvent = new Event("change", {"bubbles": true})
Copy link
Member Author

Choose a reason for hiding this comment

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

this is what allows the event to be dispatched. By default is false

Copy link

@tejasdrolia tejasdrolia left a comment

Choose a reason for hiding this comment

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

LGTM

@fcojfernandez fcojfernandez merged commit b8b6b97 into jenkinsci:master Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants