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 ingress path fields #9309

Merged
merged 3 commits into from
Nov 17, 2022
Merged

Conversation

rikatz
Copy link
Contributor

@rikatz rikatz commented Nov 15, 2022

What this PR does / why we need it:

Adds validation on "path" fields in Ingress objects

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • CVE Report (Scanner found CVE and adding report)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

How Has This Been Tested?

Added additional unit and e2e tests

Does my pull request need a release note?

Validate the path field on ingress objects. Now Ingresses without regex annotation will just accept a small set of characters as path, and with regex annotation enabled will accept this small set of characters + characters required for regex to work

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 15, 2022
@k8s-ci-robot
Copy link
Contributor

@rikatz: This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 15, 2022
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2022
@rikatz rikatz force-pushed the validate-path-field branch 2 times, most recently from 2c53bcd to 12ae609 Compare November 15, 2022 23:13
Copy link
Member

@tao12345666333 tao12345666333 left a comment

Choose a reason for hiding this comment

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

LGTM

internal/ingress/controller/store/store_test.go Outdated Show resolved Hide resolved
internal/ingress/controller/store/store.go Outdated Show resolved Hide resolved
pkg/util/ingress/ingress.go Outdated Show resolved Hide resolved
Copy link
Member

@tao12345666333 tao12345666333 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rikatz, tao12345666333

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:
  • OWNERS [rikatz,tao12345666333]

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

@k8s-ci-robot k8s-ci-robot merged commit c1413e6 into kubernetes:main Nov 17, 2022
jaehnri pushed a commit to jaehnri/ingress-nginx that referenced this pull request Jan 2, 2023
* Validate characters in path fields

* Add e2e tests for path validation

* Fix review comments
@haisum
Copy link

haisum commented Jan 11, 2023

@rikatz This seems to have broken our ingress resources.

This was working before this change:

spec:
  ingressClassName: internal-ingress
  rules:
  - host: foo.com
    http:
      paths:
      - backend:
          service:
            name: foo
            port:
              number: 8080
        path: /foo(/|$)(.*)
        pathType: Prefix

What would be a 'valid' path in above after this change?

@matthewdevenny
Copy link

To add to this... Would it not be better to use url.ParseRequestURI to validate the non-regex path? I think this change currently doesn't support all valid URI paths.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants