An open API service indexing awesome lists of open source software.

https://github.com/trailofbits/dmarc

Ruby DMARC Parser
https://github.com/trailofbits/dmarc

dmarc dns

Last synced: 3 months ago
JSON representation

Ruby DMARC Parser

Awesome Lists containing this project

README

          

# DMARC

[![CI](https://github.com/trailofbits/dmarc/actions/workflows/ci.yml/badge.svg)](https://github.com/trailofbits/dmarc/actions/workflows/ci.yml)
[![Gem Version](https://badge.fury.io/rb/dmarc.svg)](http://badge.fury.io/rb/dmarc)
[![YARD Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/dmarc)

[DMARC] is a technical specification intended to solve a couple of long-standing
email authentication problems. DMARC policies are described in DMARC "records,"
which are stored as DNS TXT records on a subdomain. This library contains a
parser for DMARC records.

## Example

Parse a DMARC record:

require 'dmarc'

record = DMARC::Record.parse("v=DMARC1; p=reject; rua=mailto:d@rua.agari.com; ruf=mailto:d@ruf.agari.com; fo=1")

record.v
# => :DMARC1

record.adkim
# => :r

record.aspf
# => :r

record.fo
# => ["0"]

record.p
# => :reject

record.pct
# => 100

record.rf
# => :afrf

record.ri
# => 86400

record.rua
# => [#, @size=nil, @unit=nil>]

record.ruf
# => [#, @size=nil, @unit=nil>]

record.sp
# => :reject

Query the DMARC record for a domain:

record = DMARC::Record.query('twitter.com')
# => #, @size=nil, @unit=nil>], @ruf=[#, @size=nil, @unit=nil>], @sp=nil>

## Requirements

* [parslet] ~> 1.5

## Install

$ gem install dmarc

## Testing

To run the RSpec tests:

$ rake spec

To test the parser against the Alexa Top 500:

$ rake spec:gauntlet

## License

See the {file:LICENSE.txt} file.

[DMARC]: https://tools.ietf.org/html/rfc7489
[parslet]: http://kschiess.github.io/parslet/