projectcontour / contour

Contour is a Kubernetes ingress controller using Envoy proxy.
https://projectcontour.io
Apache License 2.0
3.73k stars 681 forks source link

Support regex with "?!" in HTTPProxy #6746

Open jadefr opened 2 weeks ago

jadefr commented 2 weeks ago

I get the following error when creating HTTPProxy with "?!":

  - errors:
    - message: 'route: supplied regex: /lorem/(?!.*\/ipsum)(.*) invalid. error: error
        parsing regexp: invalid or unsupported Perl syntax: `(?!`'
      reason: PathMatchConditionsNotValid
      status: "True"
      type: RouteError

Steps to reproduce:

Deploy yaml:

apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: basic
spec:
  virtualhost:
    fqdn: foo-basic.bar.com
  routes:
    - conditions:
      - regex: /lorem/(?!.*\/ipsum)(.*)
      services:
        - name: s1
          port: 80

I believe using package regexp2 would solve the issue. As an example, the following PR was done in NGINX Virtual Server: https://github.com/nginxinc/kubernetes-ingress/pull/4465

github-actions[bot] commented 2 weeks ago

Hey @jadefr! Thanks for opening your first issue. We appreciate your contribution and welcome you to our community! We are glad to have you here and to have your input on Contour. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace

tsaarni commented 2 weeks ago

Hi @jadefr. the validation Contour does using Go’s regexpshould align with Google’s RE2 engine as used in Envoy. It appears that NGINX uses PCRE, which does support negative lookaheads.