Skip to content

Commit

Permalink
BUG: Fix cymru whois encoding issue
Browse files Browse the repository at this point in the history
fixes #307

Signed-off-by: Sebastian Wagner <sebix@sebix.at>
  • Loading branch information
sebix committed Sep 2, 2015
1 parent 75f8a3e commit cb4948b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion intelmq/bots/experts/cymru_whois/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def query(ip):
result = Cymru.__ip_query_parse(raw_result)

if "asn" in result:
raw_result = Cymru.__asn_query(result['asn'])
raw_result = Cymru.__asn_query(result['asn']).decode('utf-8')
extra_info = Cymru.__asn_query_parse(raw_result)
result.update(extra_info)

Expand Down
20 changes: 20 additions & 0 deletions intelmq/tests/bots/experts/cymru_whois/test_expert.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@
"destination.asn": 16876,
"destination.network": "2001:500:88::/48",
}
UNICODE_INPUT = {"__type": "Event",
"destination.ip": "177.81.215.80", # some brazil IP
"time.observation": "2015-01-01T00:00:00+00:00",
}
UNICODE_OUTPUT = {"__type": "Event",
"destination.ip": "177.81.215.80", # some brazil IP
"time.observation": "2015-01-01T00:00:00+00:00",
"destination.registry": "lacnic",
"destination.allocated": "2011-08-30T00:00:00+00:00",
"destination.as_name": "NET Servi\xe7os de Comunica\xe7\xe3o"
" S.A.,BR",
"destination.geolocation.cc": "BR",
"destination.asn": 28573,
"destination.network": "177.81.0.0/16",
}


class TestCymruExpertBot(test.BotTestCase, unittest.TestCase):
Expand All @@ -57,6 +72,11 @@ def test_ipv6_lookup(self):
self.run_bot()
self.assertMessageEqual(0, EXAMPLE_OUTPUT6)

def test_unicode_as_name(self):
self.input_message = json.dumps(UNICODE_INPUT)
self.run_bot()
self.assertMessageEqual(0, UNICODE_OUTPUT)


if __name__ == '__main__':
unittest.main()

0 comments on commit cb4948b

Please sign in to comment.