Skip to content

Commit

Permalink
category fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Feb 12, 2025
1 parent 42e56e5 commit da925e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
50 changes: 25 additions & 25 deletions checks/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,30 +1313,30 @@ 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",
init_tech_type="table_translatable",
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):
Expand Down Expand Up @@ -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):
Expand Down
13 changes: 8 additions & 5 deletions checks/tasks/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
resolve_a_aaaa,
resolve_dane,
results_per_domain,
TranslatableTechTableItem,
)
from checks.tasks.tls_connection import (
MAX_REDIRECT_DEPTH,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit da925e0

Please sign in to comment.