From 6c2ec6a58c30fe22e38afe0af314dc1fc617cb44 Mon Sep 17 00:00:00 2001 From: Ilya Glotov Date: Thu, 23 Apr 2020 13:16:30 +0300 Subject: [PATCH 1/4] Fix slow search tests --- tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.py b/tests/tests.py index 8c391f4..71643af 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -43,6 +43,6 @@ class TestPyMISPWarningLists(unittest.TestCase): results = self.warninglists.search('2001:DB8::34:1') self.assertEqual(results[0].name, 'List of RFC 3849 CIDR blocks') results = self.warninglists.search('1e100.net') - self.assertEqual(results[0].name, 'Top 1,000,000 most-used sites from Tranco') + self.assertEqual(results[0].name, 'List of known google domains') results = self.warninglists.search('something.files.1drv.com') self.assertEqual(results[0].name, 'Top 1,000,000 most-used sites from Tranco') From 5fe0d7fd6b75a71a19dccc3f3f849913c98087f4 Mon Sep 17 00:00:00 2001 From: Ilya Glotov Date: Thu, 23 Apr 2020 16:16:54 +0300 Subject: [PATCH 2/4] Fix slow search #6 --- pymispwarninglists/api.py | 2 +- tests/tests.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pymispwarninglists/api.py b/pymispwarninglists/api.py index 34489aa..799ddef 100644 --- a/pymispwarninglists/api.py +++ b/pymispwarninglists/api.py @@ -102,7 +102,7 @@ class WarningList(): parsed_url = urlparse(value) if parsed_url.hostname: value = parsed_url.hostname - return any(value.endswith(v) for v in self.list) + return any(value == v or value.endswith("."+v.lstrip(".")) for v in self.list) elif self.type == 'cidr': try: value = ip_address(value) diff --git a/tests/tests.py b/tests/tests.py index 71643af..c8d31b2 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -45,4 +45,8 @@ class TestPyMISPWarningLists(unittest.TestCase): results = self.warninglists.search('1e100.net') self.assertEqual(results[0].name, 'List of known google domains') results = self.warninglists.search('something.files.1drv.com') - self.assertEqual(results[0].name, 'Top 1,000,000 most-used sites from Tranco') + self.assertTrue('List of known microsoft domains' in [r.name for r in results]) + results = self.warninglists.search('arbitrary-domain-1e100.net') + self.assertEqual(results, []) + results = self.warninglists.search('phishing.co.uk') + self.assertEqual(results, []) From ea2093ef0cf049dc2e9135c9363ac38c6bfe675e Mon Sep 17 00:00:00 2001 From: Ilya Glotov Date: Thu, 23 Apr 2020 16:48:35 +0300 Subject: [PATCH 3/4] Rework test to check value in a list --- tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.py b/tests/tests.py index c8d31b2..1def6ee 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -43,7 +43,7 @@ class TestPyMISPWarningLists(unittest.TestCase): results = self.warninglists.search('2001:DB8::34:1') self.assertEqual(results[0].name, 'List of RFC 3849 CIDR blocks') results = self.warninglists.search('1e100.net') - self.assertEqual(results[0].name, 'List of known google domains') + self.assertTrue('List of known google domains' in [r.name for r in results]) results = self.warninglists.search('something.files.1drv.com') self.assertTrue('List of known microsoft domains' in [r.name for r in results]) results = self.warninglists.search('arbitrary-domain-1e100.net') From 14d8f239996211c6c9efce36d2c4f0ea9a427a41 Mon Sep 17 00:00:00 2001 From: Kimmo Linnavuo Date: Wed, 6 May 2020 11:53:52 +0300 Subject: [PATCH 4/4] chg: move coveralls to dev dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4f30296..da7d407 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,9 +23,9 @@ include = ["pymispwarninglists/data/misp-warninglists/schema.json", [tool.poetry.dependencies] python = "^3.6" -coveralls = "^2.0.0" [tool.poetry.dev-dependencies] +coveralls = "^2.0.0" codecov = "^2.0.22" jsonschema = "^3.2.0" nose = "^1.3.7"