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

Validate parameter name format #4799

Merged
merged 1 commit into from
May 11, 2022

Conversation

chuangw6
Copy link
Member

@chuangw6 chuangw6 commented Apr 26, 2022

Changes

Fixes #4792

This doc mentioned that the parameter names should follow the following rules:

  • Must only contain alphanumeric characters, hyphens (-), underscores (_), and dots (.).
  • Must begin with a letter or an underscore (_).

For example, foo.Is-Bar_ is a valid parameter name, but barIsBa$ or 0banana are not.

But the current code has not implemented the validation against the name format, which can cause some problems mentioned in #4792 .

In this PR, we enforce the rules. If invalid name format is found, validation webhook will complain.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 26, 2022
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 26, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.2% 0.1

@chuangw6 chuangw6 marked this pull request as draft April 26, 2022 23:52
Copy link
Member Author

@chuangw6 chuangw6 left a comment

Choose a reason for hiding this comment

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

additional work to be done with extractVariablesFromString function.

pkg/apis/pipeline/v1beta1/task_validation.go Outdated Show resolved Hide resolved
@chuangw6
Copy link
Member Author

/retest

@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 1, 2022
`tasks.md` mentioned that the parameter names should follow the
following rules. But we didn't enforce it.
- Must only contain alphanumeric characters, hyphens (-),
  underscores (_), and dots (.).
- Must begin with a letter or an underscore (_).

In this commit, we enforce the rules. If invalid name format is found,
validation webhook will complain.
@chuangw6 chuangw6 force-pushed the validate-param-name-format branch from 0aced0f to 133a5ec Compare May 6, 2022 01:46
@chuangw6 chuangw6 marked this pull request as ready for review May 6, 2022 01:47
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 6, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.2% 0.1

@chuangw6
Copy link
Member Author

chuangw6 commented May 6, 2022

/test pull-tekton-pipeline-integration-tests

@chuangw6 chuangw6 changed the title Validate variable name format Validate parameter name format May 6, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 6, 2022
chitrangpatel added a commit to chitrangpatel/pipeline that referenced this pull request May 11, 2022
We want to extract everything that `NAME` contains in (`$param.<NAME> | $param.<NAME>[*]`)
or (`param["<NAME>"] | $param["<NAME>"][*]`) or (`param['NAME'][*] | $param['<NAME>'][*]`).
We dont want to enforce the pattern that it should follow. That part should be done by
`Step 1` in tektoncd#4799 (comment)

The regex pattern substitution `.*?(\[\*\])?` matches and extracts everything that is
contained in `<NAME>` or `<NAME>[*]`.
chitrangpatel added a commit to chitrangpatel/pipeline that referenced this pull request May 11, 2022
We want to extract everything that `NAME` contains in (`$param.<NAME> | $param.<NAME>[*]`)
or (`param["<NAME>"] | $param["<NAME>"][*]`) or (`param['NAME'][*] | $param['<NAME>'][*]`).
We dont want to enforce the pattern that it should follow. That part should be done by
`Step 1` in tektoncd#4799 (comment)

The regex pattern substitution `.*?(\[\*\])?` matches and extracts everything that is
contained in `<NAME>` or `<NAME>[*]`.
Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 11, 2022
@tekton-robot tekton-robot merged commit 9c0e081 into tektoncd:main May 11, 2022
chitrangpatel added a commit to chitrangpatel/pipeline that referenced this pull request May 18, 2022
We want to extract everything that `NAME` contains in (`$param.<NAME> | $param.<NAME>[*]`)
or (`param["<NAME>"] | $param["<NAME>"][*]`) or (`param['NAME'][*] | $param['<NAME>'][*]`).
We dont want to enforce the pattern that it should follow. That part should be done by
`Step 1` in tektoncd#4799 (comment)

The regex pattern substitution `.*?(\[\*\])?` matches and extracts everything that is
contained in `<NAME>` or `<NAME>[*]`.
tekton-robot pushed a commit that referenced this pull request Jul 4, 2022
We want to extract everything that `NAME` contains in (`$param.<NAME> | $param.<NAME>[*]`)
or (`param["<NAME>"] | $param["<NAME>"][*]`) or (`param['NAME'][*] | $param['<NAME>'][*]`).
We dont want to enforce the pattern that it should follow. That part should be done by
`Step 1` in #4799 (comment)

The regex pattern substitution `.*?(\[\*\])?` matches and extracts everything that is
contained in `<NAME>` or `<NAME>[*]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing validation against parameter name format
4 participants