From e39bdfc97dab0a7d01944a739c6d78d4068d4a9a Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 11:32:52 -0300 Subject: [PATCH 01/39] Updated Dmarc Tags --- .../domain/email_scan/dmarc/__init__.py | 21 +++- .../domain/email_scan/dmarc/dmarc_tags.py | 117 ++++++++++++------ 2 files changed, 91 insertions(+), 47 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/__init__.py b/api/schemas/domain/email_scan/dmarc/__init__.py index f521672ec2..8ac1c9d44b 100644 --- a/api/schemas/domain/email_scan/dmarc/__init__.py +++ b/api/schemas/domain/email_scan/dmarc/__init__.py @@ -43,7 +43,7 @@ class Meta: description="The percentage of messages to which the DMARC policy is " "to be applied. " ) - dmarc_guidance_tags = graphene.List( + dmarc_guidance_tags = graphene.Field( lambda: DmarcTags, description="Key tags found during DMARC Scan" ) @@ -57,16 +57,25 @@ def resolve_dmarc_phase(self: Dmarc_scans, info): return self.dmarc_phase def resolve_record(self: Dmarc_scans, info): - return self.dmarc_scan["dmarc"]["record"] + return self.dmarc_scan.get("dmarc", {}).get("record", None) def resolve_p_policy(self: Dmarc_scans, info): - return self.dmarc_scan["dmarc"]["tags"]["p"]["value"] + return self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("p", {}) \ + .get("value", None) def resolve_sp_policy(self: Dmarc_scans, info): - return self.dmarc_scan["dmarc"]["tags"]["sp"]["value"] + return self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("sp", {}) \ + .get("value", None) def resolve_pct(self: Dmarc_scans, info): - return self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] + return self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("pct", {}) \ + .get("value", None) def resolve_dmarc_guidance_tags(self: Dmarc_scans, info): - return DmarcTags.get_query(info).all() + return DmarcTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 5dc02294c1..c933ff6c49 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -7,67 +7,102 @@ class DmarcTags(SQLAlchemyObjectType): """ + Guidance tags for dmarc scan results """ - class Meta: model = Dmarc_scans exclude_fields = ("id", "dmarc_scan") - value = graphene.String(description="Important tags retrieved during scan") + value = graphene.List( + lambda: graphene.String, + description="Important tags retrieved during scan" + ) def resolve_value(self: Dmarc_scans, info): - tags = {} + tags = [] - if "missing" in self.dmarc_scan: - return tags.update({"dmarc2": "missing"}) + if self.dmarc_scan.get("missing", None) is not None: + tags.append({"dmarc2": "missing"}) + return tags # Check P Policy Tag - if self.dmarc_scan["dmarc"]["tags"]["p"]["value"] == "missing": - tags.update({"dmarc3": "P-missing"}) - elif self.dmarc_scan["dmarc"]["tags"]["p"]["value"] == "none": - tags.update({"dmarc4": "P-none"}) - elif self.dmarc_scan["dmarc"]["tags"]["p"]["value"] == "quarantine": - tags.update({"dmarc5": "P-quarantine"}) - elif self.dmarc_scan["dmarc"]["tags"]["p"]["value"] == "reject": - tags.update({"dmarc6": "P-reject"}) + p_policy_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("p", {}) \ + .get("value", None) + + if p_policy_tag == "missing" or p_policy_tag == "Missing": + tags.append({"dmarc3": "P-missing"}) + elif p_policy_tag == "none" or p_policy_tag == "None": + tags.append({"dmarc4": "P-none"}) + elif p_policy_tag == "quarantine" or p_policy_tag == "Quarantine": + tags.append({"dmarc5": "P-quarantine"}) + elif p_policy_tag == "reject" or p_policy_tag == "Reject": + tags.append({"dmarc6": "P-reject"}) # Check PCT Tag - if self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] == 100: - tags.update({"dmarc7": "PCT-100"}) - elif 100 > self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] > 0: + pct_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("pct", {}) \ + .get("value", None) + + if pct_tag == 100: + tags.append({"dmarc7": "PCT-100"}) + elif 100 > pct_tag > 0: pct_string = "PCT-" + str( - self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] + pct_tag ) - tags.update({"dmarc8": pct_string}) - elif self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] == "invalid": - tags.update({"dmarc9": "PCT-invalid"}) - elif self.dmarc_scan["dmarc"]["tags"]["pct"]["value"] == "none": - tags.update({"dmarc20": "PCT-none=exists"}) + tags.append({"dmarc8": pct_string}) + elif pct_tag == "invalid" or pct_tag == "Invalid": + tags.append({"dmarc9": "PCT-invalid"}) + elif pct_tag == "none" or pct_tag == "None": + tags.append({"dmarc20": "PCT-none=exists"}) else: - tags.update({"dmarc21": "PCT-0"}) + tags.append({"dmarc21": "PCT-0"}) # Check RUA Tag - for value in self.dmarc_scan["dmarc"]["tags"]["rua"]["value"]: - if value["address"] == "dmarc@cyber.gc.ca": - tags.update({"dmarc10": "RUA-CCCS"}) - else: - tags.update({"dmarc12": "RUA-none"}) + rua_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("rua", {}) \ + .get("value", None) + + if rua_tag is None: + tags.append({"dmarc12": "RUA-none"}) + else: + for value in rua_tag: + if value["address"] == "dmarc@cyber.gc.ca": + tags.append({"dmarc10": "RUA-CCCS"}) + else: + tags.append({"dmarc12": "RUA-none"}) # Check RUF Tag - for value in self.dmarc_scan["dmarc"]["tags"]["ruf"]["value"]: - if value["address"] == "dmarc@cyber.gc.ca": - tags.update({"dmarc11": "RUF-CCCS"}) - else: - tags.update({"dmarc13": "RUF-none"}) + ruf_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("ruf", {}) \ + .get("value", None) + + if ruf_tag is None: + tags.append({"dmarc13": "RUF-none"}) + else: + for value in ruf_tag: + if value["address"] == "dmarc@cyber.gc.ca": + tags.append({"dmarc11": "RUF-CCCS"}) + else: + tags.append({"dmarc13": "RUF-none"}) # Check SP tag - if self.dmarc_scan["dmarc"]["tags"]["sp"]["value"] == "missing": - tags.update({"dmarc16": "SP-missing"}) - elif self.dmarc_scan["dmarc"]["tags"]["sp"]["value"] == "none": - tags.update({"dmarc17": "SP-none"}) - elif self.dmarc_scan["dmarc"]["tags"]["sp"]["value"] == "quarantine": - tags.update({"dmarc18": "SP-quarantine"}) - elif self.dmarc_scan["dmarc"]["tags"]["sp"]["value"] == "reject": - tags.update({"dmarc19": "SP-reject"}) + sp_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("tags", {}) \ + .get("sp", {}) \ + .get("value", None) + + if sp_tag == "missing" or sp_tag == "Missing": + tags.append({"dmarc16": "SP-missing"}) + elif sp_tag == "none" or sp_tag == "None": + tags.append({"dmarc17": "SP-none"}) + elif sp_tag == "quarantine" or sp_tag == "Quarantine": + tags.append({"dmarc18": "SP-quarantine"}) + elif sp_tag == "reject" or sp_tag == "Reject": + tags.append({"dmarc19": "SP-reject"}) return tags From bfa0b74e15886f2ee09d909c74326625d404f81b Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 13:36:51 -0300 Subject: [PATCH 02/39] small fix to the dmarc tags --- .../domain/email_scan/dmarc/dmarc_tags.py | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index c933ff6c49..0947686c6e 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -31,13 +31,16 @@ def resolve_value(self: Dmarc_scans, info): .get("p", {}) \ .get("value", None) - if p_policy_tag == "missing" or p_policy_tag == "Missing": + if isinstance(str, p_policy_tag): + p_policy_tag = p_policy_tag.lower() + + if p_policy_tag == "missing": tags.append({"dmarc3": "P-missing"}) - elif p_policy_tag == "none" or p_policy_tag == "None": + elif p_policy_tag == "none": tags.append({"dmarc4": "P-none"}) - elif p_policy_tag == "quarantine" or p_policy_tag == "Quarantine": + elif p_policy_tag == "quarantine": tags.append({"dmarc5": "P-quarantine"}) - elif p_policy_tag == "reject" or p_policy_tag == "Reject": + elif p_policy_tag == "reject": tags.append({"dmarc6": "P-reject"}) # Check PCT Tag @@ -46,6 +49,9 @@ def resolve_value(self: Dmarc_scans, info): .get("pct", {}) \ .get("value", None) + if isinstance(str, pct_tag): + pct_tag = pct_tag.lower() + if pct_tag == 100: tags.append({"dmarc7": "PCT-100"}) elif 100 > pct_tag > 0: @@ -53,9 +59,9 @@ def resolve_value(self: Dmarc_scans, info): pct_tag ) tags.append({"dmarc8": pct_string}) - elif pct_tag == "invalid" or pct_tag == "Invalid": + elif pct_tag == "invalid": tags.append({"dmarc9": "PCT-invalid"}) - elif pct_tag == "none" or pct_tag == "None": + elif pct_tag == "none": tags.append({"dmarc20": "PCT-none=exists"}) else: tags.append({"dmarc21": "PCT-0"}) @@ -66,6 +72,9 @@ def resolve_value(self: Dmarc_scans, info): .get("rua", {}) \ .get("value", None) + if isinstance(str, rua_tag): + rua_tag = rua_tag.lower() + if rua_tag is None: tags.append({"dmarc12": "RUA-none"}) else: @@ -96,13 +105,16 @@ def resolve_value(self: Dmarc_scans, info): .get("sp", {}) \ .get("value", None) - if sp_tag == "missing" or sp_tag == "Missing": + if isinstance(str, sp_tag): + sp_tag = sp_tag.lower() + + if sp_tag == "missing": tags.append({"dmarc16": "SP-missing"}) - elif sp_tag == "none" or sp_tag == "None": + elif sp_tag == "none": tags.append({"dmarc17": "SP-none"}) - elif sp_tag == "quarantine" or sp_tag == "Quarantine": + elif sp_tag == "quarantine": tags.append({"dmarc18": "SP-quarantine"}) - elif sp_tag == "reject" or sp_tag == "Reject": + elif sp_tag == "reject": tags.append({"dmarc19": "SP-reject"}) return tags From 3b81f82ec1df237077881977e7e051b22d085a66 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 13:41:18 -0300 Subject: [PATCH 03/39] fix isintance checks --- api/schemas/domain/email_scan/dmarc/dmarc_tags.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 0947686c6e..669f396964 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -31,7 +31,7 @@ def resolve_value(self: Dmarc_scans, info): .get("p", {}) \ .get("value", None) - if isinstance(str, p_policy_tag): + if isinstance(p_policy_tag, str): p_policy_tag = p_policy_tag.lower() if p_policy_tag == "missing": @@ -49,7 +49,7 @@ def resolve_value(self: Dmarc_scans, info): .get("pct", {}) \ .get("value", None) - if isinstance(str, pct_tag): + if isinstance(pct_tag, str): pct_tag = pct_tag.lower() if pct_tag == 100: @@ -72,7 +72,7 @@ def resolve_value(self: Dmarc_scans, info): .get("rua", {}) \ .get("value", None) - if isinstance(str, rua_tag): + if isinstance(rua_tag, str): rua_tag = rua_tag.lower() if rua_tag is None: @@ -105,7 +105,7 @@ def resolve_value(self: Dmarc_scans, info): .get("sp", {}) \ .get("value", None) - if isinstance(str, sp_tag): + if isinstance(sp_tag, str): sp_tag = sp_tag.lower() if sp_tag == "missing": From 7a33b5dc30a91d20cf6a88f69d44c8b9dfb19d61 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 13:42:18 -0300 Subject: [PATCH 04/39] Spf tags re-factor --- api/schemas/domain/email_scan/spf/spf_tags.py | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index c3a22c861e..f2857522bf 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -13,30 +13,43 @@ class Meta: model = Spf_scans exclude_fields = ("id", "spf_scan") - value = graphene.String(description="Important tags retrieved during scan") + value = graphene.List( + lambda: graphene.String, + description="Important tags retrieved during scan" + ) def resolve_value(self: Spf_scans, info): - tags = {} + tags = [] - if "missing" in self.spf_scan: - return tags.update({"spf2": "missing"}) + if self.spf_scan.get("missing", None) is not None: + return tags.append({"spf2": "missing"}) # Check all tag - if self.spf_scan["spf"]["parsed"]["all"] == "missing": - tags.update({"spf3": "ALL-missing"}) - elif self.spf_scan["spf"]["parsed"]["all"] == "allow": - tags.update({"spf4": "ALL-allow"}) - elif self.spf_scan["spf"]["parsed"]["all"] == "neutral": - tags.update({"spf5": "ALL-neutral"}) - elif self.spf_scan["spf"]["parsed"]["all"] == "redirect": - tags.update({"spf8": "ALL-redirect"}) - elif self.spf_scan["spf"]["parsed"]["all"] == "fail": - if self.spf_scan["spf"]["record"][-4:] == "-all": - tags.update({"spf7": "ALL-hardfail"}) - elif self.spf_scan["spf"]["record"][-4:] == "~all": - tags.update({"spf6": "ALL-softfail"}) - - if self.spf_scan["spf"]["dns_lookups"] > 10: - tags.update({"spf10": "INCLUDE-limit"}) + all_tag = self.spf_scan.get("spf", {}) \ + .get("parsed", {}) \ + .get("all", None) + + if isinstance(all_tag, str): + all_tag = all_tag.lower() + + if all_tag == "missing": + tags.append({"spf3": "ALL-missing"}) + elif all_tag == "allow": + tags.append({"spf4": "ALL-allow"}) + elif all_tag == "neutral": + tags.append({"spf5": "ALL-neutral"}) + elif all_tag == "redirect": + tags.append({"spf8": "ALL-redirect"}) + elif all_tag == "fail": + record_all_tag = self.spf_scan.get("spf", {}) \ + .get("record", "")[-4:].lower() + if record_all_tag == "-all": + tags.append({"spf7": "ALL-hardfail"}) + elif record_all_tag == "~all": + tags.append({"spf6": "ALL-softfail"}) + + dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) + if dns_lookups > 10: + tags.append({"spf10": "INCLUDE-limit"}) return tags From 49a14cb87a51861944da6ee6ec3a6d64642b3d06 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 13:48:47 -0300 Subject: [PATCH 05/39] Dkim tags re-factor --- .../domain/email_scan/dkim/dkim_tags.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index d18e09f62d..a0fae56014 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -9,28 +9,28 @@ class Meta: model = Dkim_scans exclude_fields = ("id", "dkim_scan") - value = graphene.String(description="Key tags found during scan") + value = graphene.List( + lambda: graphene.String, + description="Key tags found during scan", + ) def resolve_value(self: Dkim_scans, info): - tags = {} + tags = [] - if "missing" in self.dkim_scan: + if self.dkim_scan.get("missing", None) is not None: return tags.update({"dkim2": "missing"}) - if ( - self.dkim_scan["dkim"]["key_size"] >= 2048 - and self.dkim_scan["dkim"]["key_type"] == "rsa" - ): + # Get Key Size, and Key Type + key_size = self.dkim_scan.get("dkim", {}) \ + .get("key_size", None) + key_type = self.dkim_scan.get("dkim", {}) \ + .get("key_type", None) + + if key_size >= 2048 and key_type == "rsa": tags.update({"dkim5": "P-2048"}) - elif ( - self.dkim_scan["dkim"]["key_size"] == 1024 - and self.dkim_scan["dkim"]["key_type"] == "rsa" - ): + elif key_size == 1024 and key_type == "rsa": tags.update({"dkim4": "P-1024"}) - elif ( - self.dkim_scan["dkim"]["key_size"] < 1024 - and self.dkim_scan["dkim"]["key_type"] == "rsa" - ): + elif key_size < 1024 and key_type == "rsa": tags.update({"dkim3": "P-sub1024"}) else: tags.update({"dkim6": "P-invalid"}) From d5e47ae9d373c244350c267795951727f906e302 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 14:27:22 -0300 Subject: [PATCH 06/39] HTTPS tags are now actually here, again ... --- .../domain/www_scan/https/https_tags.py | 102 +++++++++++++++++- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index ccb10b5e91..a3417dcdc4 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -5,12 +5,108 @@ class HTTPSTags(SQLAlchemyObjectType): + """ + Guidance tags for HTTPS scan results + """ class Meta: model = Https_scans exclude_fields = ("id", "https_scan") - value = graphene.String() + value = graphene.List( + lambda: graphene.String, + description="" + ) + + def resolve_value(self: Https_scans, info): + tags = [] + + if self.https_scan.get("missing", None) is not None: + return tags.append({"https2": "missing"}) + + # Implementation + implementation = self.https_scan.get("https", {}) \ + .get("implementation", None) + + if isinstance(implementation, str): + implementation = implementation.lower() + + if implementation == "downgrades https": + tags.append({"https3": "HTTPS-downgraded"}) + elif implementation == "bad chain": + tags.append({"https4": "HTTPS-bad-chain"}) + elif implementation == "bad hostname": + tags.append({"https5": "HTTPS-bad-hostname"}) + + # Enforced + enforced = self.https_scan.get("https", {}) \ + .get("enforced", None) + + if isinstance(enforced, str): + enforced = enforced.lower() + + if enforced == "moderate": + tags.append({"https8": "HTTPS-moderately-enforced"}) + elif enforced == "weak": + tags.append({"https7": "HTTPS-weakly-enforced"}) + elif enforced == "not enforced": + tags.append({"https6": "HTTPS-not-enforced"}) + + # HSTS + hsts = self.https_scan.get("https", {}) \ + .get("hsts", None) + + if isinstance(hsts, str): + hsts = hsts.lower() + + if hsts == "hsts max age too short": + tags.append() + elif hsts == "no hsts": + tags.append({"https9": "HSTS-missing"}) + + # HSTS Age + hsts_age = self.https_scan.get("https", {}) \ + .get("hsts_age") + + if hsts_age < 31536000: + tags.append({"https10": "HSTS-short-age"}) + + # Preload Status + preload_status = self.https_scan.get("https", {}) \ + .get("preload_status", None) + + if preload_status(preload_status, str): + preload_status = preload_status.lower() + + if preload_status == "hsts preload ready": + tags.append({"https11": "HSTS-preload-ready"}) + elif preload_status == "hsts not preloaded": + tags.append({"https12": "HSTS-not-preloaded"}) + + # Expired Cert + expired_cert = self.https_scan.get("https", {}) \ + .get("expired_cert", None) + + if expired_cert: + tags.append({"https13": "HTTPS-certificate-expired"}) + + # Self Signed Cert + self_signed_cert = self.https_scan.get("https", {}) \ + .get("self_signed_cert", None) + + if self_signed_cert: + tags.append({"https14": "HTTPS-certificate-self-signed"}) - def resolve_value(self, info): - tags = {} return tags + + +# { +# "https": { +# "hsts": "No HSTS", +# "enforced": "Weak", +# "hsts_age": null, +# "expired_cert": false, +# "implementation": "Valid HTTPS", +# "preload_status": "HSTS Not Preloaded", +# "self_signed_cert": false +# } +# } From 6b2030ec8d8218e326b3a60a019b973fa4e831bd Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 14:29:59 -0300 Subject: [PATCH 07/39] Removed comment --- api/schemas/domain/www_scan/https/https_tags.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index a3417dcdc4..4d1c52eab8 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -97,16 +97,3 @@ def resolve_value(self: Https_scans, info): tags.append({"https14": "HTTPS-certificate-self-signed"}) return tags - - -# { -# "https": { -# "hsts": "No HSTS", -# "enforced": "Weak", -# "hsts_age": null, -# "expired_cert": false, -# "implementation": "Valid HTTPS", -# "preload_status": "HSTS Not Preloaded", -# "self_signed_cert": false -# } -# } From c8f38dbd4d9c3a4e879948ebda3e7b1e2cd8dc0c Mon Sep 17 00:00:00 2001 From: IdezHD Date: Fri, 5 Jun 2020 14:38:26 -0300 Subject: [PATCH 08/39] First iteration of ssl tags --- api/schemas/domain/www_scan/ssl/ssl_tags.py | 88 +++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl/ssl_tags.py index e69de29bb2..ea247dbb9a 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl/ssl_tags.py @@ -0,0 +1,88 @@ +import graphene +from graphene_sqlalchemy import SQLAlchemyObjectType + +from models import Ssl_scans + + +class SSLTags(SQLAlchemyObjectType): + """ + Guidance tags for HTTPS scan results + """ + class Meta: + model = Ssl_scans + exclude_fields = ("id", "ssl_scan") + + value = graphene.List( + lambda: graphene.String, + description="" + ) + + def resolve_value(self: Ssl_scans, info): + tags = [] + + if self.ssl_scan.get("missing", None) is not None: + return tags.append({"ssl2": "missing"}) + + # Signature Algorithm + signature_algorithm = self.ssl_scan.get("ssl", {}) \ + .get("signature_algorithm", None) + + if isinstance(signature_algorithm, str): + signature_algorithm = signature_algorithm.lower() + + if signature_algorithm == "sha-256" \ + or signature_algorithm == "sha-384" \ + or signature_algorithm == "aead": + tags.append({"ssl7": "SSL-acceptable-certificate"}) + else: + tags.append({"ssl8": "SSL-invalid-cipher"}) + + # Heartbleed + heart_bleed = self.ssl_scan.get("ssl", {}) \ + .get("heartbleed", None) + + if heart_bleed: + tags.append({"ssl9": "Vulnerability-heartbleed"}) + + # openssl ccs injection + openssl_ccs_injection = self.ssl_scan.get("ssl", {}) \ + .get("openssl_ccs_injection", None) + + if openssl_ccs_injection: + tags.append({"ssl10": "Vulnerability-ccs-injection"}) + + return tags + +# { +# "ssl": { +# "rc4": true, +# "3des": true, +# "SSL_2_0": false, +# "SSL_3_0": false, +# "TLS_1_0": false, +# "TLS_1_1": true, +# "TLS_1_2": true, +# "TLS_1_3": false, +# "heartbleed": false, +# "weak_ciphers": [ +# "TLS_RSA_WITH_RC4_128_SHA", +# "TLS_RSA_WITH_RC4_128_MD5", +# "TLS_RSA_WITH_AES_256_CBC_SHA", +# "TLS_RSA_WITH_AES_128_CBC_SHA", +# "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +# ], +# "strong_ciphers": [ +# +# ], +# "preferred_cipher": null, +# "acceptable_ciphers": [ +# "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", +# "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", +# "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", +# "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" +# ], +# "signature_algorithm": "SHA256", +# "openssl_ccs_injection": false, +# "acceptable_certificate": true +# } +# } From 510fef9bc1812e555d3f5fc0dd1e400aaa21208a Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 10:06:33 -0300 Subject: [PATCH 09/39] Updated ssl tags --- api/schemas/domain/www_scan/ssl/ssl_tags.py | 46 ++++++--------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl/ssl_tags.py index ea247dbb9a..4fb3c42c66 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl/ssl_tags.py @@ -23,6 +23,18 @@ def resolve_value(self: Ssl_scans, info): if self.ssl_scan.get("missing", None) is not None: return tags.append({"ssl2": "missing"}) + # SSL-rc4 + ssl_rc4 = self.get('ssl', {}) \ + .get("rc4", None) + if ssl_rc4: + tags.append({"ssl4": "SSL-rc4"}) + + # SSL-3des + ssl_3des = self.get('ssl', {}) \ + .get("3des", None) + if ssl_3des: + tags.append({"ssl5": "SSL-3des"}) + # Signature Algorithm signature_algorithm = self.ssl_scan.get("ssl", {}) \ .get("signature_algorithm", None) @@ -52,37 +64,3 @@ def resolve_value(self: Ssl_scans, info): tags.append({"ssl10": "Vulnerability-ccs-injection"}) return tags - -# { -# "ssl": { -# "rc4": true, -# "3des": true, -# "SSL_2_0": false, -# "SSL_3_0": false, -# "TLS_1_0": false, -# "TLS_1_1": true, -# "TLS_1_2": true, -# "TLS_1_3": false, -# "heartbleed": false, -# "weak_ciphers": [ -# "TLS_RSA_WITH_RC4_128_SHA", -# "TLS_RSA_WITH_RC4_128_MD5", -# "TLS_RSA_WITH_AES_256_CBC_SHA", -# "TLS_RSA_WITH_AES_128_CBC_SHA", -# "TLS_RSA_WITH_3DES_EDE_CBC_SHA" -# ], -# "strong_ciphers": [ -# -# ], -# "preferred_cipher": null, -# "acceptable_ciphers": [ -# "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", -# "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", -# "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", -# "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" -# ], -# "signature_algorithm": "SHA256", -# "openssl_ccs_injection": false, -# "acceptable_certificate": true -# } -# } From 1e10df794f6fcd0ee7f4eeabb3214fa3738caacb Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 10:14:37 -0300 Subject: [PATCH 10/39] Update dkim tags --- .../domain/email_scan/dkim/dkim_tags.py | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index a0fae56014..23a2fba64b 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -18,7 +18,7 @@ def resolve_value(self: Dkim_scans, info): tags = [] if self.dkim_scan.get("missing", None) is not None: - return tags.update({"dkim2": "missing"}) + return tags.append({"dkim2": "missing"}) # Get Key Size, and Key Type key_size = self.dkim_scan.get("dkim", {}) \ @@ -27,10 +27,46 @@ def resolve_value(self: Dkim_scans, info): .get("key_type", None) if key_size >= 2048 and key_type == "rsa": - tags.update({"dkim5": "P-2048"}) + tags.append({"dkim5": "P-2048"}) elif key_size == 1024 and key_type == "rsa": - tags.update({"dkim4": "P-1024"}) + tags.append({"dkim4": "P-1024"}) elif key_size < 1024 and key_type == "rsa": - tags.update({"dkim3": "P-sub1024"}) + tags.append({"dkim3": "P-sub1024"}) else: - tags.update({"dkim6": "P-invalid"}) + tags.append({"dkim6": "P-invalid"}) + + # Update Recommended + key_invalid = self.get("dkim", {}) \ + .get("update-recommend", None) + + if key_invalid: + tags.append({"dkim10": "P-update-recommended"}) + + # Invalid Crypto + invalid_crypto = self.dkim_scan.get("dkim", {}) \ + .get("txt_record", {}) \ + .get("k", None) + # if k != rsa + if invalid_crypto != 'rsa': + tags.append({"dkim11": "DKIM-invalid-crypto"}) + + # Dkim value invalid + # Check if v, k, and p exist in txt_record + v_tag = self.dkim_scan.get("dkim", {}) \ + .get("txt_record", {}) \ + .get("v", None) + k_tag = self.dkim_scan.get("dkim", {}) \ + .get("txt_record", {}) \ + .get("k", None) + p_tag = self.get("dkim", {}) \ + .get("txt_record", {}) \ + .get("p", None) + + if v_tag and k_tag and p_tag: + tags.append({"dkim12": "DKIM-value-invalid"}) + + # Testing Enabled + t_enabled = self.dkim_scan.get("dkim", {}) \ + .get("t_value") + if t_enabled is not None: + tags.append({"dkim13": "T-enabled"}) From 652c6d4a5a6047f7d962607a70152d0f8656ee9a Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 11:59:24 -0300 Subject: [PATCH 11/39] Update dmarc, and spf tags --- .../domain/email_scan/dmarc/dmarc_tags.py | 2 +- api/schemas/domain/email_scan/spf/spf_tags.py | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 669f396964..6651b1cb78 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -62,7 +62,7 @@ def resolve_value(self: Dmarc_scans, info): elif pct_tag == "invalid": tags.append({"dmarc9": "PCT-invalid"}) elif pct_tag == "none": - tags.append({"dmarc20": "PCT-none=exists"}) + tags.append({"dmarc20": "PCT-none-exists"}) else: tags.append({"dmarc21": "PCT-0"}) diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index f2857522bf..422b8f3bf9 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -33,23 +33,29 @@ def resolve_value(self: Spf_scans, info): all_tag = all_tag.lower() if all_tag == "missing": - tags.append({"spf3": "ALL-missing"}) + tags.append({"spf4": "ALL-missing"}) elif all_tag == "allow": - tags.append({"spf4": "ALL-allow"}) + tags.append({"spf5": "ALL-allow"}) elif all_tag == "neutral": - tags.append({"spf5": "ALL-neutral"}) + tags.append({"spf6": "ALL-neutral"}) elif all_tag == "redirect": - tags.append({"spf8": "ALL-redirect"}) + tags.append({"spf9": "ALL-redirect"}) elif all_tag == "fail": record_all_tag = self.spf_scan.get("spf", {}) \ .get("record", "")[-4:].lower() if record_all_tag == "-all": - tags.append({"spf7": "ALL-hardfail"}) + tags.append({"spf8": "ALL-hardfail"}) elif record_all_tag == "~all": - tags.append({"spf6": "ALL-softfail"}) + tags.append({"spf7": "ALL-softfail"}) + + # All tag check + record_all_tag = self.spf_scan.get("spf", {}) \ + .get("record", "")[-4:].lower() + if record_all_tag == "-all": + tags.append({"spf10": "A-all"}) dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) if dns_lookups > 10: - tags.append({"spf10": "INCLUDE-limit"}) + tags.append({"spf11": "INCLUDE-limit"}) return tags From 97519fec7423bdbc3de386f031bf7164e501455f Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 11:59:37 -0300 Subject: [PATCH 12/39] Created mock data for guidance tags tests --- .../testdata/domain_guidance_tags/__init__.py | 0 .../domain_guidance_tags/dkim_mock_data.py | 145 +++ .../domain_guidance_tags/dmarc_mock_data.py | 856 ++++++++++++ .../domain_guidance_tags/https_mock_data.py | 149 +++ .../domain_guidance_tags/spf_mock_data.py | 1157 +++++++++++++++++ .../domain_guidance_tags/ssl_mock_data.py | 197 +++ 6 files changed, 2504 insertions(+) create mode 100644 api/tests/testdata/domain_guidance_tags/__init__.py create mode 100644 api/tests/testdata/domain_guidance_tags/dkim_mock_data.py create mode 100644 api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py create mode 100644 api/tests/testdata/domain_guidance_tags/https_mock_data.py create mode 100644 api/tests/testdata/domain_guidance_tags/spf_mock_data.py create mode 100644 api/tests/testdata/domain_guidance_tags/ssl_mock_data.py diff --git a/api/tests/testdata/domain_guidance_tags/__init__.py b/api/tests/testdata/domain_guidance_tags/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py new file mode 100644 index 0000000000..096a5d7d54 --- /dev/null +++ b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py @@ -0,0 +1,145 @@ +dkim_mock_data_dkim2 = { + "dkim": { + "missing": True + } +} + +dkim_mock_data_dkim5 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 100, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } +} + +dkim_mock_data_dkim6 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 1024, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } +} + +dkim_mock_data_dkim7 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 2048, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } +} + +dkim_mock_data_dkim8 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 4096, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } +} + +dkim_mock_data_dkim9 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } +} + +dkim_mock_data_dkim10 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } +} + +dkim_mock_data_dkim11 = { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } +} + +dkim_mock_data_dkim12 = { + "dkim": { + "t_value": None, + "txt_record": {}, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } +} + +dkim_mock_data_dkim13 = { + "dkim": { + "t_value": True, + "txt_record": {}, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } +} diff --git a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py new file mode 100644 index 0000000000..d868ca6ab0 --- /dev/null +++ b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py @@ -0,0 +1,856 @@ +dmarc_mock_data_dmarc2 = { + "dmarc": { + "missing": True + } +} + +dmarc_mock_data_dmarc3 = { + "dmarc": { + "tags": { + "p": { + "value": "Missing", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc4 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc5 = { + "dmarc": { + "tags": { + "p": { + "value": "Quarantine", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc6 = { + "dmarc": { + "tags": { + "p": { + "value": "Reject", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc7 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc8 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 80, + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc9 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc10_dmarc_11 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "ruf": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc12_dmarc_13 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc16 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Missing", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc17 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc18 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Quarantine", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc19 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc20 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": "None", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} + +dmarc_mock_data_dmarc21 = { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": 0, + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } +} diff --git a/api/tests/testdata/domain_guidance_tags/https_mock_data.py b/api/tests/testdata/domain_guidance_tags/https_mock_data.py new file mode 100644 index 0000000000..c90fc43e9c --- /dev/null +++ b/api/tests/testdata/domain_guidance_tags/https_mock_data.py @@ -0,0 +1,149 @@ +https_mock_data_https2 = { + "https": { + "missing": True + } +} + +https_mock_data_https3 = { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Downgrades HTTPS", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https4 = { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Chain", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https5 = { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https6 = { + "https": { + "hsts": "No HSTS", + "enforced": "Not Enforced", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https7 = { + "https": { + "hsts": "No HSTS", + "enforced": "Not Enforced", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https8 = { + "https": { + "hsts": "No HSTS", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https9 = { + "https": { + "hsts": "No HSTS", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https10 = { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https11 = { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Preload Ready", + "self_signed_cert": False + } +} + +https_mock_data_https12 = { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https13 = { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": True, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } +} + +https_mock_data_https14 = { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": True, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": True + } +} diff --git a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py new file mode 100644 index 0000000000..51354a0002 --- /dev/null +++ b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py @@ -0,0 +1,1157 @@ +spf_mock_data_spf2 = { + "spf": { + "missing": True + } +} + +spf_mock_data_spf3 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } + } +} + +spf_mock_data_spf4 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "missing" + } + } +} + +spf_mock_data_spf5 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "Allow" + } + } +} + +spf_mock_data_spf6 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "Neutral" + } + } +} + +spf_mock_data_spf7 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com ~all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } + } +} + +spf_mock_data_spf8 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } + } +} + +spf_mock_data_spf9 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } + } +} + +spf_mock_data_spf10 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } + } +} + +spf_mock_data_spf11 = { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 15, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } + } +} diff --git a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py new file mode 100644 index 0000000000..4d9cfd6806 --- /dev/null +++ b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py @@ -0,0 +1,197 @@ +ssl_mock_data_ssl2 = { + "ssl": { + "missing": True + } +} + +ssl_mock_data_ssl3 = { + "ssl": { + "rc4": True, + "3des": True, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } +} + +ssl_mock_data_ssl4 = { + "ssl": { + "rc4": False, + "3des": True, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } +} + +ssl_mock_data_ssl5 = { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } +} + +ssl_mock_data_ssl6 = { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } +} + +ssl_mock_data_ssl7 = { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": True, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } +} + +ssl_mock_data_ssl8 = { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": True, + "acceptable_certificate": True + } +} From be406775143e1cfd1b93905ea233805dbfae59d8 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 12:14:10 -0300 Subject: [PATCH 13/39] Moved all mock data into separate dicts --- .../domain_guidance_tags/dkim_mock_data.py | 279 +- .../domain_guidance_tags/dmarc_mock_data.py | 1695 ++++++------ .../domain_guidance_tags/https_mock_data.py | 284 +-- .../domain_guidance_tags/spf_mock_data.py | 2267 ++++++++--------- .../domain_guidance_tags/ssl_mock_data.py | 386 ++- 5 files changed, 2435 insertions(+), 2476 deletions(-) diff --git a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py index 096a5d7d54..56892ec7e5 100644 --- a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py @@ -1,145 +1,138 @@ -dkim_mock_data_dkim2 = { - "dkim": { - "missing": True - } -} - -dkim_mock_data_dkim5 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 100, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 - } -} - -dkim_mock_data_dkim6 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 1024, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 - } -} - -dkim_mock_data_dkim7 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 2048, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 - } -} - -dkim_mock_data_dkim8 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 4096, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 - } -} - -dkim_mock_data_dkim9 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 - } -} - -dkim_mock_data_dkim10 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True - } -} - -dkim_mock_data_dkim11 = { - "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True - } -} - -dkim_mock_data_dkim12 = { - "dkim": { - "t_value": None, - "txt_record": {}, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True - } -} - -dkim_mock_data_dkim13 = { - "dkim": { - "t_value": True, - "txt_record": {}, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True +dkim_mock_data = { + "dkim_mock_data_dkim2": { + "dkim": { + "missing": True + } + }, + "dkim_mock_data_dkim5": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 100, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } + }, + "dkim_mock_data_dkim6": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 1024, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } + }, + "dkim_mock_data_dkim7": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 2048, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } + }, + "dkim_mock_data_dkim8": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": 4096, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } + }, + "dkim_mock_data_dkim9": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537 + } + }, + "dkim_mock_data_dkim10": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "rsa", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } + }, + "dkim_mock_data_dkim11": { + "dkim": { + "t_value": None, + "txt_record": { + "v": "DKIM1", + "k": "rsa", + "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" + }, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } + }, + "dkim_mock_data_dkim12": { + "dkim": { + "t_value": None, + "txt_record": {}, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } + }, + "dkim_mock_data_dkim13": { + "dkim": { + "t_value": True, + "txt_record": {}, + "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", + "key_size": None, + "key_type": "SHA256", + "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, + "public_exponent": 65537, + "update-recommend": True + } } } diff --git a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py index d868ca6ab0..de80d82978 100644 --- a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py @@ -1,856 +1,843 @@ -dmarc_mock_data_dmarc2 = { - "dmarc": { - "missing": True - } -} - -dmarc_mock_data_dmarc3 = { - "dmarc": { - "tags": { - "p": { - "value": "Missing", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc4 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc5 = { - "dmarc": { - "tags": { - "p": { - "value": "Quarantine", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc6 = { - "dmarc": { - "tags": { - "p": { - "value": "Reject", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc7 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": True - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc8 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 80, - "explicit": True - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc9 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc10_dmarc_11 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "ruf": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc12_dmarc_13 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc16 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Missing", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc17 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc18 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Quarantine", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc19 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Reject", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc20 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Reject", - "explicit": True - }, - "pct": { - "value": "None", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } -} - -dmarc_mock_data_dmarc21 = { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Reject", - "explicit": True - }, - "pct": { - "value": 0, - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] +dmarc_mock_data = { + "dmarc_mock_data_dmarc2": { + "dmarc": { + "missing": True + } + }, + "dmarc_mock_data_dmarc3": { + "dmarc": { + "tags": { + "p": { + "value": "Missing", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc4": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc5": { + "dmarc": { + "tags": { + "p": { + "value": "Quarantine", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc6": { + "dmarc": { + "tags": { + "p": { + "value": "Reject", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": False + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc7": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 100, + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc8": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": 80, + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc9": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc10_dmarc_11": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "ruf": { + "value": [ + { + "scheme": "mailto", + "address": "dmarc@cyber.gc.ca", + "size_limit": None + } + ], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc12_dmarc_13": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc16": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Missing", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc17": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "None", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc18": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Quarantine", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc19": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": "Invalid", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc20": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": "None", + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } + }, + "dmarc_mock_data_dmarc21": { + "dmarc": { + "tags": { + "p": { + "value": "None", + "explicit": True + }, + "v": { + "value": "DMARC1", + "explicit": True + }, + "fo": { + "value": ["0"], + "explicit": False + }, + "rf": { + "value": ["afrf"], + "explicit": False + }, + "ri": { + "value": 86400, + "explicit": False + }, + "sp": { + "value": "Reject", + "explicit": True + }, + "pct": { + "value": 0, + "explicit": True + }, + "rua": { + "value": [], + "explicit": True + }, + "ruf": { + "value": [], + "explicit": True + }, + "aspf": { + "value": "r", + "explicit": False + }, + "adkim": { + "value": "r", + "explicit": False + } + }, + "valid": True, + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + "location": "forces.gc.ca", + "warnings": [] + } } } diff --git a/api/tests/testdata/domain_guidance_tags/https_mock_data.py b/api/tests/testdata/domain_guidance_tags/https_mock_data.py index c90fc43e9c..92c448b7fa 100644 --- a/api/tests/testdata/domain_guidance_tags/https_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/https_mock_data.py @@ -1,149 +1,139 @@ -https_mock_data_https2 = { - "https": { - "missing": True - } -} - -https_mock_data_https3 = { - "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, - "implementation": "Downgrades HTTPS", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https4 = { - "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Chain", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https5 = { - "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https6 = { - "https": { - "hsts": "No HSTS", - "enforced": "Not Enforced", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https7 = { - "https": { - "hsts": "No HSTS", - "enforced": "Not Enforced", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https8 = { - "https": { - "hsts": "No HSTS", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https9 = { - "https": { - "hsts": "No HSTS", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https10 = { - "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https11 = { - "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Preload Ready", - "self_signed_cert": False - } -} - -https_mock_data_https12 = { - "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https13 = { - "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": True, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False - } -} - -https_mock_data_https14 = { - "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": True, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": True +https_mock_data = { + "https_mock_data_https2": { + "https": { + "missing": True + } + }, + "https_mock_data_https3": { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Downgrades HTTPS", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https4": { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Chain", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https5": { + "https": { + "hsts": "No HSTS", + "enforced": "Weak", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https6": { + "https": { + "hsts": "No HSTS", + "enforced": "Not Enforced", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https7": { + "https": { + "hsts": "No HSTS", + "enforced": "Not Enforced", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https8": { + "https": { + "hsts": "No HSTS", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https9": { + "https": { + "hsts": "No HSTS", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https10": { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https11": { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Preload Ready", + "self_signed_cert": False + } + }, + "https_mock_data_https12": { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": False, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https13": { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": True, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": False + } + }, + "https_mock_data_https14": { + "https": { + "hsts": "HSTS Max Age Too Short", + "enforced": "Moderate", + "hsts_age": None, + "expired_cert": True, + "implementation": "Bad Hostname", + "preload_status": "HSTS Not Preloaded", + "self_signed_cert": True + } } } diff --git a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py index 51354a0002..9e9a9bf355 100644 --- a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py @@ -1,1157 +1,1150 @@ -spf_mock_data_spf2 = { - "spf": { - "missing": True - } -} - -spf_mock_data_spf3 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" +spf_mock_data = { + "spf_mock_data_spf2": { + "spf": { + "missing": True } - } -} - -spf_mock_data_spf4 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + }, + "spf_mock_data_spf3": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "missing" - } - } -} - -spf_mock_data_spf5 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "205.193.218.37", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "Allow" - } - } -} - -spf_mock_data_spf6 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "205.193.218.114", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "Neutral" - } - } -} - -spf_mock_data_spf7 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com ~all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } } - } -} - -spf_mock_data_spf8 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" + }, + "spf_mock_data_spf4": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "missing" + } + } + }, + "spf_mock_data_spf5": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "Allow" + } } - } -} - -spf_mock_data_spf9 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" + }, + "spf_mock_data_spf6": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "Neutral" + } + } + }, + "spf_mock_data_spf7": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com ~all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "redirect" + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } } - } -} - -spf_mock_data_spf10 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" + }, + "spf_mock_data_spf8": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + } + } + }, + "spf_mock_data_spf9": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "redirect" + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } } - } -} - -spf_mock_data_spf11 = { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 15, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" + }, + "spf_mock_data_spf10": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 5, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" + }, + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } + } + }, + "spf_mock_data_spf11": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "valid": True, + "dns_lookups": 15, + "warnings": [], + "parsed": { + "pass": [ + { + "value": "205.193.218.38", + "mechanism": "a" + }, + { + "value": "205.193.218.37", + "mechanism": "a" + }, + { + "value": "205.193.218.114", + "mechanism": "a" }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "redirect" + { + "value": "205.193.218.115", + "mechanism": "a" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spf.protection.outlook.com", + "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", + "dns_lookups": 1, + "parsed": { + "pass": [ + { + "value": "40.92.0.0/15", + "mechanism": "ip4" + }, + { + "value": "40.107.0.0/16", + "mechanism": "ip4" + }, + { + "value": "52.100.0.0/14", + "mechanism": "ip4" + }, + { + "value": "104.47.0.0/17", + "mechanism": "ip4" + }, + { + "value": "2a01:111:f400::/48", + "mechanism": "ip6" + }, + { + "value": "2a01:111:f403::/48", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [ + { + "domain": "spfd.protection.outlook.com", + "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", + "dns_lookups": 0, + "parsed": { + "pass": [ + { + "value": "51.4.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.72.0/24", + "mechanism": "ip4" + }, + { + "value": "51.5.80.0/27", + "mechanism": "ip4" + }, + { + "value": "51.4.80.0/27", + "mechanism": "ip4" + }, + { + "value": "2a01:4180:4051:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0800::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4051:0400::/64", + "mechanism": "ip6" + }, + { + "value": "2a01:4180:4050:0400::/64", + "mechanism": "ip6" + } + ], + "neutral": [], + "softfail": [], + "fail": [], + "include": [], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "fail" + }, + "warnings": [] + } + ], + "redirect": None, + "exp": None, + "all": "redirect" + } } } } diff --git a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py index 4d9cfd6806..0663ccceda 100644 --- a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py @@ -1,197 +1,193 @@ -ssl_mock_data_ssl2 = { - "ssl": { - "missing": True - } -} - -ssl_mock_data_ssl3 = { - "ssl": { - "rc4": True, - "3des": True, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, - "acceptable_certificate": True - } -} - -ssl_mock_data_ssl4 = { - "ssl": { - "rc4": False, - "3des": True, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, - "acceptable_certificate": True - } -} - -ssl_mock_data_ssl5 = { - "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, - "acceptable_certificate": True - } -} - -ssl_mock_data_ssl6 = { - "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "RSA", - "openssl_ccs_injection": False, - "acceptable_certificate": True - } -} - -ssl_mock_data_ssl7 = { - "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": True, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "RSA", - "openssl_ccs_injection": False, - "acceptable_certificate": True - } -} - -ssl_mock_data_ssl8 = { - "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "RSA", - "openssl_ccs_injection": True, - "acceptable_certificate": True +ssl_mock_data = { + "ssl_mock_data_ssl2": { + "ssl": { + "missing": True + } + }, + "ssl_mock_data_ssl3": { + "ssl": { + "rc4": True, + "3des": True, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } + }, + "ssl_mock_data_ssl4": { + "ssl": { + "rc4": False, + "3des": True, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } + }, + "ssl_mock_data_ssl5": { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "SHA256", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } + }, + "ssl_mock_data_ssl6": { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } + }, + "ssl_mock_data_ssl7": { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": True, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": False, + "acceptable_certificate": True + } + }, + "ssl_mock_data_ssl8": { + "ssl": { + "rc4": False, + "3des": False, + "SSL_2_0": False, + "SSL_3_0": False, + "TLS_1_0": False, + "TLS_1_1": True, + "TLS_1_2": True, + "TLS_1_3": False, + "heartbleed": False, + "weak_ciphers": [ + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ], + "strong_ciphers": [], + "preferred_cipher": None, + "acceptable_ciphers": [ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ], + "signature_algorithm": "RSA", + "openssl_ccs_injection": True, + "acceptable_certificate": True + } } } From aae91c01eaa9d59e5483a0329f20142a11343fed Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 13:20:59 -0300 Subject: [PATCH 14/39] Fix missing checks --- api/schemas/domain/email_scan/dkim/dkim_tags.py | 2 +- api/schemas/domain/email_scan/dmarc/dmarc_tags.py | 2 +- api/schemas/domain/email_scan/spf/spf_tags.py | 2 +- api/schemas/domain/www_scan/https/https_tags.py | 2 +- api/schemas/domain/www_scan/ssl/ssl_tags.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index 23a2fba64b..6715dd0f72 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -17,7 +17,7 @@ class Meta: def resolve_value(self: Dkim_scans, info): tags = [] - if self.dkim_scan.get("missing", None) is not None: + if self.dkim_scan.get("dkim", {}).get("missing", None) is not None: return tags.append({"dkim2": "missing"}) # Get Key Size, and Key Type diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 6651b1cb78..935265524f 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -21,7 +21,7 @@ class Meta: def resolve_value(self: Dmarc_scans, info): tags = [] - if self.dmarc_scan.get("missing", None) is not None: + if self.dmarc_scan.get("dmarc", {}).get("missing", None) is not None: tags.append({"dmarc2": "missing"}) return tags diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index 422b8f3bf9..53f314e7f6 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -21,7 +21,7 @@ class Meta: def resolve_value(self: Spf_scans, info): tags = [] - if self.spf_scan.get("missing", None) is not None: + if self.spf_scan.get("spf", {}).get("missing", None) is not None: return tags.append({"spf2": "missing"}) # Check all tag diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index 4d1c52eab8..ccc0622c88 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -20,7 +20,7 @@ class Meta: def resolve_value(self: Https_scans, info): tags = [] - if self.https_scan.get("missing", None) is not None: + if self.https_scan.get("https", {}).get("missing", None) is not None: return tags.append({"https2": "missing"}) # Implementation diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl/ssl_tags.py index 4fb3c42c66..40efa1757a 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl/ssl_tags.py @@ -20,7 +20,7 @@ class Meta: def resolve_value(self: Ssl_scans, info): tags = [] - if self.ssl_scan.get("missing", None) is not None: + if self.ssl_scan.get("ssl", {}).get("missing", None) is not None: return tags.append({"ssl2": "missing"}) # SSL-rc4 From 780576ea84835f26825215f7fe7694bf5631c907 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 13:26:56 -0300 Subject: [PATCH 15/39] switched guidance tag fields to fields --- api/schemas/domain/email_scan/dkim/__init__.py | 4 ++-- api/schemas/domain/email_scan/spf/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim/__init__.py b/api/schemas/domain/email_scan/dkim/__init__.py index 1bfb65119d..48d25cd91a 100644 --- a/api/schemas/domain/email_scan/dkim/__init__.py +++ b/api/schemas/domain/email_scan/dkim/__init__.py @@ -28,7 +28,7 @@ class Meta: description="DKIM record retrieved during the scan of the " "given domain " ) key_length = graphene.String(description="Length of DKIM public key") - dkim_guidance_tags = graphene.List( + dkim_guidance_tags = graphene.Field( lambda: DkimTags, description="Key tags found during scan" ) @@ -45,4 +45,4 @@ def resolve_key_length(self, info): return self.dkim_scan["dkim"]["key_size"] def resolve_dkim_guidance_tags(self, info): - return DkimTags.get_query(info).all() + return DkimTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/spf/__init__.py b/api/schemas/domain/email_scan/spf/__init__.py index a2a850dc58..c5303b30a1 100644 --- a/api/schemas/domain/email_scan/spf/__init__.py +++ b/api/schemas/domain/email_scan/spf/__init__.py @@ -34,7 +34,7 @@ class Meta: description="Instruction of what a recipient should do if there is " "not a match to your SPF record. " ) - spf_guidance_tags = graphene.List( + spf_guidance_tags = graphene.Field( lambda: SPFTags, description="Key tags found during SPF scan" ) @@ -60,4 +60,4 @@ def resolve_spf_default(self: Spf_scans, info): return self.spf_scan["spf"]["parsed"]["all"] def resolve_spf_guidance_tags(self: Spf_scans, info): - return SPFTags.get_query(info).all() + return SPFTags.get_query(info).first() From 53703b7bfb5612bdd3fd6ae1a71e2a3507785ea9 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 14:08:58 -0300 Subject: [PATCH 16/39] Fixes to dkim tags, and testing for the majority of dkim tags --- api/schemas/domain/email_scan/__init__.py | 12 +- .../domain/email_scan/dkim/dkim_tags.py | 33 +- api/tests/test_dkim_guidance_tags.py | 755 ++++++++++++++++++ .../testdata/domain_guidance_tags/__init__.py | 5 + .../domain_guidance_tags/dkim_mock_data.py | 4 +- 5 files changed, 790 insertions(+), 19 deletions(-) create mode 100644 api/tests/test_dkim_guidance_tags.py diff --git a/api/schemas/domain/email_scan/__init__.py b/api/schemas/domain/email_scan/__init__.py index a94dc8edeb..52fd7147d3 100644 --- a/api/schemas/domain/email_scan/__init__.py +++ b/api/schemas/domain/email_scan/__init__.py @@ -23,17 +23,17 @@ class Meta: domain = URL(description="The domain the scan was run on") timestamp = graphene.DateTime(description="The time the scan was initiated") - dmarc = graphene.List( + dmarc = graphene.Field( lambda: DMARC, description="Domain-based Message Authentication, Reporting, " "and Conformance (DMARC) ", ) - spf = graphene.List( + spf = graphene.Field( lambda: SPF, description="Sender Policy Framework (SPF) for Authorizing Use of " "Domains in Email ", ) - dkim = graphene.List( + dkim = graphene.Field( lambda: DKIM, description="DomainKeys Identified Mail (DKIM) Signatures" ) @@ -45,15 +45,15 @@ def resolve_timestamp(self: Scans, info): def resolve_dmarc(self: Scans, info): query = DMARC.get_query(info) - return query.filter(self.id == Dmarc_scans.id).all() + return query.filter(self.id == Dmarc_scans.id).first() def resolve_spf(self: Scans, info): query = SPF.get_query(info) - return query.filter(self.id == Spf_scans.id).all() + return query.filter(self.id == Spf_scans.id).first() def resolve_dkim(self: Scans, info): query = DKIM.get_query(info) - return query.filter(self.id == Dkim_scans.id).all() + return query.filter(self.id == Dkim_scans.id).first() class EmailScanConnection(relay.Connection): diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index 6715dd0f72..e0518254e5 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -18,7 +18,9 @@ def resolve_value(self: Dkim_scans, info): tags = [] if self.dkim_scan.get("dkim", {}).get("missing", None) is not None: - return tags.append({"dkim2": "missing"}) + print("WHY WONT THIS WORK") + tags.append({"dkim2": "DKIM-missing"}) + return tags # Get Key Size, and Key Type key_size = self.dkim_scan.get("dkim", {}) \ @@ -26,17 +28,24 @@ def resolve_value(self: Dkim_scans, info): key_type = self.dkim_scan.get("dkim", {}) \ .get("key_type", None) - if key_size >= 2048 and key_type == "rsa": - tags.append({"dkim5": "P-2048"}) - elif key_size == 1024 and key_type == "rsa": - tags.append({"dkim4": "P-1024"}) - elif key_size < 1024 and key_type == "rsa": - tags.append({"dkim3": "P-sub1024"}) + if key_size is None: + tags.append({"dkim9": "P-invalid"}) + elif key_type is None: + tags.append({"dkim9": "P-invalid"}) else: - tags.append({"dkim6": "P-invalid"}) + if key_size >= 4096 and key_type == "rsa": + tags.append({"dkim8": "P-4096"}) + elif key_size >= 2048 and key_type == "rsa": + tags.append({"dkim7": "P-2048"}) + elif key_size == 1024 and key_type == "rsa": + tags.append({"dkim6": "P-1024"}) + elif key_size < 1024 and key_type == "rsa": + tags.append({"dkim5": "P-sub1024"}) + else: + tags.append({"dkim9": "P-invalid"}) # Update Recommended - key_invalid = self.get("dkim", {}) \ + key_invalid = self.dkim_scan.get("dkim", {}) \ .get("update-recommend", None) if key_invalid: @@ -58,11 +67,11 @@ def resolve_value(self: Dkim_scans, info): k_tag = self.dkim_scan.get("dkim", {}) \ .get("txt_record", {}) \ .get("k", None) - p_tag = self.get("dkim", {}) \ + p_tag = self.dkim_scan.get("dkim", {}) \ .get("txt_record", {}) \ .get("p", None) - if v_tag and k_tag and p_tag: + if v_tag is None and k_tag is None and p_tag is None: tags.append({"dkim12": "DKIM-value-invalid"}) # Testing Enabled @@ -70,3 +79,5 @@ def resolve_value(self: Dkim_scans, info): .get("t_value") if t_enabled is not None: tags.append({"dkim13": "T-enabled"}) + + return tags diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py new file mode 100644 index 0000000000..7d6d3747d8 --- /dev/null +++ b/api/tests/test_dkim_guidance_tags.py @@ -0,0 +1,755 @@ +import pytest +from datetime import datetime +from pytest import fail + +from db import DB +from models import Users, Organizations, Domains, Scans, Dkim_scans, User_affiliations +from tests.testdata.domain_guidance_tags import dkim_mock_data +from tests.test_functions import json, run + + +@pytest.fixture +def save(): + save, cleanup, session = DB() + yield save + cleanup() + + +def test_dkim_guidance_tags_dkim_2(save): + """ + Test that dkim guidance tag dkim 2 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim2") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim2': 'DKIM-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_5(save): + """ + Test that dkim guidance tag dkim 5 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim5") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim5': 'P-sub1024'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_6(save): + """ + Test that dkim guidance tag dkim 6 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim6") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim6': 'P-1024'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_7(save): + """ + Test that dkim guidance tag dkim 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim7") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim7': 'P-2048'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_8(save): + """ + Test that dkim guidance tag dkim 8 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim8") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim8': 'P-4096'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_9(save): + """ + Test that dkim guidance tag dkim 9 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim9") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim9': 'P-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_10(save): + """ + Test that dkim guidance tag dkim 10 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim10") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim10': 'P-update-recommended'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_11(save): + """ + Test that dkim guidance tag dkim 11 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim11") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim11': 'DKIM-invalid-crypto'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_12(save): + """ + Test that dkim guidance tag dkim 12 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim12") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim12': 'DKIM-value-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dkim_13(save): + """ + Test that dkim guidance tag dkim 13 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim13") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dkim { + dkimGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dkim13': 'T-enabled'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] diff --git a/api/tests/testdata/domain_guidance_tags/__init__.py b/api/tests/testdata/domain_guidance_tags/__init__.py index e69de29bb2..ac29340027 100644 --- a/api/tests/testdata/domain_guidance_tags/__init__.py +++ b/api/tests/testdata/domain_guidance_tags/__init__.py @@ -0,0 +1,5 @@ +from tests.testdata.domain_guidance_tags.dkim_mock_data import dkim_mock_data +from tests.testdata.domain_guidance_tags.dmarc_mock_data import dmarc_mock_data +from tests.testdata.domain_guidance_tags.https_mock_data import https_mock_data +from tests.testdata.domain_guidance_tags.spf_mock_data import spf_mock_data +from tests.testdata.domain_guidance_tags.ssl_mock_data import ssl_mock_data diff --git a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py index 56892ec7e5..58810b5361 100644 --- a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py @@ -100,11 +100,11 @@ "t_value": None, "txt_record": { "v": "DKIM1", - "k": "rsa", + "k": "SHA256", "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, + "key_size": 1024, "key_type": "SHA256", "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, "public_exponent": 65537, From 25c7dd9045cce8749f17768bb09770a8bf6cf649 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 14:09:45 -0300 Subject: [PATCH 17/39] Remove print debug statement --- api/schemas/domain/email_scan/dkim/dkim_tags.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index e0518254e5..85e62d71d0 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -18,7 +18,6 @@ def resolve_value(self: Dkim_scans, info): tags = [] if self.dkim_scan.get("dkim", {}).get("missing", None) is not None: - print("WHY WONT THIS WORK") tags.append({"dkim2": "DKIM-missing"}) return tags From 4d281468f002a8b0917f32e251bf0fd031dc5918 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 14:35:42 -0300 Subject: [PATCH 18/39] Fixed guidance tag generation, and implemented tests --- .../domain/email_scan/dmarc/dmarc_tags.py | 34 +- api/tests/test_dmarc_guidance_tags.py | 1201 +++++++++++++++++ 2 files changed, 1218 insertions(+), 17 deletions(-) create mode 100644 api/tests/test_dmarc_guidance_tags.py diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 935265524f..51f1061c7f 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -22,7 +22,7 @@ def resolve_value(self: Dmarc_scans, info): tags = [] if self.dmarc_scan.get("dmarc", {}).get("missing", None) is not None: - tags.append({"dmarc2": "missing"}) + tags.append({"dmarc2": "DMARC-missing"}) return tags # Check P Policy Tag @@ -51,20 +51,20 @@ def resolve_value(self: Dmarc_scans, info): if isinstance(pct_tag, str): pct_tag = pct_tag.lower() - - if pct_tag == 100: - tags.append({"dmarc7": "PCT-100"}) - elif 100 > pct_tag > 0: - pct_string = "PCT-" + str( - pct_tag - ) - tags.append({"dmarc8": pct_string}) - elif pct_tag == "invalid": - tags.append({"dmarc9": "PCT-invalid"}) - elif pct_tag == "none": - tags.append({"dmarc20": "PCT-none-exists"}) - else: - tags.append({"dmarc21": "PCT-0"}) + if pct_tag == "invalid": + tags.append({"dmarc9": "PCT-invalid"}) + elif pct_tag == "none": + tags.append({"dmarc20": "PCT-none-exists"}) + elif isinstance(pct_tag, int): + if pct_tag == 100: + tags.append({"dmarc7": "PCT-100"}) + elif 100 > pct_tag > 0: + pct_string = "PCT-" + str( + pct_tag + ) + tags.append({"dmarc8": pct_string}) + else: + tags.append({"dmarc21": "PCT-0"}) # Check RUA Tag rua_tag = self.dmarc_scan.get("dmarc", {}) \ @@ -75,7 +75,7 @@ def resolve_value(self: Dmarc_scans, info): if isinstance(rua_tag, str): rua_tag = rua_tag.lower() - if rua_tag is None: + if rua_tag is None or not rua_tag: tags.append({"dmarc12": "RUA-none"}) else: for value in rua_tag: @@ -90,7 +90,7 @@ def resolve_value(self: Dmarc_scans, info): .get("ruf", {}) \ .get("value", None) - if ruf_tag is None: + if ruf_tag is None or not ruf_tag: tags.append({"dmarc13": "RUF-none"}) else: for value in ruf_tag: diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py new file mode 100644 index 0000000000..ea78013ffb --- /dev/null +++ b/api/tests/test_dmarc_guidance_tags.py @@ -0,0 +1,1201 @@ +import pytest +from datetime import datetime +from pytest import fail + +from db import DB +from models import Users, Organizations, Domains, Scans, Dmarc_scans, User_affiliations +from tests.testdata.domain_guidance_tags import dmarc_mock_data +from tests.test_functions import json, run + + +@pytest.fixture +def save(): + save, cleanup, session = DB() + yield save + cleanup() + + +def test_dkim_guidance_tags_dmarc_2(save): + """ + Test that dmarc guidance tag dmarc 2 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc2") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc2': 'DMARC-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_3(save): + """ + Test that dmarc guidance tag dmarc 3 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc3") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc3': 'P-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_4(save): + """ + Test that dmarc guidance tag dmarc 4 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc4") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc4': 'P-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_5(save): + """ + Test that dmarc guidance tag dmarc 5 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc5") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc5': 'P-quarantine'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_6(save): + """ + Test that dmarc guidance tag dmarc 6 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc6") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc6': 'P-reject'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_7(save): + """ + Test that dmarc guidance tag dmarc 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc7") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc7': 'PCT-100'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_8(save): + """ + Test that dmarc guidance tag dmarc 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc8") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc8': 'PCT-80'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_9(save): + """ + Test that dmarc guidance tag dmarc 9 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc9") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc9': 'PCT-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): + """ + Test that dmarc guidance tag dmarc 10, dmarc 11 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc10_dmarc_11") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc10': 'RUA-CCCS'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert "{'dmarc11': 'RUF-CCCS'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): + """ + Test that dmarc guidance tag dmarc 12, dmarc 13 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc12_dmarc_13") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc12': 'RUA-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert "{'dmarc13': 'RUF-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_16(save): + """ + Test that dmarc guidance tag dmarc 16 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc16") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc16': 'SP-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_17(save): + """ + Test that dmarc guidance tag dmarc 17 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc17") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc17': 'SP-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_18(save): + """ + Test that dmarc guidance tag dmarc 18 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc18") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc18': 'SP-quarantine'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_19(save): + """ + Test that dmarc guidance tag dmarc 19 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc19") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc19': 'SP-reject'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_20(save): + """ + Test that dmarc guidance tag dmarc 20 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc20") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc20': 'PCT-none-exists'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_21(save): + """ + Test that dmarc guidance tag dmarc 21 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc21") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc21': 'PCT-0'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] From 14cf440b8e2cb5d829e9b78bf753f2e8445344b6 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Mon, 8 Jun 2020 14:41:36 -0300 Subject: [PATCH 19/39] Trimmed down data for dkim, and dmarc tests --- .../domain_guidance_tags/dkim_mock_data.py | 75 +- .../domain_guidance_tags/dmarc_mock_data.py | 677 +----------------- 2 files changed, 10 insertions(+), 742 deletions(-) diff --git a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py index 58810b5361..bd504fc3e6 100644 --- a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py @@ -6,133 +6,66 @@ }, "dkim_mock_data_dkim5": { "dkim": { - "t_value": None, "txt_record": { - "v": "DKIM1", "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 100, "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 + "key_size": 100, } }, "dkim_mock_data_dkim6": { "dkim": { - "t_value": None, "txt_record": { - "v": "DKIM1", "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 1024, "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 + "key_size": 1024, } }, "dkim_mock_data_dkim7": { "dkim": { - "t_value": None, "txt_record": { - "v": "DKIM1", "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 2048, "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 + "key_size": 2048, } }, "dkim_mock_data_dkim8": { "dkim": { - "t_value": None, "txt_record": { - "v": "DKIM1", "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 4096, "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 + "key_size": 4096, } }, "dkim_mock_data_dkim9": { "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", "key_size": None, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537 } }, "dkim_mock_data_dkim10": { "dkim": { - "t_value": None, - "txt_record": { - "v": "DKIM1", - "k": "rsa", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" - }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "rsa", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, "update-recommend": True } }, "dkim_mock_data_dkim11": { "dkim": { - "t_value": None, "txt_record": { - "v": "DKIM1", "k": "SHA256", - "p": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB" }, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": 1024, "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True } }, "dkim_mock_data_dkim12": { "dkim": { - "t_value": None, - "txt_record": {}, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", "key_size": None, - "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True } }, "dkim_mock_data_dkim13": { "dkim": { "t_value": True, - "txt_record": {}, - "public_key_value": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3rvAQg9bl72tae1RFu4zdx1ZE4E8VUbQfxDcm/x6YW2eNRdGg9cRSgqSLXmj4I+HQQ4GHFItn7Hb0ubGt6AJYMCvygbnnwFX2Skt+w/msnXzQOYY+NR6DEfL/4kwiDaawcDumvD2JfEXD3yCyPBoZStg1wf0a9KgLQQNe4aMREQIDAQAB", - "key_size": None, - "key_type": "SHA256", - "public_key_modulus": 128986835293314190150497987524189448449432921513193192948873532904302192799974922792602624695895630642090219163581382671361079596067726465810188870659566753252627341029040386217423692275583904625222303885358524296924420382485253455698862760166022132727095317896399159035250651155696560064015533460599431434513, - "public_exponent": 65537, - "update-recommend": True } } } diff --git a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py index de80d82978..fbd929f8dc 100644 --- a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py @@ -11,53 +11,7 @@ "value": "Missing", "explicit": True }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] + } } }, "dmarc_mock_data_dmarc4": { @@ -67,53 +21,7 @@ "value": "None", "explicit": True }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] + } } }, "dmarc_mock_data_dmarc5": { @@ -123,53 +31,7 @@ "value": "Quarantine", "explicit": True }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } - }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] + } } }, "dmarc_mock_data_dmarc6": { @@ -179,254 +41,43 @@ "value": "Reject", "explicit": True }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": 100, - "explicit": False - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } + }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc7": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, "pct": { "value": 100, "explicit": True }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc8": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, "pct": { "value": 80, "explicit": True - }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc9": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, "pct": { "value": "Invalid", "explicit": True }, - "rua": { - "value": [ - { - "scheme": "mailto", - "address": "dmarc@cyber.gc.ca", - "size_limit": None - } - ], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc10_dmarc_11": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, "rua": { "value": [ { @@ -447,52 +98,12 @@ ], "explicit": True }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc12_dmarc_13": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "None", - "explicit": True - }, - "pct": { - "value": "Invalid", - "explicit": True - }, "rua": { "value": [], "explicit": True @@ -501,343 +112,67 @@ "value": [], "explicit": True }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc16": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, "sp": { "value": "Missing", "explicit": True }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc17": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, "sp": { "value": "None", "explicit": True }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc18": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, "sp": { "value": "Quarantine", "explicit": True }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc19": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, "sp": { "value": "Reject", "explicit": True }, - "pct": { - "value": "Invalid", - "explicit": True - }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc20": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Reject", - "explicit": True - }, "pct": { "value": "None", "explicit": True }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] } }, "dmarc_mock_data_dmarc21": { "dmarc": { "tags": { - "p": { - "value": "None", - "explicit": True - }, - "v": { - "value": "DMARC1", - "explicit": True - }, - "fo": { - "value": ["0"], - "explicit": False - }, - "rf": { - "value": ["afrf"], - "explicit": False - }, - "ri": { - "value": 86400, - "explicit": False - }, - "sp": { - "value": "Reject", - "explicit": True - }, "pct": { "value": 0, "explicit": True }, - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, - "aspf": { - "value": "r", - "explicit": False - }, - "adkim": { - "value": "r", - "explicit": False - } }, - "valid": True, - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - "location": "forces.gc.ca", - "warnings": [] - } - } + }, + }, } From 85aa266d33fce993eaaf68b6196bb5c28e2f2658 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 07:32:39 -0300 Subject: [PATCH 20/39] Updated dmarc and spf tags --- .../domain/email_scan/dmarc/dmarc_tags.py | 69 +++++++++++++++++++ api/schemas/domain/email_scan/spf/spf_tags.py | 24 +++++-- 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 51f1061c7f..a693d465d7 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -99,6 +99,14 @@ def resolve_value(self: Dmarc_scans, info): else: tags.append({"dmarc13": "RUF-none"}) + # TXT DMARC + record_tag = self.dmarc_scan.get("dmarc", {}) \ + .get("record", None) + if record_tag == "" or record_tag is None: + tags.append({"dmarc15": "TXT-DMARC-missing"}) + else: + tags.append({"dmarc14": "TXT-DMARC-enabled"}) + # Check SP tag sp_tag = self.dmarc_scan.get("dmarc", {}) \ .get("tags", {}) \ @@ -118,3 +126,64 @@ def resolve_value(self: Dmarc_scans, info): tags.append({"dmarc19": "SP-reject"}) return tags + +# { +# "dmarc": { +# "tags": { +# "p": { +# "value": "None", +# "explicit": true +# }, +# "v": { +# "value": "DMARC1", +# "explicit": true +# }, +# "fo": { +# "value": [ +# "0" +# ], +# "explicit": false +# }, +# "rf": { +# "value": [ +# "afrf" +# ], +# "explicit": false +# }, +# "ri": { +# "value": 86400, +# "explicit": false +# }, +# "sp": { +# "value": "None", +# "explicit": true +# }, +# "pct": { +# "value": 100, +# "explicit": false +# }, +# "rua": { +# "value": [ +# { +# "scheme": "mailto", +# "address": "dmarc@cyber.gc.ca", +# "size_limit": null +# } +# ], +# "explicit": true +# }, +# "aspf": { +# "value": "r", +# "explicit": false +# }, +# "adkim": { +# "value": "r", +# "explicit": false +# } +# }, +# "valid": true, +# "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", +# "location": "forces.gc.ca", +# "warnings": [] +# } +# } diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index 53f314e7f6..8860924ff6 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -1,4 +1,6 @@ import graphene +import re + from graphene_sqlalchemy import SQLAlchemyObjectType from models import Spf_scans @@ -22,17 +24,21 @@ def resolve_value(self: Spf_scans, info): tags = [] if self.spf_scan.get("spf", {}).get("missing", None) is not None: - return tags.append({"spf2": "missing"}) + return tags.append({"spf2": "SPF-missing"}) # Check all tag all_tag = self.spf_scan.get("spf", {}) \ .get("parsed", {}) \ .get("all", None) + record_all_tag = self.spf_scan.get("spf", {}) \ + .get("record", "")[-4:].lower() if isinstance(all_tag, str): all_tag = all_tag.lower() - if all_tag == "missing": + if record_all_tag == "": + tags.append({"spf10": "ALL-invalid"}) + elif all_tag == "missing": tags.append({"spf4": "ALL-missing"}) elif all_tag == "allow": tags.append({"spf5": "ALL-allow"}) @@ -41,12 +47,20 @@ def resolve_value(self: Spf_scans, info): elif all_tag == "redirect": tags.append({"spf9": "ALL-redirect"}) elif all_tag == "fail": - record_all_tag = self.spf_scan.get("spf", {}) \ - .get("record", "")[-4:].lower() if record_all_tag == "-all": tags.append({"spf8": "ALL-hardfail"}) elif record_all_tag == "~all": tags.append({"spf7": "ALL-softfail"}) + else: + record = self.spf_scan.get("spf", {}) \ + .get("record", None) + if record is not None: + search_string = "a:" + matches = re.finditer(search_string, record) + + for match in matches: + if record[match:1] == "": + tags.append({"spf11": "A-all"}) # All tag check record_all_tag = self.spf_scan.get("spf", {}) \ @@ -56,6 +70,6 @@ def resolve_value(self: Spf_scans, info): dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) if dns_lookups > 10: - tags.append({"spf11": "INCLUDE-limit"}) + tags.append({"spf12": "INCLUDE-limit"}) return tags From 435c04fb5abdcd3c2784a25ca51aaa07ba057777 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 07:36:01 -0300 Subject: [PATCH 21/39] Updated dmarc tags, and added tests for dmarc14, and dmarc15 --- .../domain/email_scan/dmarc/dmarc_tags.py | 61 -------- api/tests/test_dmarc_guidance_tags.py | 148 ++++++++++++++++++ .../domain_guidance_tags/dmarc_mock_data.py | 9 ++ 3 files changed, 157 insertions(+), 61 deletions(-) diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index a693d465d7..62e5add757 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -126,64 +126,3 @@ def resolve_value(self: Dmarc_scans, info): tags.append({"dmarc19": "SP-reject"}) return tags - -# { -# "dmarc": { -# "tags": { -# "p": { -# "value": "None", -# "explicit": true -# }, -# "v": { -# "value": "DMARC1", -# "explicit": true -# }, -# "fo": { -# "value": [ -# "0" -# ], -# "explicit": false -# }, -# "rf": { -# "value": [ -# "afrf" -# ], -# "explicit": false -# }, -# "ri": { -# "value": 86400, -# "explicit": false -# }, -# "sp": { -# "value": "None", -# "explicit": true -# }, -# "pct": { -# "value": 100, -# "explicit": false -# }, -# "rua": { -# "value": [ -# { -# "scheme": "mailto", -# "address": "dmarc@cyber.gc.ca", -# "size_limit": null -# } -# ], -# "explicit": true -# }, -# "aspf": { -# "value": "r", -# "explicit": false -# }, -# "adkim": { -# "value": "r", -# "explicit": false -# } -# }, -# "valid": true, -# "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", -# "location": "forces.gc.ca", -# "warnings": [] -# } -# } diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index ea78013ffb..df67270c18 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -757,6 +757,154 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): assert "{'dmarc13': 'RUF-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] +def test_dkim_guidance_tags_dmarc_14(save): + """ + Test that dmarc guidance tag dmarc 14 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc14") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc14': 'TXT-DMARC-enabled'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_dmarc_15(save): + """ + Test that dmarc guidance tag dmarc 15 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc15") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + dmarc { + dmarcGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'dmarc15': 'TXT-DMARC-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + + def test_dkim_guidance_tags_dmarc_16(save): """ Test that dmarc guidance tag dmarc 16 shows up diff --git a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py index fbd929f8dc..37f8bc547d 100644 --- a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py @@ -115,6 +115,15 @@ }, } }, + "dmarc_mock_data_dmarc14": { + "dmarc": { + "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", + } + }, + "dmarc_mock_data_dmarc15": { + "dmarc": { + } + }, "dmarc_mock_data_dmarc16": { "dmarc": { "tags": { From 24cd81d2a17800d88cb144f92a15c74b7880da31 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 07:38:07 -0300 Subject: [PATCH 22/39] Updated https, ssl objects --- api/schemas/domain/www_scan/https/__init__.py | 3 +++ api/schemas/domain/www_scan/ssl/__init__.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/api/schemas/domain/www_scan/https/__init__.py b/api/schemas/domain/www_scan/https/__init__.py index 2049090148..132a35408b 100644 --- a/api/schemas/domain/www_scan/https/__init__.py +++ b/api/schemas/domain/www_scan/https/__init__.py @@ -9,6 +9,9 @@ class HTTPS(SQLAlchemyObjectType): + """ + Http Scan Object + """ class Meta: model = Https_scans exclude_fields = ("id", "https_scan") diff --git a/api/schemas/domain/www_scan/ssl/__init__.py b/api/schemas/domain/www_scan/ssl/__init__.py index 7f5408226c..9a7fc05039 100644 --- a/api/schemas/domain/www_scan/ssl/__init__.py +++ b/api/schemas/domain/www_scan/ssl/__init__.py @@ -5,9 +5,13 @@ from scalars.url import URL from functions.get_domain import get_domain from functions.get_timestamp import get_timestamp +from schemas.domain.www_scan.ssl.ssl_tags import SSLTags class SSL(SQLAlchemyObjectType): + """ + SSL Scan Object + """ class Meta: model = Ssl_scans exclude_fields = ("id", "ssl_scan") @@ -15,9 +19,13 @@ class Meta: id = graphene.ID() domain = URL() timestamp = graphene.DateTime() + ssl_guidance_tags = graphene.List(lambda: SSLTags) def resolve_domain(self, info): return get_domain(self, info) def resolve_timestamp(self, info): return get_timestamp(self, info) + + def resolve_ssl_guidance_tags(self: Ssl_scans, info): + return SSLTags.get_query(info).all() From 132c5172a9df4bac73e7524a58605cdce1b9e01c Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 07:42:52 -0300 Subject: [PATCH 23/39] Fix www scan objects --- api/schemas/domain/www_scan/__init__.py | 8 ++++---- api/schemas/domain/www_scan/https/__init__.py | 4 ++-- api/schemas/domain/www_scan/https/https_tags.py | 3 ++- api/schemas/domain/www_scan/ssl/__init__.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/schemas/domain/www_scan/__init__.py b/api/schemas/domain/www_scan/__init__.py index 44a366ae8a..499fde4665 100644 --- a/api/schemas/domain/www_scan/__init__.py +++ b/api/schemas/domain/www_scan/__init__.py @@ -22,8 +22,8 @@ class Meta: domain = URL(description="The domain the scan was run on") timestamp = graphene.DateTime(description="The time the scan was initiated") - https = graphene.List(lambda: HTTPS) - ssl = graphene.List(lambda: SSL) + https = graphene.Field(lambda: HTTPS) + ssl = graphene.Field(lambda: SSL) def resolve_domain(self: Scans, info): return get_domain(self, info) @@ -33,11 +33,11 @@ def resolve_timestamp(self: Scans, info): def resolve_https(self: Scans, info): query = HTTPS.get_query(info) - return query.filter(self.id == Https_scans.id).all() + return query.filter(self.id == Https_scans.id).first() def resolve_ssl(self: Scans, info): query = SSL.get_query(info) - return query.filter(self.id == Ssl_scans.id).all() + return query.filter(self.id == Ssl_scans.id).first() class WWWScanConnection(relay.Connection): diff --git a/api/schemas/domain/www_scan/https/__init__.py b/api/schemas/domain/www_scan/https/__init__.py index 132a35408b..8ddd3d2c24 100644 --- a/api/schemas/domain/www_scan/https/__init__.py +++ b/api/schemas/domain/www_scan/https/__init__.py @@ -24,7 +24,7 @@ class Meta: hsts = graphene.String() hsts_age = graphene.String() preloaded = graphene.String() - https_guidance_tags = graphene.List(lambda: HTTPSTags) + https_guidance_tags = graphene.Field(lambda: HTTPSTags) def resole_domain(self: Https_scans, info): return get_domain(self, info) @@ -48,4 +48,4 @@ def resolve_preloaded(self: Https_scans, info): return self.https_scan["https"]["preloaded"] def resolve_https_guidance_tags(self: Https_scans, info): - return HTTPS.get_query(info).all() + return HTTPS.get_query(info).first() diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index ccc0622c88..979e5337f7 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -21,7 +21,8 @@ def resolve_value(self: Https_scans, info): tags = [] if self.https_scan.get("https", {}).get("missing", None) is not None: - return tags.append({"https2": "missing"}) + tags.append({"https2": "HTTPS-missing"}) + return tags # Implementation implementation = self.https_scan.get("https", {}) \ diff --git a/api/schemas/domain/www_scan/ssl/__init__.py b/api/schemas/domain/www_scan/ssl/__init__.py index 9a7fc05039..4493cf5184 100644 --- a/api/schemas/domain/www_scan/ssl/__init__.py +++ b/api/schemas/domain/www_scan/ssl/__init__.py @@ -19,7 +19,7 @@ class Meta: id = graphene.ID() domain = URL() timestamp = graphene.DateTime() - ssl_guidance_tags = graphene.List(lambda: SSLTags) + ssl_guidance_tags = graphene.Field(lambda: SSLTags) def resolve_domain(self, info): return get_domain(self, info) @@ -28,4 +28,4 @@ def resolve_timestamp(self, info): return get_timestamp(self, info) def resolve_ssl_guidance_tags(self: Ssl_scans, info): - return SSLTags.get_query(info).all() + return SSLTags.get_query(info).first() From 07e630cbd8d25dae055df21f5994edc5abddbc6d Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 07:56:35 -0300 Subject: [PATCH 24/39] HTTPS guidance tags fixed, and tested --- .../domain/www_scan/https/https_tags.py | 11 +- api/tests/test_https_guidance_tags.py | 977 ++++++++++++++++++ .../domain_guidance_tags/https_mock_data.py | 74 +- 3 files changed, 984 insertions(+), 78 deletions(-) create mode 100644 api/tests/test_https_guidance_tags.py diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index 979e5337f7..9c1e9755a7 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -60,22 +60,23 @@ def resolve_value(self: Https_scans, info): hsts = hsts.lower() if hsts == "hsts max age too short": - tags.append() + tags.append({"https:10": "HSTS-short-age"}) elif hsts == "no hsts": tags.append({"https9": "HSTS-missing"}) # HSTS Age hsts_age = self.https_scan.get("https", {}) \ - .get("hsts_age") + .get("hsts_age", None) - if hsts_age < 31536000: - tags.append({"https10": "HSTS-short-age"}) + if hsts_age is not None: + if hsts_age < 31536000: + tags.append({"https10": "HSTS-short-age"}) # Preload Status preload_status = self.https_scan.get("https", {}) \ .get("preload_status", None) - if preload_status(preload_status, str): + if isinstance(preload_status, str): preload_status = preload_status.lower() if preload_status == "hsts preload ready": diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py new file mode 100644 index 0000000000..e345bc02d1 --- /dev/null +++ b/api/tests/test_https_guidance_tags.py @@ -0,0 +1,977 @@ +import pytest +from datetime import datetime +from pytest import fail + +from db import DB +from models import Users, Organizations, Domains, Scans, Https_scans, User_affiliations +from tests.testdata.domain_guidance_tags import https_mock_data +from tests.test_functions import json, run + + +@pytest.fixture +def save(): + save, cleanup, session = DB() + yield save + cleanup() + + +def test_dkim_guidance_tags_https_2(save): + """ + Test that https guidance tag https 2 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https2") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https2': 'HTTPS-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_3(save): + """ + Test that https guidance tag https 3 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https3") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https3': 'HTTPS-downgraded'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_4(save): + """ + Test that https guidance tag https 4 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https4") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https4': 'HTTPS-bad-chain'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_5(save): + """ + Test that https guidance tag https 5 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https5") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https5': 'HTTPS-bad-hostname'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_6(save): + """ + Test that https guidance tag https 6 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https6") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https6': 'HTTPS-not-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_7(save): + """ + Test that https guidance tag https 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https7") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https7': 'HTTPS-weakly-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_8(save): + """ + Test that https guidance tag https 8 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https8") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https8': 'HTTPS-moderately-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_9(save): + """ + Test that https guidance tag https 9 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https9") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https9': 'HSTS-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_10(save): + """ + Test that https guidance tag https 10 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https10") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https:10': 'HSTS-short-age'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_11(save): + """ + Test that https guidance tag https 11 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https11") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https11': 'HSTS-preload-ready'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_12(save): + """ + Test that https guidance tag https 12 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https12") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https12': 'HSTS-not-preloaded'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_13(save): + """ + Test that https guidance tag https 13 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https13") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https13': 'HTTPS-certificate-expired'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + + +def test_dkim_guidance_tags_https_14(save): + """ + Test that https guidance tag https 14 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Https_scans( + id=test_scan.id, + https_scan=https_mock_data.get("https_mock_data_https14") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + https { + httpsGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected signin for a normal user to succeed. Instead:" + "{}".format(json(result)) + ) + + assert "{'https14': 'HTTPS-certificate-self-signed'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] diff --git a/api/tests/testdata/domain_guidance_tags/https_mock_data.py b/api/tests/testdata/domain_guidance_tags/https_mock_data.py index 92c448b7fa..e468c5509a 100644 --- a/api/tests/testdata/domain_guidance_tags/https_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/https_mock_data.py @@ -6,133 +6,61 @@ }, "https_mock_data_https3": { "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, "implementation": "Downgrades HTTPS", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https4": { "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, "implementation": "Bad Chain", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https5": { "https": { - "hsts": "No HSTS", - "enforced": "Weak", - "hsts_age": None, - "expired_cert": False, "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https6": { "https": { - "hsts": "No HSTS", "enforced": "Not Enforced", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https7": { "https": { - "hsts": "No HSTS", - "enforced": "Not Enforced", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False + "enforced": "Weak", } }, "https_mock_data_https8": { "https": { - "hsts": "No HSTS", "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https9": { "https": { "hsts": "No HSTS", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https10": { "https": { "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https11": { "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", "preload_status": "HSTS Preload Ready", - "self_signed_cert": False } }, "https_mock_data_https12": { "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": False, - "implementation": "Bad Hostname", "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https13": { "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, "expired_cert": True, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", - "self_signed_cert": False } }, "https_mock_data_https14": { "https": { - "hsts": "HSTS Max Age Too Short", - "enforced": "Moderate", - "hsts_age": None, - "expired_cert": True, - "implementation": "Bad Hostname", - "preload_status": "HSTS Not Preloaded", "self_signed_cert": True } } From 2c91ed5c5955b57132a6226f88650057836ba3b9 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 08:10:28 -0300 Subject: [PATCH 25/39] Updated error out messages --- api/tests/test_dkim_guidance_tags.py | 20 +++++++-------- api/tests/test_dmarc_guidance_tags.py | 36 +++++++++++++-------------- api/tests/test_https_guidance_tags.py | 26 +++++++++---------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py index 7d6d3747d8..410c61cfb1 100644 --- a/api/tests/test_dkim_guidance_tags.py +++ b/api/tests/test_dkim_guidance_tags.py @@ -82,7 +82,7 @@ def test_dkim_guidance_tags_dkim_2(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -156,7 +156,7 @@ def test_dkim_guidance_tags_dkim_5(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -230,7 +230,7 @@ def test_dkim_guidance_tags_dkim_6(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -304,7 +304,7 @@ def test_dkim_guidance_tags_dkim_7(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -378,7 +378,7 @@ def test_dkim_guidance_tags_dkim_8(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -452,7 +452,7 @@ def test_dkim_guidance_tags_dkim_9(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -526,7 +526,7 @@ def test_dkim_guidance_tags_dkim_10(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -600,7 +600,7 @@ def test_dkim_guidance_tags_dkim_11(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -674,7 +674,7 @@ def test_dkim_guidance_tags_dkim_12(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -748,7 +748,7 @@ def test_dkim_guidance_tags_dkim_13(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dkim guidance tags to be returned. Instead:" "{}".format(json(result)) ) diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index df67270c18..2fb8b66d47 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -82,7 +82,7 @@ def test_dkim_guidance_tags_dmarc_2(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -156,7 +156,7 @@ def test_dkim_guidance_tags_dmarc_3(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -230,7 +230,7 @@ def test_dkim_guidance_tags_dmarc_4(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -304,7 +304,7 @@ def test_dkim_guidance_tags_dmarc_5(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -378,7 +378,7 @@ def test_dkim_guidance_tags_dmarc_6(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -452,7 +452,7 @@ def test_dkim_guidance_tags_dmarc_7(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -526,7 +526,7 @@ def test_dkim_guidance_tags_dmarc_8(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -600,7 +600,7 @@ def test_dkim_guidance_tags_dmarc_9(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -674,7 +674,7 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -749,7 +749,7 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -824,7 +824,7 @@ def test_dkim_guidance_tags_dmarc_14(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -898,7 +898,7 @@ def test_dkim_guidance_tags_dmarc_15(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -972,7 +972,7 @@ def test_dkim_guidance_tags_dmarc_16(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -1046,7 +1046,7 @@ def test_dkim_guidance_tags_dmarc_17(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -1120,7 +1120,7 @@ def test_dkim_guidance_tags_dmarc_18(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -1194,7 +1194,7 @@ def test_dkim_guidance_tags_dmarc_19(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -1268,7 +1268,7 @@ def test_dkim_guidance_tags_dmarc_20(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -1342,7 +1342,7 @@ def test_dkim_guidance_tags_dmarc_21(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected dmarc guidance tags to be returned. Instead:" "{}".format(json(result)) ) diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index e345bc02d1..765286ab15 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -82,7 +82,7 @@ def test_dkim_guidance_tags_https_2(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -156,7 +156,7 @@ def test_dkim_guidance_tags_https_3(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -230,7 +230,7 @@ def test_dkim_guidance_tags_https_4(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -304,7 +304,7 @@ def test_dkim_guidance_tags_https_5(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -378,7 +378,7 @@ def test_dkim_guidance_tags_https_6(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -452,7 +452,7 @@ def test_dkim_guidance_tags_https_7(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -526,7 +526,7 @@ def test_dkim_guidance_tags_https_8(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -600,7 +600,7 @@ def test_dkim_guidance_tags_https_9(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -674,7 +674,7 @@ def test_dkim_guidance_tags_https_10(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -748,7 +748,7 @@ def test_dkim_guidance_tags_https_11(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -822,7 +822,7 @@ def test_dkim_guidance_tags_https_12(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -896,7 +896,7 @@ def test_dkim_guidance_tags_https_13(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) @@ -970,7 +970,7 @@ def test_dkim_guidance_tags_https_14(save): if "errors" in result: fail( - "expected signin for a normal user to succeed. Instead:" + "expected https guidance tags to be returned. Instead:" "{}".format(json(result)) ) From c1ae5d4de0f0e65843177e3d4af8e2100bcbc01f Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 08:11:20 -0300 Subject: [PATCH 26/39] Removed unused import --- api/tests/test_dkim_guidance_tags.py | 1 - api/tests/test_dmarc_guidance_tags.py | 1 - api/tests/test_https_guidance_tags.py | 1 - 3 files changed, 3 deletions(-) diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py index 410c61cfb1..ec24c7dc9f 100644 --- a/api/tests/test_dkim_guidance_tags.py +++ b/api/tests/test_dkim_guidance_tags.py @@ -1,5 +1,4 @@ import pytest -from datetime import datetime from pytest import fail from db import DB diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index 2fb8b66d47..aeac8a0421 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -1,5 +1,4 @@ import pytest -from datetime import datetime from pytest import fail from db import DB diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index 765286ab15..f6645e1110 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -1,5 +1,4 @@ import pytest -from datetime import datetime from pytest import fail from db import DB From 722787d06e156b911c7bad2ffbd80a4847a40be8 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 09:28:25 -0300 Subject: [PATCH 27/39] Updated spf tags, and completed testing --- api/schemas/domain/email_scan/spf/spf_tags.py | 48 +- api/tests/test_spf_guidance_tags.py | 903 ++++++++++++++++ .../domain_guidance_tags/spf_mock_data.py | 988 +----------------- 3 files changed, 962 insertions(+), 977 deletions(-) create mode 100644 api/tests/test_spf_guidance_tags.py diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index 8860924ff6..96f447273c 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -24,7 +24,8 @@ def resolve_value(self: Spf_scans, info): tags = [] if self.spf_scan.get("spf", {}).get("missing", None) is not None: - return tags.append({"spf2": "SPF-missing"}) + tags.append({"spf2": "SPF-missing"}) + return tags # Check all tag all_tag = self.spf_scan.get("spf", {}) \ @@ -36,7 +37,7 @@ def resolve_value(self: Spf_scans, info): if isinstance(all_tag, str): all_tag = all_tag.lower() - if record_all_tag == "": + if record_all_tag != "-all" and record_all_tag != "~all": tags.append({"spf10": "ALL-invalid"}) elif all_tag == "missing": tags.append({"spf4": "ALL-missing"}) @@ -51,25 +52,36 @@ def resolve_value(self: Spf_scans, info): tags.append({"spf8": "ALL-hardfail"}) elif record_all_tag == "~all": tags.append({"spf7": "ALL-softfail"}) - else: - record = self.spf_scan.get("spf", {}) \ - .get("record", None) - if record is not None: - search_string = "a:" - matches = re.finditer(search_string, record) - - for match in matches: - if record[match:1] == "": - tags.append({"spf11": "A-all"}) - - # All tag check - record_all_tag = self.spf_scan.get("spf", {}) \ - .get("record", "")[-4:].lower() - if record_all_tag == "-all": - tags.append({"spf10": "A-all"}) + # Check for no host + record = self.spf_scan.get("spf", {}) \ + .get("record", None) + if record is not None: + search_string = "a:" + matches = re.finditer(search_string, record) + match_pos = [match.start() for match in matches] + + for pos in match_pos: + if record[pos+1:1] == "" and not {"spf11": "A-all"} in tags: + tags.append({"spf11": "A-all"}) + + # Look up limit check dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) if dns_lookups > 10: tags.append({"spf12": "INCLUDE-limit"}) + # Check for missing include + include = self.spf_scan.get("spf", {}) \ + .get("parsed", {}) \ + .get("include", None) + record = self.spf_scan.get("spf", {}) \ + .get("record", None) + + if include is not None and record is not None: + for item in include: + check_item = item.get("domain", None) + if check_item is not None and f"include:{check_item}" not in record: + if not {"spf13": "INCLUDE-missing"} in tags: + tags.append({"spf13": "INCLUDE-missing"}) + return tags diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py new file mode 100644 index 0000000000..cff5b682f0 --- /dev/null +++ b/api/tests/test_spf_guidance_tags.py @@ -0,0 +1,903 @@ +import pytest +from pytest import fail + +from db import DB +from models import Users, Organizations, Domains, Scans, Spf_scans, User_affiliations +from tests.testdata.domain_guidance_tags import spf_mock_data +from tests.test_functions import json, run + + +@pytest.fixture +def save(): + save, cleanup, session = DB() + yield save + cleanup() + + +def test_spf_guidance_tags_spf_2(save): + """ + Test that spf guidance tag spf 2 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf2") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf2': 'SPF-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +@pytest.mark.skip +def test_spf_guidance_tags_spf_3(save): + """ + Test that spf guidance tag spf 3 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf3") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf3': 'SPF-bad-path'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_4(save): + """ + Test that spf guidance tag spf 4 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf4") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf4': 'ALL-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_5(save): + """ + Test that spf guidance tag spf 5 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf5") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf5': 'ALL-allow'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_6(save): + """ + Test that spf guidance tag spf 6 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf6") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf6': 'ALL-neutral'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_7(save): + """ + Test that spf guidance tag spf 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf7") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf7': 'ALL-softfail'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_8(save): + """ + Test that spf guidance tag spf 8 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf8") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf8': 'ALL-hardfail'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_9(save): + """ + Test that spf guidance tag spf 9 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf9") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf9': 'ALL-redirect'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_10(save): + """ + Test that spf guidance tag spf 10 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf10") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf10': 'ALL-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_11(save): + """ + Test that spf guidance tag spf 11 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf11") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf11': 'A-all'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_12(save): + """ + Test that spf guidance tag spf 12 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf12") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf12': 'INCLUDE-limit'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_13(save): + """ + Test that spf guidance tag spf 13 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf13") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf13': 'INCLUDE-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] diff --git a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py index 9e9a9bf355..2270f23a96 100644 --- a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py @@ -134,126 +134,7 @@ "spf_mock_data_spf4": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, "all": "missing" } } @@ -261,126 +142,7 @@ "spf_mock_data_spf5": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, "all": "Allow" } } @@ -388,126 +150,7 @@ "spf_mock_data_spf6": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, "all": "Neutral" } } @@ -515,507 +158,34 @@ "spf_mock_data_spf7": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com ~all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - } - } - }, - "spf_mock_data_spf8": { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, "all": "fail" } - } - }, - "spf_mock_data_spf9": { - "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], - "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, + } + }, + "spf_mock_data_spf8": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "parsed": { + "all": "fail" + } + } + }, + "spf_mock_data_spf9": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "parsed": { "all": "redirect" } } }, "spf_mock_data_spf10": { "spf": { - "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com", "valid": True, "dns_lookups": 5, "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, "all": "redirect" } } @@ -1023,127 +193,27 @@ "spf_mock_data_spf11": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, + "parsed": { + "redirect": None, + "exp": None, + "all": "redirect" + } + } + }, + "spf_mock_data_spf12": { + "spf": { "dns_lookups": 15, - "warnings": [], + } + }, + "spf_mock_data_spf13": { + "spf": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca -all", "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], "include": [ { "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] } ], - "redirect": None, - "exp": None, - "all": "redirect" } } } From 508dfe06a23b43bb81572df97fceb73855bba2a3 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 10:02:47 -0300 Subject: [PATCH 28/39] Updated ssl tags, and completed tests for ssl --- api/schemas/domain/www_scan/ssl/ssl_tags.py | 27 +- api/tests/test_dmarc_guidance_tags.py | 4 +- api/tests/test_https_guidance_tags.py | 4 +- api/tests/test_spf_guidance_tags.py | 4 +- api/tests/test_ssl_guidance_tags.py | 532 ++++++++++++++++++ .../domain_guidance_tags/ssl_mock_data.py | 157 +----- 6 files changed, 553 insertions(+), 175 deletions(-) create mode 100644 api/tests/test_ssl_guidance_tags.py diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl/ssl_tags.py index 40efa1757a..b6d0478f51 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl/ssl_tags.py @@ -21,19 +21,20 @@ def resolve_value(self: Ssl_scans, info): tags = [] if self.ssl_scan.get("ssl", {}).get("missing", None) is not None: - return tags.append({"ssl2": "missing"}) + tags.append({"ssl2": "SSL-missing"}) + return tags # SSL-rc4 - ssl_rc4 = self.get('ssl', {}) \ + ssl_rc4 = self.ssl_scan.get('ssl', {}) \ .get("rc4", None) - if ssl_rc4: - tags.append({"ssl4": "SSL-rc4"}) + if ssl_rc4 is True: + tags.append({"ssl3": "SSL-rc4"}) # SSL-3des - ssl_3des = self.get('ssl', {}) \ + ssl_3des = self.ssl_scan.get('ssl', {}) \ .get("3des", None) - if ssl_3des: - tags.append({"ssl5": "SSL-3des"}) + if ssl_3des is True: + tags.append({"ssl4": "SSL-3des"}) # Signature Algorithm signature_algorithm = self.ssl_scan.get("ssl", {}) \ @@ -45,22 +46,22 @@ def resolve_value(self: Ssl_scans, info): if signature_algorithm == "sha-256" \ or signature_algorithm == "sha-384" \ or signature_algorithm == "aead": - tags.append({"ssl7": "SSL-acceptable-certificate"}) + tags.append({"ssl5": "SSL-acceptable-certificate"}) else: - tags.append({"ssl8": "SSL-invalid-cipher"}) + tags.append({"ssl6": "SSL-invalid-cipher"}) # Heartbleed heart_bleed = self.ssl_scan.get("ssl", {}) \ .get("heartbleed", None) - if heart_bleed: - tags.append({"ssl9": "Vulnerability-heartbleed"}) + if heart_bleed is True: + tags.append({"ssl7": "Vulnerability-heartbleed"}) # openssl ccs injection openssl_ccs_injection = self.ssl_scan.get("ssl", {}) \ .get("openssl_ccs_injection", None) - if openssl_ccs_injection: - tags.append({"ssl10": "Vulnerability-ccs-injection"}) + if openssl_ccs_injection is True: + tags.append({"ssl8": "Vulnerability-ccs-injection"}) return tags diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index aeac8a0421..9fb105c35c 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -37,11 +37,11 @@ def test_dkim_guidance_tags_dmarc_2(save): ) save(test_scan) - test_dkim_scan = Dmarc_scans( + test_dmarc_scan = Dmarc_scans( id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc2") ) - save(test_dkim_scan) + save(test_dmarc_scan) user = Users( display_name="testuser", diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index f6645e1110..a185364675 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -37,11 +37,11 @@ def test_dkim_guidance_tags_https_2(save): ) save(test_scan) - test_dkim_scan = Https_scans( + test_https_scan = Https_scans( id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https2") ) - save(test_dkim_scan) + save(test_https_scan) user = Users( display_name="testuser", diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py index cff5b682f0..7801e633a5 100644 --- a/api/tests/test_spf_guidance_tags.py +++ b/api/tests/test_spf_guidance_tags.py @@ -37,11 +37,11 @@ def test_spf_guidance_tags_spf_2(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf2") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", diff --git a/api/tests/test_ssl_guidance_tags.py b/api/tests/test_ssl_guidance_tags.py new file mode 100644 index 0000000000..5b6590bddb --- /dev/null +++ b/api/tests/test_ssl_guidance_tags.py @@ -0,0 +1,532 @@ +import pytest +from pytest import fail + +from db import DB +from models import Users, Organizations, Domains, Scans, Ssl_scans, User_affiliations +from tests.testdata.domain_guidance_tags import ssl_mock_data +from tests.test_functions import json, run + + +@pytest.fixture +def save(): + save, cleanup, session = DB() + yield save + cleanup() + + +def test_spf_guidance_tags_spf_2(save): + """ + Test that ssl guidance tag ssl 2 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl2") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl2': 'SSL-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_3(save): + """ + Test that ssl guidance tag ssl 3 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl3") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl3': 'SSL-rc4'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_4(save): + """ + Test that ssl guidance tag ssl 4 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl4") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl4': 'SSL-3des'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_5(save): + """ + Test that ssl guidance tag ssl 5 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl5") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl5': 'SSL-acceptable-certificate'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_6(save): + """ + Test that ssl guidance tag ssl 6 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl6") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl6': 'SSL-invalid-cipher'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_7(save): + """ + Test that ssl guidance tag ssl 7 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl7") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl7': 'Vulnerability-heartbleed'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + + +def test_spf_guidance_tags_spf_8(save): + """ + Test that ssl guidance tag ssl 8 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_dkim_scan = Ssl_scans( + id=test_scan.id, + ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl8") + ) + save(test_dkim_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + www { + edges { + node { + ssl { + sslGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected ssl guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'ssl8': 'Vulnerability-ccs-injection'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] diff --git a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py index 0663ccceda..0f0900c022 100644 --- a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py @@ -7,187 +7,32 @@ "ssl_mock_data_ssl3": { "ssl": { "rc4": True, - "3des": True, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, - "acceptable_certificate": True } }, "ssl_mock_data_ssl4": { "ssl": { - "rc4": False, "3des": True, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, - "acceptable_certificate": True } }, "ssl_mock_data_ssl5": { "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "SHA256", - "openssl_ccs_injection": False, + "signature_algorithm": "SHA-256", "acceptable_certificate": True } }, "ssl_mock_data_ssl6": { "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], "signature_algorithm": "RSA", - "openssl_ccs_injection": False, - "acceptable_certificate": True } }, "ssl_mock_data_ssl7": { "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, "heartbleed": True, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "RSA", - "openssl_ccs_injection": False, - "acceptable_certificate": True } }, "ssl_mock_data_ssl8": { "ssl": { - "rc4": False, - "3des": False, - "SSL_2_0": False, - "SSL_3_0": False, - "TLS_1_0": False, - "TLS_1_1": True, - "TLS_1_2": True, - "TLS_1_3": False, - "heartbleed": False, - "weak_ciphers": [ - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA" - ], - "strong_ciphers": [], - "preferred_cipher": None, - "acceptable_ciphers": [ - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" - ], - "signature_algorithm": "RSA", "openssl_ccs_injection": True, - "acceptable_certificate": True } } } From 9da5d0fbfad895ded03d6842cbd96802df4ad53b Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 10:41:25 -0300 Subject: [PATCH 29/39] spf3 guidance tag implemented --- api/schemas/domain/email_scan/spf/spf_tags.py | 25 +++- api/tests/test_spf_guidance_tags.py | 135 +++++++++++++---- .../domain_guidance_tags/spf_mock_data.py | 138 ++---------------- 3 files changed, 150 insertions(+), 148 deletions(-) diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index 96f447273c..104d523ac6 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -3,7 +3,8 @@ from graphene_sqlalchemy import SQLAlchemyObjectType -from models import Spf_scans +from db import db_session +from models import Spf_scans, Dmarc_scans, Dkim_scans class SPFTags(SQLAlchemyObjectType): @@ -27,6 +28,28 @@ def resolve_value(self: Spf_scans, info): tags.append({"spf2": "SPF-missing"}) return tags + # Check for bad path + dkim_orm : Dkim_scans = db_session.query(Dkim_scans).filter( + Dkim_scans.id == self.id + ).first() + dmarc_orm : Dmarc_scans = db_session.query(Dmarc_scans).filter( + Dmarc_scans.id == self.id + ).first() + + if dkim_orm is not None: + dkim_record = dkim_orm.dkim_scan.get("dkim", {}) \ + .get("txt_record", None) + for key in dkim_record: + if key == "a" or key == "include": + tags.append({"spf3": "SPF-bad-path"}) + + if dmarc_orm is not None: + dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}) \ + .get("record", None) + if ("include:" in dmarc_record) or ("a:" in dmarc_record) or ("all" in dmarc_record): + if not {"spf3": "SPF-bad-path"} in tags: + tags.append({"spf3": "SPF-bad-path"}) + # Check all tag all_tag = self.spf_scan.get("spf", {}) \ .get("parsed", {}) \ diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py index 7801e633a5..9e5122c3cf 100644 --- a/api/tests/test_spf_guidance_tags.py +++ b/api/tests/test_spf_guidance_tags.py @@ -2,7 +2,7 @@ from pytest import fail from db import DB -from models import Users, Organizations, Domains, Scans, Spf_scans, User_affiliations +from models import Users, Organizations, Domains, Scans, Dkim_scans, Dmarc_scans, Spf_scans, User_affiliations from tests.testdata.domain_guidance_tags import spf_mock_data from tests.test_functions import json, run @@ -88,8 +88,7 @@ def test_spf_guidance_tags_spf_2(save): assert "{'spf2': 'SPF-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] -@pytest.mark.skip -def test_spf_guidance_tags_spf_3(save): +def test_spf_guidance_tags_spf_3_dkim(save): """ Test that spf guidance tag spf 3 shows up """ @@ -112,9 +111,15 @@ def test_spf_guidance_tags_spf_3(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf3") + spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf") + ) + save(test_spf_scan) + + test_dkim_scan = Dkim_scans( + id=test_scan.id, + dkim_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_dkim") ) save(test_dkim_scan) @@ -163,6 +168,86 @@ def test_spf_guidance_tags_spf_3(save): assert "{'spf3': 'SPF-bad-path'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] +def test_spf_guidance_tags_spf_3_dmarc(save): + """ + Test that spf guidance tag spf 3 shows up + """ + org_one = Organizations( + acronym="ORG1", + name="Organization 1", + slug="organization-1", + ) + save(org_one) + + test_domain = Domains( + organization=org_one, + domain="test.domain.ca", + slug="test-domain-ca" + ) + save(test_domain) + + test_scan = Scans( + domain=test_domain + ) + save(test_scan) + + test_spf_scan = Spf_scans( + id=test_scan.id, + spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf") + ) + save(test_spf_scan) + + test_dmarc_scan = Dmarc_scans( + id=test_scan.id, + dmarc_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_dmarc") + ) + save(test_dmarc_scan) + + user = Users( + display_name="testuser", + user_name="testuser@testemail.ca", + password="testpassword123", + user_affiliation=[ + User_affiliations( + permission="user_read", + user_organization=org_one + ), + ], + ) + save(user) + + result = run( + mutation=""" + { + domain( + urlSlug: "test-domain-ca" + ) { + email { + edges { + node { + spf { + spfGuidanceTags { + value + } + } + } + } + } + } + } + """, + as_user=user + ) + + if "errors" in result: + fail( + "expected spf guidance tags to be returned. Instead:" + "{}".format(json(result)) + ) + + assert "{'spf3': 'SPF-bad-path'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + + def test_spf_guidance_tags_spf_4(save): """ Test that spf guidance tag spf 4 shows up @@ -186,11 +271,11 @@ def test_spf_guidance_tags_spf_4(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf4") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -260,11 +345,11 @@ def test_spf_guidance_tags_spf_5(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf5") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -334,11 +419,11 @@ def test_spf_guidance_tags_spf_6(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf6") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -408,11 +493,11 @@ def test_spf_guidance_tags_spf_7(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf7") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -482,11 +567,11 @@ def test_spf_guidance_tags_spf_8(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf8") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -556,11 +641,11 @@ def test_spf_guidance_tags_spf_9(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf9") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -630,11 +715,11 @@ def test_spf_guidance_tags_spf_10(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf10") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -704,11 +789,11 @@ def test_spf_guidance_tags_spf_11(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf11") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -778,11 +863,11 @@ def test_spf_guidance_tags_spf_12(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf12") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", @@ -852,11 +937,11 @@ def test_spf_guidance_tags_spf_13(save): ) save(test_scan) - test_dkim_scan = Spf_scans( + test_spf_scan = Spf_scans( id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf13") ) - save(test_dkim_scan) + save(test_spf_scan) user = Users( display_name="testuser", diff --git a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py index 2270f23a96..d5fcd34a1b 100644 --- a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py @@ -5,131 +5,25 @@ } }, "spf_mock_data_spf3": { - "spf": { + "spf_mock_data_spf3_spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "valid": True, - "dns_lookups": 5, - "warnings": [], "parsed": { - "pass": [ - { - "value": "205.193.218.38", - "mechanism": "a" - }, - { - "value": "205.193.218.37", - "mechanism": "a" - }, - { - "value": "205.193.218.114", - "mechanism": "a" - }, - { - "value": "205.193.218.115", - "mechanism": "a" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spf.protection.outlook.com", - "record": "v=spf1 ip4:40.92.0.0/15 ip4:40.107.0.0/16 ip4:52.100.0.0/14 ip4:104.47.0.0/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 include:spfd.protection.outlook.com -all", - "dns_lookups": 1, - "parsed": { - "pass": [ - { - "value": "40.92.0.0/15", - "mechanism": "ip4" - }, - { - "value": "40.107.0.0/16", - "mechanism": "ip4" - }, - { - "value": "52.100.0.0/14", - "mechanism": "ip4" - }, - { - "value": "104.47.0.0/17", - "mechanism": "ip4" - }, - { - "value": "2a01:111:f400::/48", - "mechanism": "ip6" - }, - { - "value": "2a01:111:f403::/48", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [ - { - "domain": "spfd.protection.outlook.com", - "record": "v=spf1 ip4:51.4.72.0/24 ip4:51.5.72.0/24 ip4:51.5.80.0/27 ip4:51.4.80.0/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all", - "dns_lookups": 0, - "parsed": { - "pass": [ - { - "value": "51.4.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.72.0/24", - "mechanism": "ip4" - }, - { - "value": "51.5.80.0/27", - "mechanism": "ip4" - }, - { - "value": "51.4.80.0/27", - "mechanism": "ip4" - }, - { - "value": "2a01:4180:4051:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0800::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4051:0400::/64", - "mechanism": "ip6" - }, - { - "value": "2a01:4180:4050:0400::/64", - "mechanism": "ip6" - } - ], - "neutral": [], - "softfail": [], - "fail": [], - "include": [], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" - }, - "warnings": [] - } - ], - "redirect": None, - "exp": None, - "all": "fail" + "all": "missing" } - } + }, + "spf_mock_data_spf3_dkim": { + "dkim": { + "txt_record": { + "a": "some.domain.ca", + "include": "some.other.domain" + }, + } + }, + "spf_mock_data_spf3_dmarc": { + "dmarc": { + "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", + } + }, }, "spf_mock_data_spf4": { "spf": { From 3522676a67ad84fe786701715faeca1462c2263f Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 10:56:12 -0300 Subject: [PATCH 30/39] Black ran on files --- .../domain/email_scan/dkim/dkim_tags.py | 35 +- .../domain/email_scan/dmarc/__init__.py | 24 +- .../domain/email_scan/dmarc/dmarc_tags.py | 51 +- api/schemas/domain/email_scan/spf/spf_tags.py | 38 +- .../domain/www_scan/https/https_tags.py | 29 +- api/schemas/domain/www_scan/ssl/__init__.py | 1 + api/schemas/domain/www_scan/ssl/ssl_tags.py | 33 +- api/tests/test_dkim_guidance_tags.py | 290 ++++------ api/tests/test_dmarc_guidance_tags.py | 534 ++++++++---------- api/tests/test_https_guidance_tags.py | 377 +++++-------- api/tests/test_spf_guidance_tags.py | 394 ++++++------- api/tests/test_ssl_guidance_tags.py | 203 +++---- .../domain_guidance_tags/dkim_mock_data.py | 69 +-- .../domain_guidance_tags/dmarc_mock_data.py | 151 +---- .../domain_guidance_tags/https_mock_data.py | 78 +-- .../domain_guidance_tags/spf_mock_data.py | 65 +-- .../domain_guidance_tags/ssl_mock_data.py | 41 +- 17 files changed, 926 insertions(+), 1487 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py index 85e62d71d0..b67db58419 100644 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ b/api/schemas/domain/email_scan/dkim/dkim_tags.py @@ -10,8 +10,7 @@ class Meta: exclude_fields = ("id", "dkim_scan") value = graphene.List( - lambda: graphene.String, - description="Key tags found during scan", + lambda: graphene.String, description="Key tags found during scan", ) def resolve_value(self: Dkim_scans, info): @@ -22,10 +21,8 @@ def resolve_value(self: Dkim_scans, info): return tags # Get Key Size, and Key Type - key_size = self.dkim_scan.get("dkim", {}) \ - .get("key_size", None) - key_type = self.dkim_scan.get("dkim", {}) \ - .get("key_type", None) + key_size = self.dkim_scan.get("dkim", {}).get("key_size", None) + key_type = self.dkim_scan.get("dkim", {}).get("key_type", None) if key_size is None: tags.append({"dkim9": "P-invalid"}) @@ -44,38 +41,30 @@ def resolve_value(self: Dkim_scans, info): tags.append({"dkim9": "P-invalid"}) # Update Recommended - key_invalid = self.dkim_scan.get("dkim", {}) \ - .get("update-recommend", None) + key_invalid = self.dkim_scan.get("dkim", {}).get("update-recommend", None) if key_invalid: tags.append({"dkim10": "P-update-recommended"}) # Invalid Crypto - invalid_crypto = self.dkim_scan.get("dkim", {}) \ - .get("txt_record", {}) \ - .get("k", None) + invalid_crypto = ( + self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) + ) # if k != rsa - if invalid_crypto != 'rsa': + if invalid_crypto != "rsa": tags.append({"dkim11": "DKIM-invalid-crypto"}) # Dkim value invalid # Check if v, k, and p exist in txt_record - v_tag = self.dkim_scan.get("dkim", {}) \ - .get("txt_record", {}) \ - .get("v", None) - k_tag = self.dkim_scan.get("dkim", {}) \ - .get("txt_record", {}) \ - .get("k", None) - p_tag = self.dkim_scan.get("dkim", {}) \ - .get("txt_record", {}) \ - .get("p", None) + v_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("v", None) + k_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) + p_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("p", None) if v_tag is None and k_tag is None and p_tag is None: tags.append({"dkim12": "DKIM-value-invalid"}) # Testing Enabled - t_enabled = self.dkim_scan.get("dkim", {}) \ - .get("t_value") + t_enabled = self.dkim_scan.get("dkim", {}).get("t_value") if t_enabled is not None: tags.append({"dkim13": "T-enabled"}) diff --git a/api/schemas/domain/email_scan/dmarc/__init__.py b/api/schemas/domain/email_scan/dmarc/__init__.py index 8ac1c9d44b..2756e98915 100644 --- a/api/schemas/domain/email_scan/dmarc/__init__.py +++ b/api/schemas/domain/email_scan/dmarc/__init__.py @@ -60,22 +60,28 @@ def resolve_record(self: Dmarc_scans, info): return self.dmarc_scan.get("dmarc", {}).get("record", None) def resolve_p_policy(self: Dmarc_scans, info): - return self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("p", {}) \ + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("p", {}) .get("value", None) + ) def resolve_sp_policy(self: Dmarc_scans, info): - return self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("sp", {}) \ + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("sp", {}) .get("value", None) + ) def resolve_pct(self: Dmarc_scans, info): - return self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("pct", {}) \ + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("pct", {}) .get("value", None) + ) def resolve_dmarc_guidance_tags(self: Dmarc_scans, info): return DmarcTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py index 62e5add757..fbe59adbcb 100644 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py @@ -9,13 +9,13 @@ class DmarcTags(SQLAlchemyObjectType): """ Guidance tags for dmarc scan results """ + class Meta: model = Dmarc_scans exclude_fields = ("id", "dmarc_scan") value = graphene.List( - lambda: graphene.String, - description="Important tags retrieved during scan" + lambda: graphene.String, description="Important tags retrieved during scan" ) def resolve_value(self: Dmarc_scans, info): @@ -26,10 +26,12 @@ def resolve_value(self: Dmarc_scans, info): return tags # Check P Policy Tag - p_policy_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("p", {}) \ + p_policy_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("p", {}) .get("value", None) + ) if isinstance(p_policy_tag, str): p_policy_tag = p_policy_tag.lower() @@ -44,10 +46,12 @@ def resolve_value(self: Dmarc_scans, info): tags.append({"dmarc6": "P-reject"}) # Check PCT Tag - pct_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("pct", {}) \ + pct_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("pct", {}) .get("value", None) + ) if isinstance(pct_tag, str): pct_tag = pct_tag.lower() @@ -59,18 +63,18 @@ def resolve_value(self: Dmarc_scans, info): if pct_tag == 100: tags.append({"dmarc7": "PCT-100"}) elif 100 > pct_tag > 0: - pct_string = "PCT-" + str( - pct_tag - ) + pct_string = "PCT-" + str(pct_tag) tags.append({"dmarc8": pct_string}) else: tags.append({"dmarc21": "PCT-0"}) # Check RUA Tag - rua_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("rua", {}) \ + rua_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("rua", {}) .get("value", None) + ) if isinstance(rua_tag, str): rua_tag = rua_tag.lower() @@ -85,10 +89,12 @@ def resolve_value(self: Dmarc_scans, info): tags.append({"dmarc12": "RUA-none"}) # Check RUF Tag - ruf_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("ruf", {}) \ + ruf_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("ruf", {}) .get("value", None) + ) if ruf_tag is None or not ruf_tag: tags.append({"dmarc13": "RUF-none"}) @@ -100,18 +106,19 @@ def resolve_value(self: Dmarc_scans, info): tags.append({"dmarc13": "RUF-none"}) # TXT DMARC - record_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("record", None) + record_tag = self.dmarc_scan.get("dmarc", {}).get("record", None) if record_tag == "" or record_tag is None: tags.append({"dmarc15": "TXT-DMARC-missing"}) else: tags.append({"dmarc14": "TXT-DMARC-enabled"}) # Check SP tag - sp_tag = self.dmarc_scan.get("dmarc", {}) \ - .get("tags", {}) \ - .get("sp", {}) \ + sp_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("sp", {}) .get("value", None) + ) if isinstance(sp_tag, str): sp_tag = sp_tag.lower() diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py index 104d523ac6..1d2a05a70b 100644 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ b/api/schemas/domain/email_scan/spf/spf_tags.py @@ -17,8 +17,7 @@ class Meta: exclude_fields = ("id", "spf_scan") value = graphene.List( - lambda: graphene.String, - description="Important tags retrieved during scan" + lambda: graphene.String, description="Important tags retrieved during scan" ) def resolve_value(self: Spf_scans, info): @@ -29,33 +28,32 @@ def resolve_value(self: Spf_scans, info): return tags # Check for bad path - dkim_orm : Dkim_scans = db_session.query(Dkim_scans).filter( + dkim_orm: Dkim_scans = db_session.query(Dkim_scans).filter( Dkim_scans.id == self.id ).first() - dmarc_orm : Dmarc_scans = db_session.query(Dmarc_scans).filter( + dmarc_orm: Dmarc_scans = db_session.query(Dmarc_scans).filter( Dmarc_scans.id == self.id ).first() if dkim_orm is not None: - dkim_record = dkim_orm.dkim_scan.get("dkim", {}) \ - .get("txt_record", None) + dkim_record = dkim_orm.dkim_scan.get("dkim", {}).get("txt_record", None) for key in dkim_record: if key == "a" or key == "include": tags.append({"spf3": "SPF-bad-path"}) if dmarc_orm is not None: - dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}) \ - .get("record", None) - if ("include:" in dmarc_record) or ("a:" in dmarc_record) or ("all" in dmarc_record): + dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}).get("record", None) + if ( + ("include:" in dmarc_record) + or ("a:" in dmarc_record) + or ("all" in dmarc_record) + ): if not {"spf3": "SPF-bad-path"} in tags: tags.append({"spf3": "SPF-bad-path"}) # Check all tag - all_tag = self.spf_scan.get("spf", {}) \ - .get("parsed", {}) \ - .get("all", None) - record_all_tag = self.spf_scan.get("spf", {}) \ - .get("record", "")[-4:].lower() + all_tag = self.spf_scan.get("spf", {}).get("parsed", {}).get("all", None) + record_all_tag = self.spf_scan.get("spf", {}).get("record", "")[-4:].lower() if isinstance(all_tag, str): all_tag = all_tag.lower() @@ -77,15 +75,14 @@ def resolve_value(self: Spf_scans, info): tags.append({"spf7": "ALL-softfail"}) # Check for no host - record = self.spf_scan.get("spf", {}) \ - .get("record", None) + record = self.spf_scan.get("spf", {}).get("record", None) if record is not None: search_string = "a:" matches = re.finditer(search_string, record) match_pos = [match.start() for match in matches] for pos in match_pos: - if record[pos+1:1] == "" and not {"spf11": "A-all"} in tags: + if record[pos + 1 : 1] == "" and not {"spf11": "A-all"} in tags: tags.append({"spf11": "A-all"}) # Look up limit check @@ -94,11 +91,8 @@ def resolve_value(self: Spf_scans, info): tags.append({"spf12": "INCLUDE-limit"}) # Check for missing include - include = self.spf_scan.get("spf", {}) \ - .get("parsed", {}) \ - .get("include", None) - record = self.spf_scan.get("spf", {}) \ - .get("record", None) + include = self.spf_scan.get("spf", {}).get("parsed", {}).get("include", None) + record = self.spf_scan.get("spf", {}).get("record", None) if include is not None and record is not None: for item in include: diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py index 9c1e9755a7..d4859f9862 100644 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ b/api/schemas/domain/www_scan/https/https_tags.py @@ -8,14 +8,12 @@ class HTTPSTags(SQLAlchemyObjectType): """ Guidance tags for HTTPS scan results """ + class Meta: model = Https_scans exclude_fields = ("id", "https_scan") - value = graphene.List( - lambda: graphene.String, - description="" - ) + value = graphene.List(lambda: graphene.String, description="") def resolve_value(self: Https_scans, info): tags = [] @@ -25,8 +23,7 @@ def resolve_value(self: Https_scans, info): return tags # Implementation - implementation = self.https_scan.get("https", {}) \ - .get("implementation", None) + implementation = self.https_scan.get("https", {}).get("implementation", None) if isinstance(implementation, str): implementation = implementation.lower() @@ -39,8 +36,7 @@ def resolve_value(self: Https_scans, info): tags.append({"https5": "HTTPS-bad-hostname"}) # Enforced - enforced = self.https_scan.get("https", {}) \ - .get("enforced", None) + enforced = self.https_scan.get("https", {}).get("enforced", None) if isinstance(enforced, str): enforced = enforced.lower() @@ -53,8 +49,7 @@ def resolve_value(self: Https_scans, info): tags.append({"https6": "HTTPS-not-enforced"}) # HSTS - hsts = self.https_scan.get("https", {}) \ - .get("hsts", None) + hsts = self.https_scan.get("https", {}).get("hsts", None) if isinstance(hsts, str): hsts = hsts.lower() @@ -65,16 +60,14 @@ def resolve_value(self: Https_scans, info): tags.append({"https9": "HSTS-missing"}) # HSTS Age - hsts_age = self.https_scan.get("https", {}) \ - .get("hsts_age", None) + hsts_age = self.https_scan.get("https", {}).get("hsts_age", None) if hsts_age is not None: if hsts_age < 31536000: tags.append({"https10": "HSTS-short-age"}) # Preload Status - preload_status = self.https_scan.get("https", {}) \ - .get("preload_status", None) + preload_status = self.https_scan.get("https", {}).get("preload_status", None) if isinstance(preload_status, str): preload_status = preload_status.lower() @@ -85,15 +78,15 @@ def resolve_value(self: Https_scans, info): tags.append({"https12": "HSTS-not-preloaded"}) # Expired Cert - expired_cert = self.https_scan.get("https", {}) \ - .get("expired_cert", None) + expired_cert = self.https_scan.get("https", {}).get("expired_cert", None) if expired_cert: tags.append({"https13": "HTTPS-certificate-expired"}) # Self Signed Cert - self_signed_cert = self.https_scan.get("https", {}) \ - .get("self_signed_cert", None) + self_signed_cert = self.https_scan.get("https", {}).get( + "self_signed_cert", None + ) if self_signed_cert: tags.append({"https14": "HTTPS-certificate-self-signed"}) diff --git a/api/schemas/domain/www_scan/ssl/__init__.py b/api/schemas/domain/www_scan/ssl/__init__.py index 4493cf5184..8628581316 100644 --- a/api/schemas/domain/www_scan/ssl/__init__.py +++ b/api/schemas/domain/www_scan/ssl/__init__.py @@ -12,6 +12,7 @@ class SSL(SQLAlchemyObjectType): """ SSL Scan Object """ + class Meta: model = Ssl_scans exclude_fields = ("id", "ssl_scan") diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl/ssl_tags.py index b6d0478f51..5e2017844d 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl/ssl_tags.py @@ -8,14 +8,12 @@ class SSLTags(SQLAlchemyObjectType): """ Guidance tags for HTTPS scan results """ + class Meta: model = Ssl_scans exclude_fields = ("id", "ssl_scan") - value = graphene.List( - lambda: graphene.String, - description="" - ) + value = graphene.List(lambda: graphene.String, description="") def resolve_value(self: Ssl_scans, info): tags = [] @@ -25,41 +23,42 @@ def resolve_value(self: Ssl_scans, info): return tags # SSL-rc4 - ssl_rc4 = self.ssl_scan.get('ssl', {}) \ - .get("rc4", None) + ssl_rc4 = self.ssl_scan.get("ssl", {}).get("rc4", None) if ssl_rc4 is True: tags.append({"ssl3": "SSL-rc4"}) # SSL-3des - ssl_3des = self.ssl_scan.get('ssl', {}) \ - .get("3des", None) + ssl_3des = self.ssl_scan.get("ssl", {}).get("3des", None) if ssl_3des is True: tags.append({"ssl4": "SSL-3des"}) # Signature Algorithm - signature_algorithm = self.ssl_scan.get("ssl", {}) \ - .get("signature_algorithm", None) + signature_algorithm = self.ssl_scan.get("ssl", {}).get( + "signature_algorithm", None + ) if isinstance(signature_algorithm, str): signature_algorithm = signature_algorithm.lower() - if signature_algorithm == "sha-256" \ - or signature_algorithm == "sha-384" \ - or signature_algorithm == "aead": + if ( + signature_algorithm == "sha-256" + or signature_algorithm == "sha-384" + or signature_algorithm == "aead" + ): tags.append({"ssl5": "SSL-acceptable-certificate"}) else: tags.append({"ssl6": "SSL-invalid-cipher"}) # Heartbleed - heart_bleed = self.ssl_scan.get("ssl", {}) \ - .get("heartbleed", None) + heart_bleed = self.ssl_scan.get("ssl", {}).get("heartbleed", None) if heart_bleed is True: tags.append({"ssl7": "Vulnerability-heartbleed"}) # openssl ccs injection - openssl_ccs_injection = self.ssl_scan.get("ssl", {}) \ - .get("openssl_ccs_injection", None) + openssl_ccs_injection = self.ssl_scan.get("ssl", {}).get( + "openssl_ccs_injection", None + ) if openssl_ccs_injection is True: tags.append({"ssl8": "Vulnerability-ccs-injection"}) diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py index ec24c7dc9f..211c073a8c 100644 --- a/api/tests/test_dkim_guidance_tags.py +++ b/api/tests/test_dkim_guidance_tags.py @@ -19,27 +19,20 @@ def test_dkim_guidance_tags_dkim_2(save): Test that dkim guidance tag dkim 2 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim2") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim2") ) save(test_dkim_scan) @@ -48,10 +41,7 @@ def test_dkim_guidance_tags_dkim_2(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -76,7 +66,7 @@ def test_dkim_guidance_tags_dkim_2(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -85,7 +75,12 @@ def test_dkim_guidance_tags_dkim_2(save): "{}".format(json(result)) ) - assert "{'dkim2': 'DKIM-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim2': 'DKIM-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_5(save): @@ -93,27 +88,20 @@ def test_dkim_guidance_tags_dkim_5(save): Test that dkim guidance tag dkim 5 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim5") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim5") ) save(test_dkim_scan) @@ -122,10 +110,7 @@ def test_dkim_guidance_tags_dkim_5(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -150,7 +135,7 @@ def test_dkim_guidance_tags_dkim_5(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -159,7 +144,12 @@ def test_dkim_guidance_tags_dkim_5(save): "{}".format(json(result)) ) - assert "{'dkim5': 'P-sub1024'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim5': 'P-sub1024'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_6(save): @@ -167,27 +157,20 @@ def test_dkim_guidance_tags_dkim_6(save): Test that dkim guidance tag dkim 6 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim6") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim6") ) save(test_dkim_scan) @@ -196,10 +179,7 @@ def test_dkim_guidance_tags_dkim_6(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -224,7 +204,7 @@ def test_dkim_guidance_tags_dkim_6(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -233,7 +213,12 @@ def test_dkim_guidance_tags_dkim_6(save): "{}".format(json(result)) ) - assert "{'dkim6': 'P-1024'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim6': 'P-1024'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_7(save): @@ -241,27 +226,20 @@ def test_dkim_guidance_tags_dkim_7(save): Test that dkim guidance tag dkim 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim7") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim7") ) save(test_dkim_scan) @@ -270,10 +248,7 @@ def test_dkim_guidance_tags_dkim_7(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -298,7 +273,7 @@ def test_dkim_guidance_tags_dkim_7(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -307,7 +282,12 @@ def test_dkim_guidance_tags_dkim_7(save): "{}".format(json(result)) ) - assert "{'dkim7': 'P-2048'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim7': 'P-2048'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_8(save): @@ -315,27 +295,20 @@ def test_dkim_guidance_tags_dkim_8(save): Test that dkim guidance tag dkim 8 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim8") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim8") ) save(test_dkim_scan) @@ -344,10 +317,7 @@ def test_dkim_guidance_tags_dkim_8(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -372,7 +342,7 @@ def test_dkim_guidance_tags_dkim_8(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -381,7 +351,12 @@ def test_dkim_guidance_tags_dkim_8(save): "{}".format(json(result)) ) - assert "{'dkim8': 'P-4096'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim8': 'P-4096'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_9(save): @@ -389,27 +364,20 @@ def test_dkim_guidance_tags_dkim_9(save): Test that dkim guidance tag dkim 9 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim9") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim9") ) save(test_dkim_scan) @@ -418,10 +386,7 @@ def test_dkim_guidance_tags_dkim_9(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -446,7 +411,7 @@ def test_dkim_guidance_tags_dkim_9(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -455,7 +420,12 @@ def test_dkim_guidance_tags_dkim_9(save): "{}".format(json(result)) ) - assert "{'dkim9': 'P-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim9': 'P-invalid'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_10(save): @@ -463,27 +433,20 @@ def test_dkim_guidance_tags_dkim_10(save): Test that dkim guidance tag dkim 10 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim10") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim10") ) save(test_dkim_scan) @@ -492,10 +455,7 @@ def test_dkim_guidance_tags_dkim_10(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -520,7 +480,7 @@ def test_dkim_guidance_tags_dkim_10(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -529,7 +489,12 @@ def test_dkim_guidance_tags_dkim_10(save): "{}".format(json(result)) ) - assert "{'dkim10': 'P-update-recommended'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim10': 'P-update-recommended'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_11(save): @@ -537,27 +502,20 @@ def test_dkim_guidance_tags_dkim_11(save): Test that dkim guidance tag dkim 11 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim11") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim11") ) save(test_dkim_scan) @@ -566,10 +524,7 @@ def test_dkim_guidance_tags_dkim_11(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -594,7 +549,7 @@ def test_dkim_guidance_tags_dkim_11(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -603,7 +558,12 @@ def test_dkim_guidance_tags_dkim_11(save): "{}".format(json(result)) ) - assert "{'dkim11': 'DKIM-invalid-crypto'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim11': 'DKIM-invalid-crypto'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_12(save): @@ -611,27 +571,20 @@ def test_dkim_guidance_tags_dkim_12(save): Test that dkim guidance tag dkim 12 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim12") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim12") ) save(test_dkim_scan) @@ -640,10 +593,7 @@ def test_dkim_guidance_tags_dkim_12(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -668,7 +618,7 @@ def test_dkim_guidance_tags_dkim_12(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -677,7 +627,12 @@ def test_dkim_guidance_tags_dkim_12(save): "{}".format(json(result)) ) - assert "{'dkim12': 'DKIM-value-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim12': 'DKIM-value-invalid'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dkim_13(save): @@ -685,27 +640,20 @@ def test_dkim_guidance_tags_dkim_13(save): Test that dkim guidance tag dkim 13 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dkim_scans( - id=test_scan.id, - dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim13") + id=test_scan.id, dkim_scan=dkim_mock_data.get("dkim_mock_data_dkim13") ) save(test_dkim_scan) @@ -714,10 +662,7 @@ def test_dkim_guidance_tags_dkim_13(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -742,7 +687,7 @@ def test_dkim_guidance_tags_dkim_13(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -751,4 +696,9 @@ def test_dkim_guidance_tags_dkim_13(save): "{}".format(json(result)) ) - assert "{'dkim13': 'T-enabled'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"]["value"] + assert ( + "{'dkim13': 'T-enabled'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ]["value"] + ) diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index 9fb105c35c..0b4459fc32 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -19,27 +19,20 @@ def test_dkim_guidance_tags_dmarc_2(save): Test that dmarc guidance tag dmarc 2 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dmarc_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc2") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc2") ) save(test_dmarc_scan) @@ -48,10 +41,7 @@ def test_dkim_guidance_tags_dmarc_2(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -76,7 +66,7 @@ def test_dkim_guidance_tags_dmarc_2(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -85,7 +75,12 @@ def test_dkim_guidance_tags_dmarc_2(save): "{}".format(json(result)) ) - assert "{'dmarc2': 'DMARC-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc2': 'DMARC-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_3(save): @@ -93,27 +88,20 @@ def test_dkim_guidance_tags_dmarc_3(save): Test that dmarc guidance tag dmarc 3 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc3") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc3") ) save(test_dkim_scan) @@ -122,10 +110,7 @@ def test_dkim_guidance_tags_dmarc_3(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -150,7 +135,7 @@ def test_dkim_guidance_tags_dmarc_3(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -159,7 +144,12 @@ def test_dkim_guidance_tags_dmarc_3(save): "{}".format(json(result)) ) - assert "{'dmarc3': 'P-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc3': 'P-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_4(save): @@ -167,27 +157,20 @@ def test_dkim_guidance_tags_dmarc_4(save): Test that dmarc guidance tag dmarc 4 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc4") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc4") ) save(test_dkim_scan) @@ -196,10 +179,7 @@ def test_dkim_guidance_tags_dmarc_4(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -224,7 +204,7 @@ def test_dkim_guidance_tags_dmarc_4(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -233,7 +213,12 @@ def test_dkim_guidance_tags_dmarc_4(save): "{}".format(json(result)) ) - assert "{'dmarc4': 'P-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc4': 'P-none'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_5(save): @@ -241,27 +226,20 @@ def test_dkim_guidance_tags_dmarc_5(save): Test that dmarc guidance tag dmarc 5 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc5") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc5") ) save(test_dkim_scan) @@ -270,10 +248,7 @@ def test_dkim_guidance_tags_dmarc_5(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -298,7 +273,7 @@ def test_dkim_guidance_tags_dmarc_5(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -307,7 +282,12 @@ def test_dkim_guidance_tags_dmarc_5(save): "{}".format(json(result)) ) - assert "{'dmarc5': 'P-quarantine'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc5': 'P-quarantine'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_6(save): @@ -315,27 +295,20 @@ def test_dkim_guidance_tags_dmarc_6(save): Test that dmarc guidance tag dmarc 6 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc6") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc6") ) save(test_dkim_scan) @@ -344,10 +317,7 @@ def test_dkim_guidance_tags_dmarc_6(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -372,7 +342,7 @@ def test_dkim_guidance_tags_dmarc_6(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -381,7 +351,12 @@ def test_dkim_guidance_tags_dmarc_6(save): "{}".format(json(result)) ) - assert "{'dmarc6': 'P-reject'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc6': 'P-reject'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_7(save): @@ -389,27 +364,20 @@ def test_dkim_guidance_tags_dmarc_7(save): Test that dmarc guidance tag dmarc 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc7") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc7") ) save(test_dkim_scan) @@ -418,10 +386,7 @@ def test_dkim_guidance_tags_dmarc_7(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -446,7 +411,7 @@ def test_dkim_guidance_tags_dmarc_7(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -455,7 +420,12 @@ def test_dkim_guidance_tags_dmarc_7(save): "{}".format(json(result)) ) - assert "{'dmarc7': 'PCT-100'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc7': 'PCT-100'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_8(save): @@ -463,27 +433,20 @@ def test_dkim_guidance_tags_dmarc_8(save): Test that dmarc guidance tag dmarc 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc8") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc8") ) save(test_dkim_scan) @@ -492,10 +455,7 @@ def test_dkim_guidance_tags_dmarc_8(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -520,7 +480,7 @@ def test_dkim_guidance_tags_dmarc_8(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -529,7 +489,12 @@ def test_dkim_guidance_tags_dmarc_8(save): "{}".format(json(result)) ) - assert "{'dmarc8': 'PCT-80'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc8': 'PCT-80'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_9(save): @@ -537,27 +502,20 @@ def test_dkim_guidance_tags_dmarc_9(save): Test that dmarc guidance tag dmarc 9 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc9") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc9") ) save(test_dkim_scan) @@ -566,10 +524,7 @@ def test_dkim_guidance_tags_dmarc_9(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -594,7 +549,7 @@ def test_dkim_guidance_tags_dmarc_9(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -603,7 +558,12 @@ def test_dkim_guidance_tags_dmarc_9(save): "{}".format(json(result)) ) - assert "{'dmarc9': 'PCT-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc9': 'PCT-invalid'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): @@ -611,27 +571,21 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): Test that dmarc guidance tag dmarc 10, dmarc 11 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc10_dmarc_11") + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc10_dmarc_11"), ) save(test_dkim_scan) @@ -640,10 +594,7 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -668,7 +619,7 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -677,8 +628,18 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): "{}".format(json(result)) ) - assert "{'dmarc10': 'RUA-CCCS'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] - assert "{'dmarc11': 'RUF-CCCS'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc10': 'RUA-CCCS'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) + assert ( + "{'dmarc11': 'RUF-CCCS'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): @@ -686,27 +647,21 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): Test that dmarc guidance tag dmarc 12, dmarc 13 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc12_dmarc_13") + dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc12_dmarc_13"), ) save(test_dkim_scan) @@ -715,10 +670,7 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -743,7 +695,7 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -752,8 +704,18 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): "{}".format(json(result)) ) - assert "{'dmarc12': 'RUA-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] - assert "{'dmarc13': 'RUF-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc12': 'RUA-none'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) + assert ( + "{'dmarc13': 'RUF-none'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_14(save): @@ -761,27 +723,20 @@ def test_dkim_guidance_tags_dmarc_14(save): Test that dmarc guidance tag dmarc 14 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc14") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc14") ) save(test_dkim_scan) @@ -790,10 +745,7 @@ def test_dkim_guidance_tags_dmarc_14(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -818,7 +770,7 @@ def test_dkim_guidance_tags_dmarc_14(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -827,7 +779,12 @@ def test_dkim_guidance_tags_dmarc_14(save): "{}".format(json(result)) ) - assert "{'dmarc14': 'TXT-DMARC-enabled'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc14': 'TXT-DMARC-enabled'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_15(save): @@ -835,27 +792,20 @@ def test_dkim_guidance_tags_dmarc_15(save): Test that dmarc guidance tag dmarc 15 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc15") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc15") ) save(test_dkim_scan) @@ -864,10 +814,7 @@ def test_dkim_guidance_tags_dmarc_15(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -892,7 +839,7 @@ def test_dkim_guidance_tags_dmarc_15(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -901,7 +848,12 @@ def test_dkim_guidance_tags_dmarc_15(save): "{}".format(json(result)) ) - assert "{'dmarc15': 'TXT-DMARC-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc15': 'TXT-DMARC-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_16(save): @@ -909,27 +861,20 @@ def test_dkim_guidance_tags_dmarc_16(save): Test that dmarc guidance tag dmarc 16 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc16") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc16") ) save(test_dkim_scan) @@ -938,10 +883,7 @@ def test_dkim_guidance_tags_dmarc_16(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -966,7 +908,7 @@ def test_dkim_guidance_tags_dmarc_16(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -975,7 +917,12 @@ def test_dkim_guidance_tags_dmarc_16(save): "{}".format(json(result)) ) - assert "{'dmarc16': 'SP-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc16': 'SP-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_17(save): @@ -983,27 +930,20 @@ def test_dkim_guidance_tags_dmarc_17(save): Test that dmarc guidance tag dmarc 17 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc17") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc17") ) save(test_dkim_scan) @@ -1012,10 +952,7 @@ def test_dkim_guidance_tags_dmarc_17(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -1040,7 +977,7 @@ def test_dkim_guidance_tags_dmarc_17(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -1049,7 +986,12 @@ def test_dkim_guidance_tags_dmarc_17(save): "{}".format(json(result)) ) - assert "{'dmarc17': 'SP-none'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc17': 'SP-none'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_18(save): @@ -1057,27 +999,20 @@ def test_dkim_guidance_tags_dmarc_18(save): Test that dmarc guidance tag dmarc 18 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc18") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc18") ) save(test_dkim_scan) @@ -1086,10 +1021,7 @@ def test_dkim_guidance_tags_dmarc_18(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -1114,7 +1046,7 @@ def test_dkim_guidance_tags_dmarc_18(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -1123,7 +1055,12 @@ def test_dkim_guidance_tags_dmarc_18(save): "{}".format(json(result)) ) - assert "{'dmarc18': 'SP-quarantine'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc18': 'SP-quarantine'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_19(save): @@ -1131,27 +1068,20 @@ def test_dkim_guidance_tags_dmarc_19(save): Test that dmarc guidance tag dmarc 19 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc19") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc19") ) save(test_dkim_scan) @@ -1160,10 +1090,7 @@ def test_dkim_guidance_tags_dmarc_19(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -1188,7 +1115,7 @@ def test_dkim_guidance_tags_dmarc_19(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -1197,7 +1124,12 @@ def test_dkim_guidance_tags_dmarc_19(save): "{}".format(json(result)) ) - assert "{'dmarc19': 'SP-reject'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc19': 'SP-reject'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_20(save): @@ -1205,27 +1137,20 @@ def test_dkim_guidance_tags_dmarc_20(save): Test that dmarc guidance tag dmarc 20 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc20") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc20") ) save(test_dkim_scan) @@ -1234,10 +1159,7 @@ def test_dkim_guidance_tags_dmarc_20(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -1262,7 +1184,7 @@ def test_dkim_guidance_tags_dmarc_20(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -1271,7 +1193,12 @@ def test_dkim_guidance_tags_dmarc_20(save): "{}".format(json(result)) ) - assert "{'dmarc20': 'PCT-none-exists'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc20': 'PCT-none-exists'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_dmarc_21(save): @@ -1279,27 +1206,20 @@ def test_dkim_guidance_tags_dmarc_21(save): Test that dmarc guidance tag dmarc 21 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Dmarc_scans( - id=test_scan.id, - dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc21") + id=test_scan.id, dmarc_scan=dmarc_mock_data.get("dmarc_mock_data_dmarc21") ) save(test_dkim_scan) @@ -1308,10 +1228,7 @@ def test_dkim_guidance_tags_dmarc_21(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -1336,7 +1253,7 @@ def test_dkim_guidance_tags_dmarc_21(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -1345,4 +1262,9 @@ def test_dkim_guidance_tags_dmarc_21(save): "{}".format(json(result)) ) - assert "{'dmarc21': 'PCT-0'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"]["value"] + assert ( + "{'dmarc21': 'PCT-0'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ]["value"] + ) diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index a185364675..096478078f 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -19,27 +19,20 @@ def test_dkim_guidance_tags_https_2(save): Test that https guidance tag https 2 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_https_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https2") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https2") ) save(test_https_scan) @@ -48,10 +41,7 @@ def test_dkim_guidance_tags_https_2(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -76,7 +66,7 @@ def test_dkim_guidance_tags_https_2(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -85,7 +75,12 @@ def test_dkim_guidance_tags_https_2(save): "{}".format(json(result)) ) - assert "{'https2': 'HTTPS-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https2': 'HTTPS-missing'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_3(save): @@ -93,27 +88,20 @@ def test_dkim_guidance_tags_https_3(save): Test that https guidance tag https 3 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https3") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https3") ) save(test_dkim_scan) @@ -122,10 +110,7 @@ def test_dkim_guidance_tags_https_3(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -150,7 +135,7 @@ def test_dkim_guidance_tags_https_3(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -159,7 +144,12 @@ def test_dkim_guidance_tags_https_3(save): "{}".format(json(result)) ) - assert "{'https3': 'HTTPS-downgraded'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https3': 'HTTPS-downgraded'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_4(save): @@ -167,27 +157,20 @@ def test_dkim_guidance_tags_https_4(save): Test that https guidance tag https 4 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https4") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https4") ) save(test_dkim_scan) @@ -196,10 +179,7 @@ def test_dkim_guidance_tags_https_4(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -224,7 +204,7 @@ def test_dkim_guidance_tags_https_4(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -233,7 +213,12 @@ def test_dkim_guidance_tags_https_4(save): "{}".format(json(result)) ) - assert "{'https4': 'HTTPS-bad-chain'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https4': 'HTTPS-bad-chain'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_5(save): @@ -241,27 +226,20 @@ def test_dkim_guidance_tags_https_5(save): Test that https guidance tag https 5 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https5") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https5") ) save(test_dkim_scan) @@ -270,10 +248,7 @@ def test_dkim_guidance_tags_https_5(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -298,7 +273,7 @@ def test_dkim_guidance_tags_https_5(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -307,7 +282,12 @@ def test_dkim_guidance_tags_https_5(save): "{}".format(json(result)) ) - assert "{'https5': 'HTTPS-bad-hostname'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https5': 'HTTPS-bad-hostname'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_6(save): @@ -315,27 +295,20 @@ def test_dkim_guidance_tags_https_6(save): Test that https guidance tag https 6 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https6") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https6") ) save(test_dkim_scan) @@ -344,10 +317,7 @@ def test_dkim_guidance_tags_https_6(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -372,7 +342,7 @@ def test_dkim_guidance_tags_https_6(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -381,7 +351,12 @@ def test_dkim_guidance_tags_https_6(save): "{}".format(json(result)) ) - assert "{'https6': 'HTTPS-not-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https6': 'HTTPS-not-enforced'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_7(save): @@ -389,27 +364,20 @@ def test_dkim_guidance_tags_https_7(save): Test that https guidance tag https 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https7") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https7") ) save(test_dkim_scan) @@ -418,10 +386,7 @@ def test_dkim_guidance_tags_https_7(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -446,7 +411,7 @@ def test_dkim_guidance_tags_https_7(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -455,7 +420,12 @@ def test_dkim_guidance_tags_https_7(save): "{}".format(json(result)) ) - assert "{'https7': 'HTTPS-weakly-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https7': 'HTTPS-weakly-enforced'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_8(save): @@ -463,27 +433,20 @@ def test_dkim_guidance_tags_https_8(save): Test that https guidance tag https 8 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https8") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https8") ) save(test_dkim_scan) @@ -492,10 +455,7 @@ def test_dkim_guidance_tags_https_8(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -520,7 +480,7 @@ def test_dkim_guidance_tags_https_8(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -529,7 +489,12 @@ def test_dkim_guidance_tags_https_8(save): "{}".format(json(result)) ) - assert "{'https8': 'HTTPS-moderately-enforced'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https8': 'HTTPS-moderately-enforced'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_9(save): @@ -537,27 +502,20 @@ def test_dkim_guidance_tags_https_9(save): Test that https guidance tag https 9 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https9") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https9") ) save(test_dkim_scan) @@ -566,10 +524,7 @@ def test_dkim_guidance_tags_https_9(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -594,7 +549,7 @@ def test_dkim_guidance_tags_https_9(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -603,7 +558,12 @@ def test_dkim_guidance_tags_https_9(save): "{}".format(json(result)) ) - assert "{'https9': 'HSTS-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https9': 'HSTS-missing'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_10(save): @@ -611,27 +571,20 @@ def test_dkim_guidance_tags_https_10(save): Test that https guidance tag https 10 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https10") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https10") ) save(test_dkim_scan) @@ -640,10 +593,7 @@ def test_dkim_guidance_tags_https_10(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -668,7 +618,7 @@ def test_dkim_guidance_tags_https_10(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -677,7 +627,12 @@ def test_dkim_guidance_tags_https_10(save): "{}".format(json(result)) ) - assert "{'https:10': 'HSTS-short-age'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https:10': 'HSTS-short-age'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_11(save): @@ -685,27 +640,20 @@ def test_dkim_guidance_tags_https_11(save): Test that https guidance tag https 11 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https11") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https11") ) save(test_dkim_scan) @@ -714,10 +662,7 @@ def test_dkim_guidance_tags_https_11(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -742,7 +687,7 @@ def test_dkim_guidance_tags_https_11(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -751,7 +696,12 @@ def test_dkim_guidance_tags_https_11(save): "{}".format(json(result)) ) - assert "{'https11': 'HSTS-preload-ready'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https11': 'HSTS-preload-ready'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_12(save): @@ -759,27 +709,20 @@ def test_dkim_guidance_tags_https_12(save): Test that https guidance tag https 12 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https12") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https12") ) save(test_dkim_scan) @@ -788,10 +731,7 @@ def test_dkim_guidance_tags_https_12(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -816,7 +756,7 @@ def test_dkim_guidance_tags_https_12(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -825,7 +765,12 @@ def test_dkim_guidance_tags_https_12(save): "{}".format(json(result)) ) - assert "{'https12': 'HSTS-not-preloaded'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https12': 'HSTS-not-preloaded'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_13(save): @@ -833,27 +778,20 @@ def test_dkim_guidance_tags_https_13(save): Test that https guidance tag https 13 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https13") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https13") ) save(test_dkim_scan) @@ -862,10 +800,7 @@ def test_dkim_guidance_tags_https_13(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -890,7 +825,7 @@ def test_dkim_guidance_tags_https_13(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -899,7 +834,12 @@ def test_dkim_guidance_tags_https_13(save): "{}".format(json(result)) ) - assert "{'https13': 'HTTPS-certificate-expired'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https13': 'HTTPS-certificate-expired'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) def test_dkim_guidance_tags_https_14(save): @@ -907,27 +847,20 @@ def test_dkim_guidance_tags_https_14(save): Test that https guidance tag https 14 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Https_scans( - id=test_scan.id, - https_scan=https_mock_data.get("https_mock_data_https14") + id=test_scan.id, https_scan=https_mock_data.get("https_mock_data_https14") ) save(test_dkim_scan) @@ -936,10 +869,7 @@ def test_dkim_guidance_tags_https_14(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -964,7 +894,7 @@ def test_dkim_guidance_tags_https_14(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -973,4 +903,9 @@ def test_dkim_guidance_tags_https_14(save): "{}".format(json(result)) ) - assert "{'https14': 'HTTPS-certificate-self-signed'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"]["value"] + assert ( + "{'https14': 'HTTPS-certificate-self-signed'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ]["value"] + ) diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py index 9e5122c3cf..11eeb81963 100644 --- a/api/tests/test_spf_guidance_tags.py +++ b/api/tests/test_spf_guidance_tags.py @@ -2,7 +2,16 @@ from pytest import fail from db import DB -from models import Users, Organizations, Domains, Scans, Dkim_scans, Dmarc_scans, Spf_scans, User_affiliations +from models import ( + Users, + Organizations, + Domains, + Scans, + Dkim_scans, + Dmarc_scans, + Spf_scans, + User_affiliations, +) from tests.testdata.domain_guidance_tags import spf_mock_data from tests.test_functions import json, run @@ -19,27 +28,20 @@ def test_spf_guidance_tags_spf_2(save): Test that spf guidance tag spf 2 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf2") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf2") ) save(test_spf_scan) @@ -48,10 +50,7 @@ def test_spf_guidance_tags_spf_2(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -76,7 +75,7 @@ def test_spf_guidance_tags_spf_2(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -85,7 +84,12 @@ def test_spf_guidance_tags_spf_2(save): "{}".format(json(result)) ) - assert "{'spf2': 'SPF-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf2': 'SPF-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_3_dkim(save): @@ -93,33 +97,29 @@ def test_spf_guidance_tags_spf_3_dkim(save): Test that spf guidance tag spf 3 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf") + spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf"), ) save(test_spf_scan) test_dkim_scan = Dkim_scans( id=test_scan.id, - dkim_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_dkim") + dkim_scan=spf_mock_data.get("spf_mock_data_spf3").get( + "spf_mock_data_spf3_dkim" + ), ) save(test_dkim_scan) @@ -128,10 +128,7 @@ def test_spf_guidance_tags_spf_3_dkim(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -156,7 +153,7 @@ def test_spf_guidance_tags_spf_3_dkim(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -165,7 +162,12 @@ def test_spf_guidance_tags_spf_3_dkim(save): "{}".format(json(result)) ) - assert "{'spf3': 'SPF-bad-path'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf3': 'SPF-bad-path'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_3_dmarc(save): @@ -173,33 +175,29 @@ def test_spf_guidance_tags_spf_3_dmarc(save): Test that spf guidance tag spf 3 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf") + spf_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_spf"), ) save(test_spf_scan) test_dmarc_scan = Dmarc_scans( id=test_scan.id, - dmarc_scan=spf_mock_data.get("spf_mock_data_spf3").get("spf_mock_data_spf3_dmarc") + dmarc_scan=spf_mock_data.get("spf_mock_data_spf3").get( + "spf_mock_data_spf3_dmarc" + ), ) save(test_dmarc_scan) @@ -208,10 +206,7 @@ def test_spf_guidance_tags_spf_3_dmarc(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -236,7 +231,7 @@ def test_spf_guidance_tags_spf_3_dmarc(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -245,7 +240,12 @@ def test_spf_guidance_tags_spf_3_dmarc(save): "{}".format(json(result)) ) - assert "{'spf3': 'SPF-bad-path'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf3': 'SPF-bad-path'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_4(save): @@ -253,27 +253,20 @@ def test_spf_guidance_tags_spf_4(save): Test that spf guidance tag spf 4 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf4") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf4") ) save(test_spf_scan) @@ -282,10 +275,7 @@ def test_spf_guidance_tags_spf_4(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -310,7 +300,7 @@ def test_spf_guidance_tags_spf_4(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -319,7 +309,12 @@ def test_spf_guidance_tags_spf_4(save): "{}".format(json(result)) ) - assert "{'spf4': 'ALL-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf4': 'ALL-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_5(save): @@ -327,27 +322,20 @@ def test_spf_guidance_tags_spf_5(save): Test that spf guidance tag spf 5 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf5") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf5") ) save(test_spf_scan) @@ -356,10 +344,7 @@ def test_spf_guidance_tags_spf_5(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -384,7 +369,7 @@ def test_spf_guidance_tags_spf_5(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -393,7 +378,12 @@ def test_spf_guidance_tags_spf_5(save): "{}".format(json(result)) ) - assert "{'spf5': 'ALL-allow'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf5': 'ALL-allow'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_6(save): @@ -401,27 +391,20 @@ def test_spf_guidance_tags_spf_6(save): Test that spf guidance tag spf 6 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf6") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf6") ) save(test_spf_scan) @@ -430,10 +413,7 @@ def test_spf_guidance_tags_spf_6(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -458,7 +438,7 @@ def test_spf_guidance_tags_spf_6(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -467,7 +447,12 @@ def test_spf_guidance_tags_spf_6(save): "{}".format(json(result)) ) - assert "{'spf6': 'ALL-neutral'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf6': 'ALL-neutral'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_7(save): @@ -475,27 +460,20 @@ def test_spf_guidance_tags_spf_7(save): Test that spf guidance tag spf 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf7") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf7") ) save(test_spf_scan) @@ -504,10 +482,7 @@ def test_spf_guidance_tags_spf_7(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -532,7 +507,7 @@ def test_spf_guidance_tags_spf_7(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -541,7 +516,12 @@ def test_spf_guidance_tags_spf_7(save): "{}".format(json(result)) ) - assert "{'spf7': 'ALL-softfail'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf7': 'ALL-softfail'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_8(save): @@ -549,27 +529,20 @@ def test_spf_guidance_tags_spf_8(save): Test that spf guidance tag spf 8 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf8") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf8") ) save(test_spf_scan) @@ -578,10 +551,7 @@ def test_spf_guidance_tags_spf_8(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -606,7 +576,7 @@ def test_spf_guidance_tags_spf_8(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -615,7 +585,12 @@ def test_spf_guidance_tags_spf_8(save): "{}".format(json(result)) ) - assert "{'spf8': 'ALL-hardfail'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf8': 'ALL-hardfail'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_9(save): @@ -623,27 +598,20 @@ def test_spf_guidance_tags_spf_9(save): Test that spf guidance tag spf 9 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf9") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf9") ) save(test_spf_scan) @@ -652,10 +620,7 @@ def test_spf_guidance_tags_spf_9(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -680,7 +645,7 @@ def test_spf_guidance_tags_spf_9(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -689,7 +654,12 @@ def test_spf_guidance_tags_spf_9(save): "{}".format(json(result)) ) - assert "{'spf9': 'ALL-redirect'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf9': 'ALL-redirect'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_10(save): @@ -697,27 +667,20 @@ def test_spf_guidance_tags_spf_10(save): Test that spf guidance tag spf 10 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf10") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf10") ) save(test_spf_scan) @@ -726,10 +689,7 @@ def test_spf_guidance_tags_spf_10(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -754,7 +714,7 @@ def test_spf_guidance_tags_spf_10(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -763,7 +723,12 @@ def test_spf_guidance_tags_spf_10(save): "{}".format(json(result)) ) - assert "{'spf10': 'ALL-invalid'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf10': 'ALL-invalid'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_11(save): @@ -771,27 +736,20 @@ def test_spf_guidance_tags_spf_11(save): Test that spf guidance tag spf 11 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf11") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf11") ) save(test_spf_scan) @@ -800,10 +758,7 @@ def test_spf_guidance_tags_spf_11(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -828,7 +783,7 @@ def test_spf_guidance_tags_spf_11(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -837,7 +792,12 @@ def test_spf_guidance_tags_spf_11(save): "{}".format(json(result)) ) - assert "{'spf11': 'A-all'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf11': 'A-all'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_12(save): @@ -845,27 +805,20 @@ def test_spf_guidance_tags_spf_12(save): Test that spf guidance tag spf 12 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf12") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf12") ) save(test_spf_scan) @@ -874,10 +827,7 @@ def test_spf_guidance_tags_spf_12(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -902,7 +852,7 @@ def test_spf_guidance_tags_spf_12(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -911,7 +861,12 @@ def test_spf_guidance_tags_spf_12(save): "{}".format(json(result)) ) - assert "{'spf12': 'INCLUDE-limit'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf12': 'INCLUDE-limit'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_13(save): @@ -919,27 +874,20 @@ def test_spf_guidance_tags_spf_13(save): Test that spf guidance tag spf 13 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_spf_scan = Spf_scans( - id=test_scan.id, - spf_scan=spf_mock_data.get("spf_mock_data_spf13") + id=test_scan.id, spf_scan=spf_mock_data.get("spf_mock_data_spf13") ) save(test_spf_scan) @@ -948,10 +896,7 @@ def test_spf_guidance_tags_spf_13(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -976,7 +921,7 @@ def test_spf_guidance_tags_spf_13(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -985,4 +930,9 @@ def test_spf_guidance_tags_spf_13(save): "{}".format(json(result)) ) - assert "{'spf13': 'INCLUDE-missing'}" in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"]["value"] + assert ( + "{'spf13': 'INCLUDE-missing'}" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ]["value"] + ) diff --git a/api/tests/test_ssl_guidance_tags.py b/api/tests/test_ssl_guidance_tags.py index 5b6590bddb..1660ed24ce 100644 --- a/api/tests/test_ssl_guidance_tags.py +++ b/api/tests/test_ssl_guidance_tags.py @@ -19,27 +19,20 @@ def test_spf_guidance_tags_spf_2(save): Test that ssl guidance tag ssl 2 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl2") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl2") ) save(test_dkim_scan) @@ -48,10 +41,7 @@ def test_spf_guidance_tags_spf_2(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -76,7 +66,7 @@ def test_spf_guidance_tags_spf_2(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -85,7 +75,12 @@ def test_spf_guidance_tags_spf_2(save): "{}".format(json(result)) ) - assert "{'ssl2': 'SSL-missing'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl2': 'SSL-missing'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_3(save): @@ -93,27 +88,20 @@ def test_spf_guidance_tags_spf_3(save): Test that ssl guidance tag ssl 3 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl3") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl3") ) save(test_dkim_scan) @@ -122,10 +110,7 @@ def test_spf_guidance_tags_spf_3(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -150,7 +135,7 @@ def test_spf_guidance_tags_spf_3(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -159,7 +144,12 @@ def test_spf_guidance_tags_spf_3(save): "{}".format(json(result)) ) - assert "{'ssl3': 'SSL-rc4'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl3': 'SSL-rc4'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_4(save): @@ -167,27 +157,20 @@ def test_spf_guidance_tags_spf_4(save): Test that ssl guidance tag ssl 4 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl4") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl4") ) save(test_dkim_scan) @@ -196,10 +179,7 @@ def test_spf_guidance_tags_spf_4(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -224,7 +204,7 @@ def test_spf_guidance_tags_spf_4(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -233,7 +213,12 @@ def test_spf_guidance_tags_spf_4(save): "{}".format(json(result)) ) - assert "{'ssl4': 'SSL-3des'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl4': 'SSL-3des'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_5(save): @@ -241,27 +226,20 @@ def test_spf_guidance_tags_spf_5(save): Test that ssl guidance tag ssl 5 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl5") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl5") ) save(test_dkim_scan) @@ -270,10 +248,7 @@ def test_spf_guidance_tags_spf_5(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -298,7 +273,7 @@ def test_spf_guidance_tags_spf_5(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -307,7 +282,12 @@ def test_spf_guidance_tags_spf_5(save): "{}".format(json(result)) ) - assert "{'ssl5': 'SSL-acceptable-certificate'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl5': 'SSL-acceptable-certificate'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_6(save): @@ -315,27 +295,20 @@ def test_spf_guidance_tags_spf_6(save): Test that ssl guidance tag ssl 6 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl6") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl6") ) save(test_dkim_scan) @@ -344,10 +317,7 @@ def test_spf_guidance_tags_spf_6(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -372,7 +342,7 @@ def test_spf_guidance_tags_spf_6(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -381,7 +351,12 @@ def test_spf_guidance_tags_spf_6(save): "{}".format(json(result)) ) - assert "{'ssl6': 'SSL-invalid-cipher'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl6': 'SSL-invalid-cipher'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_7(save): @@ -389,27 +364,20 @@ def test_spf_guidance_tags_spf_7(save): Test that ssl guidance tag ssl 7 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl7") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl7") ) save(test_dkim_scan) @@ -418,10 +386,7 @@ def test_spf_guidance_tags_spf_7(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -446,7 +411,7 @@ def test_spf_guidance_tags_spf_7(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -455,7 +420,12 @@ def test_spf_guidance_tags_spf_7(save): "{}".format(json(result)) ) - assert "{'ssl7': 'Vulnerability-heartbleed'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl7': 'Vulnerability-heartbleed'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) def test_spf_guidance_tags_spf_8(save): @@ -463,27 +433,20 @@ def test_spf_guidance_tags_spf_8(save): Test that ssl guidance tag ssl 8 shows up """ org_one = Organizations( - acronym="ORG1", - name="Organization 1", - slug="organization-1", + acronym="ORG1", name="Organization 1", slug="organization-1", ) save(org_one) test_domain = Domains( - organization=org_one, - domain="test.domain.ca", - slug="test-domain-ca" + organization=org_one, domain="test.domain.ca", slug="test-domain-ca" ) save(test_domain) - test_scan = Scans( - domain=test_domain - ) + test_scan = Scans(domain=test_domain) save(test_scan) test_dkim_scan = Ssl_scans( - id=test_scan.id, - ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl8") + id=test_scan.id, ssl_scan=ssl_mock_data.get("ssl_mock_data_ssl8") ) save(test_dkim_scan) @@ -492,10 +455,7 @@ def test_spf_guidance_tags_spf_8(save): user_name="testuser@testemail.ca", password="testpassword123", user_affiliation=[ - User_affiliations( - permission="user_read", - user_organization=org_one - ), + User_affiliations(permission="user_read", user_organization=org_one), ], ) save(user) @@ -520,7 +480,7 @@ def test_spf_guidance_tags_spf_8(save): } } """, - as_user=user + as_user=user, ) if "errors" in result: @@ -529,4 +489,9 @@ def test_spf_guidance_tags_spf_8(save): "{}".format(json(result)) ) - assert "{'ssl8': 'Vulnerability-ccs-injection'}" in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"]["value"] + assert ( + "{'ssl8': 'Vulnerability-ccs-injection'}" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ]["value"] + ) diff --git a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py index bd504fc3e6..474994969b 100644 --- a/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dkim_mock_data.py @@ -1,71 +1,22 @@ dkim_mock_data = { - "dkim_mock_data_dkim2": { - "dkim": { - "missing": True - } - }, + "dkim_mock_data_dkim2": {"dkim": {"missing": True}}, "dkim_mock_data_dkim5": { - "dkim": { - "txt_record": { - "k": "rsa", - }, - "key_type": "rsa", - "key_size": 100, - } + "dkim": {"txt_record": {"k": "rsa",}, "key_type": "rsa", "key_size": 100,} }, "dkim_mock_data_dkim6": { - "dkim": { - "txt_record": { - "k": "rsa", - }, - "key_type": "rsa", - "key_size": 1024, - } + "dkim": {"txt_record": {"k": "rsa",}, "key_type": "rsa", "key_size": 1024,} }, "dkim_mock_data_dkim7": { - "dkim": { - "txt_record": { - "k": "rsa", - }, - "key_type": "rsa", - "key_size": 2048, - } + "dkim": {"txt_record": {"k": "rsa",}, "key_type": "rsa", "key_size": 2048,} }, "dkim_mock_data_dkim8": { - "dkim": { - "txt_record": { - "k": "rsa", - }, - "key_type": "rsa", - "key_size": 4096, - } - }, - "dkim_mock_data_dkim9": { - "dkim": { - "key_size": None, - } - }, - "dkim_mock_data_dkim10": { - "dkim": { - "update-recommend": True - } + "dkim": {"txt_record": {"k": "rsa",}, "key_type": "rsa", "key_size": 4096,} }, + "dkim_mock_data_dkim9": {"dkim": {"key_size": None,}}, + "dkim_mock_data_dkim10": {"dkim": {"update-recommend": True}}, "dkim_mock_data_dkim11": { - "dkim": { - "txt_record": { - "k": "SHA256", - }, - "key_type": "SHA256", - } - }, - "dkim_mock_data_dkim12": { - "dkim": { - "key_size": None, - } + "dkim": {"txt_record": {"k": "SHA256",}, "key_type": "SHA256",} }, - "dkim_mock_data_dkim13": { - "dkim": { - "t_value": True, - } - } + "dkim_mock_data_dkim12": {"dkim": {"key_size": None,}}, + "dkim_mock_data_dkim13": {"dkim": {"t_value": True,}}, } diff --git a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py index 37f8bc547d..c3dd9eeab7 100644 --- a/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/dmarc_mock_data.py @@ -1,79 +1,25 @@ dmarc_mock_data = { - "dmarc_mock_data_dmarc2": { - "dmarc": { - "missing": True - } - }, + "dmarc_mock_data_dmarc2": {"dmarc": {"missing": True}}, "dmarc_mock_data_dmarc3": { - "dmarc": { - "tags": { - "p": { - "value": "Missing", - "explicit": True - }, - } - } + "dmarc": {"tags": {"p": {"value": "Missing", "explicit": True},}} }, "dmarc_mock_data_dmarc4": { - "dmarc": { - "tags": { - "p": { - "value": "None", - "explicit": True - }, - } - } + "dmarc": {"tags": {"p": {"value": "None", "explicit": True},}} }, "dmarc_mock_data_dmarc5": { - "dmarc": { - "tags": { - "p": { - "value": "Quarantine", - "explicit": True - }, - } - } + "dmarc": {"tags": {"p": {"value": "Quarantine", "explicit": True},}} }, "dmarc_mock_data_dmarc6": { - "dmarc": { - "tags": { - "p": { - "value": "Reject", - "explicit": True - }, - - }, - } + "dmarc": {"tags": {"p": {"value": "Reject", "explicit": True},},} }, "dmarc_mock_data_dmarc7": { - "dmarc": { - "tags": { - "pct": { - "value": 100, - "explicit": True - }, - }, - } + "dmarc": {"tags": {"pct": {"value": 100, "explicit": True},},} }, "dmarc_mock_data_dmarc8": { - "dmarc": { - "tags": { - "pct": { - "value": 80, - "explicit": True - } - }, - } + "dmarc": {"tags": {"pct": {"value": 80, "explicit": True}},} }, "dmarc_mock_data_dmarc9": { - "dmarc": { - "tags": { - "pct": { - "value": "Invalid", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"pct": {"value": "Invalid", "explicit": True},},} }, "dmarc_mock_data_dmarc10_dmarc_11": { "dmarc": { @@ -83,20 +29,20 @@ { "scheme": "mailto", "address": "dmarc@cyber.gc.ca", - "size_limit": None + "size_limit": None, } ], - "explicit": True + "explicit": True, }, "ruf": { "value": [ { "scheme": "mailto", "address": "dmarc@cyber.gc.ca", - "size_limit": None + "size_limit": None, } ], - "explicit": True + "explicit": True, }, }, } @@ -104,84 +50,31 @@ "dmarc_mock_data_dmarc12_dmarc_13": { "dmarc": { "tags": { - "rua": { - "value": [], - "explicit": True - }, - "ruf": { - "value": [], - "explicit": True - }, + "rua": {"value": [], "explicit": True}, + "ruf": {"value": [], "explicit": True}, }, } }, "dmarc_mock_data_dmarc14": { - "dmarc": { - "record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca", - } - }, - "dmarc_mock_data_dmarc15": { - "dmarc": { - } + "dmarc": {"record": "v=DMARC1;p=None;sp=None;rua=mailto:dmarc@cyber.gc.ca",} }, + "dmarc_mock_data_dmarc15": {"dmarc": {}}, "dmarc_mock_data_dmarc16": { - "dmarc": { - "tags": { - "sp": { - "value": "Missing", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"sp": {"value": "Missing", "explicit": True},},} }, "dmarc_mock_data_dmarc17": { - "dmarc": { - "tags": { - "sp": { - "value": "None", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"sp": {"value": "None", "explicit": True},},} }, "dmarc_mock_data_dmarc18": { - "dmarc": { - "tags": { - "sp": { - "value": "Quarantine", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"sp": {"value": "Quarantine", "explicit": True},},} }, "dmarc_mock_data_dmarc19": { - "dmarc": { - "tags": { - "sp": { - "value": "Reject", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"sp": {"value": "Reject", "explicit": True},},} }, "dmarc_mock_data_dmarc20": { - "dmarc": { - "tags": { - "pct": { - "value": "None", - "explicit": True - }, - }, - } + "dmarc": {"tags": {"pct": {"value": "None", "explicit": True},},} }, "dmarc_mock_data_dmarc21": { - "dmarc": { - "tags": { - "pct": { - "value": 0, - "explicit": True - }, - }, - }, + "dmarc": {"tags": {"pct": {"value": 0, "explicit": True},},}, }, } diff --git a/api/tests/testdata/domain_guidance_tags/https_mock_data.py b/api/tests/testdata/domain_guidance_tags/https_mock_data.py index e468c5509a..2e6138dc22 100644 --- a/api/tests/testdata/domain_guidance_tags/https_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/https_mock_data.py @@ -1,67 +1,15 @@ https_mock_data = { - "https_mock_data_https2": { - "https": { - "missing": True - } - }, - "https_mock_data_https3": { - "https": { - "implementation": "Downgrades HTTPS", - } - }, - "https_mock_data_https4": { - "https": { - "implementation": "Bad Chain", - } - }, - "https_mock_data_https5": { - "https": { - "implementation": "Bad Hostname", - } - }, - "https_mock_data_https6": { - "https": { - "enforced": "Not Enforced", - } - }, - "https_mock_data_https7": { - "https": { - "enforced": "Weak", - } - }, - "https_mock_data_https8": { - "https": { - "enforced": "Moderate", - } - }, - "https_mock_data_https9": { - "https": { - "hsts": "No HSTS", - } - }, - "https_mock_data_https10": { - "https": { - "hsts": "HSTS Max Age Too Short", - } - }, - "https_mock_data_https11": { - "https": { - "preload_status": "HSTS Preload Ready", - } - }, - "https_mock_data_https12": { - "https": { - "preload_status": "HSTS Not Preloaded", - } - }, - "https_mock_data_https13": { - "https": { - "expired_cert": True, - } - }, - "https_mock_data_https14": { - "https": { - "self_signed_cert": True - } - } + "https_mock_data_https2": {"https": {"missing": True}}, + "https_mock_data_https3": {"https": {"implementation": "Downgrades HTTPS",}}, + "https_mock_data_https4": {"https": {"implementation": "Bad Chain",}}, + "https_mock_data_https5": {"https": {"implementation": "Bad Hostname",}}, + "https_mock_data_https6": {"https": {"enforced": "Not Enforced",}}, + "https_mock_data_https7": {"https": {"enforced": "Weak",}}, + "https_mock_data_https8": {"https": {"enforced": "Moderate",}}, + "https_mock_data_https9": {"https": {"hsts": "No HSTS",}}, + "https_mock_data_https10": {"https": {"hsts": "HSTS Max Age Too Short",}}, + "https_mock_data_https11": {"https": {"preload_status": "HSTS Preload Ready",}}, + "https_mock_data_https12": {"https": {"preload_status": "HSTS Not Preloaded",}}, + "https_mock_data_https13": {"https": {"expired_cert": True,}}, + "https_mock_data_https14": {"https": {"self_signed_cert": True}}, } diff --git a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py index d5fcd34a1b..ec695d6579 100644 --- a/api/tests/testdata/domain_guidance_tags/spf_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/spf_mock_data.py @@ -1,22 +1,13 @@ spf_mock_data = { - "spf_mock_data_spf2": { - "spf": { - "missing": True - } - }, + "spf_mock_data_spf2": {"spf": {"missing": True}}, "spf_mock_data_spf3": { "spf_mock_data_spf3_spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "missing" - } + "parsed": {"all": "missing"}, }, "spf_mock_data_spf3_dkim": { "dkim": { - "txt_record": { - "a": "some.domain.ca", - "include": "some.other.domain" - }, + "txt_record": {"a": "some.domain.ca", "include": "some.other.domain"}, } }, "spf_mock_data_spf3_dmarc": { @@ -28,49 +19,37 @@ "spf_mock_data_spf4": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "missing" - } + "parsed": {"all": "missing"}, } }, "spf_mock_data_spf5": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "Allow" - } + "parsed": {"all": "Allow"}, } }, "spf_mock_data_spf6": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "Neutral" - } + "parsed": {"all": "Neutral"}, } }, "spf_mock_data_spf7": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com ~all", - "parsed": { - "all": "fail" - } + "parsed": {"all": "fail"}, } }, "spf_mock_data_spf8": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "fail" - } + "parsed": {"all": "fail"}, } }, "spf_mock_data_spf9": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "all": "redirect" - } + "parsed": {"all": "redirect"}, } }, "spf_mock_data_spf10": { @@ -79,36 +58,20 @@ "valid": True, "dns_lookups": 5, "warnings": [], - "parsed": { - "all": "redirect" - } + "parsed": {"all": "redirect"}, } }, "spf_mock_data_spf11": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca include:spf.protection.outlook.com -all", - "parsed": { - "redirect": None, - "exp": None, - "all": "redirect" - } - } - }, - "spf_mock_data_spf12": { - "spf": { - "dns_lookups": 15, + "parsed": {"redirect": None, "exp": None, "all": "redirect"}, } }, + "spf_mock_data_spf12": {"spf": {"dns_lookups": 15,}}, "spf_mock_data_spf13": { "spf": { "record": "v=spf1 a:Cranberry.cse-cst.gc.ca a:beechnut.cse-cst.gc.ca a:edge.cyber.gc.ca -all", - "parsed": { - "include": [ - { - "domain": "spf.protection.outlook.com", - } - ], - } + "parsed": {"include": [{"domain": "spf.protection.outlook.com",}],}, } - } + }, } diff --git a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py index 0f0900c022..282bdb1f8c 100644 --- a/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py +++ b/api/tests/testdata/domain_guidance_tags/ssl_mock_data.py @@ -1,38 +1,11 @@ ssl_mock_data = { - "ssl_mock_data_ssl2": { - "ssl": { - "missing": True - } - }, - "ssl_mock_data_ssl3": { - "ssl": { - "rc4": True, - } - }, - "ssl_mock_data_ssl4": { - "ssl": { - "3des": True, - } - }, + "ssl_mock_data_ssl2": {"ssl": {"missing": True}}, + "ssl_mock_data_ssl3": {"ssl": {"rc4": True,}}, + "ssl_mock_data_ssl4": {"ssl": {"3des": True,}}, "ssl_mock_data_ssl5": { - "ssl": { - "signature_algorithm": "SHA-256", - "acceptable_certificate": True - } - }, - "ssl_mock_data_ssl6": { - "ssl": { - "signature_algorithm": "RSA", - } - }, - "ssl_mock_data_ssl7": { - "ssl": { - "heartbleed": True, - } + "ssl": {"signature_algorithm": "SHA-256", "acceptable_certificate": True} }, - "ssl_mock_data_ssl8": { - "ssl": { - "openssl_ccs_injection": True, - } - } + "ssl_mock_data_ssl6": {"ssl": {"signature_algorithm": "RSA",}}, + "ssl_mock_data_ssl7": {"ssl": {"heartbleed": True,}}, + "ssl_mock_data_ssl8": {"ssl": {"openssl_ccs_injection": True,}}, } From 1fe887a864f41354b8272770700fbf17ac06923d Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 11:38:14 -0300 Subject: [PATCH 31/39] Refactored spf --- api/schemas/domain/email_scan/spf.py | 150 ++++++++++++++++++ api/schemas/domain/email_scan/spf/__init__.py | 63 -------- api/schemas/domain/email_scan/spf/spf_tags.py | 104 ------------ api/tests/test_spf_guidance_tags.py | 130 +++++---------- 4 files changed, 189 insertions(+), 258 deletions(-) create mode 100644 api/schemas/domain/email_scan/spf.py delete mode 100644 api/schemas/domain/email_scan/spf/__init__.py delete mode 100644 api/schemas/domain/email_scan/spf/spf_tags.py diff --git a/api/schemas/domain/email_scan/spf.py b/api/schemas/domain/email_scan/spf.py new file mode 100644 index 0000000000..62bc2924ed --- /dev/null +++ b/api/schemas/domain/email_scan/spf.py @@ -0,0 +1,150 @@ +import graphene +import re + +from graphene_sqlalchemy import SQLAlchemyObjectType + +from db import db_session +from models import Spf_scans, Dkim_scans, Dmarc_scans +from scalars.url import URL +from functions.get_domain import get_domain +from functions.get_timestamp import get_timestamp + + +class SPF(SQLAlchemyObjectType): + """ + Email on the Internet can be forged in a number of ways. In + particular, existing protocols place no restriction on what a sending + host can use as the "MAIL FROM" of a message or the domain given on + the SMTP HELO/EHLO commands. Version 1 of the Sender Policy Framework (SPF) + protocol is where ADministrative Management Domains (ADMDs) can explicitly + authorize the hosts that are allowed to use their domain names, and a + receiving host can check such authorization. + """ + + class Meta: + model = Spf_scans + exclude_fields = ("id", "spf_scan") + + id = graphene.ID(description="ID of the object") + domain = URL(description="The domain the scan was run on") + timestamp = graphene.DateTime(description="The time the scan was initiated") + lookups = graphene.Int(description="The current amount of DNS lookups") + record = graphene.String( + description="SPF record retrieved during the scan of the " "given domain " + ) + spf_default = graphene.String( + description="Instruction of what a recipient should do if there is " + "not a match to your SPF record. " + ) + spf_guidance_tags = graphene.List( + lambda: graphene.String, description="Key tags found during SPF scan" + ) + + def resolve_domain(self: Spf_scans, info): + return get_domain(self, info) + + def resolve_timestamp(self: Spf_scans, info): + return get_timestamp(self, info) + + def resolve_lookups(self: Spf_scans, info): + return self.spf_scan["spf"]["dns_lookups"] + + def resolve_record(self: Spf_scans, info): + return self.spf_scan["spf"]["record"] + + def resolve_spf_default(self: Spf_scans, info): + if self.spf_scan["spf"]["parsed"]["all"] == "fail": + if self.spf_scan["spf"]["record"][-4:] == "-all": + return "hardfail" + elif self.spf_scan["spf"]["record"][-4:] == "~all": + return "softfail" + else: + return self.spf_scan["spf"]["parsed"]["all"] + + def resolve_spf_guidance_tags(self: Spf_scans, info): + tags = [] + + if self.spf_scan.get("spf", {}).get("missing", None) is not None: + tags.append("spf2") + return tags + + # Check for bad path + dkim_orm: Dkim_scans = db_session.query(Dkim_scans).filter( + Dkim_scans.id == self.id + ).first() + dmarc_orm: Dmarc_scans = db_session.query(Dmarc_scans).filter( + Dmarc_scans.id == self.id + ).first() + + if dkim_orm is not None: + dkim_record = dkim_orm.dkim_scan.get("dkim", {}).get("txt_record", + None) + for key in dkim_record: + if key == "a" or key == "include": + tags.append("spf3") + + if dmarc_orm is not None: + dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}).get("record", + None) + if ( + ("include:" in dmarc_record) + or ("a:" in dmarc_record) + or ("all" in dmarc_record) + ): + if not "spf3" in tags: + tags.append("spf3") + + # Check all tag + all_tag = self.spf_scan.get("spf", {}).get("parsed", {}).get("all", + None) + record_all_tag = self.spf_scan.get("spf", {}).get("record", "")[ + -4:].lower() + + if isinstance(all_tag, str): + all_tag = all_tag.lower() + + if record_all_tag != "-all" and record_all_tag != "~all": + tags.append("spf10") + elif all_tag == "missing": + tags.append("spf4") + elif all_tag == "allow": + tags.append("spf5") + elif all_tag == "neutral": + tags.append("spf6") + elif all_tag == "redirect": + tags.append("spf9") + elif all_tag == "fail": + if record_all_tag == "-all": + tags.append("spf8") + elif record_all_tag == "~all": + tags.append("spf7") + + # Check for no host + record = self.spf_scan.get("spf", {}).get("record", None) + if record is not None: + search_string = "a:" + matches = re.finditer(search_string, record) + match_pos = [match.start() for match in matches] + + for pos in match_pos: + if record[pos + 1: 1] == "" and not "spf11" in tags: + tags.append("spf11") + + # Look up limit check + dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) + if dns_lookups > 10: + tags.append("spf12") + + # Check for missing include + include = self.spf_scan.get("spf", {}).get("parsed", {}).get("include", + None) + record = self.spf_scan.get("spf", {}).get("record", None) + + if include is not None and record is not None: + for item in include: + check_item = item.get("domain", None) + if check_item is not None and f"include:{check_item}" not in record: + if not "spf13" in tags: + tags.append("spf13") + + return tags diff --git a/api/schemas/domain/email_scan/spf/__init__.py b/api/schemas/domain/email_scan/spf/__init__.py deleted file mode 100644 index c5303b30a1..0000000000 --- a/api/schemas/domain/email_scan/spf/__init__.py +++ /dev/null @@ -1,63 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Spf_scans -from scalars.url import URL -from functions.get_domain import get_domain -from functions.get_timestamp import get_timestamp -from schemas.domain.email_scan.spf.spf_tags import SPFTags - - -class SPF(SQLAlchemyObjectType): - """ - Email on the Internet can be forged in a number of ways. In - particular, existing protocols place no restriction on what a sending - host can use as the "MAIL FROM" of a message or the domain given on - the SMTP HELO/EHLO commands. Version 1 of the Sender Policy Framework (SPF) - protocol is where ADministrative Management Domains (ADMDs) can explicitly - authorize the hosts that are allowed to use their domain names, and a - receiving host can check such authorization. - """ - - class Meta: - model = Spf_scans - exclude_fields = ("id", "spf_scan") - - id = graphene.ID(description="ID of the object") - domain = URL(description="The domain the scan was run on") - timestamp = graphene.DateTime(description="The time the scan was initiated") - lookups = graphene.Int(description="The current amount of DNS lookups") - record = graphene.String( - description="SPF record retrieved during the scan of the " "given domain " - ) - spf_default = graphene.String( - description="Instruction of what a recipient should do if there is " - "not a match to your SPF record. " - ) - spf_guidance_tags = graphene.Field( - lambda: SPFTags, description="Key tags found during SPF scan" - ) - - def resolve_domain(self: Spf_scans, info): - return get_domain(self, info) - - def resolve_timestamp(self: Spf_scans, info): - return get_timestamp(self, info) - - def resolve_lookups(self: Spf_scans, info): - return self.spf_scan["spf"]["dns_lookups"] - - def resolve_record(self: Spf_scans, info): - return self.spf_scan["spf"]["record"] - - def resolve_spf_default(self: Spf_scans, info): - if self.spf_scan["spf"]["parsed"]["all"] == "fail": - if self.spf_scan["spf"]["record"][-4:] == "-all": - return "hardfail" - elif self.spf_scan["spf"]["record"][-4:] == "~all": - return "softfail" - else: - return self.spf_scan["spf"]["parsed"]["all"] - - def resolve_spf_guidance_tags(self: Spf_scans, info): - return SPFTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/spf/spf_tags.py b/api/schemas/domain/email_scan/spf/spf_tags.py deleted file mode 100644 index 1d2a05a70b..0000000000 --- a/api/schemas/domain/email_scan/spf/spf_tags.py +++ /dev/null @@ -1,104 +0,0 @@ -import graphene -import re - -from graphene_sqlalchemy import SQLAlchemyObjectType - -from db import db_session -from models import Spf_scans, Dmarc_scans, Dkim_scans - - -class SPFTags(SQLAlchemyObjectType): - """ - Current settings of the currently configured SPF - """ - - class Meta: - model = Spf_scans - exclude_fields = ("id", "spf_scan") - - value = graphene.List( - lambda: graphene.String, description="Important tags retrieved during scan" - ) - - def resolve_value(self: Spf_scans, info): - tags = [] - - if self.spf_scan.get("spf", {}).get("missing", None) is not None: - tags.append({"spf2": "SPF-missing"}) - return tags - - # Check for bad path - dkim_orm: Dkim_scans = db_session.query(Dkim_scans).filter( - Dkim_scans.id == self.id - ).first() - dmarc_orm: Dmarc_scans = db_session.query(Dmarc_scans).filter( - Dmarc_scans.id == self.id - ).first() - - if dkim_orm is not None: - dkim_record = dkim_orm.dkim_scan.get("dkim", {}).get("txt_record", None) - for key in dkim_record: - if key == "a" or key == "include": - tags.append({"spf3": "SPF-bad-path"}) - - if dmarc_orm is not None: - dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}).get("record", None) - if ( - ("include:" in dmarc_record) - or ("a:" in dmarc_record) - or ("all" in dmarc_record) - ): - if not {"spf3": "SPF-bad-path"} in tags: - tags.append({"spf3": "SPF-bad-path"}) - - # Check all tag - all_tag = self.spf_scan.get("spf", {}).get("parsed", {}).get("all", None) - record_all_tag = self.spf_scan.get("spf", {}).get("record", "")[-4:].lower() - - if isinstance(all_tag, str): - all_tag = all_tag.lower() - - if record_all_tag != "-all" and record_all_tag != "~all": - tags.append({"spf10": "ALL-invalid"}) - elif all_tag == "missing": - tags.append({"spf4": "ALL-missing"}) - elif all_tag == "allow": - tags.append({"spf5": "ALL-allow"}) - elif all_tag == "neutral": - tags.append({"spf6": "ALL-neutral"}) - elif all_tag == "redirect": - tags.append({"spf9": "ALL-redirect"}) - elif all_tag == "fail": - if record_all_tag == "-all": - tags.append({"spf8": "ALL-hardfail"}) - elif record_all_tag == "~all": - tags.append({"spf7": "ALL-softfail"}) - - # Check for no host - record = self.spf_scan.get("spf", {}).get("record", None) - if record is not None: - search_string = "a:" - matches = re.finditer(search_string, record) - match_pos = [match.start() for match in matches] - - for pos in match_pos: - if record[pos + 1 : 1] == "" and not {"spf11": "A-all"} in tags: - tags.append({"spf11": "A-all"}) - - # Look up limit check - dns_lookups = self.spf_scan.get("spf", {}).get("dns_lookups", 0) - if dns_lookups > 10: - tags.append({"spf12": "INCLUDE-limit"}) - - # Check for missing include - include = self.spf_scan.get("spf", {}).get("parsed", {}).get("include", None) - record = self.spf_scan.get("spf", {}).get("record", None) - - if include is not None and record is not None: - for item in include: - check_item = item.get("domain", None) - if check_item is not None and f"include:{check_item}" not in record: - if not {"spf13": "INCLUDE-missing"} in tags: - tags.append({"spf13": "INCLUDE-missing"}) - - return tags diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py index 11eeb81963..7e50aadfdd 100644 --- a/api/tests/test_spf_guidance_tags.py +++ b/api/tests/test_spf_guidance_tags.py @@ -65,9 +65,7 @@ def test_spf_guidance_tags_spf_2(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -85,10 +83,8 @@ def test_spf_guidance_tags_spf_2(save): ) assert ( - "{'spf2': 'SPF-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf2" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -143,9 +139,7 @@ def test_spf_guidance_tags_spf_3_dkim(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -163,10 +157,8 @@ def test_spf_guidance_tags_spf_3_dkim(save): ) assert ( - "{'spf3': 'SPF-bad-path'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf3" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -221,9 +213,7 @@ def test_spf_guidance_tags_spf_3_dmarc(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -241,10 +231,8 @@ def test_spf_guidance_tags_spf_3_dmarc(save): ) assert ( - "{'spf3': 'SPF-bad-path'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf3" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -290,9 +278,7 @@ def test_spf_guidance_tags_spf_4(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -310,10 +296,8 @@ def test_spf_guidance_tags_spf_4(save): ) assert ( - "{'spf4': 'ALL-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf4" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -359,9 +343,7 @@ def test_spf_guidance_tags_spf_5(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -379,10 +361,8 @@ def test_spf_guidance_tags_spf_5(save): ) assert ( - "{'spf5': 'ALL-allow'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf5" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -428,9 +408,7 @@ def test_spf_guidance_tags_spf_6(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -448,10 +426,8 @@ def test_spf_guidance_tags_spf_6(save): ) assert ( - "{'spf6': 'ALL-neutral'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf6" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -497,9 +473,7 @@ def test_spf_guidance_tags_spf_7(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -517,10 +491,8 @@ def test_spf_guidance_tags_spf_7(save): ) assert ( - "{'spf7': 'ALL-softfail'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf7" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -566,9 +538,7 @@ def test_spf_guidance_tags_spf_8(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -586,10 +556,8 @@ def test_spf_guidance_tags_spf_8(save): ) assert ( - "{'spf8': 'ALL-hardfail'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf8" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -635,9 +603,7 @@ def test_spf_guidance_tags_spf_9(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -655,10 +621,8 @@ def test_spf_guidance_tags_spf_9(save): ) assert ( - "{'spf9': 'ALL-redirect'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf9" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -704,9 +668,7 @@ def test_spf_guidance_tags_spf_10(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -724,10 +686,8 @@ def test_spf_guidance_tags_spf_10(save): ) assert ( - "{'spf10': 'ALL-invalid'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf10" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -773,9 +733,7 @@ def test_spf_guidance_tags_spf_11(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -793,10 +751,8 @@ def test_spf_guidance_tags_spf_11(save): ) assert ( - "{'spf11': 'A-all'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf11" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -842,9 +798,7 @@ def test_spf_guidance_tags_spf_12(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -862,10 +816,8 @@ def test_spf_guidance_tags_spf_12(save): ) assert ( - "{'spf12': 'INCLUDE-limit'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf12" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) @@ -911,9 +863,7 @@ def test_spf_guidance_tags_spf_13(save): edges { node { spf { - spfGuidanceTags { - value - } + spfGuidanceTags } } } @@ -931,8 +881,6 @@ def test_spf_guidance_tags_spf_13(save): ) assert ( - "{'spf13': 'INCLUDE-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ - "spfGuidanceTags" - ]["value"] + "spf13" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] ) From bd4544dde0e423c1ac34a39504d2744d795be606 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 11:49:22 -0300 Subject: [PATCH 32/39] Refactored dmarc --- api/schemas/domain/email_scan/dmarc.py | 198 ++++++++++++++++++ .../domain/email_scan/dmarc/__init__.py | 87 -------- .../domain/email_scan/dmarc/dmarc_tags.py | 135 ------------ api/tests/test_dmarc_guidance_tags.py | 192 +++++------------ 4 files changed, 256 insertions(+), 356 deletions(-) create mode 100644 api/schemas/domain/email_scan/dmarc.py delete mode 100644 api/schemas/domain/email_scan/dmarc/__init__.py delete mode 100644 api/schemas/domain/email_scan/dmarc/dmarc_tags.py diff --git a/api/schemas/domain/email_scan/dmarc.py b/api/schemas/domain/email_scan/dmarc.py new file mode 100644 index 0000000000..f7d2a4c73d --- /dev/null +++ b/api/schemas/domain/email_scan/dmarc.py @@ -0,0 +1,198 @@ +import graphene +from graphene_sqlalchemy import SQLAlchemyObjectType + +from db import db_session +from models import Dmarc_scans, Scans, Domains +from scalars.url import URL +from functions.get_domain import get_domain +from functions.get_timestamp import get_timestamp + + +class DMARC(SQLAlchemyObjectType): + """ + Domain-based Message Authentication, Reporting, and Conformance + (DMARC) is a scalable mechanism by which a mail-originating + organization can express domain-level policies and preferences for + message validation, disposition, and reporting, that a mail-receiving + organization can use to improve mail handling. + """ + + class Meta: + model = Dmarc_scans + exclude_fields = ("id", "dmarc_scan") + + id = graphene.ID(description="ID of the object") + domain = URL(description="The domain the scan was run on") + timestamp = graphene.DateTime(description="Time when scan was initiated") + dmarc_phase = graphene.Int(description="DMARC Phase found when running scan") + record = graphene.String( + description="DMARC record retrieved during the scan of the " "given domain " + ) + p_policy = graphene.String( + description="The requested policy you wish mailbox providers to apply " + "when your email fails DMARC authentication and alignment" + " checks. " + ) + sp_policy = graphene.String( + description="This tag is used to indicate a requested policy for all " + "subdomains where mail is failing the DMARC " + "authentication and alignment checks. " + ) + pct = graphene.Int( + description="The percentage of messages to which the DMARC policy is " + "to be applied. " + ) + dmarc_guidance_tags = graphene.List( + lambda: graphene.String, description="Key tags found during DMARC Scan" + ) + + def resolve_domain(self: Dmarc_scans, info): + return get_domain(self, info) + + def resolve_timestamp(self: Dmarc_scans, info): + return get_timestamp(self, info) + + def resolve_dmarc_phase(self: Dmarc_scans, info): + return self.dmarc_phase + + def resolve_record(self: Dmarc_scans, info): + return self.dmarc_scan.get("dmarc", {}).get("record", None) + + def resolve_p_policy(self: Dmarc_scans, info): + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("p", {}) + .get("value", None) + ) + + def resolve_sp_policy(self: Dmarc_scans, info): + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("sp", {}) + .get("value", None) + ) + + def resolve_pct(self: Dmarc_scans, info): + return ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("pct", {}) + .get("value", None) + ) + + def resolve_dmarc_guidance_tags(self: Dmarc_scans, info): + tags = [] + + if self.dmarc_scan.get("dmarc", {}).get("missing", None) is not None: + tags.append("dmarc2") + return tags + + # Check P Policy Tag + p_policy_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("p", {}) + .get("value", None) + ) + + if isinstance(p_policy_tag, str): + p_policy_tag = p_policy_tag.lower() + + if p_policy_tag == "missing": + tags.append("dmarc3") + elif p_policy_tag == "none": + tags.append("dmarc4") + elif p_policy_tag == "quarantine": + tags.append("dmarc5") + elif p_policy_tag == "reject": + tags.append("dmarc6") + + # Check PCT Tag + pct_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("pct", {}) + .get("value", None) + ) + + if isinstance(pct_tag, str): + pct_tag = pct_tag.lower() + if pct_tag == "invalid": + tags.append("dmarc9") + elif pct_tag == "none": + tags.append("dmarc20") + elif isinstance(pct_tag, int): + if pct_tag == 100: + tags.append("dmarc7") + elif 100 > pct_tag > 0: + tags.append("dmarc8") + else: + tags.append("dmarc21") + + # Check RUA Tag + rua_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("rua", {}) + .get("value", None) + ) + + if isinstance(rua_tag, str): + rua_tag = rua_tag.lower() + + if rua_tag is None or not rua_tag: + tags.append("dmarc12") + else: + for value in rua_tag: + if value["address"] == "dmarc@cyber.gc.ca": + tags.append("dmarc10") + else: + tags.append("dmarc12") + + # Check RUF Tag + ruf_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("ruf", {}) + .get("value", None) + ) + + if ruf_tag is None or not ruf_tag: + tags.append("dmarc13") + else: + for value in ruf_tag: + if value["address"] == "dmarc@cyber.gc.ca": + tags.append("dmarc11") + else: + tags.append("dmarc13") + + # TXT DMARC + record_tag = self.dmarc_scan.get("dmarc", {}).get("record", None) + if record_tag == "" or record_tag is None: + tags.append("dmarc15") + else: + tags.append("dmarc14") + + # Check SP tag + sp_tag = ( + self.dmarc_scan.get("dmarc", {}) + .get("tags", {}) + .get("sp", {}) + .get("value", None) + ) + + if isinstance(sp_tag, str): + sp_tag = sp_tag.lower() + + if sp_tag == "missing": + tags.append("dmarc16") + elif sp_tag == "none": + tags.append("dmarc17") + elif sp_tag == "quarantine": + tags.append("dmarc18") + elif sp_tag == "reject": + tags.append("dmarc19") + + return tags diff --git a/api/schemas/domain/email_scan/dmarc/__init__.py b/api/schemas/domain/email_scan/dmarc/__init__.py deleted file mode 100644 index 2756e98915..0000000000 --- a/api/schemas/domain/email_scan/dmarc/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from db import db_session -from models import Dmarc_scans, Scans, Domains -from scalars.url import URL -from functions.get_domain import get_domain -from functions.get_timestamp import get_timestamp -from schemas.domain.email_scan.dmarc.dmarc_tags import DmarcTags - - -class DMARC(SQLAlchemyObjectType): - """ - Domain-based Message Authentication, Reporting, and Conformance - (DMARC) is a scalable mechanism by which a mail-originating - organization can express domain-level policies and preferences for - message validation, disposition, and reporting, that a mail-receiving - organization can use to improve mail handling. - """ - - class Meta: - model = Dmarc_scans - exclude_fields = ("id", "dmarc_scan") - - id = graphene.ID(description="ID of the object") - domain = URL(description="The domain the scan was run on") - timestamp = graphene.DateTime(description="Time when scan was initiated") - dmarc_phase = graphene.Int(description="DMARC Phase found when running scan") - record = graphene.String( - description="DMARC record retrieved during the scan of the " "given domain " - ) - p_policy = graphene.String( - description="The requested policy you wish mailbox providers to apply " - "when your email fails DMARC authentication and alignment" - " checks. " - ) - sp_policy = graphene.String( - description="This tag is used to indicate a requested policy for all " - "subdomains where mail is failing the DMARC " - "authentication and alignment checks. " - ) - pct = graphene.Int( - description="The percentage of messages to which the DMARC policy is " - "to be applied. " - ) - dmarc_guidance_tags = graphene.Field( - lambda: DmarcTags, description="Key tags found during DMARC Scan" - ) - - def resolve_domain(self: Dmarc_scans, info): - return get_domain(self, info) - - def resolve_timestamp(self: Dmarc_scans, info): - return get_timestamp(self, info) - - def resolve_dmarc_phase(self: Dmarc_scans, info): - return self.dmarc_phase - - def resolve_record(self: Dmarc_scans, info): - return self.dmarc_scan.get("dmarc", {}).get("record", None) - - def resolve_p_policy(self: Dmarc_scans, info): - return ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("p", {}) - .get("value", None) - ) - - def resolve_sp_policy(self: Dmarc_scans, info): - return ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("sp", {}) - .get("value", None) - ) - - def resolve_pct(self: Dmarc_scans, info): - return ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("pct", {}) - .get("value", None) - ) - - def resolve_dmarc_guidance_tags(self: Dmarc_scans, info): - return DmarcTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py b/api/schemas/domain/email_scan/dmarc/dmarc_tags.py deleted file mode 100644 index fbe59adbcb..0000000000 --- a/api/schemas/domain/email_scan/dmarc/dmarc_tags.py +++ /dev/null @@ -1,135 +0,0 @@ -import graphene -import json -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Dmarc_scans - - -class DmarcTags(SQLAlchemyObjectType): - """ - Guidance tags for dmarc scan results - """ - - class Meta: - model = Dmarc_scans - exclude_fields = ("id", "dmarc_scan") - - value = graphene.List( - lambda: graphene.String, description="Important tags retrieved during scan" - ) - - def resolve_value(self: Dmarc_scans, info): - tags = [] - - if self.dmarc_scan.get("dmarc", {}).get("missing", None) is not None: - tags.append({"dmarc2": "DMARC-missing"}) - return tags - - # Check P Policy Tag - p_policy_tag = ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("p", {}) - .get("value", None) - ) - - if isinstance(p_policy_tag, str): - p_policy_tag = p_policy_tag.lower() - - if p_policy_tag == "missing": - tags.append({"dmarc3": "P-missing"}) - elif p_policy_tag == "none": - tags.append({"dmarc4": "P-none"}) - elif p_policy_tag == "quarantine": - tags.append({"dmarc5": "P-quarantine"}) - elif p_policy_tag == "reject": - tags.append({"dmarc6": "P-reject"}) - - # Check PCT Tag - pct_tag = ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("pct", {}) - .get("value", None) - ) - - if isinstance(pct_tag, str): - pct_tag = pct_tag.lower() - if pct_tag == "invalid": - tags.append({"dmarc9": "PCT-invalid"}) - elif pct_tag == "none": - tags.append({"dmarc20": "PCT-none-exists"}) - elif isinstance(pct_tag, int): - if pct_tag == 100: - tags.append({"dmarc7": "PCT-100"}) - elif 100 > pct_tag > 0: - pct_string = "PCT-" + str(pct_tag) - tags.append({"dmarc8": pct_string}) - else: - tags.append({"dmarc21": "PCT-0"}) - - # Check RUA Tag - rua_tag = ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("rua", {}) - .get("value", None) - ) - - if isinstance(rua_tag, str): - rua_tag = rua_tag.lower() - - if rua_tag is None or not rua_tag: - tags.append({"dmarc12": "RUA-none"}) - else: - for value in rua_tag: - if value["address"] == "dmarc@cyber.gc.ca": - tags.append({"dmarc10": "RUA-CCCS"}) - else: - tags.append({"dmarc12": "RUA-none"}) - - # Check RUF Tag - ruf_tag = ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("ruf", {}) - .get("value", None) - ) - - if ruf_tag is None or not ruf_tag: - tags.append({"dmarc13": "RUF-none"}) - else: - for value in ruf_tag: - if value["address"] == "dmarc@cyber.gc.ca": - tags.append({"dmarc11": "RUF-CCCS"}) - else: - tags.append({"dmarc13": "RUF-none"}) - - # TXT DMARC - record_tag = self.dmarc_scan.get("dmarc", {}).get("record", None) - if record_tag == "" or record_tag is None: - tags.append({"dmarc15": "TXT-DMARC-missing"}) - else: - tags.append({"dmarc14": "TXT-DMARC-enabled"}) - - # Check SP tag - sp_tag = ( - self.dmarc_scan.get("dmarc", {}) - .get("tags", {}) - .get("sp", {}) - .get("value", None) - ) - - if isinstance(sp_tag, str): - sp_tag = sp_tag.lower() - - if sp_tag == "missing": - tags.append({"dmarc16": "SP-missing"}) - elif sp_tag == "none": - tags.append({"dmarc17": "SP-none"}) - elif sp_tag == "quarantine": - tags.append({"dmarc18": "SP-quarantine"}) - elif sp_tag == "reject": - tags.append({"dmarc19": "SP-reject"}) - - return tags diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index 0b4459fc32..abcc07dba0 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -56,9 +56,7 @@ def test_dkim_guidance_tags_dmarc_2(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -76,10 +74,8 @@ def test_dkim_guidance_tags_dmarc_2(save): ) assert ( - "{'dmarc2': 'DMARC-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc2" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -125,9 +121,7 @@ def test_dkim_guidance_tags_dmarc_3(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -145,10 +139,8 @@ def test_dkim_guidance_tags_dmarc_3(save): ) assert ( - "{'dmarc3': 'P-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc3" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -194,9 +186,7 @@ def test_dkim_guidance_tags_dmarc_4(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -214,10 +204,8 @@ def test_dkim_guidance_tags_dmarc_4(save): ) assert ( - "{'dmarc4': 'P-none'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc4" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -263,9 +251,7 @@ def test_dkim_guidance_tags_dmarc_5(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -283,10 +269,8 @@ def test_dkim_guidance_tags_dmarc_5(save): ) assert ( - "{'dmarc5': 'P-quarantine'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc5" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -332,9 +316,7 @@ def test_dkim_guidance_tags_dmarc_6(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -352,10 +334,8 @@ def test_dkim_guidance_tags_dmarc_6(save): ) assert ( - "{'dmarc6': 'P-reject'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc6" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -401,9 +381,7 @@ def test_dkim_guidance_tags_dmarc_7(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -421,10 +399,8 @@ def test_dkim_guidance_tags_dmarc_7(save): ) assert ( - "{'dmarc7': 'PCT-100'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc7" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -470,9 +446,7 @@ def test_dkim_guidance_tags_dmarc_8(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -490,10 +464,8 @@ def test_dkim_guidance_tags_dmarc_8(save): ) assert ( - "{'dmarc8': 'PCT-80'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc8" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -539,9 +511,7 @@ def test_dkim_guidance_tags_dmarc_9(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -559,10 +529,8 @@ def test_dkim_guidance_tags_dmarc_9(save): ) assert ( - "{'dmarc9': 'PCT-invalid'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc9" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -609,9 +577,7 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -629,16 +595,12 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): ) assert ( - "{'dmarc10': 'RUA-CCCS'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc10" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) assert ( - "{'dmarc11': 'RUF-CCCS'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc11" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -685,9 +647,7 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -705,16 +665,12 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): ) assert ( - "{'dmarc12': 'RUA-none'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc12" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) assert ( - "{'dmarc13': 'RUF-none'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc13" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -760,9 +716,7 @@ def test_dkim_guidance_tags_dmarc_14(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -780,10 +734,8 @@ def test_dkim_guidance_tags_dmarc_14(save): ) assert ( - "{'dmarc14': 'TXT-DMARC-enabled'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc14" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -829,9 +781,7 @@ def test_dkim_guidance_tags_dmarc_15(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -849,10 +799,8 @@ def test_dkim_guidance_tags_dmarc_15(save): ) assert ( - "{'dmarc15': 'TXT-DMARC-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc15" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -898,9 +846,7 @@ def test_dkim_guidance_tags_dmarc_16(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -918,10 +864,8 @@ def test_dkim_guidance_tags_dmarc_16(save): ) assert ( - "{'dmarc16': 'SP-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc16" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -967,9 +911,7 @@ def test_dkim_guidance_tags_dmarc_17(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -987,10 +929,8 @@ def test_dkim_guidance_tags_dmarc_17(save): ) assert ( - "{'dmarc17': 'SP-none'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc17" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -1036,9 +976,7 @@ def test_dkim_guidance_tags_dmarc_18(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -1056,10 +994,8 @@ def test_dkim_guidance_tags_dmarc_18(save): ) assert ( - "{'dmarc18': 'SP-quarantine'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc18" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -1105,9 +1041,7 @@ def test_dkim_guidance_tags_dmarc_19(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -1125,10 +1059,8 @@ def test_dkim_guidance_tags_dmarc_19(save): ) assert ( - "{'dmarc19': 'SP-reject'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc19" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -1174,9 +1106,7 @@ def test_dkim_guidance_tags_dmarc_20(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -1194,10 +1124,8 @@ def test_dkim_guidance_tags_dmarc_20(save): ) assert ( - "{'dmarc20': 'PCT-none-exists'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc20" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) @@ -1243,9 +1171,7 @@ def test_dkim_guidance_tags_dmarc_21(save): edges { node { dmarc { - dmarcGuidanceTags { - value - } + dmarcGuidanceTags } } } @@ -1263,8 +1189,6 @@ def test_dkim_guidance_tags_dmarc_21(save): ) assert ( - "{'dmarc21': 'PCT-0'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ - "dmarcGuidanceTags" - ]["value"] + "dmarc21" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] ) From 7772db25da47f679e0f794dac48500e426c6dc57 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 12:03:06 -0300 Subject: [PATCH 33/39] Refactored dkim --- api/schemas/domain/email_scan/dkim.py | 106 ++++++++++++++++++ .../domain/email_scan/dkim/__init__.py | 48 -------- .../domain/email_scan/dkim/dkim_tags.py | 71 ------------ api/tests/test_dkim_guidance_tags.py | 100 +++++------------ 4 files changed, 136 insertions(+), 189 deletions(-) create mode 100644 api/schemas/domain/email_scan/dkim.py delete mode 100644 api/schemas/domain/email_scan/dkim/__init__.py delete mode 100644 api/schemas/domain/email_scan/dkim/dkim_tags.py diff --git a/api/schemas/domain/email_scan/dkim.py b/api/schemas/domain/email_scan/dkim.py new file mode 100644 index 0000000000..6b6a32a876 --- /dev/null +++ b/api/schemas/domain/email_scan/dkim.py @@ -0,0 +1,106 @@ +import graphene +from graphene_sqlalchemy import SQLAlchemyObjectType + +from models import Dkim_scans +from scalars.url import URL +from functions.get_domain import get_domain +from functions.get_timestamp import get_timestamp + + +class DKIM(SQLAlchemyObjectType): + """ + DomainKeys Identified Mail (DKIM) permits a person, role, or + organization that owns the signing domain to claim some + responsibility for a message by associating the domain with the + message. This can be an author's organization, an operational relay, + or one of their agents. + """ + + class Meta: + model = Dkim_scans + exclude_fields = ("id", "dkim_scan") + + id = graphene.ID(description="ID of the object") + domain = URL(description="The domain the scan was run on") + timestamp = graphene.DateTime(description="Time when scan was initiated") + record = graphene.String( + description="DKIM record retrieved during the scan of the " "given domain " + ) + key_length = graphene.String(description="Length of DKIM public key") + dkim_guidance_tags = graphene.List( + lambda: graphene.String, description="Key tags found during scan" + ) + + def resolve_domain(self, info): + get_domain(self, info) + + def resolve_timestamp(self, info): + get_timestamp(self, info) + + def resolve_record(self, info): + return self.dkim_scan["dkim"]["txt_record"] + + def resolve_key_length(self, info): + return self.dkim_scan["dkim"]["key_size"] + + def resolve_dkim_guidance_tags(self, info): + tags = [] + + if self.dkim_scan.get("dkim", {}).get("missing", None) is not None: + tags.append("dkim2") + return tags + + # Get Key Size, and Key Type + key_size = self.dkim_scan.get("dkim", {}).get("key_size", None) + key_type = self.dkim_scan.get("dkim", {}).get("key_type", None) + + if key_size is None: + tags.append("dkim9") + elif key_type is None: + tags.append("dkim9") + else: + if key_size >= 4096 and key_type == "rsa": + tags.append("dkim8") + elif key_size >= 2048 and key_type == "rsa": + tags.append("dkim7") + elif key_size == 1024 and key_type == "rsa": + tags.append("dkim6") + elif key_size < 1024 and key_type == "rsa": + tags.append("dkim5") + else: + tags.append("dkim9") + + # Update Recommended + key_invalid = self.dkim_scan.get("dkim", {}).get("update-recommend", + None) + + if key_invalid: + tags.append("dkim10") + + # Invalid Crypto + invalid_crypto = ( + self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) + ) + # if k != rsa + if invalid_crypto != "rsa": + tags.append("dkim11") + + # Dkim value invalid + # Check if v, k, and p exist in txt_record + v_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("v", + None) + k_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", + None) + p_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("p", + None) + + if v_tag is None and k_tag is None and p_tag is None: + if "dkim12" not in tags: + tags.append("dkim12") + + # Testing Enabled + t_enabled = self.dkim_scan.get("dkim", {}).get("t_value") + if t_enabled is not None: + tags.append("dkim13") + + return tags diff --git a/api/schemas/domain/email_scan/dkim/__init__.py b/api/schemas/domain/email_scan/dkim/__init__.py deleted file mode 100644 index 48d25cd91a..0000000000 --- a/api/schemas/domain/email_scan/dkim/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Dkim_scans -from scalars.url import URL -from functions.get_domain import get_domain -from functions.get_timestamp import get_timestamp -from schemas.domain.email_scan.dkim.dkim_tags import DkimTags - - -class DKIM(SQLAlchemyObjectType): - """ - DomainKeys Identified Mail (DKIM) permits a person, role, or - organization that owns the signing domain to claim some - responsibility for a message by associating the domain with the - message. This can be an author's organization, an operational relay, - or one of their agents. - """ - - class Meta: - model = Dkim_scans - exclude_fields = ("id", "dkim_scan") - - id = graphene.ID(description="ID of the object") - domain = URL(description="The domain the scan was run on") - timestamp = graphene.DateTime(description="Time when scan was initiated") - record = graphene.String( - description="DKIM record retrieved during the scan of the " "given domain " - ) - key_length = graphene.String(description="Length of DKIM public key") - dkim_guidance_tags = graphene.Field( - lambda: DkimTags, description="Key tags found during scan" - ) - - def resolve_domain(self, info): - get_domain(self, info) - - def resolve_timestamp(self, info): - get_timestamp(self, info) - - def resolve_record(self, info): - return self.dkim_scan["dkim"]["txt_record"] - - def resolve_key_length(self, info): - return self.dkim_scan["dkim"]["key_size"] - - def resolve_dkim_guidance_tags(self, info): - return DkimTags.get_query(info).first() diff --git a/api/schemas/domain/email_scan/dkim/dkim_tags.py b/api/schemas/domain/email_scan/dkim/dkim_tags.py deleted file mode 100644 index b67db58419..0000000000 --- a/api/schemas/domain/email_scan/dkim/dkim_tags.py +++ /dev/null @@ -1,71 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Dkim_scans - - -class DkimTags(SQLAlchemyObjectType): - class Meta: - model = Dkim_scans - exclude_fields = ("id", "dkim_scan") - - value = graphene.List( - lambda: graphene.String, description="Key tags found during scan", - ) - - def resolve_value(self: Dkim_scans, info): - tags = [] - - if self.dkim_scan.get("dkim", {}).get("missing", None) is not None: - tags.append({"dkim2": "DKIM-missing"}) - return tags - - # Get Key Size, and Key Type - key_size = self.dkim_scan.get("dkim", {}).get("key_size", None) - key_type = self.dkim_scan.get("dkim", {}).get("key_type", None) - - if key_size is None: - tags.append({"dkim9": "P-invalid"}) - elif key_type is None: - tags.append({"dkim9": "P-invalid"}) - else: - if key_size >= 4096 and key_type == "rsa": - tags.append({"dkim8": "P-4096"}) - elif key_size >= 2048 and key_type == "rsa": - tags.append({"dkim7": "P-2048"}) - elif key_size == 1024 and key_type == "rsa": - tags.append({"dkim6": "P-1024"}) - elif key_size < 1024 and key_type == "rsa": - tags.append({"dkim5": "P-sub1024"}) - else: - tags.append({"dkim9": "P-invalid"}) - - # Update Recommended - key_invalid = self.dkim_scan.get("dkim", {}).get("update-recommend", None) - - if key_invalid: - tags.append({"dkim10": "P-update-recommended"}) - - # Invalid Crypto - invalid_crypto = ( - self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) - ) - # if k != rsa - if invalid_crypto != "rsa": - tags.append({"dkim11": "DKIM-invalid-crypto"}) - - # Dkim value invalid - # Check if v, k, and p exist in txt_record - v_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("v", None) - k_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) - p_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("p", None) - - if v_tag is None and k_tag is None and p_tag is None: - tags.append({"dkim12": "DKIM-value-invalid"}) - - # Testing Enabled - t_enabled = self.dkim_scan.get("dkim", {}).get("t_value") - if t_enabled is not None: - tags.append({"dkim13": "T-enabled"}) - - return tags diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py index 211c073a8c..cb86f8f04e 100644 --- a/api/tests/test_dkim_guidance_tags.py +++ b/api/tests/test_dkim_guidance_tags.py @@ -56,9 +56,7 @@ def test_dkim_guidance_tags_dkim_2(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -76,10 +74,8 @@ def test_dkim_guidance_tags_dkim_2(save): ) assert ( - "{'dkim2': 'DKIM-missing'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim2" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -125,9 +121,7 @@ def test_dkim_guidance_tags_dkim_5(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -145,10 +139,8 @@ def test_dkim_guidance_tags_dkim_5(save): ) assert ( - "{'dkim5': 'P-sub1024'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim5" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -194,9 +186,7 @@ def test_dkim_guidance_tags_dkim_6(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -214,10 +204,8 @@ def test_dkim_guidance_tags_dkim_6(save): ) assert ( - "{'dkim6': 'P-1024'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim6" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -263,9 +251,7 @@ def test_dkim_guidance_tags_dkim_7(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -283,10 +269,8 @@ def test_dkim_guidance_tags_dkim_7(save): ) assert ( - "{'dkim7': 'P-2048'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim7" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -332,9 +316,7 @@ def test_dkim_guidance_tags_dkim_8(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -352,10 +334,8 @@ def test_dkim_guidance_tags_dkim_8(save): ) assert ( - "{'dkim8': 'P-4096'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim8" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -401,9 +381,7 @@ def test_dkim_guidance_tags_dkim_9(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -421,10 +399,8 @@ def test_dkim_guidance_tags_dkim_9(save): ) assert ( - "{'dkim9': 'P-invalid'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim9" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -470,9 +446,7 @@ def test_dkim_guidance_tags_dkim_10(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -490,10 +464,8 @@ def test_dkim_guidance_tags_dkim_10(save): ) assert ( - "{'dkim10': 'P-update-recommended'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim10" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -539,9 +511,7 @@ def test_dkim_guidance_tags_dkim_11(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -559,10 +529,8 @@ def test_dkim_guidance_tags_dkim_11(save): ) assert ( - "{'dkim11': 'DKIM-invalid-crypto'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim11" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -608,9 +576,7 @@ def test_dkim_guidance_tags_dkim_12(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -628,10 +594,8 @@ def test_dkim_guidance_tags_dkim_12(save): ) assert ( - "{'dkim12': 'DKIM-value-invalid'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim12" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) @@ -677,9 +641,7 @@ def test_dkim_guidance_tags_dkim_13(save): edges { node { dkim { - dkimGuidanceTags { - value - } + dkimGuidanceTags } } } @@ -697,8 +659,6 @@ def test_dkim_guidance_tags_dkim_13(save): ) assert ( - "{'dkim13': 'T-enabled'}" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ - "dkimGuidanceTags" - ]["value"] + "dkim13" + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] ) From 20303804fe92d53749c865b91146245912e09ab4 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 13:24:31 -0300 Subject: [PATCH 34/39] Refactored https --- api/Pipfile.lock | 30 ++-- api/schemas/domain/www_scan/https.py | 138 ++++++++++++++++++ api/schemas/domain/www_scan/https/__init__.py | 51 ------- .../domain/www_scan/https/https_tags.py | 94 ------------ api/tests/test_https_guidance_tags.py | 130 +++++------------ 5 files changed, 192 insertions(+), 251 deletions(-) create mode 100644 api/schemas/domain/www_scan/https.py delete mode 100644 api/schemas/domain/www_scan/https/__init__.py delete mode 100644 api/schemas/domain/www_scan/https/https_tags.py diff --git a/api/Pipfile.lock b/api/Pipfile.lock index 21200c2b6e..ec23b8281c 100644 --- a/api/Pipfile.lock +++ b/api/Pipfile.lock @@ -62,10 +62,10 @@ }, "certifi": { "hashes": [ - "sha256:1d987a998c75633c40847cc966fcf5904906c920a7f17ef374f5aa4282abd304", - "sha256:51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519" + "sha256:5ad7e9a056d25ffa5082862e36f119f7f7cec6457fa07ee2f8c339814b80c9b1", + "sha256:9cd41137dc19af6a5e03b630eefe7d1f458d964d406342dd3edf625839b944cc" ], - "version": "==2020.4.5.1" + "version": "==2020.4.5.2" }, "cffi": { "hashes": [ @@ -527,10 +527,10 @@ }, "wcwidth": { "hashes": [ - "sha256:980fbf4f3c196c0f329cdcd1e84c554d6a211f18e252e525a0cf4223154a41d6", - "sha256:edbc2b718b4db6cdf393eefe3a420183947d6aa312505ce6754516f458ff8830" + "sha256:79375666b9954d4a1a10739315816324c3e73110af9d0e102d906fdb0aec009f", + "sha256:8c6b5b6ee1360b842645f336d9e5d68c55817c26d3050f46b235ef2bc650e48f" ], - "version": "==0.2.3" + "version": "==0.2.4" }, "werkzeug": { "hashes": [ @@ -543,10 +543,10 @@ "develop": { "astroid": { "hashes": [ - "sha256:4c17cea3e592c21b6e222f673868961bad77e1f985cb1694ed077475a89229c1", - "sha256:d8506842a3faf734b81599c8b98dcc423de863adcc1999248480b18bd31a0f38" + "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703", + "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386" ], - "version": "==2.4.1" + "version": "==2.4.2" }, "attrs": { "hashes": [ @@ -688,11 +688,11 @@ }, "pylint": { "hashes": [ - "sha256:b95e31850f3af163c2283ed40432f053acbc8fc6eba6a069cb518d9dbf71848c", - "sha256:dd506acce0427e9e08fb87274bcaa953d38b50a58207170dbf5b36cf3e16957b" + "sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc", + "sha256:d0ece7d223fe422088b0e8f13fa0a1e8eb745ebffcb8ed53d3e95394b6101a1c" ], "index": "pypi", - "version": "==2.5.2" + "version": "==2.5.3" }, "pyparsing": { "hashes": [ @@ -767,10 +767,10 @@ }, "wcwidth": { "hashes": [ - "sha256:980fbf4f3c196c0f329cdcd1e84c554d6a211f18e252e525a0cf4223154a41d6", - "sha256:edbc2b718b4db6cdf393eefe3a420183947d6aa312505ce6754516f458ff8830" + "sha256:79375666b9954d4a1a10739315816324c3e73110af9d0e102d906fdb0aec009f", + "sha256:8c6b5b6ee1360b842645f336d9e5d68c55817c26d3050f46b235ef2bc650e48f" ], - "version": "==0.2.3" + "version": "==0.2.4" }, "wrapt": { "hashes": [ diff --git a/api/schemas/domain/www_scan/https.py b/api/schemas/domain/www_scan/https.py new file mode 100644 index 0000000000..6439304d0d --- /dev/null +++ b/api/schemas/domain/www_scan/https.py @@ -0,0 +1,138 @@ +import graphene +from graphene_sqlalchemy import SQLAlchemyObjectType + +from models import Https_scans +from scalars.url import URL +from functions.get_domain import get_domain +from functions.get_timestamp import get_timestamp + + +class HTTPS(SQLAlchemyObjectType): + """ + Http Scan Object + """ + class Meta: + model = Https_scans + exclude_fields = ("id", "https_scan") + + id = graphene.ID(description="The ID of the object") + domain = URL(description="The domain the scan was run on") + timestamp = graphene.DateTime(description="The time the scan was initiated") + implementation = graphene.String( + description="" + ) + enforced = graphene.String( + description="" + ) + hsts = graphene.String( + description="" + ) + hsts_age = graphene.String( + description="" + ) + preloaded = graphene.String( + description="" + ) + https_guidance_tags = graphene.List( + lambda: graphene.String, + description="" + ) + + def resole_domain(self: Https_scans, info): + return get_domain(self, info) + + def resolve_timestamp(self: Https_scans, info): + return get_timestamp(self, info) + + def resolve_implementation(self: Https_scans, info): + return self.https_scan["https"]["implementation"] + + def resolve_enforced(self: Https_scans, info): + return self.https_scan["https"]["enforced"] + + def resolve_hsts(self: Https_scans, info): + return self.https_scan["https"]["hsts"] + + def resolve_hsts_age(self: Https_scans, info): + return self.https_scan["https"]["hsts_age"] + + def resolve_preloaded(self: Https_scans, info): + return self.https_scan["https"]["preloaded"] + + def resolve_https_guidance_tags(self: Https_scans, info): + tags = [] + + if self.https_scan.get("https", {}).get("missing", None) is not None: + tags.append("https2") + return tags + + # Implementation + implementation = self.https_scan.get("https", {}).get("implementation", None) + + if isinstance(implementation, str): + implementation = implementation.lower() + + if implementation == "downgrades https": + tags.append("https3") + elif implementation == "bad chain": + tags.append("https4") + elif implementation == "bad hostname": + tags.append("https5") + + # Enforced + enforced = self.https_scan.get("https", {}).get("enforced", None) + + if isinstance(enforced, str): + enforced = enforced.lower() + + if enforced == "moderate": + tags.append("https8") + elif enforced == "weak": + tags.append("https7") + elif enforced == "not enforced": + tags.append("https6") + + # HSTS + hsts = self.https_scan.get("https", {}).get("hsts", None) + + if isinstance(hsts, str): + hsts = hsts.lower() + + if hsts == "hsts max age too short": + tags.append("https10") + elif hsts == "no hsts": + tags.append("https9") + + # HSTS Age + hsts_age = self.https_scan.get("https", {}).get("hsts_age", None) + + if hsts_age is not None: + if hsts_age < 31536000 and "https" not in tags: + tags.append("https10") + + # Preload Status + preload_status = self.https_scan.get("https", {}).get("preload_status", None) + + if isinstance(preload_status, str): + preload_status = preload_status.lower() + + if preload_status == "hsts preload ready": + tags.append("https11") + elif preload_status == "hsts not preloaded": + tags.append("https12") + + # Expired Cert + expired_cert = self.https_scan.get("https", {}).get("expired_cert", None) + + if expired_cert: + tags.append("https13") + + # Self Signed Cert + self_signed_cert = self.https_scan.get("https", {}).get( + "self_signed_cert", None + ) + + if self_signed_cert: + tags.append("https14") + + return tags diff --git a/api/schemas/domain/www_scan/https/__init__.py b/api/schemas/domain/www_scan/https/__init__.py deleted file mode 100644 index 8ddd3d2c24..0000000000 --- a/api/schemas/domain/www_scan/https/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Https_scans -from scalars.url import URL -from functions.get_domain import get_domain -from functions.get_timestamp import get_timestamp -from schemas.domain.www_scan.https.https_tags import HTTPSTags - - -class HTTPS(SQLAlchemyObjectType): - """ - Http Scan Object - """ - class Meta: - model = Https_scans - exclude_fields = ("id", "https_scan") - - id = graphene.ID(description="The ID of the object") - domain = URL(description="The domain the scan was run on") - timestamp = graphene.DateTime(description="The time the scan was initiated") - implementation = graphene.String() - enforced = graphene.String() - hsts = graphene.String() - hsts_age = graphene.String() - preloaded = graphene.String() - https_guidance_tags = graphene.Field(lambda: HTTPSTags) - - def resole_domain(self: Https_scans, info): - return get_domain(self, info) - - def resolve_timestamp(self: Https_scans, info): - return get_timestamp(self, info) - - def resolve_implementation(self: Https_scans, info): - return self.https_scan["https"]["implementation"] - - def resolve_enforced(self: Https_scans, info): - return self.https_scan["https"]["enforced"] - - def resolve_hsts(self: Https_scans, info): - return self.https_scan["https"]["hsts"] - - def resolve_hsts_age(self: Https_scans, info): - return self.https_scan["https"]["hsts_age"] - - def resolve_preloaded(self: Https_scans, info): - return self.https_scan["https"]["preloaded"] - - def resolve_https_guidance_tags(self: Https_scans, info): - return HTTPS.get_query(info).first() diff --git a/api/schemas/domain/www_scan/https/https_tags.py b/api/schemas/domain/www_scan/https/https_tags.py deleted file mode 100644 index d4859f9862..0000000000 --- a/api/schemas/domain/www_scan/https/https_tags.py +++ /dev/null @@ -1,94 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Https_scans - - -class HTTPSTags(SQLAlchemyObjectType): - """ - Guidance tags for HTTPS scan results - """ - - class Meta: - model = Https_scans - exclude_fields = ("id", "https_scan") - - value = graphene.List(lambda: graphene.String, description="") - - def resolve_value(self: Https_scans, info): - tags = [] - - if self.https_scan.get("https", {}).get("missing", None) is not None: - tags.append({"https2": "HTTPS-missing"}) - return tags - - # Implementation - implementation = self.https_scan.get("https", {}).get("implementation", None) - - if isinstance(implementation, str): - implementation = implementation.lower() - - if implementation == "downgrades https": - tags.append({"https3": "HTTPS-downgraded"}) - elif implementation == "bad chain": - tags.append({"https4": "HTTPS-bad-chain"}) - elif implementation == "bad hostname": - tags.append({"https5": "HTTPS-bad-hostname"}) - - # Enforced - enforced = self.https_scan.get("https", {}).get("enforced", None) - - if isinstance(enforced, str): - enforced = enforced.lower() - - if enforced == "moderate": - tags.append({"https8": "HTTPS-moderately-enforced"}) - elif enforced == "weak": - tags.append({"https7": "HTTPS-weakly-enforced"}) - elif enforced == "not enforced": - tags.append({"https6": "HTTPS-not-enforced"}) - - # HSTS - hsts = self.https_scan.get("https", {}).get("hsts", None) - - if isinstance(hsts, str): - hsts = hsts.lower() - - if hsts == "hsts max age too short": - tags.append({"https:10": "HSTS-short-age"}) - elif hsts == "no hsts": - tags.append({"https9": "HSTS-missing"}) - - # HSTS Age - hsts_age = self.https_scan.get("https", {}).get("hsts_age", None) - - if hsts_age is not None: - if hsts_age < 31536000: - tags.append({"https10": "HSTS-short-age"}) - - # Preload Status - preload_status = self.https_scan.get("https", {}).get("preload_status", None) - - if isinstance(preload_status, str): - preload_status = preload_status.lower() - - if preload_status == "hsts preload ready": - tags.append({"https11": "HSTS-preload-ready"}) - elif preload_status == "hsts not preloaded": - tags.append({"https12": "HSTS-not-preloaded"}) - - # Expired Cert - expired_cert = self.https_scan.get("https", {}).get("expired_cert", None) - - if expired_cert: - tags.append({"https13": "HTTPS-certificate-expired"}) - - # Self Signed Cert - self_signed_cert = self.https_scan.get("https", {}).get( - "self_signed_cert", None - ) - - if self_signed_cert: - tags.append({"https14": "HTTPS-certificate-self-signed"}) - - return tags diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index 096478078f..c56cdbefef 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -56,9 +56,7 @@ def test_dkim_guidance_tags_https_2(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -76,10 +74,8 @@ def test_dkim_guidance_tags_https_2(save): ) assert ( - "{'https2': 'HTTPS-missing'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https2" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -125,9 +121,7 @@ def test_dkim_guidance_tags_https_3(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -145,10 +139,8 @@ def test_dkim_guidance_tags_https_3(save): ) assert ( - "{'https3': 'HTTPS-downgraded'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https3" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -194,9 +186,7 @@ def test_dkim_guidance_tags_https_4(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -214,10 +204,8 @@ def test_dkim_guidance_tags_https_4(save): ) assert ( - "{'https4': 'HTTPS-bad-chain'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https4" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -263,9 +251,7 @@ def test_dkim_guidance_tags_https_5(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -283,10 +269,8 @@ def test_dkim_guidance_tags_https_5(save): ) assert ( - "{'https5': 'HTTPS-bad-hostname'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https5" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -332,9 +316,7 @@ def test_dkim_guidance_tags_https_6(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -352,10 +334,8 @@ def test_dkim_guidance_tags_https_6(save): ) assert ( - "{'https6': 'HTTPS-not-enforced'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https6" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -401,9 +381,7 @@ def test_dkim_guidance_tags_https_7(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -421,10 +399,8 @@ def test_dkim_guidance_tags_https_7(save): ) assert ( - "{'https7': 'HTTPS-weakly-enforced'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https7" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -470,9 +446,7 @@ def test_dkim_guidance_tags_https_8(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -490,10 +464,8 @@ def test_dkim_guidance_tags_https_8(save): ) assert ( - "{'https8': 'HTTPS-moderately-enforced'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https8" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -539,9 +511,7 @@ def test_dkim_guidance_tags_https_9(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -559,10 +529,8 @@ def test_dkim_guidance_tags_https_9(save): ) assert ( - "{'https9': 'HSTS-missing'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https9" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -608,9 +576,7 @@ def test_dkim_guidance_tags_https_10(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -628,10 +594,8 @@ def test_dkim_guidance_tags_https_10(save): ) assert ( - "{'https:10': 'HSTS-short-age'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https10" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -677,9 +641,7 @@ def test_dkim_guidance_tags_https_11(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -697,10 +659,8 @@ def test_dkim_guidance_tags_https_11(save): ) assert ( - "{'https11': 'HSTS-preload-ready'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https11" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -746,9 +706,7 @@ def test_dkim_guidance_tags_https_12(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -766,10 +724,8 @@ def test_dkim_guidance_tags_https_12(save): ) assert ( - "{'https12': 'HSTS-not-preloaded'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https12" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -815,9 +771,7 @@ def test_dkim_guidance_tags_https_13(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -835,10 +789,8 @@ def test_dkim_guidance_tags_https_13(save): ) assert ( - "{'https13': 'HTTPS-certificate-expired'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https13" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) @@ -884,9 +836,7 @@ def test_dkim_guidance_tags_https_14(save): edges { node { https { - httpsGuidanceTags { - value - } + httpsGuidanceTags } } } @@ -904,8 +854,6 @@ def test_dkim_guidance_tags_https_14(save): ) assert ( - "{'https14': 'HTTPS-certificate-self-signed'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ - "httpsGuidanceTags" - ]["value"] + "https14" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] ) From 38a1db01f159d895430b5f9eb4d9a6a5db428339 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 13:28:46 -0300 Subject: [PATCH 35/39] Refactored ssl --- .../www_scan/{ssl/ssl_tags.py => ssl.py} | 34 ++++++--- api/schemas/domain/www_scan/ssl/__init__.py | 32 --------- api/tests/test_ssl_guidance_tags.py | 70 ++++++------------- 3 files changed, 44 insertions(+), 92 deletions(-) rename api/schemas/domain/www_scan/{ssl/ssl_tags.py => ssl.py} (63%) delete mode 100644 api/schemas/domain/www_scan/ssl/__init__.py diff --git a/api/schemas/domain/www_scan/ssl/ssl_tags.py b/api/schemas/domain/www_scan/ssl.py similarity index 63% rename from api/schemas/domain/www_scan/ssl/ssl_tags.py rename to api/schemas/domain/www_scan/ssl.py index 5e2017844d..2614fa0193 100644 --- a/api/schemas/domain/www_scan/ssl/ssl_tags.py +++ b/api/schemas/domain/www_scan/ssl.py @@ -2,35 +2,47 @@ from graphene_sqlalchemy import SQLAlchemyObjectType from models import Ssl_scans +from scalars.url import URL +from functions.get_domain import get_domain +from functions.get_timestamp import get_timestamp -class SSLTags(SQLAlchemyObjectType): +class SSL(SQLAlchemyObjectType): """ - Guidance tags for HTTPS scan results + SSL Scan Object """ class Meta: model = Ssl_scans exclude_fields = ("id", "ssl_scan") - value = graphene.List(lambda: graphene.String, description="") + id = graphene.ID() + domain = URL() + timestamp = graphene.DateTime() + ssl_guidance_tags = graphene.List(lambda: graphene.String) - def resolve_value(self: Ssl_scans, info): + def resolve_domain(self, info): + return get_domain(self, info) + + def resolve_timestamp(self, info): + return get_timestamp(self, info) + + def resolve_ssl_guidance_tags(self: Ssl_scans, info): tags = [] if self.ssl_scan.get("ssl", {}).get("missing", None) is not None: - tags.append({"ssl2": "SSL-missing"}) + tags.append("ssl2") return tags # SSL-rc4 ssl_rc4 = self.ssl_scan.get("ssl", {}).get("rc4", None) if ssl_rc4 is True: - tags.append({"ssl3": "SSL-rc4"}) + tags.append("ssl3") # SSL-3des ssl_3des = self.ssl_scan.get("ssl", {}).get("3des", None) if ssl_3des is True: - tags.append({"ssl4": "SSL-3des"}) + tags.append("ssl4") # Signature Algorithm signature_algorithm = self.ssl_scan.get("ssl", {}).get( @@ -45,15 +57,15 @@ def resolve_value(self: Ssl_scans, info): or signature_algorithm == "sha-384" or signature_algorithm == "aead" ): - tags.append({"ssl5": "SSL-acceptable-certificate"}) + tags.append("ssl5") else: - tags.append({"ssl6": "SSL-invalid-cipher"}) + tags.append("ssl6") # Heartbleed heart_bleed = self.ssl_scan.get("ssl", {}).get("heartbleed", None) if heart_bleed is True: - tags.append({"ssl7": "Vulnerability-heartbleed"}) + tags.append("ssl7") # openssl ccs injection openssl_ccs_injection = self.ssl_scan.get("ssl", {}).get( @@ -61,6 +73,6 @@ def resolve_value(self: Ssl_scans, info): ) if openssl_ccs_injection is True: - tags.append({"ssl8": "Vulnerability-ccs-injection"}) + tags.append("ssl8") return tags diff --git a/api/schemas/domain/www_scan/ssl/__init__.py b/api/schemas/domain/www_scan/ssl/__init__.py deleted file mode 100644 index 8628581316..0000000000 --- a/api/schemas/domain/www_scan/ssl/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -import graphene -from graphene_sqlalchemy import SQLAlchemyObjectType - -from models import Ssl_scans -from scalars.url import URL -from functions.get_domain import get_domain -from functions.get_timestamp import get_timestamp -from schemas.domain.www_scan.ssl.ssl_tags import SSLTags - - -class SSL(SQLAlchemyObjectType): - """ - SSL Scan Object - """ - - class Meta: - model = Ssl_scans - exclude_fields = ("id", "ssl_scan") - - id = graphene.ID() - domain = URL() - timestamp = graphene.DateTime() - ssl_guidance_tags = graphene.Field(lambda: SSLTags) - - def resolve_domain(self, info): - return get_domain(self, info) - - def resolve_timestamp(self, info): - return get_timestamp(self, info) - - def resolve_ssl_guidance_tags(self: Ssl_scans, info): - return SSLTags.get_query(info).first() diff --git a/api/tests/test_ssl_guidance_tags.py b/api/tests/test_ssl_guidance_tags.py index 1660ed24ce..63f6abf5a4 100644 --- a/api/tests/test_ssl_guidance_tags.py +++ b/api/tests/test_ssl_guidance_tags.py @@ -56,9 +56,7 @@ def test_spf_guidance_tags_spf_2(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -76,10 +74,8 @@ def test_spf_guidance_tags_spf_2(save): ) assert ( - "{'ssl2': 'SSL-missing'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl2" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -125,9 +121,7 @@ def test_spf_guidance_tags_spf_3(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -145,10 +139,8 @@ def test_spf_guidance_tags_spf_3(save): ) assert ( - "{'ssl3': 'SSL-rc4'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl3" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -194,9 +186,7 @@ def test_spf_guidance_tags_spf_4(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -214,10 +204,8 @@ def test_spf_guidance_tags_spf_4(save): ) assert ( - "{'ssl4': 'SSL-3des'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl4" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -263,9 +251,7 @@ def test_spf_guidance_tags_spf_5(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -283,10 +269,8 @@ def test_spf_guidance_tags_spf_5(save): ) assert ( - "{'ssl5': 'SSL-acceptable-certificate'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl5" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -332,9 +316,7 @@ def test_spf_guidance_tags_spf_6(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -352,10 +334,8 @@ def test_spf_guidance_tags_spf_6(save): ) assert ( - "{'ssl6': 'SSL-invalid-cipher'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl6" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -401,9 +381,7 @@ def test_spf_guidance_tags_spf_7(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -421,10 +399,8 @@ def test_spf_guidance_tags_spf_7(save): ) assert ( - "{'ssl7': 'Vulnerability-heartbleed'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl7" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) @@ -470,9 +446,7 @@ def test_spf_guidance_tags_spf_8(save): edges { node { ssl { - sslGuidanceTags { - value - } + sslGuidanceTags } } } @@ -490,8 +464,6 @@ def test_spf_guidance_tags_spf_8(save): ) assert ( - "{'ssl8': 'Vulnerability-ccs-injection'}" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ - "sslGuidanceTags" - ]["value"] + "ssl8" + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] ) From 1cbb14ee90d3cb8ff30db3c6f1059fc4c1b75830 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 13:32:01 -0300 Subject: [PATCH 36/39] Black re-ran on files --- api/schemas/domain/email_scan/dkim.py | 12 ++-- api/schemas/domain/email_scan/spf.py | 17 ++---- api/schemas/domain/www_scan/https.py | 26 +++------ api/tests/test_dkim_guidance_tags.py | 40 ++++++++++---- api/tests/test_dmarc_guidance_tags.py | 80 ++++++++++++++++++++------- api/tests/test_https_guidance_tags.py | 52 ++++++++++++----- api/tests/test_spf_guidance_tags.py | 52 ++++++++++++----- api/tests/test_ssl_guidance_tags.py | 28 +++++++--- 8 files changed, 206 insertions(+), 101 deletions(-) diff --git a/api/schemas/domain/email_scan/dkim.py b/api/schemas/domain/email_scan/dkim.py index 6b6a32a876..b17f4097ed 100644 --- a/api/schemas/domain/email_scan/dkim.py +++ b/api/schemas/domain/email_scan/dkim.py @@ -71,8 +71,7 @@ def resolve_dkim_guidance_tags(self, info): tags.append("dkim9") # Update Recommended - key_invalid = self.dkim_scan.get("dkim", {}).get("update-recommend", - None) + key_invalid = self.dkim_scan.get("dkim", {}).get("update-recommend", None) if key_invalid: tags.append("dkim10") @@ -87,12 +86,9 @@ def resolve_dkim_guidance_tags(self, info): # Dkim value invalid # Check if v, k, and p exist in txt_record - v_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("v", - None) - k_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", - None) - p_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("p", - None) + v_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("v", None) + k_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("k", None) + p_tag = self.dkim_scan.get("dkim", {}).get("txt_record", {}).get("p", None) if v_tag is None and k_tag is None and p_tag is None: if "dkim12" not in tags: diff --git a/api/schemas/domain/email_scan/spf.py b/api/schemas/domain/email_scan/spf.py index 62bc2924ed..eb846aa490 100644 --- a/api/schemas/domain/email_scan/spf.py +++ b/api/schemas/domain/email_scan/spf.py @@ -77,15 +77,13 @@ def resolve_spf_guidance_tags(self: Spf_scans, info): ).first() if dkim_orm is not None: - dkim_record = dkim_orm.dkim_scan.get("dkim", {}).get("txt_record", - None) + dkim_record = dkim_orm.dkim_scan.get("dkim", {}).get("txt_record", None) for key in dkim_record: if key == "a" or key == "include": tags.append("spf3") if dmarc_orm is not None: - dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}).get("record", - None) + dmarc_record = dmarc_orm.dmarc_scan.get("dmarc", {}).get("record", None) if ( ("include:" in dmarc_record) or ("a:" in dmarc_record) @@ -95,10 +93,8 @@ def resolve_spf_guidance_tags(self: Spf_scans, info): tags.append("spf3") # Check all tag - all_tag = self.spf_scan.get("spf", {}).get("parsed", {}).get("all", - None) - record_all_tag = self.spf_scan.get("spf", {}).get("record", "")[ - -4:].lower() + all_tag = self.spf_scan.get("spf", {}).get("parsed", {}).get("all", None) + record_all_tag = self.spf_scan.get("spf", {}).get("record", "")[-4:].lower() if isinstance(all_tag, str): all_tag = all_tag.lower() @@ -127,7 +123,7 @@ def resolve_spf_guidance_tags(self: Spf_scans, info): match_pos = [match.start() for match in matches] for pos in match_pos: - if record[pos + 1: 1] == "" and not "spf11" in tags: + if record[pos + 1 : 1] == "" and not "spf11" in tags: tags.append("spf11") # Look up limit check @@ -136,8 +132,7 @@ def resolve_spf_guidance_tags(self: Spf_scans, info): tags.append("spf12") # Check for missing include - include = self.spf_scan.get("spf", {}).get("parsed", {}).get("include", - None) + include = self.spf_scan.get("spf", {}).get("parsed", {}).get("include", None) record = self.spf_scan.get("spf", {}).get("record", None) if include is not None and record is not None: diff --git a/api/schemas/domain/www_scan/https.py b/api/schemas/domain/www_scan/https.py index 6439304d0d..fb3ba4afbe 100644 --- a/api/schemas/domain/www_scan/https.py +++ b/api/schemas/domain/www_scan/https.py @@ -11,6 +11,7 @@ class HTTPS(SQLAlchemyObjectType): """ Http Scan Object """ + class Meta: model = Https_scans exclude_fields = ("id", "https_scan") @@ -18,25 +19,12 @@ class Meta: id = graphene.ID(description="The ID of the object") domain = URL(description="The domain the scan was run on") timestamp = graphene.DateTime(description="The time the scan was initiated") - implementation = graphene.String( - description="" - ) - enforced = graphene.String( - description="" - ) - hsts = graphene.String( - description="" - ) - hsts_age = graphene.String( - description="" - ) - preloaded = graphene.String( - description="" - ) - https_guidance_tags = graphene.List( - lambda: graphene.String, - description="" - ) + implementation = graphene.String(description="") + enforced = graphene.String(description="") + hsts = graphene.String(description="") + hsts_age = graphene.String(description="") + preloaded = graphene.String(description="") + https_guidance_tags = graphene.List(lambda: graphene.String, description="") def resole_domain(self: Https_scans, info): return get_domain(self, info) diff --git a/api/tests/test_dkim_guidance_tags.py b/api/tests/test_dkim_guidance_tags.py index cb86f8f04e..f3f8269bf3 100644 --- a/api/tests/test_dkim_guidance_tags.py +++ b/api/tests/test_dkim_guidance_tags.py @@ -75,7 +75,9 @@ def test_dkim_guidance_tags_dkim_2(save): assert ( "dkim2" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -140,7 +142,9 @@ def test_dkim_guidance_tags_dkim_5(save): assert ( "dkim5" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -205,7 +209,9 @@ def test_dkim_guidance_tags_dkim_6(save): assert ( "dkim6" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -270,7 +276,9 @@ def test_dkim_guidance_tags_dkim_7(save): assert ( "dkim7" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -335,7 +343,9 @@ def test_dkim_guidance_tags_dkim_8(save): assert ( "dkim8" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -400,7 +410,9 @@ def test_dkim_guidance_tags_dkim_9(save): assert ( "dkim9" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -465,7 +477,9 @@ def test_dkim_guidance_tags_dkim_10(save): assert ( "dkim10" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -530,7 +544,9 @@ def test_dkim_guidance_tags_dkim_11(save): assert ( "dkim11" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -595,7 +611,9 @@ def test_dkim_guidance_tags_dkim_12(save): assert ( "dkim12" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) @@ -660,5 +678,7 @@ def test_dkim_guidance_tags_dkim_13(save): assert ( "dkim13" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"]["dkimGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dkim"][ + "dkimGuidanceTags" + ] ) diff --git a/api/tests/test_dmarc_guidance_tags.py b/api/tests/test_dmarc_guidance_tags.py index abcc07dba0..0906fe4677 100644 --- a/api/tests/test_dmarc_guidance_tags.py +++ b/api/tests/test_dmarc_guidance_tags.py @@ -75,7 +75,9 @@ def test_dkim_guidance_tags_dmarc_2(save): assert ( "dmarc2" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -140,7 +142,9 @@ def test_dkim_guidance_tags_dmarc_3(save): assert ( "dmarc3" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -205,7 +209,9 @@ def test_dkim_guidance_tags_dmarc_4(save): assert ( "dmarc4" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -270,7 +276,9 @@ def test_dkim_guidance_tags_dmarc_5(save): assert ( "dmarc5" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -335,7 +343,9 @@ def test_dkim_guidance_tags_dmarc_6(save): assert ( "dmarc6" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -400,7 +410,9 @@ def test_dkim_guidance_tags_dmarc_7(save): assert ( "dmarc7" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -465,7 +477,9 @@ def test_dkim_guidance_tags_dmarc_8(save): assert ( "dmarc8" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -530,7 +544,9 @@ def test_dkim_guidance_tags_dmarc_9(save): assert ( "dmarc9" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -596,11 +612,15 @@ def test_dkim_guidance_tags_dmarc_10_dmarc_11(save): assert ( "dmarc10" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) assert ( "dmarc11" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -666,11 +686,15 @@ def test_dkim_guidance_tags_dmarc_12_dmarc_13(save): assert ( "dmarc12" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) assert ( "dmarc13" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -735,7 +759,9 @@ def test_dkim_guidance_tags_dmarc_14(save): assert ( "dmarc14" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -800,7 +826,9 @@ def test_dkim_guidance_tags_dmarc_15(save): assert ( "dmarc15" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -865,7 +893,9 @@ def test_dkim_guidance_tags_dmarc_16(save): assert ( "dmarc16" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -930,7 +960,9 @@ def test_dkim_guidance_tags_dmarc_17(save): assert ( "dmarc17" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -995,7 +1027,9 @@ def test_dkim_guidance_tags_dmarc_18(save): assert ( "dmarc18" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -1060,7 +1094,9 @@ def test_dkim_guidance_tags_dmarc_19(save): assert ( "dmarc19" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -1125,7 +1161,9 @@ def test_dkim_guidance_tags_dmarc_20(save): assert ( "dmarc20" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) @@ -1190,5 +1228,7 @@ def test_dkim_guidance_tags_dmarc_21(save): assert ( "dmarc21" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"]["dmarcGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["dmarc"][ + "dmarcGuidanceTags" + ] ) diff --git a/api/tests/test_https_guidance_tags.py b/api/tests/test_https_guidance_tags.py index c56cdbefef..5007c66aa8 100644 --- a/api/tests/test_https_guidance_tags.py +++ b/api/tests/test_https_guidance_tags.py @@ -75,7 +75,9 @@ def test_dkim_guidance_tags_https_2(save): assert ( "https2" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -140,7 +142,9 @@ def test_dkim_guidance_tags_https_3(save): assert ( "https3" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -205,7 +209,9 @@ def test_dkim_guidance_tags_https_4(save): assert ( "https4" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -270,7 +276,9 @@ def test_dkim_guidance_tags_https_5(save): assert ( "https5" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -335,7 +343,9 @@ def test_dkim_guidance_tags_https_6(save): assert ( "https6" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -400,7 +410,9 @@ def test_dkim_guidance_tags_https_7(save): assert ( "https7" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -465,7 +477,9 @@ def test_dkim_guidance_tags_https_8(save): assert ( "https8" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -530,7 +544,9 @@ def test_dkim_guidance_tags_https_9(save): assert ( "https9" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -595,7 +611,9 @@ def test_dkim_guidance_tags_https_10(save): assert ( "https10" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -660,7 +678,9 @@ def test_dkim_guidance_tags_https_11(save): assert ( "https11" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -725,7 +745,9 @@ def test_dkim_guidance_tags_https_12(save): assert ( "https12" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -790,7 +812,9 @@ def test_dkim_guidance_tags_https_13(save): assert ( "https13" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) @@ -855,5 +879,7 @@ def test_dkim_guidance_tags_https_14(save): assert ( "https14" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"]["httpsGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["https"][ + "httpsGuidanceTags" + ] ) diff --git a/api/tests/test_spf_guidance_tags.py b/api/tests/test_spf_guidance_tags.py index 7e50aadfdd..8ebe017cc7 100644 --- a/api/tests/test_spf_guidance_tags.py +++ b/api/tests/test_spf_guidance_tags.py @@ -84,7 +84,9 @@ def test_spf_guidance_tags_spf_2(save): assert ( "spf2" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -158,7 +160,9 @@ def test_spf_guidance_tags_spf_3_dkim(save): assert ( "spf3" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -232,7 +236,9 @@ def test_spf_guidance_tags_spf_3_dmarc(save): assert ( "spf3" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -297,7 +303,9 @@ def test_spf_guidance_tags_spf_4(save): assert ( "spf4" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -362,7 +370,9 @@ def test_spf_guidance_tags_spf_5(save): assert ( "spf5" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -427,7 +437,9 @@ def test_spf_guidance_tags_spf_6(save): assert ( "spf6" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -492,7 +504,9 @@ def test_spf_guidance_tags_spf_7(save): assert ( "spf7" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -557,7 +571,9 @@ def test_spf_guidance_tags_spf_8(save): assert ( "spf8" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -622,7 +638,9 @@ def test_spf_guidance_tags_spf_9(save): assert ( "spf9" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -687,7 +705,9 @@ def test_spf_guidance_tags_spf_10(save): assert ( "spf10" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -752,7 +772,9 @@ def test_spf_guidance_tags_spf_11(save): assert ( "spf11" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -817,7 +839,9 @@ def test_spf_guidance_tags_spf_12(save): assert ( "spf12" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) @@ -882,5 +906,7 @@ def test_spf_guidance_tags_spf_13(save): assert ( "spf13" - in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"]["spfGuidanceTags"] + in result["data"]["domain"][0]["email"]["edges"][0]["node"]["spf"][ + "spfGuidanceTags" + ] ) diff --git a/api/tests/test_ssl_guidance_tags.py b/api/tests/test_ssl_guidance_tags.py index 63f6abf5a4..2702f8389c 100644 --- a/api/tests/test_ssl_guidance_tags.py +++ b/api/tests/test_ssl_guidance_tags.py @@ -75,7 +75,9 @@ def test_spf_guidance_tags_spf_2(save): assert ( "ssl2" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -140,7 +142,9 @@ def test_spf_guidance_tags_spf_3(save): assert ( "ssl3" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -205,7 +209,9 @@ def test_spf_guidance_tags_spf_4(save): assert ( "ssl4" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -270,7 +276,9 @@ def test_spf_guidance_tags_spf_5(save): assert ( "ssl5" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -335,7 +343,9 @@ def test_spf_guidance_tags_spf_6(save): assert ( "ssl6" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -400,7 +410,9 @@ def test_spf_guidance_tags_spf_7(save): assert ( "ssl7" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) @@ -465,5 +477,7 @@ def test_spf_guidance_tags_spf_8(save): assert ( "ssl8" - in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"]["sslGuidanceTags"] + in result["data"]["domain"][0]["www"]["edges"][0]["node"]["ssl"][ + "sslGuidanceTags" + ] ) From 38d0c866eb0be8acc2796437ee3958e329014710 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 13:45:44 -0300 Subject: [PATCH 37/39] Updated descriptions --- api/schemas/domain/__init__.py | 1 + api/schemas/domain/email_scan/dmarc.py | 2 +- api/schemas/domain/email_scan/spf.py | 2 +- api/schemas/domain/www_scan/https.py | 27 ++++++++++++++++++++------ api/schemas/domain/www_scan/ssl.py | 10 ++++++---- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/api/schemas/domain/__init__.py b/api/schemas/domain/__init__.py index 882d17cd91..a805b85406 100644 --- a/api/schemas/domain/__init__.py +++ b/api/schemas/domain/__init__.py @@ -25,6 +25,7 @@ class Meta: "organization", "scans", "slug", + "dmarc_reports" ) url = URL(description="The domain the scan was run on") diff --git a/api/schemas/domain/email_scan/dmarc.py b/api/schemas/domain/email_scan/dmarc.py index f7d2a4c73d..bacf1f9ba0 100644 --- a/api/schemas/domain/email_scan/dmarc.py +++ b/api/schemas/domain/email_scan/dmarc.py @@ -43,7 +43,7 @@ class Meta: "to be applied. " ) dmarc_guidance_tags = graphene.List( - lambda: graphene.String, description="Key tags found during DMARC Scan" + lambda: graphene.String, description="Key tags found during scan" ) def resolve_domain(self: Dmarc_scans, info): diff --git a/api/schemas/domain/email_scan/spf.py b/api/schemas/domain/email_scan/spf.py index eb846aa490..096e1f6b3b 100644 --- a/api/schemas/domain/email_scan/spf.py +++ b/api/schemas/domain/email_scan/spf.py @@ -37,7 +37,7 @@ class Meta: "not a match to your SPF record. " ) spf_guidance_tags = graphene.List( - lambda: graphene.String, description="Key tags found during SPF scan" + lambda: graphene.String, description="Key tags found during scan" ) def resolve_domain(self: Spf_scans, info): diff --git a/api/schemas/domain/www_scan/https.py b/api/schemas/domain/www_scan/https.py index fb3ba4afbe..2234bb726c 100644 --- a/api/schemas/domain/www_scan/https.py +++ b/api/schemas/domain/www_scan/https.py @@ -19,12 +19,27 @@ class Meta: id = graphene.ID(description="The ID of the object") domain = URL(description="The domain the scan was run on") timestamp = graphene.DateTime(description="The time the scan was initiated") - implementation = graphene.String(description="") - enforced = graphene.String(description="") - hsts = graphene.String(description="") - hsts_age = graphene.String(description="") - preloaded = graphene.String(description="") - https_guidance_tags = graphene.List(lambda: graphene.String, description="") + implementation = graphene.String( + description="State of the HTTPS implementation on the server and any " + "issues therein" + ) + enforced = graphene.String( + description="Degree to which HTTPS is enforced on the server based " + "on behaviour" + ) + hsts = graphene.String( + description="Presence and completeness of HSTS implementation" + ) + hsts_age = graphene.String( + description="Denotes how long the domain should only be accessed using " "HTTPS" + ) + preloaded = graphene.String( + description="Denotes whether the domain has been submitted and " + "included within HSTS preload list" + ) + https_guidance_tags = graphene.List( + lambda: graphene.String, description="Key tags found during scan" + ) def resole_domain(self: Https_scans, info): return get_domain(self, info) diff --git a/api/schemas/domain/www_scan/ssl.py b/api/schemas/domain/www_scan/ssl.py index 2614fa0193..5245906c80 100644 --- a/api/schemas/domain/www_scan/ssl.py +++ b/api/schemas/domain/www_scan/ssl.py @@ -16,10 +16,12 @@ class Meta: model = Ssl_scans exclude_fields = ("id", "ssl_scan") - id = graphene.ID() - domain = URL() - timestamp = graphene.DateTime() - ssl_guidance_tags = graphene.List(lambda: graphene.String) + id = graphene.ID(description="The ID of the object") + domain = URL(description="The domain the scan was run on") + timestamp = graphene.DateTime(description="The time the scan was initiated") + ssl_guidance_tags = graphene.List( + lambda: graphene.String, descriptions="Key tags found during scan" + ) def resolve_domain(self, info): return get_domain(self, info) From 569f8211d2917fc171592b7c29c0cbcabe4b77dc Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 13:46:18 -0300 Subject: [PATCH 38/39] typo in description(s) --- api/schemas/domain/www_scan/ssl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/schemas/domain/www_scan/ssl.py b/api/schemas/domain/www_scan/ssl.py index 5245906c80..bd1d273a77 100644 --- a/api/schemas/domain/www_scan/ssl.py +++ b/api/schemas/domain/www_scan/ssl.py @@ -20,7 +20,7 @@ class Meta: domain = URL(description="The domain the scan was run on") timestamp = graphene.DateTime(description="The time the scan was initiated") ssl_guidance_tags = graphene.List( - lambda: graphene.String, descriptions="Key tags found during scan" + lambda: graphene.String, description="Key tags found during scan" ) def resolve_domain(self, info): From 19ae93ff66542d3636d2b9dcecf2e5ee2a234663 Mon Sep 17 00:00:00 2001 From: IdezHD Date: Tue, 9 Jun 2020 14:15:13 -0300 Subject: [PATCH 39/39] Updated faker --- frontend/schema.faker.graphql | 191 ++++++++++++++-------------------- 1 file changed, 79 insertions(+), 112 deletions(-) diff --git a/frontend/schema.faker.graphql b/frontend/schema.faker.graphql index 1392e8fb0c..ca0331ef6a 100644 --- a/frontend/schema.faker.graphql +++ b/frontend/schema.faker.graphql @@ -221,17 +221,7 @@ type DKIM { """ Key tags found during scan """ - dkimGuidanceTags: [DkimTags] - @examples( - values: [ - "DKIM-GC" - "DKIM-missing" - "P-1024" - "P-2048" - "P-invalid" - "T-enabled" - ] - ) + dkimGuidanceTags: [String] } """ @@ -254,13 +244,6 @@ type DkimReport { result: String } -type DkimTags { - """ - Key tags found during scan - """ - value: String -} - """ Domain-based Message Authentication, Reporting, and Conformance (DMARC) is a scalable mechanism by which a mail-originating @@ -289,6 +272,11 @@ type DMARC { """ timestamp: DateTime @fake(type: pastDate) + """ + DMARC Phase found when running scan + """ + dmarcPhase: Int + """ DMARC record retrieved during the scan of the given domain """ @@ -320,7 +308,7 @@ type DMARC { """ Key tags found during DMARC Scan """ - dmarcGuidanceTags: [DmarcTags] + dmarcGuidanceTags: [String] } """ @@ -460,29 +448,6 @@ type DmarcReportEdge { cursor: String! } -""" - -""" -type DmarcTags { - dmarcPhase: Int - - """ - Important tags retrieved during scan - """ - value: String - @examples( - values: [ - "DMARC-GC" - "DMARC-missing" - "P-missing" - "P-None" - "P-quarantine" - "CNAME-DMARC" - "RUA-none" - ] - ) -} - type Domain implements Node { organization: Organization dmarcReports( @@ -660,6 +625,7 @@ type EmailVerifyAccount { status: Boolean } +"""Http Scan Object""" type HTTPS { """ The ID of the object @@ -675,16 +641,26 @@ type HTTPS { The time the scan was initiated """ timestamp: DateTime + + """State of the HTTPS implementation on the server and any issues therein""" implementation: String + + """Degree to which HTTPS is enforced on the server based on behaviour""" enforced: String + + """Presence and completeness of HSTS implementation""" hsts: String + + """Denotes how long the domain should only be accessed using HTTPS""" hstsAge: String + + """ + Denotes whether the domain has been submitted and included within HSTS preload list + """ preloaded: String - httpsGuidanceTags: [HTTPSTags] -} -type HTTPSTags { - value: String + """Key tags found during scan""" + httpsGuidanceTags: [String] } """ @@ -1595,15 +1571,67 @@ type SPFTags { ) } +"""SSL Scan Object""" type SSL { + """The ID of the object""" id: ID - domain: URL @fake(type: domainName) - timestamp: DateTime @fake(type: pastDate) + + """The domain the scan was run on""" + domain: URL + + """The time the scan was initiated""" + timestamp: DateTime + + """Key tags found during scan""" + sslGuidanceTags: [String] } -""" -This class handles the inner nested dict given by key: 'template'. -""" +"""Object that contains the fields of each detail table""" +type TableStructure { + """IP address of sending server""" + sourceIpAddress: String + + """Domain from SMTP banner message""" + envelopeFrom: String + + """Domains used for SPF validation""" + spfDomains: String + + """Domains used for DKIM validation""" + dkimDomains: String + + """Pointer to a DKIM public key record in DNS""" + dkimSelectors: String + + """Total messages related to this record""" + totalMessages: Int + + """Geographic location of source IP address""" + countryCode: String + + """Owner of ISP for source IP address""" + ispOrg: String + + """Owner of prefix for source IP address""" + prefixOrg: String + + """Name of AS for source IP address""" + asName: String + + """Number of AS for source IP address""" + asNum: Int + + """Owner of AS for source IP address""" + asOrg: String + + """Host from reverse DNS of source IP address""" + dnsHost: String + + """Domain from reverse DNS of source IP address""" + dnsDomain: String +} + +"""This class handles the inner nested dict given by key: 'template'. """ type Template { id: String uri: String @@ -1973,64 +2001,3 @@ type YearlyDmarcReportSummary { categoryTotal: CategoryTotals } -""" -Object that contains the fields of each detail table -""" -type TableStructure { - """ - IP address of sending server - """ - sourceIpAddress: String - """ - Domain from SMTP banner message - """ - envelopeFrom: String - """ - Domains used for SPF validation - """ - spfDomains: String - """ - Domains used for DKIM validation - """ - dkimDomains: String - """ - Pointer to a DKIM public key record in DNS - """ - dkimSelectors: String - """ - Total messages related to this record - """ - totalMessages: Int - """ - Geographic location of source IP address - """ - countryCode: String - """ - Owner of ISP for source IP address - """ - ispOrg: String - """ - Owner of prefix for source IP address - """ - prefixOrg: String - """ - Name of AS for source IP address - """ - asName: String - """ - Number of AS for source IP address - """ - asNum: Int - """ - Owner of AS for source IP address - """ - asOrg: String - """ - Host from reverse DNS of source IP address - """ - dnsHost: String - """ - Domain from reverse DNS of source IP address - """ - dnsDomain: String -}