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-62889] ParameterDefinition check for validity #4826

Merged
merged 4 commits into from
Jul 6, 2020

Conversation

jeffret-b
Copy link
Contributor

@jeffret-b jeffret-b commented Jun 30, 2020

Add an API to ParameterDefinition by which a caller can validate a ParameterValue for that specific definition. This provides a mechanism to ensure that users cannot inject unrecognized values. This is particularly useful for things like ChoiceParameterDefinition, which process a value as a string, but should only allow a specific set of choices.

This new API is optional in two different ways:

  1. A subclass of ParameterDefinition has to optionally add implementation to participate in the API. The base implementation just accepts everything as valid because it doesn't know any better. I have added implementations for all of the subclasses in core, though most of them are pretty meaningless. Most of them just check that the value is of the correct class.
  2. A caller has to optionally invoke the new API to determine if a value is valid. The only place I know of that currently does anything like this is pipeline-build-step-plugin. I'm preparing another PR for that project to demonstrate usage of this new API.

JobParameterDefinition and JobParameterValue were never completed. These are only used in tests in MockClassUtils in graphql-server-plugin. These should be removed as part of clean up.

See JENKINS-62889.

Proposed changelog entries

N/A

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • [N/A] Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • [N/A] For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • [N/A] If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • [N/A] If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

Add a simple API to ParameterDefinition by which a caller can validate a ParameterValue for that specific definition.
@jeffret-b jeffret-b added the developer Changes which impact plugin developers label Jun 30, 2020
@jeffret-b jeffret-b changed the base branch from master to stable-2.222 June 30, 2020 21:02
@jeffret-b jeffret-b changed the base branch from stable-2.222 to master June 30, 2020 21:02
Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

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

Reviewed prior.

Copy link
Contributor

@MRamonLeon MRamonLeon left a comment

Choose a reason for hiding this comment

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

Do you plan to file a PR or ticket to fix graphql-server-plugin after removing these classes? It would be appreciated.

https://github.com/jenkinsci/graphql-server-plugin/blob/ca276ee90ab5d0a5bdad07d4e013eff757112e2b/src/test/java/io/jenkins/plugins/graphql/MockClassUtils.java#L106

Co-authored-by: stellargo <sumitsarinofficial@gmail.com>
@jeffret-b
Copy link
Contributor Author

We've got sufficient approvals and passing builds so I'm going to mark this as ready-for-merge and let the waiting period begin.

@jeffret-b jeffret-b added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jul 2, 2020
@timja timja added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label Jul 6, 2020
@timja timja merged commit 55d1b9e into jenkinsci:master Jul 6, 2020
@daniel-beck daniel-beck mentioned this pull request Jul 27, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer Changes which impact plugin developers ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback squash-merge-me Unclean or useless commit history, should be merged only with squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants