cgmcintyr / pycadvisor

Python api wrapper for google/cadvisor rest api
Other
1 stars 1 forks source link

Cadvisor object url protocol not validated correctly #1

Open cgmcintyr opened 6 years ago

cgmcintyr commented 6 years ago

Initialising a Cadvisor object without a protocol can result in errors when making requests to paths joined onto url.

For example:

from cadvisor import Cadvisor

cad = Cadvisor('127.0.0.1:8080', '1.3')

Results in that Cadvisor instance's 'get' methods trying to urljoin a string onto 127.0.0.1:8080.

For example calling cad.get_machine_info():

https://github.com/cgmcintyr/pycadvisor/blob/d15c00a0769792940b6253d85c9b3e2001715e5d/cadvisor/cadvisor.py#L39-L41

In this instance would result in callling api.machine_info_url with base_url arg set to 127.0.0.1:8080

https://github.com/cgmcintyr/pycadvisor/blob/d15c00a0769792940b6253d85c9b3e2001715e5d/cadvisor/api.py#L13-L14

Which would return the string 'machine/', which leads to a MissingSchema: Invalid URL 'machine' when this string is passed as argument into self.__get_json_data.

cgmcintyr commented 6 years ago

First step would be to create a test case. After this look at adding http:// to start of url cadvisor is being initialised with if there is no procotol given.