Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Allow for a period in the GUID of the External ID#1034

Merged
arschles merged 1 commit into
kubernetes-retired:masterfrom
emaildanwilson:allowForPeriodInGUID
Jul 20, 2017
Merged

Allow for a period in the GUID of the External ID#1034
arschles merged 1 commit into
kubernetes-retired:masterfrom
emaildanwilson:allowForPeriodInGUID

Conversation

@emaildanwilson
Copy link
Copy Markdown
Contributor

The hashicorp/cf-vault-service-broker appends the plan name onto the GUID for the External ID using a period as the separator. The existing regEx validation does not allow for periods. The Pivotal docs do not specify an exact format and simply state using a GUID is recommended.

This change relaxes the regEx check to allow for periods in the External ID so this and other brokers that use this style will work for k8s.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 14, 2017
var validateServiceClassName = apivalidation.NameIsDNSSubdomain

const guidFmt string = "[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?"
const guidFmt string = "[a-zA-Z0-9]([-a-zA-Z0-9\.]*[a-zA-Z0-9])?"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should add a unit test case for this in serviceclass_test.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, the escape sequence isn't valid - you need to escape the backslash :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, will do.

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Jul 14, 2017

is this sufficient? I don't think we should have to wait for the next broker to break us - can't we just make it a string w/o any constraints? The spec does not require it to have any special constraints aside from being non-empty so we shouldn't add new ones w/o a very big reason.

@emaildanwilson
Copy link
Copy Markdown
Contributor Author

I added a test case and actually ran them locally this time 😄. It turns out that the period is evaluated as a literal inside the square brackets so it didn't need the backslash at all. doh.

var validateServiceClassName = apivalidation.NameIsDNSSubdomain

const guidFmt string = "[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?"
const guidFmt string = "[a-zA-Z0-9]([-a-zA-Z0-9.]*[a-zA-Z0-9])?"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's drop all checks except for non-empty string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm ok with changing that. @pmorie are you ok with this too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer not to drop them all, or we will never get a clear picture of what kind of stuff people return in this field.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we care since we don't do anything with this data except echo it back to the broker?

@emaildanwilson
Copy link
Copy Markdown
Contributor Author

@duglin I was going for the least impactful change. If removing the check is preferred I'm ok with that. Are there any other downstream risks with allowing for all special characters?

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Jul 14, 2017

I don't think there are (but yea we should check), because these IDs are not used by us or even really exposed to our users (they're just visible, not used by them) - we just use them when we talk to the brokers. We may need to make sure we escape them properly when we encode them in URLs tho.

@emaildanwilson
Copy link
Copy Markdown
Contributor Author

@duglin @pmorie
I created a new pull request #1038 that removes the GUID regEx check for the Plans[].ExternalID field. If that is preferred I'll close this one out.

@pmorie
Copy link
Copy Markdown
Contributor

pmorie commented Jul 14, 2017

I would prefer to loosen the validation on a case-by-case basis so that we can gather datapoints for the OSB WG. Ideally I would like to have the API spec to contain a validation regex

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Jul 14, 2017

@pmorie the OSB API spec just says its a non-empty string, not other requirement. It only "recommends" a GUID.

@pmorie
Copy link
Copy Markdown
Contributor

pmorie commented Jul 14, 2017

@duglin okay, does that mean I can send emoji? I feel like this field is in practice conformant to some regex, and 'non-empty string' is way too permissive to relax to. Remember that loosening a validation is OK, tightening is not. Hence my interest in gradually relaxing the regex.

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Jul 14, 2017

yes an emoji is ok ;-)
And I think so for a few reasons:
1 - because the spec says so by saying its just a string. If we want to add a regex to this 'string' field then we should look to do it for all - this one is not special. In fact its less special because of the next point.
2 - this is not a field that's for human consumption - so who cares what's in it? There are other fields that are spec'd as just 'string' that are for humans that would be more concerning w.r.t. funky things like emoji and html scripting tags than this one.

Ultimately, I think our hands are tied as the original issue proved - people are already treating it as a string, the spec says its a string so its a string. If we want to tighten it then its not an issue for svc-cat, its an issue for osb api and we'd need to change it there first. As I said earlier, the last thing I want to have happen is for us to have the svc-cat fail for a customer because they tried to use a broker that's spec compliant but we reject their IDs unnecessarily. Or put another way... IMO, svc-cat isn't spec compliant if we tighten it.

@pmorie pmorie added the LGTM1 label Jul 18, 2017
Copy link
Copy Markdown
Contributor

@arschles arschles left a comment

Choose a reason for hiding this comment

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

As we discussed in the design meeting today, we are going to merge this and discuss whether to relax the formatting restrictions on external IDs even further. The work to do that is in #1038.

LGTM

@arschles arschles added the LGTM2 label Jul 20, 2017
@arschles arschles merged commit be04cd5 into kubernetes-retired:master Jul 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. LGTM1 LGTM2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants