@@ -366,39 +366,39 @@ def validate_email_domain(hostname, result_dict, global_translation, local_trans
366
366
367
367
# 1 - Get Email servers
368
368
# dns_lookup
369
- rating , ipv4_servers , ipv6_servers = Validate_MX_Records (
369
+ rating , ipv4_servers , ipv6_servers = validate_mx_records (
370
370
global_translation , rating , result_dict , local_translation , hostname )
371
371
372
372
# If we have -1.0 in rating, we have no MX records, ignore test.
373
373
if rating .get_overall () != - 1.0 :
374
374
# 1.2 - Check operational
375
375
if support_port25 and len (ipv4_servers ) > 0 :
376
- rating = Validate_IPv4_Operation_Status (
376
+ rating = validate_ip4_operation_status (
377
377
global_translation , rating , local_translation , ipv4_servers )
378
378
379
379
# 1.2 - Check operational
380
380
if support_port25 and support_ipv6 and len (ipv6_servers ) > 0 :
381
- rating = Validate_IPv6_Operation_Status (
381
+ rating = validate_ip6_operation_status (
382
382
global_translation , rating , local_translation , ipv6_servers )
383
383
384
384
# 1.4 - Check TLS
385
385
# 1.5 - Check PKI
386
386
# 1.6 - Check DNSSEC
387
387
# 1.7 - Check DANE
388
388
# 1.8 - Check MTA-STS policy
389
- rating = Validate_MTA_STS_Policy (global_translation , rating , local_translation , hostname )
389
+ rating = validate_mta_sts_policy (global_translation , rating , local_translation , hostname )
390
390
# 1.9 - Check SPF policy
391
- rating = Validate_SPF_Policies (
391
+ rating = validate_spf_policies (
392
392
global_translation , rating , result_dict , local_translation , hostname )
393
393
# 2.0 - Check DMARK
394
- rating = Validate_DMARC_Policies (
394
+ rating = validate_dmarc_policies (
395
395
global_translation , rating , result_dict , local_translation , hostname )
396
396
397
397
398
398
return rating , result_dict
399
399
400
400
401
- def Validate_MTA_STS_Policy (global_translation , rating , local_translation , hostname ):
401
+ def validate_mta_sts_policy (global_translation , rating , local_translation , hostname ):
402
402
has_mta_sts_policy = False
403
403
# https://www.rfc-editor.org/rfc/rfc8461#section-3.1
404
404
mta_sts_results = dns_lookup ('_mta-sts.' + hostname , dns .rdatatype .TXT )
@@ -471,8 +471,8 @@ def Validate_MTA_STS_Policy(global_translation, rating, local_translation, hostn
471
471
has_version = True
472
472
elif 'mode' in key :
473
473
if value == 'enforce' :
474
- a = 1
475
- elif value == 'testing' or value == 'none' :
474
+ _ = 1
475
+ elif value in ( 'testing' , 'none' ) :
476
476
mta_sts_records_not_enforced_rating = Rating (
477
477
global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
478
478
mta_sts_records_not_enforced_rating .set_overall (3.0 )
@@ -525,11 +525,11 @@ def Validate_MTA_STS_Policy(global_translation, rating, local_translation, hostn
525
525
return rating
526
526
527
527
528
- def Validate_DMARC_Policies (global_translation , rating , result_dict , local_translation , hostname ):
529
- dmarc_result_dict = Validate_DMARC_Policy (local_translation , hostname , result_dict )
528
+ def validate_dmarc_policies (global_translation , rating , result_dict , local_translation , hostname ):
529
+ dmarc_result_dict = validate_dmarc_policy (local_translation , hostname , result_dict )
530
530
result_dict .update (dmarc_result_dict )
531
531
532
- rating = Rate_has_DMARC_Policies (global_translation , rating , result_dict , local_translation )
532
+ rating = rate_has_dmarc_policies (global_translation , rating , result_dict , local_translation )
533
533
# rating = Rate_Invalid_format_DMARC_Policies(
534
534
# global_translation,
535
535
# rating,
@@ -539,7 +539,7 @@ def Validate_DMARC_Policies(global_translation, rating, result_dict, local_trans
539
539
return rating
540
540
541
541
542
- def Validate_DMARC_Policy (local_translation , hostname , result_dict ):
542
+ def validate_dmarc_policy (local_translation , hostname , result_dict ):
543
543
# https://proton.me/support/anti-spoofing-custom-domain
544
544
545
545
dmarc_results = dns_lookup (f"_dmarc.{ hostname } " , "TXT" )
@@ -626,7 +626,7 @@ def Validate_DMARC_Policy(local_translation, hostname, result_dict):
626
626
result_dict ['dmarc-warnings' ].append (
627
627
local_translation (
628
628
'TEXT_REVIEW_DMARC_FO_USES_DEFAULT' ))
629
- elif field == '1' or field == 'd' or field == 's' :
629
+ elif field in ( '1' , 'd' , 's' ) :
630
630
result_dict ['dmarc-fo' ].append (field )
631
631
else :
632
632
result_dict ['dmarc-errors' ].append (
@@ -677,9 +677,7 @@ def Validate_DMARC_Policy(local_translation, hostname, result_dict):
677
677
return result_dict
678
678
679
679
680
-
681
-
682
- def Rate_has_DMARC_Policies (global_translation , rating , result_dict , local_translation ):
680
+ def rate_has_dmarc_policies (global_translation , rating , result_dict , local_translation ):
683
681
if 'dmarc-has-policy' in result_dict :
684
682
no_dmarc_record_rating = Rating (global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
685
683
no_dmarc_record_rating .set_overall (5.0 )
@@ -805,37 +803,37 @@ def Rate_has_DMARC_Policies(global_translation, rating, result_dict, local_trans
805
803
return rating
806
804
807
805
808
- def Validate_SPF_Policies (global_translation , rating , result_dict , local_translation , hostname ):
809
- spf_result_dict = Validate_SPF_Policy (
806
+ def validate_spf_policies (global_translation , rating , result_dict , local_translation , hostname ):
807
+ spf_result_dict = validate_spf_policy (
810
808
global_translation ,
811
809
local_translation ,
812
810
hostname ,
813
811
result_dict )
814
812
result_dict .update (spf_result_dict )
815
813
816
- rating = Rate_has_SPF_Policies (global_translation , rating , result_dict , local_translation )
817
- rating = Rate_Invalid_format_SPF_Policies (
814
+ rating = rate_has_spf_policies (global_translation , rating , result_dict , local_translation )
815
+ rating = rate_invalid_format_spf_policies (
818
816
global_translation ,
819
817
rating ,
820
818
result_dict ,
821
819
local_translation )
822
- rating = Rate_Too_many_DNS_lookup_for_SPF_Policies (
820
+ rating = rate_too_many_dns_lookup_for_spf_policies (
823
821
global_translation , rating , result_dict , local_translation )
824
- rating = Rate_Use_of_PTR_for_SPF_Policies (
822
+ rating = rate_use_of_ptr_for_spf_policies (
825
823
global_translation ,
826
824
rating ,
827
825
result_dict ,
828
826
local_translation )
829
827
830
- rating = Rate_Fail_Configuration_for_SPF_Policies (
828
+ rating = rate_fail_configuration_for_spf_policies (
831
829
global_translation , rating , result_dict , local_translation )
832
830
833
- rating = Rate_GDPR_for_SPF_Policies (global_translation , rating , result_dict , local_translation )
831
+ rating = rate_gdpr_for_spf_policies (global_translation , rating , result_dict , local_translation )
834
832
835
833
return rating
836
834
837
835
838
- def Rate_Use_of_PTR_for_SPF_Policies (global_translation , rating , result_dict , local_translation ):
836
+ def rate_use_of_ptr_for_spf_policies (global_translation , rating , result_dict , local_translation ):
839
837
if 'spf-uses-ptr' in result_dict :
840
838
has_spf_record_ptr_being_used_rating = Rating (
841
839
global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
@@ -847,7 +845,7 @@ def Rate_Use_of_PTR_for_SPF_Policies(global_translation, rating, result_dict, lo
847
845
return rating
848
846
849
847
850
- def Rate_Fail_Configuration_for_SPF_Policies (
848
+ def rate_fail_configuration_for_spf_policies (
851
849
global_translation ,
852
850
rating ,
853
851
result_dict ,
@@ -895,7 +893,7 @@ def Rate_Fail_Configuration_for_SPF_Policies(
895
893
return rating
896
894
897
895
898
- def Rate_Invalid_format_SPF_Policies (global_translation , rating , result_dict , local_translation ):
896
+ def rate_invalid_format_spf_policies (global_translation , rating , result_dict , local_translation ):
899
897
if 'spf-uses-none-standard' in result_dict :
900
898
has_spf_unknown_section_rating = Rating (
901
899
global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
@@ -915,7 +913,7 @@ def Rate_Invalid_format_SPF_Policies(global_translation, rating, result_dict, lo
915
913
return rating
916
914
917
915
918
- def Rate_has_SPF_Policies (global_translation , rating , result_dict , local_translation ):
916
+ def rate_has_spf_policies (global_translation , rating , result_dict , local_translation ):
919
917
has_spf_records_rating = Rating (global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
920
918
if 'spf-has-policy' in result_dict :
921
919
txt = local_translation ('TEXT_REVIEW_SPF_DNS_RECORD_SUPPORT' )
@@ -935,7 +933,7 @@ def Rate_has_SPF_Policies(global_translation, rating, result_dict, local_transla
935
933
return rating
936
934
937
935
938
- def Rate_Too_many_DNS_lookup_for_SPF_Policies (
936
+ def rate_too_many_dns_lookup_for_spf_policies (
939
937
global_translation ,
940
938
rating ,
941
939
result_dict ,
@@ -952,7 +950,7 @@ def Rate_Too_many_DNS_lookup_for_SPF_Policies(
952
950
return rating
953
951
954
952
955
- def Rate_GDPR_for_SPF_Policies (global_translation , rating , result_dict , local_translation ):
953
+ def rate_gdpr_for_spf_policies (global_translation , rating , result_dict , local_translation ):
956
954
spf_addresses = []
957
955
if 'spf-ipv4' not in result_dict :
958
956
result_dict ['spf-ipv4' ] = []
@@ -971,7 +969,7 @@ def Rate_GDPR_for_SPF_Policies(global_translation, rating, result_dict, local_tr
971
969
country_code = ''
972
970
country_code = get_best_country_code (
973
971
ip_address , country_code )
974
- if country_code == '' or country_code == '-' :
972
+ if country_code in ( '' , '-' ) :
975
973
country_code = 'unknown'
976
974
977
975
if is_country_code_in_eu_or_on_exception_list (country_code ):
@@ -1005,7 +1003,7 @@ def Rate_GDPR_for_SPF_Policies(global_translation, rating, result_dict, local_tr
1005
1003
return rating
1006
1004
1007
1005
1008
- def Validate_SPF_Policy (global_translation , local_translation , hostname , result_dict ):
1006
+ def validate_spf_policy (global_translation , local_translation , hostname , result_dict ):
1009
1007
# https://proton.me/support/anti-spoofing-custom-domain
1010
1008
1011
1009
if 'spf-dns-lookup-count' in result_dict and result_dict ['spf-dns-lookup-count' ] >= 10 :
@@ -1048,7 +1046,7 @@ def Validate_SPF_Policy(global_translation, local_translation, hostname, result_
1048
1046
result_dict ['spf-ipv6' ].append (data )
1049
1047
elif section .startswith ('include:' ) or section .startswith ('+include:' ):
1050
1048
spf_domain = section [8 :]
1051
- subresult_dict = Validate_SPF_Policy (
1049
+ subresult_dict = validate_spf_policy (
1052
1050
global_translation , local_translation , spf_domain , result_dict )
1053
1051
result_dict .update (subresult_dict )
1054
1052
elif section .startswith ('?all' ):
@@ -1111,7 +1109,7 @@ def replace_network_with_first_and_last_ipaddress(spf_addresses):
1111
1109
spf_addresses .remove (ip_address )
1112
1110
1113
1111
1114
- def Validate_IPv6_Operation_Status (global_translation , rating , local_translation , ipv6_servers ):
1112
+ def validate_ip6_operation_status (global_translation , rating , local_translation , ipv6_servers ):
1115
1113
ipv6_servers_operational = []
1116
1114
# 1.3 - Check Start TLS
1117
1115
ipv6_servers_operational_starttls = []
@@ -1161,7 +1159,7 @@ def Validate_IPv6_Operation_Status(global_translation, rating, local_translation
1161
1159
return rating
1162
1160
1163
1161
1164
- def Validate_IPv4_Operation_Status (global_translation , rating , local_translation , ipv4_servers ):
1162
+ def validate_ip4_operation_status (global_translation , rating , local_translation , ipv4_servers ):
1165
1163
ipv4_servers_operational = []
1166
1164
# 1.3 - Check Start TLS
1167
1165
ipv4_servers_operational_starttls = []
@@ -1209,7 +1207,7 @@ def Validate_IPv4_Operation_Status(global_translation, rating, local_translation
1209
1207
return rating
1210
1208
1211
1209
1212
- def Validate_MX_Records (global_translation , rating , result_dict , local_translation , hostname ):
1210
+ def validate_mx_records (global_translation , rating , result_dict , local_translation , hostname ):
1213
1211
email_results = dns_lookup (hostname , dns .rdatatype .MX )
1214
1212
email_servers = []
1215
1213
# 1.1 - Check IPv4 and IPv6 support
@@ -1289,7 +1287,7 @@ def Validate_MX_Records(global_translation, rating, result_dict, local_translati
1289
1287
country_code = ''
1290
1288
country_code = get_best_country_code (
1291
1289
ip_address , country_code )
1292
- if country_code == '' or country_code == '-' :
1290
+ if country_code in ( '' , '-' ) :
1293
1291
country_code = 'unknown'
1294
1292
1295
1293
if is_country_code_in_eu_or_on_exception_list (country_code ):
0 commit comments