Skip to content

Commit 5348b39

Browse files
committed
add BOTS config for domaintools
1 parent 5c61f0a commit 5348b39

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

intelmq/bots/BOTS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@
476476
"redis_cache_ttl": "86400"
477477
}
478478
},
479+
"Domaintools": {
480+
"description": "Domaintools expert is a bot which queries domaintools.com for a scoring of a domain name",
481+
"module": "intelmq.bots.experts.domaintools.expert",
482+
"parameters": {
483+
"user": "",
484+
"password": ""
485+
}
486+
},
479487
"Field Reducer": {
480488
"description": "The field reducer bot is capable of removing fields from events.",
481489
"module": "intelmq.bots.experts.field_reducer.expert",

intelmq/bots/experts/domaintools/expert.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,30 @@ def init(self):
2626
self.api = API(self.parameters.user, self.parameters.password)
2727

2828
def domaintools_get_score(self, fqdn):
29-
29+
score = None
3030
if fqdn:
31-
resp = self.api.reputation(fqdn, include_reason=False) # don't include a reason in the JSON response
31+
resp = self.api.reputation(fqdn, include_reasons=False) # don't include a reason in the JSON response
32+
3233
try:
3334
score = resp['risk_score']
3435
except exceptions.NotFoundException:
35-
score = None
36+
score = None
3637
except exceptions.BadRequestException:
37-
score = None
38+
score = None
3839
return score
3940

4041
def process(self):
4142
event = self.receive_message()
43+
extra = {}
4244

4345
for key in ["source.", "destination."]:
4446
key_fqdn = key + "fqdn"
4547
if key_fqdn not in event:
4648
continue # can't query if we don't have a domain name
47-
score = self.domaintools_get_score(key_fqdn)
48-
if score:
49-
event.add("extra.domaintools_score", score, raise_failure=False)
49+
score = self.domaintools_get_score(event.get(key_fqdn))
50+
if score is not None:
51+
extra["domaintools_score"] = score
52+
event.add("extra", extra)
5053

5154
self.send_message(event)
5255
self.acknowledge_message()

intelmq/tests/bots/experts/domaintools/__init__.py

Whitespace-only changes.

intelmq/tests/bots/experts/domaintools/test_expert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import unittest
77

88
import intelmq.lib.test as test
9-
from intelmq.bots.experts.gethostbyname.expert import DomaintoolsExpertBot
9+
from intelmq.bots.experts.domaintools.expert import DomaintoolsExpertBot
1010

1111
EXAMPLE_INPUT = {"__type": "Event",
1212
"source.fqdn": "google.com",
1313
"time.observation": "2015-01-01T00:00:00+00:00"
1414
}
1515
EXAMPLE_OUTPUT = {"__type": "Event",
16-
"source.fqdn": "example.com",
17-
"extra.domaintools_score": 0,
16+
"source.fqdn": "google.com",
17+
"extra": '{"domaintools_score": 0}',
1818
"time.observation": "2015-01-01T00:00:00+00:00"
1919
}
2020
NONEXISTING_INPUT = {"__type": "Event",
@@ -33,6 +33,7 @@ class TestDomaintoolsExpertBot(test.BotTestCase, unittest.TestCase):
3333
@classmethod
3434
def set_bot(self):
3535
self.bot_reference = DomaintoolsExpertBot
36+
self.sysconfig = {'user': 'mkendrick_first2017', 'password': 'c0e4e-e2527-dc6af-824a4-229d5'}
3637

3738
def test_existing(self):
3839
self.input_message = EXAMPLE_INPUT

0 commit comments

Comments
 (0)