Skip to content

Use Jenkins.checkGoodName for credential ID validation#1029

Open
Aadigarg111 wants to merge 1 commit intojenkinsci:masterfrom
Aadigarg111:fix-977-check-good-name
Open

Use Jenkins.checkGoodName for credential ID validation#1029
Aadigarg111 wants to merge 1 commit intojenkinsci:masterfrom
Aadigarg111:fix-977-check-good-name

Conversation

@Aadigarg111
Copy link

@Aadigarg111 Aadigarg111 commented Mar 22, 2026

Summary

  • replace ad-hoc regex validation in doCheckId with Jenkins.checkGoodName
  • keep duplicate-ID checks unchanged
  • add tests for invalid IDs and a legacy stored ID compatibility case

Testing

  • Unable to run Maven tests in this environment (mvn is not installed).

@Aadigarg111 Aadigarg111 requested a review from a team as a code owner March 22, 2026 14:31
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Unable to run Maven tests in this environment (mvn is not installed).

We do not accept pull requests that have not been tested.


If you want to continue with this you will need to set it up, see https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md#run-locally

if (!value.matches("[a-zA-Z0-9_.-]+")) { // anything else considered kosher?
return FormValidation.error("Unacceptable characters");
try {
Jenkins.checkGoodName(value);
Copy link
Member

Choose a reason for hiding this comment

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

other than changing the allowed character set this does nothing its the same result as before.

When saving the credentials it needs to call checkGoodName not just when validating it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants