mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 00:22:04 +02:00
First pass at logs analysis
This commit is contained in:
+16
-1
@@ -4,7 +4,7 @@ import sys
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import string
|
import string
|
||||||
|
import collections
|
||||||
|
|
||||||
def parse_timestamp(ts):
|
def parse_timestamp(ts):
|
||||||
try:
|
try:
|
||||||
@@ -60,10 +60,25 @@ class Config:
|
|||||||
self.tls_policies[domain]["min-tls-version"] = str(value)
|
self.tls_policies[domain]["min-tls-version"] = str(value)
|
||||||
elif atr == "acceptable-mxs":
|
elif atr == "acceptable-mxs":
|
||||||
self.acceptable_mxs = val
|
self.acceptable_mxs = val
|
||||||
|
self.mx_domain_to_address_domains = collections.defaultdict(set)
|
||||||
|
for address_domain, properties in self.acceptable_mxs.items():
|
||||||
|
mx_list = properties["accept-mx-domains"]
|
||||||
|
if len(mx_list) > 1:
|
||||||
|
print "Lists of multiple accept-mx-domains not yet supported, skipping ", address_domain
|
||||||
|
mx_domain = mx_list[0]
|
||||||
|
self.mx_domain_to_address_domains[mx_domain].add(address_domain)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("Unknown attribute: " + `atr` + "\n")
|
sys.stderr.write("Unknown attribute: " + `atr` + "\n")
|
||||||
|
|
||||||
|
def get_address_domains(self, mx_hostname):
|
||||||
|
for mx_domain, address_domains in self.mx_domain_to_address_domains.items():
|
||||||
|
# TODO: write this better
|
||||||
|
if (mx_hostname.find(mx_domain) > 0 and
|
||||||
|
mx_hostname.find(mx_domain) == len(mx_hostname) - len(mx_domain)):
|
||||||
|
return address_domains
|
||||||
|
return None
|
||||||
|
|
||||||
def check_tls_policy_domains(self, val):
|
def check_tls_policy_domains(self, val):
|
||||||
if type(val) != dict:
|
if type(val) != dict:
|
||||||
raise TypeError, "tls-policies should be a dict" + `val`
|
raise TypeError, "tls-policies should be a dict" + `val`
|
||||||
|
|||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/python2.7
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import collections
|
||||||
|
|
||||||
|
import ConfigParser
|
||||||
|
|
||||||
|
def get_counts(input, config):
|
||||||
|
counts = collections.defaultdict(lambda: collections.defaultdict(int))
|
||||||
|
r = re.compile("([A-Za-z]+) TLS connection established to ([^[]*)")
|
||||||
|
for line in sys.stdin:
|
||||||
|
result = r.search(line)
|
||||||
|
if result:
|
||||||
|
validation = result.group(1)
|
||||||
|
mx_hostname = result.group(2)
|
||||||
|
address_domains = config.get_address_domains(mx_hostname)
|
||||||
|
if address_domains:
|
||||||
|
for d in address_domains:
|
||||||
|
counts[d][validation] += 1
|
||||||
|
counts[d]["all"] += 1
|
||||||
|
return counts
|
||||||
|
|
||||||
|
def print_summary(counts):
|
||||||
|
for mx_hostname, validations in counts.items():
|
||||||
|
for validation, validation_count in validations.items():
|
||||||
|
if validation == "all":
|
||||||
|
continue
|
||||||
|
print mx_hostname, validation, validation_count / validations["all"]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
config = ConfigParser.Config("starttls-everywhere.json")
|
||||||
|
counts = get_counts(sys.stdin, config)
|
||||||
|
print_summary(counts)
|
||||||
Reference in New Issue
Block a user