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

Enhance the 'Forwarded' header checker in conformance tests. #4626

Merged

Conversation

markusthoemmes
Copy link
Contributor

Proposed Changes

This test uses an intricate regular-expression to verify the returned Forwarded header roughly conforms to the spec. Unfortunately, it does not account for arbitrary additions (known as extensions to the spec) and trailing delimiters. While trailing delimiters are non-standard, they are unfortunately added by some routers.

Release Note

NONE

/assign @vagababov @dgerd

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 5, 2019
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 5, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@markusthoemmes: 0 warnings.

In response to this:

Proposed Changes

This test uses an intricate regular-expression to verify the returned Forwarded header roughly conforms to the spec. Unfortunately, it does not account for arbitrary additions (known as extensions to the spec) and trailing delimiters. While trailing delimiters are non-standard, they are unfortunately added by some routers.

Release Note

NONE

/assign @vagababov @dgerd

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.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markusthoemmes

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

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Jul 5, 2019
expected string
}

// token as defined in https://tools.ietf.org/html/rfc7230#section-3.2.6
Copy link
Contributor

Choose a reason for hiding this comment

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

var (
...
)

Perhaps?

if pair == "" {
continue
}
parts := strings.Split(strings.TrimSpace(pair), "=")
Copy link
Contributor

Choose a reason for hiding this comment

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

what if it's a=b=c? SplitN, may be? Since this will pass token matcher validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will it? = is not an allowed character in token. I‘ll habe another look though

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess, it's a delimeter.

var tokenMatcher = regexp.MustCompile(`^[0-9a-zA-Z!#$%&'*+-.^_|~]+$`)

// approximation of quoted-string as defined in https://tools.ietf.org/html/rfc7230#section-3.2.6
var quotedStringMatcher = regexp.MustCompile(`^"[^"]+"$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

The way I read A sender SHOULD NOT generate a quoted-pair in a quoted-string except where necessary to quote DQUOTE , it feels that \" is valid inside quoted text. But, I do not think we have to be that precise. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, hence it‘s an approximation 😬

Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold
if you want to collect "vars" together, otherwise just cancel.

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jul 5, 2019
This test uses an intricate regular-expression to verify the returned Forwarded header roughly conforms to the spec. Unfortunately, it does not account for arbitrary additions (known as extensions to the spec) and trailing delimiters. While trailing delimiters are non-standard, they are unfortunately added by some routers.
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 6, 2019
@markusthoemmes
Copy link
Contributor Author

/hold cancel

@vagababov collapsed the var statements.

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 6, 2019
@vagababov
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 6, 2019
@knative-prow-robot knative-prow-robot merged commit 04097e0 into knative:master Jul 6, 2019
nak3 pushed a commit to nak3/serving that referenced this pull request Jul 8, 2019
…#4626)

* Enhance the 'Forwarded' header checker in conformance tests.

This test uses an intricate regular-expression to verify the returned Forwarded header roughly conforms to the spec. Unfortunately, it does not account for arbitrary additions (known as extensions to the spec) and trailing delimiters. While trailing delimiters are non-standard, they are unfortunately added by some routers.

* Collapse var statements.
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. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

5 participants