Skip to content

Commit 853e114

Browse files
committed
chg: [pdns] filter option to exclude records added
1 parent 94042a1 commit 853e114

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

bin/pdns-ingestion.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
config.read('../etc/analyzer.conf')
2828

2929
expirations = config.items('expiration')
30-
30+
excludesubstrings = config.get('exclude', 'substring').split(',')
3131
myuuid = config.get('global', 'my-uuid')
3232
myqueue = "analyzer:8:{}".format(myuuid)
3333
mylogginglevel = config.get('global', 'logging-level')
@@ -89,7 +89,7 @@ def process_format_passivedns(line=None):
8989

9090
while (True):
9191
expiration = None
92-
d4_record_line = r_d4.rpop(myqueue)
92+
d4_record_line = r_d4.rpop(myqueue)
9393
if d4_record_line is None:
9494
time.sleep (1)
9595
continue
@@ -103,6 +103,13 @@ def process_format_passivedns(line=None):
103103
logger.debug('Parsing of passive DNS line is incomplete: {}'.format(l.strip()))
104104
continue
105105
if rdns['q'] and rdns['type']:
106+
excludeflag = False
107+
for exclude in excludesubstrings:
108+
if exclude in rdns['q']:
109+
excludeflag = True
110+
if excludeflag:
111+
logger.debug('Excluded {}'.format(rdns['q']))
112+
continue
106113
for y in expirations:
107114
if y[0] == rdns['type']:
108115
expiration=y[1]

etc/analyzer.conf.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ logging-level = INFO
66
[expiration]
77
16 = 24000
88
99 = 26000
9+
[exclude]
10+
substring = spamhaus.org,asn.cymru.com

0 commit comments

Comments
 (0)