Skip to content

Commit

Permalink
internetstandards#881 fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
uwekamper committed Apr 8, 2024
1 parent 0fbe116 commit 63b7e5b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion checks/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
MAIL_AUTH_SPF_ERROR = NO_POINTS
MAIL_AUTH_SPF_WORST_STATUS = STATUS_FAIL

MAIL_AUTH_TLSRPT_PASS = NO_POINTS
MAIL_AUTH_TLSRPT_PASS = NO_POINTS
MAIL_AUTH_TLSRPT_FAIL = NO_POINTS # TLS-RPT fail does not give a points penalty
MAIL_AUTH_TLSRPT_ERROR = NO_POINTS
MAIL_AUTH_TLSRPT_WORST_STATUS = STATUS_FAIL
Expand Down
4 changes: 1 addition & 3 deletions checks/tasks/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def callback(results, addr, category):
subtests["spf_policy"].result_bad_include(spf_records)
elif spf_policy_status == SpfPolicyStatus.invalid_redirect:
subtests["spf_policy"].result_bad_redirect(spf_records)

else:
subtests["spf"].result_bad(spf_record)

elif testname == "tlsrpt":
tlsrpt_available = result.get("available")
tlsrpt_record = result.get("record")
Expand All @@ -243,8 +243,6 @@ def callback(results, addr, category):
subtests["tlsrpt"].result_good(tlsrpt_record)
else:
subtests["tlsrpt"].result_bad(tlsrpt_record)


if skip_dkim_for_non_sending_domain(mtauth):
mtauth.dkim_score = scoring.MAIL_AUTH_DKIM_PASS
subtests["dkim"].result_no_email()
Expand Down
10 changes: 5 additions & 5 deletions checks/tasks/tlsrpt_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'''
SMTP TLS Reporting policy parser as defined by:
RFC 8460, Section "3. Reporting Policy", see:
RFC 8460, Section "3. Reporting Policy", see:
https://datatracker.ietf.org/doc/html/rfc8460#section-3
'''

Expand All @@ -28,8 +28,8 @@
field_delim = ZeroOrMore(WSP) + Literal(';') + ZeroOrMore(WSP) # Fields are semicolon-delimited
ura_delim = ZeroOrMore(WSP) + Literal(',') + ZeroOrMore(WSP) # multiple RUAs are comma-delimited

tlsrpt_ext_name = Word(alphanums, alphanums+"_-.", max=32)
tlsrpt_ext_value = Word(alphanums, alphanums+"_-.")
tlsrpt_ext_name = Word(alphanums, alphanums + "_-.", max=32)
tlsrpt_ext_value = Word(alphanums, alphanums + "_-.")
tlsrpt_extension = ZeroOrMore(tlsrpt_ext_name + Literal('=') + tlsrpt_ext_value)

# RegEx for parsing email.
Expand All @@ -38,8 +38,8 @@
r"(?P<mailaddr>([a-zA-Z0-9]{0,61}@)?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+" r"" + regex_tld + ")"
)
mail_uri = Combine(CaselessLiteral("mailto:") + Regex(regex_mailaddr))
tlsrpt_rua = Literal("rua=") +\
delimitedList(mail_uri | pyparsing_common.url, delim=',').setResultsName('tlsrpt_uri')
tlsrpt_rua = Literal("rua=") + \
delimitedList(mail_uri | pyparsing_common.url, delim=',').setResultsName('tlsrpt_uri')

tlsrpt_field = tlsrpt_rua + ZeroOrMore(field_delim + tlsrpt_extension)

Expand Down
7 changes: 3 additions & 4 deletions checks/test/test_tlsrpt_parsing.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from checks.tasks import tlsrpt_parsing
from checks.tasks import tlsrpt_parsing


def test_record_parse_simple_mailto():
TXT_RECORD="v=TLSRPTv1; rua=mailto:[email protected]"
TXT_RECORD = "v=TLSRPTv1; rua=mailto:[email protected]"
parsed = tlsrpt_parsing.record.parseString(TXT_RECORD)
assert parsed.tlsrpt_version == 'v=TLSRPTv1'
assert parsed.tlsrpt_uri[0] == 'mailto:[email protected]'


def test_record_parse_multiple_mailto():
TXT_RECORD="v=TLSRPTv1;rua=mailto:[email protected],mailto:[email protected]"
TXT_RECORD = "v=TLSRPTv1;rua=mailto:[email protected],mailto:[email protected]"
parsed = tlsrpt_parsing.record.parseString(TXT_RECORD)
assert parsed.tlsrpt_version == 'v=TLSRPTv1'
assert parsed.tlsrpt_uri[0] == 'mailto:[email protected]'
Expand All @@ -27,7 +27,6 @@ def test_record_parse_with_extension():
TXT_RECORD = "v=TLSRPTv1; rua=https://reporting.example.com/v1/tlsrpt; ext=extvalue"
parsed = tlsrpt_parsing.record.parseString(TXT_RECORD)
assert parsed.tlsrpt_version == 'v=TLSRPTv1'
#assert parsed.tlsrpt_uri[0] == 'https://reporting.example.com/v1/tlsrpt'


def test_parse_silent():
Expand Down

0 comments on commit 63b7e5b

Please sign in to comment.