diff --git a/CHANGES.rst b/CHANGES.rst index 72df293..a9a84d9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,10 +1,11 @@ Changelog ========= -0.15.1 (TBD) ------------- +0.15.1 (2017-02-16) +------------------- - Fixed IPv6 parsing for ASN origin lookups and added tests (#162 - ti-mo) +- Fixed recursive role parsing at depths greater than 0 (#161 - cdubz) 0.15.0 (2017-02-02) ------------------- diff --git a/README.rst b/README.rst index d1d5229..f115142 100644 --- a/README.rst +++ b/README.rst @@ -11,8 +11,8 @@ ipwhois :target: https://github.com/secynic/ipwhois/tree/master/LICENSE.txt .. image:: https://img.shields.io/badge/python-2.6%2C%202.7%2C%203.3+-blue.svg :target: https://docs.python.org -.. image:: https://img.shields.io/badge/docs-release%20v0.15.0-green.svg?style=flat - :target: https://ipwhois.readthedocs.io/en/v0.15.0 +.. image:: https://img.shields.io/badge/docs-release%20v0.15.1-green.svg?style=flat + :target: https://ipwhois.readthedocs.io/en/v0.15.1 .. image:: https://readthedocs.org/projects/pip/badge/?version=latest :target: https://ipwhois.readthedocs.io/en/latest .. image:: https://img.shields.io/badge/docs-dev-yellow.svg?style=flat @@ -39,7 +39,7 @@ for IPv4 and IPv6 addresses. RDAP (IPWhois.lookup_rdap()) is the recommended query method as of v0.11.0. If you are upgrading from earlier than 0.11.0, please see the - `upgrade info `_. .. note:: @@ -77,10 +77,10 @@ Links Documentation ------------- -Release v0.15.0 +Release v0.15.1 ^^^^^^^^^^^^^^^ -https://ipwhois.readthedocs.io/en/v0.15.0 +https://ipwhois.readthedocs.io/en/v0.15.1 GitHub master ^^^^^^^^^^^^^ diff --git a/ipwhois/__init__.py b/ipwhois/__init__.py index 9d50d2f..8d0504b 100644 --- a/ipwhois/__init__.py +++ b/ipwhois/__init__.py @@ -22,7 +22,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -__version__ = '0.15.0' +__version__ = '0.15.1' from .exceptions import * from .net import Net diff --git a/ipwhois/docs/source/conf.py b/ipwhois/docs/source/conf.py index 09d3d38..27b495d 100644 --- a/ipwhois/docs/source/conf.py +++ b/ipwhois/docs/source/conf.py @@ -67,9 +67,9 @@ # built documents. # # The short X.Y version. -version = '0.15.0' +version = '0.15.1' # The full version, including alpha/beta/rc tags. -release = '0.15.0' +release = '0.15.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/ipwhois/rdap.py b/ipwhois/rdap.py index 5c1b549..e97286c 100644 --- a/ipwhois/rdap.py +++ b/ipwhois/rdap.py @@ -747,6 +747,7 @@ def lookup(self, inc_raw=False, retry_count=3, asn_data=None, depth=0, results['network'] = result_net.vars results['entities'] = [] results['objects'] = {} + roles = {} # Iterate through and parse the root level entities. log.debug('Parsing RDAP root level entities') @@ -764,6 +765,16 @@ def lookup(self, inc_raw=False, retry_count=3, asn_data=None, depth=0, results['entities'].append(ent['handle']) + try: + + for tmp in ent['entities']: + + roles[tmp['handle']] = tmp['roles'] + + except KeyError: + + pass + except KeyError: pass @@ -811,6 +822,27 @@ def lookup(self, inc_raw=False, retry_count=3, asn_data=None, depth=0, result_ent.parse() new_objects[ent] = result_ent.vars + new_objects[ent]['roles'] = None + try: + + new_objects[ent]['roles'] = roles[ent] + + except KeyError: # pragma: no cover + + pass + + try: + + for tmp in response['entities']: + + if tmp['handle'] not in roles: + + roles[tmp['handle']] = tmp['roles'] + + except (IndexError, KeyError): + + pass + if inc_raw: new_objects[ent]['raw'] = response diff --git a/ipwhois/tests/test_rdap.py b/ipwhois/tests/test_rdap.py index 1e1ae16..b203be3 100644 --- a/ipwhois/tests/test_rdap.py +++ b/ipwhois/tests/test_rdap.py @@ -113,6 +113,20 @@ def test__RDAPLookup(self): bootstrap=True, inc_raw=True), dict) + # No sub entities. This is for coverage, but won't error out. + entity = [{'handle': 'test', 'roles': [ + 'administrative', 'technical']}] + + self.assertIsInstance(obj.lookup(response={ + 'handle': 'test', + 'ipVersion': 'v4', + 'startAddress': '74.125.225.229', + 'endAddress': '74.125.225.229', + 'entities': entity + }, + asn_data=val['asn_data'], + depth=1), dict) + class TestRDAPContact(TestCommon): diff --git a/setup.py b/setup.py index a5db3d5..86a68e5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import io NAME = 'ipwhois' -VERSION = '0.15.0' +VERSION = '0.15.1' AUTHOR = 'Philip Hane' AUTHOR_EMAIL = 'secynic AT gmail DOT com' DESCRIPTION = 'Retrieve and parse whois data for IPv4 and IPv6 addresses.'