Skip to main content

Extract and parse DMARC reports/forensic feedback

Project description

Package Pylint

DMARC Parser

Public helper methods

These methods are only included for your convenience. Code is "not" part of the main library/parser but acts as a great segway to implement the parser with ease.

    from dmarc import dmarc_from_folder, dmarc_from_file

    Multi-threaded:    dmarc_from_folder(folder: str, recursive: bool, debug_level: int)
    Single-threaded:   dmarc_from_file(path: str, debug_level: int):

Public class / methods

    DmarcParser(queue_name: str, queue: Queue, debug_level: int)        # Queue is for logging and optional. 
        .read_file(path: str)
        .extract_report_from_zip(data: io.BytesIO) -> dict
        .extract_report_from_gzip(data: io.BytesIO) -> dict
        .extract_report_from_xml(data: bytes) -> dict
        .extract_report_from_eml(data: bytes) -> dict

Minimal example program

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" Main """

import argparse
import logging

from dmarc import dmarc_from_folder

def run(debug_level=logging.INFO):
    """ Main """
    dmarc_from_folder("example/private/data/", recursive=True, debug_level=debug_level)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true")
    args = parser.parse_args()
    run_args = {}
    if args.verbose:
        run_args["debug_level"] = logging.DEBUG
    run(**run_args)

Install instructions

# Production
pip install .

# Development
## Setup
python -m venv env
.\env\Scripts\activate

## Install
pip install .

## Test
python -m pytest

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmarcparser-0.1.tar.gz (24.8 kB view hashes)

Uploaded Source

Built Distribution

dmarcparser-0.1-py3-none-any.whl (26.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page