Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstrings to Octopoes models #4038

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
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: 30 additions & 0 deletions octopoes/octopoes/models/ooi/email_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@


class DNSSPFRecord(OOI):
"""Returns the DNS SPF record.

Functions:
natural_keys: returns property of the class.
format_reference_human_readable: returns the title text for objects on the object details page.
Comment on lines +15 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  • This isn't necessary to document here. If we want to document them, then this should be placed in the base OOI class
  • Replace (also in the other changes) "Returns" with "Represents"
Suggested change
Functions:
natural_keys: returns property of the class.
format_reference_human_readable: returns the title text for objects on the object details page.

"""

object_type: Literal["DNSSPFRecord"] = "DNSSPFRecord"
value: str
ttl: int | None = None
Expand All @@ -32,6 +39,10 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class MechanismQualifier(Enum):
"""Returns the SPF Mechanism Qualifiers: allow' fail, softfail or neutral
to specify how e-mail should be handled.
"""

ALLOW = "+"
FAIL = "-"
SOFTFAIL = "~"
Expand All @@ -48,11 +59,18 @@ def __str__(self):


class DNSSPFMechanism(OOI):
"""Returns the DNS SPF Mechanism

SPF Mechanisms may be: all, a, ipv4, ipv6, mx, ptr, exists or include.
"""

spf_record: Reference = ReferenceField(DNSSPFRecord, max_inherit_scan_level=1)
mechanism: str


class DNSSPFMechanismIP(DNSSPFMechanism):
"""Returns the DNS SPF Mechanism for IPs."""

object_type: Literal["DNSSPFMechanismIP"] = "DNSSPFMechanismIP"

ip: Reference = ReferenceField(IPAddress)
Expand All @@ -71,6 +89,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DNSSPFMechanismHostname(DNSSPFMechanism):
"""Returns the DNS SPF Mechanism for Hostnames."""

object_type: Literal["DNSSPFMechanismHostname"] = "DNSSPFMechanismHostname"

hostname: Reference = ReferenceField(Hostname)
Expand All @@ -89,6 +109,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DNSSPFMechanismNetBlock(DNSSPFMechanism):
"""Returns the DNS SPF Mechanism for net blocks."""

object_type: Literal["DNSSPFMechanismNetBlock"] = "DNSSPFMechanismNetBlock"

netblock: Reference = ReferenceField(NetBlock)
Expand All @@ -108,6 +130,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DMARCTXTRecord(OOI):
"""Returns the DMARC TXT record for a hostname."""

object_type: Literal["DMARCTXTRecord"] = "DMARCTXTRecord"
value: str
ttl: int | None
Expand All @@ -122,6 +146,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DKIMExists(OOI):
"""Returns the the DKIM exists object if a DKIM record was identified."""

object_type: Literal["DKIMExists"] = "DKIMExists"
hostname: Reference = ReferenceField(Hostname)

Expand All @@ -134,6 +160,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DKIMSelector(OOI):
"""Returns the DKIM Selector object if present."""

object_type: Literal["DKIMSelector"] = "DKIMSelector"
selector: str
hostname: Reference = ReferenceField(Hostname)
Expand All @@ -147,6 +175,8 @@ def format_reference_human_readable(cls, reference: Reference) -> str:


class DKIMKey(OOI):
"""Returns the value of the DKIM key."""

object_type: Literal["DKIMKey"] = "DKIMKey"
key: str
dkim_selector: Reference = ReferenceField(DKIMSelector)
Expand Down
Loading