Slightly better Rapid7 parser
This commit is contained in:
parent
d976752797
commit
954b33b2a6
13
feed_dns.py
13
feed_dns.py
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import database
|
import database
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import typing
|
import typing
|
||||||
|
@ -66,12 +65,16 @@ class Rapid7Parser(Parser):
|
||||||
}
|
}
|
||||||
|
|
||||||
def consume(self) -> None:
|
def consume(self) -> None:
|
||||||
|
data = dict()
|
||||||
for line in self.buf:
|
for line in self.buf:
|
||||||
self.db.enter_step('parse_rapid7')
|
self.db.enter_step('parse_rapid7')
|
||||||
try:
|
split = line.split('"')
|
||||||
data = json.loads(line)
|
|
||||||
except json.decoder.JSONDecodeError:
|
for k in range(1, 14, 4):
|
||||||
continue
|
key = split[k]
|
||||||
|
val = split[k+2]
|
||||||
|
data[key] = val
|
||||||
|
|
||||||
self.register(
|
self.register(
|
||||||
Rapid7Parser.TYPES[data['type']],
|
Rapid7Parser.TYPES[data['type']],
|
||||||
int(data['timestamp']),
|
int(data['timestamp']),
|
||||||
|
|
Loading…
Reference in a new issue