Skip to content

Commit

Permalink
Fixes intelsdi-x#260: Adds URL checking
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanyfay committed Feb 24, 2016
1 parent 3b1ae75 commit 2fe0dde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions mgmt/rest/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"path/filepath"
"strings"

"github.com/asaskevich/govalidator"
"github.com/intelsdi-x/snap/mgmt/rest/rbody"
)

Expand Down Expand Up @@ -111,6 +112,11 @@ func (c *Client) do(method, path string, ct contentType, body ...[]byte) (*rbody
rsp *http.Response
err error
)
// URL validation
validURL := govalidator.IsURL(c.prefix + path)
if !validURL {
return nil, errors.New("URL is not in the format of http(s)://<ip>:<port>")
}
switch method {
case "GET":
rsp, err = c.http.Get(c.prefix + path)
Expand Down

0 comments on commit 2fe0dde

Please sign in to comment.