From d1f64214de00090c3faae0bf544c6c2602ab8c31 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Oct 2019 17:18:14 -0700 Subject: [PATCH] add authority parsing --- jc/parsers/dig.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/jc/parsers/dig.py b/jc/parsers/dig.py index 79d5d462..904361da 100644 --- a/jc/parsers/dig.py +++ b/jc/parsers/dig.py @@ -82,7 +82,19 @@ def parse_question(question): def parse_authority(authority): - return {} + # cnn.com. 3600 IN NS ns-1086.awsdns-07.org. + authority = authority.split() + authority_name = authority[0] + authority_class = authority[2] + authority_type = authority[3] + authority_ttl = authority[1] + authority_data = authority[4] + + return {'name': authority_name, + 'class': authority_class, + 'type': authority_type, + 'ttl': authority_ttl, + 'data': authority_data} def parse_answer(answer): @@ -135,16 +147,20 @@ def parse(data): if question: output_entry['question'] = parse_question(line) question = False + authority = False + answer = False continue if line.find(';; AUTHORITY SECTION:') == 0: question = False authority = True answer = False + authority_list = [] continue - if authority: - output_entry['authority'] = parse_authority(line) + if line.find(';') == -1 and authority: + authority_list.append(parse_authority(line)) + output_entry.update({'authority': authority_list}) continue if line.find(';; ANSWER SECTION:') == 0: