rework result printing

new script printresults.py replaces old nsprint.py and diffresults.py
parent 412f1567
Pipeline #41260 passed with stage
in 1 minute and 24 seconds
......@@ -187,9 +187,9 @@ PATH=$PATH:<path to genreport tool> ./testedns.py
# print list of domains which are going to break in 2019
# i.e. list of domains which are clasified as "high latency"
# in the permissive mode but are "dead" in strict mode
./diffresults.py
./printresults.py new
# alternatively print dead domains + list of their NSses
# some of the NSes might be broken for other reasons than EDNS,
# e.g. some might not be authoritative for domain in question etc.
./nsprint.py
./printresults.py new --ns
......@@ -9,5 +9,6 @@ genednscomp.py > ednscomp.input
testedns.py 2
ednscomp2pickle.py ednscompresult-*
evalzone.py
diffresults.py
nsprint.py
printresults.py new
printresults.py new --ns
printresults.py all permissive dead --ns
#!/usr/bin/python3
"""
print list of new "dead" domains
i.e. list of domains which will break after 2019 EDNS Flag Day
"""
import logging
import pickle
from evalzone import EDNSResult
def main():
"""
compute stats and print them to stdout
"""
logging.info('loading permissive mode results')
with open('results_permissive.pickle', 'rb') as pickle_bin:
permissive = pickle.load(pickle_bin)
logging.info('loading strict mode results')
with open('results_strict.pickle', 'rb') as pickle_bin:
strict = pickle.load(pickle_bin)
logging.info('loading NS sets')
logging.info('computing domains which are going to stop working in 2019')
edns_broken_domains = set(strict[EDNSResult.dead].keys()) \
- set(permissive[EDNSResult.dead].keys())
for domain in edns_broken_domains:
print(domain)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
main()
......@@ -20,6 +20,10 @@ class EDNSResult(IntEnum):
high_latency = 3 # timeouts are likely but it will work eventually
dead = 4 # not even one NS works
def __str__(self):
"""omit class name"""
return self.name
ZoneNSStats = NamedTuple('ZoneNSStats', [('origin', dns.name.Name),
# stats: ip -> # replies
('stats', Dict[str, int]), # ip -> # replies
......
#!/usr/bin/python3
"""
print list of new "dead" domains + their NSes
i.e. list of domains which will break after 2019 EDNS Flag Day
"""
import logging
import pickle
from evalzone import EDNSResult
def main():
"""
compute stats and print them to stdout
"""
logging.info('loading permissive mode results')
with open('results_permissive.pickle', 'rb') as pickle_bin:
permissive = pickle.load(pickle_bin)
logging.info('loading strict mode results')
with open('results_strict.pickle', 'rb') as pickle_bin:
strict = pickle.load(pickle_bin)
logging.info('loading NS sets')
with open('domain2nsset.pickle', 'rb') as pickle_bin:
domain2nssec = pickle.load(pickle_bin)
logging.info('computing domains with NS which are going to stop working')
edns_broken_domains = set(strict[EDNSResult.dead].keys()) \
- set(permissive[EDNSResult.dead].keys())
for domain in edns_broken_domains:
for nsname in domain2nssec[domain]:
print(domain, nsname)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
main()
#!/usr/bin/python3
"""
print list of new "dead" domains + their NSes
i.e. list of domains which will break after 2019 EDNS Flag Day
"""
import argparse
import logging
import pickle
import sys
from typing import Dict, Set
import dns.name
from evalzone import EDNSResult
def print_domain(mode: str, result: EDNSResult, domain: dns.name.Name,
nsset: Set[dns.name.Name], reason) \
-> None:
if not nsset:
print(mode, result, domain, ';', reason)
else:
for nsname in nsset:
print(mode, result, domain, nsname, ';', reason)
def new_domains(permissive, strict,
args, domain2ns: Dict[dns.name.Name, dns.name.Name]) -> None:
logging.info('computing domains with NS which are going to stop working')
edns_broken_domains = set(strict[EDNSResult.dead].keys()) \
- set(permissive[EDNSResult.dead].keys())
for domain in edns_broken_domains:
nsset = args.ns and domain2ns[domain]
print_domain('strict', EDNSResult.dead, domain, nsset, strict[EDNSResult.dead][domain])
def print_all(permissive, strict, args, domain2ns) -> None:
if not args.mode:
modes = {'permissive': permissive,
'strict': strict}
else:
modes = {args.mode: locals()[args.mode]}
if not args.result:
args.result = EDNSResult
else:
# workaround for non-functional argparse choices=Enum
args.result = (getattr(EDNSResult, args.result), )
for modename, modedata in modes.items():
for result in args.result:
for domain, reason in modedata[result].items():
nsset = args.ns and domain2ns[domain]
print_domain(modename, result, domain, nsset, reason)
def main():
"""
compute stats and print them to stdout
"""
parser = argparse.ArgumentParser(description='''
print test result for each domain in format:
<mode> <result> <domain name> [ns name] ; commentary
''')
subparsers = parser.add_subparsers(dest='cmd')
allcmd = subparsers.add_parser('all', help='list results for all domains (see list --help)')
allcmd.add_argument('mode', nargs='?', choices=['permissive', 'strict'],
help='limit listing to specified mode')
# workaround for non-functional argparse choices=Enum
allcmd.add_argument('result', nargs='?', choices=EDNSResult.__members__,
help='limit listing to specified result category')
allcmd.add_argument('--ns', action='store_true', default=False,
help='print NS for each domain')
allcmd.set_defaults(func=print_all)
newcmd = subparsers.add_parser('new',
help='list only domains which will die after 2019 DNS flag day')
newcmd.add_argument('--ns', action='store_true', default=False,
help='print NS for each domain')
newcmd.set_defaults(func=new_domains)
args = parser.parse_args()
# parser.add_subparsers() call is missing required= option in Python 3.6
if not args.cmd:
sys.exit('subcommand required, see --help for usage')
# this can be optimized but it is probably not worth the effort
logging.info('loading permissive mode results')
with open('results_permissive.pickle', 'rb') as pickle_bin:
permissive = pickle.load(pickle_bin)
logging.info('loading strict mode results')
with open('results_strict.pickle', 'rb') as pickle_bin:
strict = pickle.load(pickle_bin)
if args.ns:
logging.info('loading NS sets')
with open('domain2nsset.pickle', 'rb') as pickle_bin:
domain2ns = pickle.load(pickle_bin)
else:
domain2ns = None
args.func(permissive, strict, args, domain2ns)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment