Coder Social home page Coder Social logo

kotokaze / dmarc-email-worker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudflare/dmarc-email-worker

0.0 0.0 0.0 135 KB

DMARC reports processor using Cloudflare Workers and Email Workers

Home Page: https://blog.cloudflare.com/how-we-built-dmarc-management/

License: MIT License

TypeScript 100.00%

dmarc-email-worker's Introduction

dmarc-email-worker

A Cloudflare worker script to process incoming DMARC reports, store them, and produce analytics.

It makes use of:

More details on the blog post.

Install instructions

  1. Clone this repo
  2. Install dependencies with npm install
  3. Login to your Cloudflare account with npx wrangler login
  4. Ensure that the names of the R2 buckets used and Worker Analytics dataset are correct in wrangler.toml
  5. Run npx wrangler publish to publish the worker
  6. Configure an Email Routing rule to forward the email from a destinattion address to this worker dmarc-email-worker
  7. Add this address as RUA to your domain's DMARC record

Inspecting the data

After obtaining the account_id and token from the API Tokens page, you can run the following query to get the DMARC reports:

curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<account_id>/analytics_engine/sql' \
-H 'Authorization: Bearer <token>' \
-d 'SELECT
    timestamp,
    blob1 AS reportMetadataReportId,
    blob2 AS reportMetadataOrgName,
    toDateTime(double1) AS reportMetadataDateRangeBegin,
    toDateTime(double2) AS reportMetadataDateRangeEnd,
    blob3 AS reportMetadataError,
    blob4 AS policyPublishedDomain,
    double3 AS policyPublishedADKIM,
    double4 AS policyPublishedASPF,
    double5 AS policyPublishedP,
    double6 AS policyPublishedSP,
    double7 AS policyPublishedPct,
    blob5 AS recordRowSourceIP,
    toUInt32(double8) AS recordRowCount,
    double9 AS recordRowPolicyEvaluatedDKIM,
    double10 AS recordRowPolicyEvaluatedSPF,
    double11 AS recordRowPolicyEvaluatedDisposition,
    double12 AS recordRowPolicyEvaluatedReasonType,
    blob6 AS recordIdentifiersEnvelopeTo,
    blob7 AS recordIdentifiersHeaderFrom
FROM dmarc_reports
WHERE timestamp > NOW() - INTERVAL '\''24'\'' DAY'

dmarc-email-worker's People

Contributors

edevil avatar nelsonjsduarte avatar cf-devtools-team avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.