dmarcrpt

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Overview

Package dmarcrpt parses DMARC aggregate feedback reports.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoReport = errors.New("no dmarc aggregate report found in message")

Functions

This section is empty.

Types

type Alignment

type Alignment string

Alignment is the identifier alignment.

const (
	AlignmentAbsent Alignment = ""

	AlignmentRelaxed Alignment = "r" // Subdomains match the DMARC from-domain.
	AlignmentStrict  Alignment = "s" // Only exact from-domain match.
)

type AuthResults

type AuthResults struct {
	DKIM []DKIMAuthResult `xml:"dkim,omitempty"`
	SPF  []SPFAuthResult  `xml:"spf"`
}

type DKIMAuthResult

type DKIMAuthResult struct {
	Domain      string     `xml:"domain"`
	Selector    string     `xml:"selector,omitempty"`
	Result      DKIMResult `xml:"result"`
	HumanResult string     `xml:"human_result,omitempty"`
}

type DKIMResult

type DKIMResult string
const (
	DKIMAbsent DKIMResult = ""

	DKIMNone      DKIMResult = "none"
	DKIMPass      DKIMResult = "pass"
	DKIMFail      DKIMResult = "fail"
	DKIMPolicy    DKIMResult = "policy"
	DKIMNeutral   DKIMResult = "neutral"
	DKIMTemperror DKIMResult = "temperror"
	DKIMPermerror DKIMResult = "permerror"
)

type DMARCResult

type DMARCResult string

DMARCResult is the final validation and alignment verdict for SPF and DKIM.

const (
	DMARCAbsent DMARCResult = ""

	DMARCPass DMARCResult = "pass"
	DMARCFail DMARCResult = "fail"
)

type DateRange

type DateRange struct {
	Begin int64 `xml:"begin"`
	End   int64 `xml:"end"`
}

type Disposition

type Disposition string

Disposition is the requested action for a DMARC fail as specified in the DMARC policy in DNS.

const (
	DispositionAbsent Disposition = ""

	DispositionNone       Disposition = "none"
	DispositionQuarantine Disposition = "quarantine"
	DispositionReject     Disposition = "reject"
)

type Feedback

type Feedback struct {
	XMLName         xml.Name        `xml:"feedback" json:"-"` // todo: removing the json tag triggers bug in sherpadoc, should fix.
	Version         string          `xml:"version"`
	ReportMetadata  ReportMetadata  `xml:"report_metadata"`
	PolicyPublished PolicyPublished `xml:"policy_published"`
	Records         []ReportRecord  `xml:"record"`
}

Feedback is the top-level XML field returned.

func ParseMessageReport

func ParseMessageReport(elog *slog.Logger, r io.ReaderAt) (*Feedback, error)

ParseMessageReport parses an aggregate feedback report from a mail message. The maximum message size is 15MB, the maximum report size after decompression is 20MB.

func ParseReport

func ParseReport(r io.Reader) (*Feedback, error)

ParseReport parses an XML aggregate feedback report. The maximum report size is 20MB.

type Identifiers

type Identifiers struct {
	EnvelopeTo   string `xml:"envelope_to,omitempty"`
	EnvelopeFrom string `xml:"envelope_from"`
	HeaderFrom   string `xml:"header_from"`
}

type PolicyEvaluated

type PolicyEvaluated struct {
	Disposition Disposition            `xml:"disposition"`
	DKIM        DMARCResult            `xml:"dkim"`
	SPF         DMARCResult            `xml:"spf"`
	Reasons     []PolicyOverrideReason `xml:"reason,omitempty"`
}

type PolicyOverride

type PolicyOverride string

PolicyOverride is a reason the requested DMARC policy from the DNS record was not applied.

const (
	PolicyOverrideAbsent PolicyOverride = ""

	PolicyOverrideForwarded        PolicyOverride = "forwarded"
	PolicyOverrideSampledOut       PolicyOverride = "sampled_out"
	PolicyOverrideTrustedForwarder PolicyOverride = "trusted_forwarder"
	PolicyOverrideMailingList      PolicyOverride = "mailing_list"
	PolicyOverrideLocalPolicy      PolicyOverride = "local_policy"
	PolicyOverrideOther            PolicyOverride = "other"
)

type PolicyOverrideReason

type PolicyOverrideReason struct {
	Type    PolicyOverride `xml:"type"`
	Comment string         `xml:"comment,omitempty"`
}

type PolicyPublished

type PolicyPublished struct {
	// Domain is where DMARC record was found, not necessarily message From. Reports we
	// generate use unicode names, incoming reports may have either ASCII-only or
	// Unicode domains.
	Domain           string      `xml:"domain"`
	ADKIM            Alignment   `xml:"adkim,omitempty"`
	ASPF             Alignment   `xml:"aspf,omitempty"`
	Policy           Disposition `xml:"p"`
	SubdomainPolicy  Disposition `xml:"sp"`
	Percentage       int         `xml:"pct"`
	ReportingOptions string      `xml:"fo"`
}

PolicyPublished is the policy as found in DNS for the domain.

type ReportMetadata

type ReportMetadata struct {
	OrgName          string    `xml:"org_name"`
	Email            string    `xml:"email"`
	ExtraContactInfo string    `xml:"extra_contact_info,omitempty"`
	ReportID         string    `xml:"report_id"`
	DateRange        DateRange `xml:"date_range"`
	Errors           []string  `xml:"error,omitempty"`
}

type ReportRecord

type ReportRecord struct {
	Row         Row         `xml:"row"`
	Identifiers Identifiers `xml:"identifiers"`
	AuthResults AuthResults `xml:"auth_results"`
}

type Row

type Row struct {
	// SourceIP must match the pattern ((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}
	// (1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])|
	// ([A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}
	SourceIP        string          `xml:"source_ip"`
	Count           int             `xml:"count"`
	PolicyEvaluated PolicyEvaluated `xml:"policy_evaluated"`
}

type SPFAuthResult

type SPFAuthResult struct {
	Domain string         `xml:"domain"`
	Scope  SPFDomainScope `xml:"scope"`
	Result SPFResult      `xml:"result"`
}

type SPFDomainScope

type SPFDomainScope string
const (
	SPFDomainScopeAbsent SPFDomainScope = ""

	SPFDomainScopeHelo     SPFDomainScope = "helo"  // SMTP EHLO
	SPFDomainScopeMailFrom SPFDomainScope = "mfrom" // SMTP "MAIL FROM".
)

type SPFResult

type SPFResult string
const (
	SPFAbsent SPFResult = ""

	SPFNone      SPFResult = "none"
	SPFNeutral   SPFResult = "neutral"
	SPFPass      SPFResult = "pass"
	SPFFail      SPFResult = "fail"
	SPFSoftfail  SPFResult = "softfail"
	SPFTemperror SPFResult = "temperror"
	SPFPermerror SPFResult = "permerror"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL