diff options
Diffstat (limited to 'monitor/josef_monitor.py')
-rwxr-xr-x | monitor/josef_monitor.py | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py index 23ba147..d11d38f 100755 --- a/monitor/josef_monitor.py +++ b/monitor/josef_monitor.py @@ -70,29 +70,23 @@ class ctlog: def fetch_and_increment_subtree(self, first, last, url, subtree =[[]]): - # global DB - # try: - new_leafs = [] - if first <= last: - entries = get_entries(url, first, last)["entries"] - tmp_cert_data = [] - for item in entries: - tmp_data = check_domain(item, url) - entry_hash = get_leaf_hash(base64.b64decode(item["leaf_input"])) - if tmp_data: - tmp_data["leaf_hash"] = base64.b64encode(entry_hash) - tmp_cert_data.append(tmp_data) - new_leafs.append(entry_hash) - if DB_PATH: - self.log("Adding to database...") - db_add_certs(DB_PATH, tmp_cert_data) - self.log("done adding to DB.") - if DEFAULT_CERT_FILE: - append_file(DEFAULT_CERT_FILE, tmp_cert_data) - subtree = reduce_tree(new_leafs, subtree) - # except: - # print "Failed to build subtree :(" - return subtree, len(new_leafs) + first + new_leafs = [] + if first <= last: + entries = get_entries(url, first, last)["entries"] + tmp_cert_data = [] + for item in entries: + tmp_data = check_domain(item, url) + entry_hash = get_leaf_hash(base64.b64decode(item["leaf_input"])) + if tmp_data: + tmp_data["leaf_hash"] = base64.b64encode(entry_hash) + tmp_cert_data.append(tmp_data) + new_leafs.append(entry_hash) + if DB_PATH: + db_add_certs(DB_PATH, tmp_cert_data) + if DEFAULT_CERT_FILE: + append_file(DEFAULT_CERT_FILE, tmp_cert_data) + subtree = reduce_tree(new_leafs, subtree) + return subtree, len(new_leafs) + first def to_dict(self): @@ -243,6 +237,8 @@ def check_domain(raw_entry, log=None): except IndexError: return None + + def verify_subtree(sth, subtree, base_url): try: tmp = deepcopy(subtree) |