Skip to content

Commit 3da4121

Browse files
bwbroersmaaequitas
authored andcommitted
CAA: use consistent msg-id: dash instead of underscore (#1763)
1 parent 7dacbfd commit 3da4121

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

checks/caa/parser.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def validate_issue_validation_methods(parameter_value: str) -> set[str]:
7777
if validation_method not in ACME_VALIDATION_METHODS and not validation_method.startswith(
7878
ACME_VALIDATION_CUSTOM_PREFIX
7979
):
80-
raise CAAParseError(msg_id="invalid_property_issue_validation_method", context={"value": parameter_value})
80+
raise CAAParseError(
81+
msg_id="invalid-parameter-validation-methods", context={"parameter_value": parameter_value}
82+
)
8183
return validation_methods
8284

8385

@@ -146,22 +148,22 @@ def validate_property_iodef(value: str):
146148
try:
147149
url = urlparse(value)
148150
except ValueError:
149-
raise CAAParseError(msg_id="invalid_property_iodef_value", context={"value": value})
151+
raise CAAParseError(msg_id="invalid-property-iodef-value", context={"property_value": value})
150152
if url.scheme == "https":
151153
# RFC8659 refers to RFC6546, which is unclear on requirements. Let's assume a netloc is needed.
152154
if not url.netloc:
153-
raise CAAParseError(msg_id="invalid_property_iodef_value", context={"value": value})
155+
raise CAAParseError(msg_id="invalid-property-iodef-value", context={"property_value": value})
154156
elif url.scheme == "mailto":
155157
if not validate_email(url.path):
156-
raise CAAParseError(msg_id="invalid_property_iodef_value", context={"value": value})
158+
raise CAAParseError(msg_id="invalid-property-iodef-value", context={"property_value": value})
157159
else:
158-
raise CAAParseError(msg_id="invalid_property_iodef_value", context={"value": value})
160+
raise CAAParseError(msg_id="invalid-property-iodef-value", context={"property_value": value})
159161

160162

161163
def validate_property_contactemail(value: str):
162164
"""Validate contactemail per CAB BR 1.6.3, requiring a single RFC 6532 3.2 address."""
163165
if not validate_email(value):
164-
raise CAAParseError(msg_id="invalid_property_contactemail_value", context={"value": value})
166+
raise CAAParseError(msg_id="invalid-property-contactemail-value", context={"property_value": value})
165167

166168

167169
@load_grammar_rulelist()
@@ -212,7 +214,7 @@ def validate_property_contactphone(value: str):
212214
"""Validate contactphone per CAB SC014, requiring an RFC3966 5.1.4 global number."""
213215
parse_result = PhoneNumberRule("global-number").parse_all(value)
214216
if not parse_result:
215-
raise CAAParseError(msg_id="invalid_property_contactphone_value", context={"value": value})
217+
raise CAAParseError(msg_id="invalid-property-contactphone-value", context={"property_value": value})
216218

217219

218220
@load_grammar_rulelist()
@@ -241,13 +243,13 @@ def validate_property_issuemail(value: str):
241243
"""Validate issuemail property per RFC9495."""
242244
parse_result = CAAPropertyIssueMailRule("issuemail-value").parse_all(value)
243245
if not parse_result:
244-
raise CAAParseError(msg_id="invalid_property_issuemail_value", context={"value": value})
246+
raise CAAParseError(msg_id="invalid-property-issuemail-value", context={"property_value": value})
245247

246248

247249
def validate_flags(flags: int):
248250
"""Validate the flags per RFC8659 4.1, i.e. only allow 0/128"""
249251
if flags not in [0, 128]:
250-
raise CAAParseError(msg_id="invalid_flags_reserved_bits", context={"value": str(flags)})
252+
raise CAAParseError(msg_id="invalid-flags-reserved-bits", context={"flags": str(flags)})
251253

252254

253255
# https://www.iana.org/assignments/pkix-parameters/pkix-parameters.xhtml#caa-properties
@@ -274,11 +276,11 @@ def validate_caa_record(flags: int, tag: str, value: str) -> None:
274276
try:
275277
validator = CAA_PROPERTY_VALIDATORS[tag.lower()]
276278
if validator is None:
277-
raise CAAParseError(msg_id="invalid_reserved_property", context={"value": tag})
279+
raise CAAParseError(msg_id="invalid-reserved-property", context={"property_tag": tag})
278280
validator(value)
279281
except ParseError as e:
280282
raise CAAParseError(
281-
msg_id="invalid_property_syntax",
283+
msg_id="invalid-property-syntax",
282284
context={
283285
"property_name": tag,
284286
"property_value": value,
@@ -287,4 +289,4 @@ def validate_caa_record(flags: int, tag: str, value: str) -> None:
287289
},
288290
)
289291
except KeyError:
290-
raise CAAParseError(msg_id="invalid_unknown_property", context={"value": tag})
292+
raise CAAParseError(msg_id="invalid-unknown-property", context={"property_tag": tag})

checks/caa/retrieval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from checks.resolver import dns_resolve_caa
1111
from checks.tasks.shared import TranslatableTechTableItem
1212

13-
CAA_MSGID_INSUFFICIENT_POLICY = "missing_required_tag"
13+
CAA_MSGID_INSUFFICIENT_POLICY = "missing-required-property-issue"
1414
CAA_TAGS_REQUIRED = {"issue"}
1515
CAA_MAX_RECORDS = 1000
1616

@@ -44,7 +44,7 @@ def __post_init__(self, caa_records: Iterable[CAA]):
4444

4545
missing_tags = CAA_TAGS_REQUIRED - self.caa_tags
4646
for tag in missing_tags:
47-
self.errors.append(TranslatableTechTableItem(CAA_MSGID_INSUFFICIENT_POLICY, {"tag": tag}))
47+
self.errors.append(TranslatableTechTableItem(CAA_MSGID_INSUFFICIENT_POLICY, {"property_tag": tag}))
4848

4949
@property
5050
def score(self) -> int:

checks/caa/tests/test_retrieval.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ def test_caa_evaluation():
2121
evaluation = CAAEvaluation(caa_found=True, canonical_name="example.com", caa_records=caa_records)
2222
assert evaluation.errors == [
2323
TranslatableTechTableItem(
24-
"invalid_property_syntax",
24+
"invalid-property-syntax",
2525
{
2626
"property_name": "issuewild",
2727
"property_value": "\x08",
2828
"invalid_character_position": 0,
2929
"invalid_character": "\x08",
3030
},
3131
),
32-
TranslatableTechTableItem("invalid_unknown_property", {"value": "unknown"}),
33-
TranslatableTechTableItem("missing_required_tag", {"tag": "issue"}),
32+
TranslatableTechTableItem("invalid-unknown-property", {"property_tag": "unknown"}),
33+
TranslatableTechTableItem("missing-required-property-issue", {"property_tag": "issue"}),
3434
]
3535
assert evaluation.caa_records_str == ['0 issuewild "\\008"', '0 unknown ";"']
3636
assert evaluation.caa_tags == {"issuewild", "unknown"}

checks/categories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ def result_bad(self, tech_data: list[dict[str, str]]):
13411341

13421342
def result_syntax_error(self, tech_data: list[dict[str, str]]):
13431343
self._status(STATUS_FAIL)
1344-
self.verdict = "detail web tls caa verdict syntax_error"
1344+
self.verdict = "detail web tls caa verdict syntax-error"
13451345
self.tech_data = self.add_tech_data_translation_root(tech_data) or ""
13461346

13471347
def result_insufficient(self, tech_data: list[dict[str, str]]):
@@ -1983,7 +1983,7 @@ def result_bad(self, tech_data: list[dict[str, str]]):
19831983

19841984
def result_syntax_error(self, tech_data: list[dict[str, str]]):
19851985
self._status(STATUS_FAIL)
1986-
self.verdict = "detail mail tls caa verdict syntax_error"
1986+
self.verdict = "detail mail tls caa verdict syntax-error"
19871987
self.tech_data = self.add_tech_data_translation_root(tech_data) or ""
19881988

19891989
def result_insufficient(self, tech_data: list[dict[str, str]]):

checks/tasks/tls.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,15 +895,15 @@ def annotate_and_combine_all(good_items, sufficient_items, bad_items, phaseout_i
895895
if dttls.caa_enabled:
896896
caa_host_message = [
897897
TranslatableTechTableItem(
898-
msgid="found_host", context={"host": dttls.caa_found_on_domain}
898+
msgid="found-host", context={"host": dttls.caa_found_on_domain}
899899
).to_dict()
900900
]
901901
else:
902-
caa_host_message = [TranslatableTechTableItem(msgid="not_found").to_dict()]
902+
caa_host_message = [TranslatableTechTableItem(msgid="not-found").to_dict()]
903903
caa_tech_table = caa_host_message + dttls.caa_errors + dttls.caa_recommendations
904904
for record in dttls.caa_records:
905905
caa_tech_table.append(
906-
TranslatableTechTableItem(msgid="caa_record", context={"record": record}).to_dict()
906+
TranslatableTechTableItem(msgid="caa-record", context={"record": record}).to_dict()
907907
)
908908
if not dttls.caa_enabled:
909909
category.subtests["web_caa"].result_bad(caa_tech_table)
@@ -1075,14 +1075,14 @@ def annotate_and_combine_all(good_items, sufficient_items, bad_items, phaseout_i
10751075

10761076
if dttls.caa_enabled:
10771077
caa_host_message = [
1078-
TranslatableTechTableItem(msgid="found_host", context={"host": dttls.caa_found_on_domain}).to_dict()
1078+
TranslatableTechTableItem(msgid="found-host", context={"host": dttls.caa_found_on_domain}).to_dict()
10791079
]
10801080
else:
1081-
caa_host_message = [TranslatableTechTableItem(msgid="not_found").to_dict()]
1081+
caa_host_message = [TranslatableTechTableItem(msgid="not-found").to_dict()]
10821082
caa_tech_table = caa_host_message + dttls.caa_errors + dttls.caa_recommendations
10831083
for record in dttls.caa_records:
10841084
caa_tech_table.append(
1085-
TranslatableTechTableItem(msgid="caa_record", context={"record": record}).to_dict()
1085+
TranslatableTechTableItem(msgid="caa-record", context={"record": record}).to_dict()
10861086
)
10871087
if not dttls.caa_enabled:
10881088
category.subtests["mail_caa"].result_bad(caa_tech_table)

0 commit comments

Comments
 (0)