6
6
import argparse
7
7
from dnssec .probing .datatypes import ValidationResult
8
8
from enum import Enum
9
+ import matplotlib .pyplot as plt
9
10
10
11
11
12
class EvalState (Enum ):
@@ -14,6 +15,43 @@ class EvalState(Enum):
14
15
FLAPPING = 2 ,
15
16
16
17
18
+ def plot_or_show (output_path ):
19
+ if output_path :
20
+ if output_path [- 1 ] != '/' :
21
+ output_path += '/'
22
+ plt .savefig (output_path + 'dnssec_deployment.pdf' ,
23
+ bbox_inches = 'tight' )
24
+ else :
25
+ plt .show ()
26
+
27
+
28
+ def plot_errors (dataframe , output_path ):
29
+ error_df = dataframe .groupby ('reason' )
30
+ print (error_df .get_group (()))
31
+ # count_df = validation_res_df.groupby('result', as_index=False).count()
32
+ # count_df = count_df.drop(['reason'], axis=1)
33
+ # count_df.columns = ['result', 'count']
34
+ # count_df.sort_values(by='count', inplace=True, ascending=False)
35
+ # print(count_df)
36
+ # plot_or_show(output_path)
37
+
38
+
39
+ def plot_deployment (validation_res_df , output_path ):
40
+ count_df = validation_res_df .groupby ('result' , as_index = False ).count ()
41
+ count_df = count_df .drop (['reason' ], axis = 1 )
42
+ count_df .columns = ['result' , 'count' ]
43
+ count_df .sort_values (by = 'count' , inplace = True , ascending = False )
44
+ print (count_df )
45
+
46
+ plt .bar (x = count_df ['result' ], height = count_df ['count' ])
47
+ plt .xlabel ('Result' )
48
+ plt .ylabel ('Count [#]' )
49
+ plt .title ('Results of DNSSEC validation' , loc = 'left' )
50
+ plt .gcf ().set_size_inches (12 , 5 )
51
+
52
+ plot_or_show (output_path )
53
+
54
+
17
55
def is_flapping (zone_infos ):
18
56
state = EvalState .UNBROKEN
19
57
for zone_info in zone_infos :
@@ -29,33 +67,36 @@ def deployed_keys(zone_infos):
29
67
for i , zone_info in enumerate (zone_infos ):
30
68
if zone_info ['num_ksk' ] != 0 and zone_info ['num_zsk' ] == 0 :
31
69
zones .append (zone_info ['name' ])
32
- # if len(zones) != 0:
33
- # return None
34
70
return zones
35
71
36
72
37
73
def to_csv (args ):
38
- weird_dnssec_deployment = set ()
74
+ only_ksks = set ()
39
75
with open (args .input , 'r' ) as json_file :
40
76
lst = []
41
77
t1 = time .time ()
42
78
for i , line in enumerate (json_file ):
43
79
dct = json .loads (line )
44
80
zones = dct ['zones' ]
45
81
flapping = is_flapping (zones )
82
+ only_ksks .update (deployed_keys (zones ))
46
83
47
- #
48
- weird_dnssec_deployment .update (deployed_keys (zones ))
49
- # lst.append([dct['name'], dct['validation_state'], dct['reason']])
84
+ lst .append ([dct ['name' ], dct ['validation_state' ], dct ['reason' ]])
50
85
51
86
# if i > 10:
52
87
# break
88
+ # break
53
89
54
90
# df = pd.DataFrame(lst,
55
91
# columns=['name', 'result', 'reason'])
92
+
93
+ df = pd .DataFrame (lst ,
94
+ columns = ['name' , 'result' , 'reason' ])
95
+ plot_deployment (df , args .output_path )
96
+ plot_errors (df , args .output_path )
56
97
t2 = time .time ()
57
98
print (t2 - t1 , 's' )
58
- print (len (weird_dnssec_deployment ), 'zones deploy dnssec only using KSKs' )
99
+ print (len (only_ksks ), 'zones deploy dnssec only using KSKs' )
59
100
60
101
61
102
def main ():
0 commit comments