Skip to content

Fix: Strict mode to enforce FQDN#65

Merged
brian-brazil merged 3 commits into
prometheus-community:masterfrom
troyanov:fix-fqdn-check
Nov 25, 2019
Merged

Fix: Strict mode to enforce FQDN#65
brian-brazil merged 3 commits into
prometheus-community:masterfrom
troyanov:fix-fqdn-check

Conversation

@troyanov

@troyanov troyanov commented Nov 21, 2019

Copy link
Copy Markdown
Contributor

Go docs:
https://golang.org/pkg/net/url/#Parse

Trying to parse a hostname and path without a scheme is invalid but may not necessarily return an error, due to parsing ambiguities.

fqdnURL, err := url.Parse(*myFqdn)
if err != nil {
    c.handleErr(request, client, err)
    return
}

Example:
myFqdn was set to b607b847b180, scheme is missing, but no error (as mentioned in the docs).

We don't need to treat myFqdn as URL since it is not an URL but rather FQDN (which is schemaless)

Fixes: #64

Go docs:
https://golang.org/pkg/net/url/#Parse
> Trying to parse a hostname and path without a scheme is invalid but may not necessarily return an error, due to parsing ambiguities.

```
fqdnURL, err := url.Parse(*myFqdn)
if err != nil {
    c.handleErr(request, client, err)
    return
}
```
Example:
myFqdn was set to `b607b847b180`, scheme is missing, but no error (as mentioned in the docs).

We don't need to treat myFqdn as URL since it is not an URL but rather FQDN (which is schemaless)
@troyanov troyanov mentioned this pull request Nov 21, 2019
Comment thread client/client.go Outdated
logger := promlog.New(&promlogConfig)
coordinator := Coordinator{logger: logger}

if myFqdn == nil || strings.TrimSpace(*myFqdn) == "" {

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.

Don't trim spaces, let's not 2nd guess the user. I don't think this can be nil either.

@troyanov troyanov Nov 22, 2019

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, let's totally remove this if statement then.

@brian-brazil
brian-brazil merged commit d946edf into prometheus-community:master Nov 25, 2019
@brian-brazil

Copy link
Copy Markdown
Contributor

Thanks!

@troyanov
troyanov deleted the fix-fqdn-check branch March 4, 2020 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect fqdn check?

2 participants