yolothreat / utilitybelt

A Python library for being a CND Batman....
MIT License
35 stars 12 forks source link

catch exceptions in reverse_dns for herror and gaierror #64

Closed deadbits closed 1 year ago

deadbits commented 8 years ago

This patches the reverse_dns() function to return an empty list if a socket.herror or socket.gaierror is caught.

>>> from utilitybelt import utilitybelt as ub

## This throws a socket.gaierror exception since the IP address contains a newline.
>>> ub.reverse_dns('50.116.59.164\n')
[]

## This is a valid lookup
>>> ub.reverse_dns('50.116.59.164')
['zeroharbor.org']

## This throws a socket.herror exception since there's no PTR record
>>> ub.reverse_dns('82.160.51.229')
[]
>>>
deadbits commented 8 years ago

This is the same test failure that my other PR gave too. I don't understand what's going on here.. There is no change that affects anything related to url. I'm thinking this is the master branch code itself.

coveralls

Submitting coverage to coveralls.io...
/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:100: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Coverage submitted!
Couldn't find a repository matching this job.

'url' coveralls returned exit code 2
deadbits commented 6 years ago

Same error. See last comment here https://github.com/yolothreat/utilitybelt/pull/62#issuecomment-416755682