Importing ICSI results into Redis

This commit is contained in:
Alexandre Dulaunoy 2015-10-02 19:57:55 +00:00
parent c7a6d5dfd8
commit d2a4c8c6f4

View file

@ -11,6 +11,8 @@
import dns.resolver
import argparse
import fileinput
import shlex
import redis
suffix = '.notary.icsi.berkeley.edu'
@ -21,11 +23,21 @@ argParser = argparse.ArgumentParser(description='Lookup a series of certificate
argParser.add_argument('-r', default='-', help='Read from a file, default is stdin')
args = argParser.parse_args()
icsi_keys = ['version','first_seen','last_seen', 'times_seen', 'validated']
rstore = redis.StrictRedis(host='localhost', port=6380, db=5)
for l in fileinput.input(args.r):
fp = l.rstrip()
fp = l.rstrip().lower()
try:
r = resolver.query(fp+suffix, 'TXT')[0]
r = resolver.query(fp+suffix, 'TXT')
except:
print ("Non-existing certificate {}".format(fp))
continue
print ("{},{}".format(fp,r))
for rdata in r:
txt = rdata.strings[0]
rd = {}
rd = dict(token.split('=') for token in shlex.split(txt))
rstore.hmset(fp, rd)
print (rd)
#print ("{},{}".format(fp,r[0]))