From e18d2e2e3539070398fc601a71dc042390c5f21e Mon Sep 17 00:00:00 2001 From: Sasha Romijn Date: Wed, 12 Feb 2025 11:51:46 +0100 Subject: [PATCH] category fixes --- checks/categories.py | 50 +++++++++++++++++++++--------------------- checks/tasks/shared.py | 1 - checks/tasks/tls.py | 13 ++++++----- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/checks/categories.py b/checks/categories.py index 0ef34151a..f7bb57684 100644 --- a/checks/categories.py +++ b/checks/categories.py @@ -1313,9 +1313,9 @@ def result_bad(self, tech_data): class WebCaa(Subtest): def __init__(self): super(WebCaa, self).__init__( - name="cert_caa", - label="detail web cert-caa label", - explanation="detail web cert-caa exp", + name="caa", + label="detail web caa label", + explanation="detail web caa exp", worst_status=scoring.CAA_WORST_STATUS, full_score=scoring.CAA_GOOD, model_score_field="caa_score", @@ -1323,20 +1323,20 @@ def __init__(self): tech_data_translation_root="detail tech data caa", ) - def result_good(self, tech_data: list[TranslatableTechTableItem]): + def result_good(self, tech_data: list[dict[str, str]]): self._status(STATUS_SUCCESS) self.verdict = "detail web caa verdict good" - self.tech_data = [tti.to_dict() for tti in tech_data] + self.tech_data = tech_data - def result_recommendations(self, tech_data: list[TranslatableTechTableItem]): + def result_recommendations(self, tech_data: list[dict[str, str]]): self._status(STATUS_INFO) self.verdict = "detail web caa verdict recommendations" - self.tech_data = [tti.to_dict() for tti in tech_data] + self.tech_data = tech_data - def result_bad(self, tech_data: list[TranslatableTechTableItem]): + def result_bad(self, tech_data: list[dict[str, str]]): self._status(STATUS_FAIL) self.verdict = "detail web caa verdict bad" - self.tech_data = [tti.to_dict() for tti in tech_data] + self.tech_data = tech_data class WebTlsDaneExists(Subtest): @@ -1943,31 +1943,31 @@ def result_has_daneTA(self, tech_data): class MailCaa(Subtest): def __init__(self): - super(MailCaa, self).__init__( - name="cert_caa", - label="detail mail cert-caa label", - explanation="detail mail cert-caa exp", - tech_string="detail mail cert-caa tech table", - init_tech_type="", + super().__init__( + name="caa", + label="detail mail caa label", + explanation="detail mail caa exp", worst_status=scoring.CAA_WORST_STATUS, full_score=scoring.CAA_GOOD, - model_score_field="cert_caa_score", + model_score_field="caa_score", + init_tech_type="table_translatable", + tech_data_translation_root="detail tech data caa", ) - def result_good(self, tech_data): + def result_good(self, tech_data: list[dict[str, str]]): self._status(STATUS_SUCCESS) - self.verdict = "detail mail cert-caa verdict good" - self.tech_data = "" + self.verdict = "detail mail caa verdict good" + self.tech_data = tech_data - def result_info(self, tech_data): + def result_recommendations(self, tech_data: list[dict[str, str]]): self._status(STATUS_INFO) - self.verdict = "detail mail cert-caa verdict warning" - self.tech_data = "" + self.verdict = "detail mail caa verdict recommendations" + self.tech_data = tech_data - def result_bad(self, tech_data): + def result_bad(self, tech_data: list[dict[str, str]]): self._status(STATUS_FAIL) - self.verdict = "detail mail cert-caa verdict bad" - self.tech_data = "" + self.verdict = "detail mail caa verdict bad" + self.tech_data = tech_data class MailTlsZeroRTT(Subtest): diff --git a/checks/tasks/shared.py b/checks/tasks/shared.py index 3beffa9ac..aa2101e22 100644 --- a/checks/tasks/shared.py +++ b/checks/tasks/shared.py @@ -348,6 +348,5 @@ class TranslatableTechTableItem: def __repr__(self): return f"TTTI({self.msg_id}, {self.context})" - @property def to_dict(self): return {"msg_id": self.msg_id, "context": self.context} diff --git a/checks/tasks/tls.py b/checks/tasks/tls.py index b0f733a13..1631c78d9 100644 --- a/checks/tasks/tls.py +++ b/checks/tasks/tls.py @@ -67,6 +67,7 @@ resolve_a_aaaa, resolve_dane, results_per_domain, + TranslatableTechTableItem, ) from checks.tasks.tls_connection import ( MAX_REDIRECT_DEPTH, @@ -654,8 +655,8 @@ def save_results(model, results, addr, domain, category): model.cert_hostmatch_score = result.get("hostmatch_score") model.cert_hostmatch_bad = result.get("hostmatch_bad") model.caa_enabled = result.get("caa_result").enabled - model.caa_error = result.get("caa_result").errors - model.caa_recommendations = result.get("caa_result").recommendations + model.caa_error = [ttti.to_dict() for ttti in result.get("caa_result").errors] + model.caa_recommendations = [ttti.to_dict() for ttti in result.get("caa_result").recommendations] model.caa_score = result.get("caa_result").score model.caa_found_host = result.get("caa_result").canonical_name model.dane_log = result.get("dane_log") @@ -727,8 +728,8 @@ def save_results(model, results, addr, domain, category): model.cert_hostmatch_score = result.get("hostmatch_score") model.cert_hostmatch_bad = result.get("hostmatch_bad") model.caa_enabled = result.get("caa_result").enabled - model.caa_error = result.get("caa_result").errors - model.caa_recommendations = result.get("caa_result").recommendations + model.caa_error = [ttti.to_dict() for ttti in result.get("caa_result").errors] + model.caa_recommendations = [ttti.to_dict() for ttti in result.get("caa_result").recommendations] model.caa_score = result.get("caa_result").score model.caa_found_host = result.get("caa_result").canonical_name model.dane_log = result.get("dane_log") @@ -888,7 +889,9 @@ def annotate_and_combine_all(good_items, sufficient_items, bad_items, phaseout_i else: category.subtests["cert_hostmatch"].result_good() - caa_found_host_message = [{"msg_id": "found_host", "context": {"host": dttls.caa_found_host}}] + caa_found_host_message = [ + TranslatableTechTableItem(msg_id="found_host", context={"host": dttls.caa_found_host}).to_dict() + ] caa_tech_table = caa_found_host_message + dttls.caa_errors + dttls.caa_recommendations if not dttls.caa_enabled or dttls.caa_errors: category.subtests["caa"].result_bad(caa_tech_table)