parsedmarc.parser
๐
InvalidAggregateReport
๐
Bases: InvalidDMARCReport
Raised when an invalid DMARC aggregate report is encountered
InvalidDMARCReport
๐
Bases: ParserError
Raised when an invalid DMARC report is encountered
InvalidForensicReport
๐
Bases: InvalidDMARCReport
Raised when an invalid DMARC forensic report is encountered
ParserError
๐
Bases: RuntimeError
Raised whenever the parser fails for some reason
ReportParser
๐
ReportParser(
offline: bool = False,
ip_db_path: str | None = None,
nameservers: list[str] | None = None,
dns_timeout: float = 2.0,
strip_attachment_payloads: bool = False,
)
Report Parser
Parses reports from messages and files.
Can handled the following types of reports:
- DMARC
- Aggregate
- Forensic
New in 9.0.
Args: offline: ip_db_path: nameservers: dns_timeout: strip_attachment_payloads: Remove attachment payloads from forensic report results
parse_aggregate_report_file
๐
parse_aggregate_report_file(
source: bytes | str | BinaryIO,
keep_alive: Callable | None = None,
) -> AggregateReport
Parse a file at the given path, a file-like object. or bytes as an aggregate DMARC report
PARAMETER | DESCRIPTION |
---|---|
source |
A path to a file, a file like object, or bytes |
keep_alive |
Keep alive function
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AggregateReport
|
The parsed DMARC aggregate report |
parse_aggregate_report_xml
๐
parse_aggregate_report_xml(
xml: str, keep_alive: Callable | None = None
) -> AggregateReport
Parses a DMARC XML report string and returns an AggregateReport
PARAMETER | DESCRIPTION |
---|---|
xml |
A string of DMARC aggregate report XML
TYPE:
|
keep_alive |
Keep alive function
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AggregateReport
|
The parsed aggregate DMARC report |
parse_forensic_report
๐
parse_forensic_report(
feedback_report: str, sample: str, msg_date: datetime
) -> ForensicReport
Converts a DMARC forensic report and sample to a ForensicReport
PARAMETER | DESCRIPTION |
---|---|
feedback_report |
A message's feedback report as a string
TYPE:
|
sample |
The RFC 822 headers or RFC 822 message sample
TYPE:
|
msg_date |
The message's date header
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ForensicReport
|
A parsed report and sample |