Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e39bdfc
Updated Dmarc Tags
Jun 5, 2020
bfa0b74
small fix to the dmarc tags
Jun 5, 2020
3b81f82
fix isintance checks
Jun 5, 2020
7a33b5d
Spf tags re-factor
Jun 5, 2020
49a14cb
Dkim tags re-factor
Jun 5, 2020
d5e47ae
HTTPS tags are now actually here, again ...
Jun 5, 2020
6b2030e
Removed comment
Jun 5, 2020
c8f38db
First iteration of ssl tags
Jun 5, 2020
510fef9
Updated ssl tags
Jun 8, 2020
1e10df7
Update dkim tags
Jun 8, 2020
652c6d4
Update dmarc, and spf tags
Jun 8, 2020
97519fe
Created mock data for guidance tags tests
Jun 8, 2020
be40677
Moved all mock data into separate dicts
Jun 8, 2020
aae91c0
Fix missing checks
Jun 8, 2020
780576e
switched guidance tag fields to fields
Jun 8, 2020
53703b7
Fixes to dkim tags, and testing for the majority of dkim tags
Jun 8, 2020
25c7dd9
Remove print debug statement
Jun 8, 2020
4d28146
Fixed guidance tag generation, and implemented tests
Jun 8, 2020
14cf440
Trimmed down data for dkim, and dmarc tests
Jun 8, 2020
85aa266
Updated dmarc and spf tags
Jun 9, 2020
435c04f
Updated dmarc tags, and added tests for dmarc14, and dmarc15
Jun 9, 2020
24cd81d
Updated https, ssl objects
Jun 9, 2020
132c517
Fix www scan objects
Jun 9, 2020
07e630c
HTTPS guidance tags fixed, and tested
Jun 9, 2020
2c91ed5
Updated error out messages
Jun 9, 2020
c1ae5d4
Removed unused import
Jun 9, 2020
722787d
Updated spf tags, and completed testing
Jun 9, 2020
508dfe0
Updated ssl tags, and completed tests for ssl
Jun 9, 2020
9da5d0f
spf3 guidance tag implemented
Jun 9, 2020
3522676
Black ran on files
Jun 9, 2020
1fe887a
Refactored spf
Jun 9, 2020
bd4544d
Refactored dmarc
Jun 9, 2020
7772db2
Refactored dkim
Jun 9, 2020
2030380
Refactored https
Jun 9, 2020
38a1db0
Refactored ssl
Jun 9, 2020
1cbb14e
Black re-ran on files
Jun 9, 2020
38d0c86
Updated descriptions
Jun 9, 2020
569f821
typo in description(s)
Jun 9, 2020
19ae93f
Updated faker
Jun 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions api/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/schemas/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Meta:
"organization",
"scans",
"slug",
"dmarc_reports"
)

url = URL(description="The domain the scan was run on")
Expand Down
12 changes: 6 additions & 6 deletions api/schemas/domain/email_scan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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):
Expand Down
102 changes: 102 additions & 0 deletions api/schemas/domain/email_scan/dkim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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
48 changes: 0 additions & 48 deletions api/schemas/domain/email_scan/dkim/__init__.py

This file was deleted.

36 changes: 0 additions & 36 deletions api/schemas/domain/email_scan/dkim/dkim_tags.py

This file was deleted.

Loading