move message() around (#1077)

This commit is contained in:
Michel Oosterhof 2019-03-28 00:44:57 +04:00 committed by GitHub
parent c02a473889
commit fe1ce7d74e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 13 deletions

View File

@ -44,6 +44,16 @@ class Output(cowrie.core.output.Output):
""" """
Scan IP againt Greynoise API Scan IP againt Greynoise API
""" """
def message(query):
log.msg(
eventid='cowrie.greynoise.result',
format='greynoise: Scan for %(IP)s with %(tag)s have %(conf)s confidence'
' along with the following %(meta)s metadata',
IP=entry['src_ip'],
tag=query['name'],
conf=query['confidence'],
meta=query['metadata']
)
gnUrl = '{0}query/ip'.format(GNAPI_URL).encode('utf8') gnUrl = '{0}query/ip'.format(GNAPI_URL).encode('utf8')
headers = ({'User-Agent': [COWRIE_USER_AGENT]}) headers = ({'User-Agent': [COWRIE_USER_AGENT]})
@ -55,8 +65,8 @@ class Output(cowrie.core.output.Output):
headers=headers) headers=headers)
if response.code != 200: if response.code != 200:
message = yield response.text() rsp = yield response.text()
log.error("greynoise: got error {}".format(message)) log.error("greynoise: got error {}".format(rsp))
return return
j = yield response.json() j = yield response.json()
@ -72,14 +82,3 @@ class Output(cowrie.core.output.Output):
message(query) message(query)
else: else:
log.msg("greynoise: no results for for IP {0}".format(entry['src_ip'])) log.msg("greynoise: no results for for IP {0}".format(entry['src_ip']))
def message(query):
log.msg(
eventid='cowrie.greynoise.result',
format='greynoise: Scan for %(IP)s with %(tag)s have %(conf)s confidence'
' along with the following %(meta)s metadata',
IP=entry['src_ip'],
tag=query['name'],
conf=query['confidence'],
meta=query['metadata']
)