dkim_parse 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.rspec +1 -0
- data/.travis.yml +16 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +23 -0
- data/bin/dkim +30 -0
- data/dkim_parse.gemspec +24 -0
- data/lib/dkim_parse/version.rb +3 -0
- data/lib/dkim_parse.rb +27 -0
- data/spec/dkim_parse_spec.rb +36 -0
- data/spec/spec_helper.rb +11 -0
- metadata +89 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 04456cd9e24e379e17f7200728a4b18a1a4b3744
|
|
4
|
+
data.tar.gz: e311913cfc2a4f8a6160a3211b04559e11eab7a8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7ba2b7ec2022277d4c14df556a8245aeacf89dfeb5560e7f43f7d336d58ee1cc6c0853d0660f085ea8f52cdd425b8e9213cf144eb109ff62dcd12408ae757c77
|
|
7
|
+
data.tar.gz: e86957e60fc477117fde585988ac573f7df406f8a0c80c9ea04c9aaa43c09f2c377fa28d2d6976f9159ac2d3a4310f5bf6033240e12624bc83a6ef7e1a6a4bba
|
data/.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<<<<<<< HEAD
|
|
2
|
+
/.bundle/
|
|
3
|
+
/.yardoc
|
|
4
|
+
/Gemfile.lock
|
|
5
|
+
/_yardoc/
|
|
6
|
+
/coverage/
|
|
7
|
+
/doc/
|
|
8
|
+
/pkg/
|
|
9
|
+
/spec/reports/
|
|
10
|
+
/tmp/
|
|
11
|
+
*.bundle
|
|
12
|
+
*.so
|
|
13
|
+
*.o
|
|
14
|
+
*.a
|
|
15
|
+
mkmf.log
|
|
16
|
+
=======
|
|
17
|
+
*.gem
|
|
18
|
+
*.rbc
|
|
19
|
+
/.config
|
|
20
|
+
/coverage/
|
|
21
|
+
/InstalledFiles
|
|
22
|
+
/pkg/
|
|
23
|
+
/spec/reports/
|
|
24
|
+
/test/tmp/
|
|
25
|
+
/test/version_tmp/
|
|
26
|
+
/tmp/
|
|
27
|
+
|
|
28
|
+
## Specific to RubyMotion:
|
|
29
|
+
.dat*
|
|
30
|
+
.repl_history
|
|
31
|
+
build/
|
|
32
|
+
|
|
33
|
+
## Documentation cache and generated files:
|
|
34
|
+
/.yardoc/
|
|
35
|
+
/_yardoc/
|
|
36
|
+
/doc/
|
|
37
|
+
/rdoc/
|
|
38
|
+
|
|
39
|
+
## Environment normalisation:
|
|
40
|
+
/.bundle/
|
|
41
|
+
/lib/bundler/man/
|
|
42
|
+
|
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
45
|
+
# Gemfile.lock
|
|
46
|
+
# .ruby-version
|
|
47
|
+
# .ruby-gemset
|
|
48
|
+
|
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
50
|
+
.rvmrc
|
|
51
|
+
>>>>>>> 62c17ee30b1a7d25ef12fab39fd6c2de0bcbadbc
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour --format documentation
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 1.9.3
|
|
4
|
+
- 2.0.0
|
|
5
|
+
- 2.1.1
|
|
6
|
+
- 2.1.2
|
|
7
|
+
- ruby-head
|
|
8
|
+
- jruby-19mode
|
|
9
|
+
- jruby-head
|
|
10
|
+
- rbx-2
|
|
11
|
+
matrix:
|
|
12
|
+
allow_failures:
|
|
13
|
+
- rvm: rbx-2
|
|
14
|
+
addons:
|
|
15
|
+
code_climate:
|
|
16
|
+
repo_token: 2dbc736868e35e0966df5712c4ac70df10e86a3e8d0d85878a3cbd57b7b086b3
|
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in dkim_parse.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'rake'
|
|
8
|
+
gem 'rspec', '~> 3.0'
|
|
9
|
+
|
|
10
|
+
gem 'yard', '~> 0.8'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :test do
|
|
14
|
+
gem 'codeclimate-test-reporter', require: nil
|
|
15
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 nickespo
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# dkim_parse
|
|
2
|
+
|
|
3
|
+
[](https://codeclimate.com/github/trailofbits/dkim_parse) [](https://travis-ci.org/trailofbits/dkim_parse)
|
|
4
|
+
[](https://codeclimate.com/github/trailofbits/dkim_parse)
|
|
5
|
+
|
|
6
|
+
The `dkim_parse` library searches the dkim records for a host. We assume the host uses standard dkim 'selectors', and also check if they use their own 'selector'.
|
|
7
|
+
|
|
8
|
+
## Examples
|
|
9
|
+
|
|
10
|
+
###CLI
|
|
11
|
+
___
|
|
12
|
+
-use a single domain
|
|
13
|
+
|
|
14
|
+
dkim google.com
|
|
15
|
+
____________________________
|
|
16
|
+
DKIM record search for google.com
|
|
17
|
+
- using selectors: ["default", "dkim", "google"]
|
|
18
|
+
- no DKIM record found for google.com
|
|
19
|
+
____________________________
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
-or a bunch in a row
|
|
23
|
+
|
|
24
|
+
dkim trailofbits.com facebook.com yahoo.com
|
|
25
|
+
____________________________
|
|
26
|
+
DKIM record search for trailofbits.com
|
|
27
|
+
- using selectors: ["default", "dkim", "google", "trailofbits"]
|
|
28
|
+
- found DKIM record for trailofbits.com at trailofbits._domainkey.trailofbits.com:
|
|
29
|
+
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwe04g1hSR55ACcRiLAg0MoEiY5BBviJHJHq/d9r6o+F50fa1TrNNulwKXaST+WCEcW6D2KZ+dt9JvgB9ApIEAFCzHRXhawga0GsfDkOllvpXgT95IPcnYrSkM+rJSbaqHh+YI5sV9sKnvzZDVmB7l5gU3yD74aDmjs9wSg8RC5wIDAQAB
|
|
30
|
+
____________________________
|
|
31
|
+
|
|
32
|
+
____________________________
|
|
33
|
+
DKIM record search for facebook.com
|
|
34
|
+
- using selectors: ["default", "dkim", "google", "facebook"]
|
|
35
|
+
- found DKIM record for facebook.com at default._domainkey.facebook.com:
|
|
36
|
+
t=y; k=rsa; p=MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhALkZ4wTn2SQ3EW0vVBExi8izmZZnjZH8JIY5Y964jzDORZku43o6ooFq6HLMjBxmcDYOrJFRdcsKDWtI0Be/uLfc/rClXuyEbcENXfadg77HHv35BI85RNy4TKeai3hxoQIDAQAB;
|
|
37
|
+
____________________________
|
|
38
|
+
|
|
39
|
+
____________________________
|
|
40
|
+
DKIM record search for yahoo.com
|
|
41
|
+
- using selectors: ["default", "dkim", "google", "yahoo"]
|
|
42
|
+
- no DKIM record found for yahoo.com
|
|
43
|
+
____________________________
|
|
44
|
+
|
|
45
|
+
###In a project
|
|
46
|
+
___
|
|
47
|
+
|
|
48
|
+
require 'dkim_parse'
|
|
49
|
+
|
|
50
|
+
DkimParse.check_host('twitter.com')
|
|
51
|
+
- using selectors: ["default", "dkim", "google", "twitter"]
|
|
52
|
+
=> {:record=>"v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrZ6zwKHLkoNpHNyPGwGd8wZoNZOk5buOf8wJwfkSZsNllZs4jTNFQLy6v4Ok9qd46NdeRZWnTAY+lmAAV1nfH6ulBjiRHsdymijqKy/VMZ9Njjdy/+FPnJSm3+tG9Id7zgLxacA1Yis/18V3TCfvJrHAR/a77Dxd65c96UvqP3QIDAQAB", :record_path=>"dkim._domainkey.twitter.com"}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
rake install
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
See the {file:LICENSE.txt} file.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'bundler/setup'
|
|
6
|
+
rescue LoadError => e
|
|
7
|
+
warn e.message
|
|
8
|
+
warn "Run `gem install bundler` to install Bundler."
|
|
9
|
+
exit -1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'rake'
|
|
13
|
+
require 'bundler/gem_tasks'
|
|
14
|
+
|
|
15
|
+
require 'rspec/core/rake_task'
|
|
16
|
+
RSpec::Core::RakeTask.new
|
|
17
|
+
|
|
18
|
+
task :test => :spec
|
|
19
|
+
task :default => :spec
|
|
20
|
+
|
|
21
|
+
require 'yard'
|
|
22
|
+
YARD::Rake::YardocTask.new
|
|
23
|
+
task :doc => :yard
|
data/bin/dkim
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'dkim_parse'
|
|
4
|
+
require 'resolv'
|
|
5
|
+
|
|
6
|
+
unless ARGV[0]
|
|
7
|
+
puts "Please supply at least one host name"
|
|
8
|
+
exit
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
resolver = Resolv::DNS.new
|
|
12
|
+
ARGV.each do |arg|
|
|
13
|
+
|
|
14
|
+
puts "____________________________\n"
|
|
15
|
+
puts "DKIM record search for #{arg}"
|
|
16
|
+
begin
|
|
17
|
+
dkim = DkimParse.check_host(arg, resolver)
|
|
18
|
+
rescue
|
|
19
|
+
puts " -error: could not process input :#{arg}"
|
|
20
|
+
puts "____________________________\n\n"
|
|
21
|
+
next
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if dkim
|
|
25
|
+
puts " - found DKIM record for #{arg} at #{dkim[:record_path]}:\n #{dkim[:record]}"
|
|
26
|
+
else
|
|
27
|
+
puts " - no DKIM record found for #{arg}"
|
|
28
|
+
end
|
|
29
|
+
puts "____________________________\n\n"
|
|
30
|
+
end
|
data/dkim_parse.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'dkim_parse/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "dkim_parse"
|
|
8
|
+
gem.version = DkimParse::VERSION
|
|
9
|
+
gem.authors = ["nicktitle"]
|
|
10
|
+
gem.email = ["nick.esposito@trailofbits.com"]
|
|
11
|
+
gem.summary = %q{DKIM Retriever and Parser}
|
|
12
|
+
gem.description = %q{Search and retrieve DKIM records for any number of hosts}
|
|
13
|
+
gem.homepage = "https://github.com/trailofbits/dkim_parse#readme"
|
|
14
|
+
gem.license = "MIT"
|
|
15
|
+
|
|
16
|
+
gem.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
gem.executables = ['dkim']
|
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
gem.require_paths = ["lib"]
|
|
20
|
+
gem.required_ruby_version = '>= 1.9.1'
|
|
21
|
+
|
|
22
|
+
gem.add_development_dependency "bundler", "~> 1.6"
|
|
23
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
|
24
|
+
end
|
data/lib/dkim_parse.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "dkim_parse/version"
|
|
2
|
+
require 'resolv'
|
|
3
|
+
|
|
4
|
+
module DkimParse
|
|
5
|
+
|
|
6
|
+
def self.check_host(host, resolver=Resolv::DNS.new)
|
|
7
|
+
begin
|
|
8
|
+
host_without_tld = host[0...host.rindex('.')]
|
|
9
|
+
rescue
|
|
10
|
+
raise StandardError.new('host'), "invalid hostname"
|
|
11
|
+
end
|
|
12
|
+
defaults = %W[default dkim google #{host_without_tld}]
|
|
13
|
+
defaults.uniq!
|
|
14
|
+
puts " - using selectors: #{defaults}"
|
|
15
|
+
dkim = nil
|
|
16
|
+
defaults.each do |selector|
|
|
17
|
+
record_path = "#{selector}._domainkey.#{host.downcase}"
|
|
18
|
+
begin
|
|
19
|
+
dkim = resolver.getresource(record_path, Resolv::DNS::Resource::IN::TXT).strings.join
|
|
20
|
+
dkim = {:record =>dkim, :record_path=>record_path}
|
|
21
|
+
break
|
|
22
|
+
rescue Resolv::ResolvError
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
dkim
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dkim_parse'
|
|
3
|
+
|
|
4
|
+
describe DkimParse do
|
|
5
|
+
describe "dkim" do
|
|
6
|
+
context "when given a domain which we know to have a DKIM record" do
|
|
7
|
+
let(:domain) { 'trailofbits.com' }
|
|
8
|
+
|
|
9
|
+
it "should return a hash containing the DKIM record and path where it was found" do
|
|
10
|
+
dkim = DkimParse.check_host(domain)
|
|
11
|
+
|
|
12
|
+
expect(dkim).to be_kind_of(Hash)
|
|
13
|
+
expect(dkim[:record_path]).to eq("trailofbits._domainkey.trailofbits.com")
|
|
14
|
+
puts " - record path: #{dkim[:record_path]}"
|
|
15
|
+
puts " - record: #{dkim[:record]}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "when given a domain which does not have a DKIM record" do
|
|
20
|
+
let(:domain) { 'fsho.trailofbits.com' }
|
|
21
|
+
|
|
22
|
+
it "should return nil" do
|
|
23
|
+
dkim = DkimParse.check_host(domain)
|
|
24
|
+
expect(dkim).to eq(nil)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "when given a bad domain" do
|
|
29
|
+
it "should raise an error explaining that the domain was malformed" do
|
|
30
|
+
expect {
|
|
31
|
+
DkimParse.check_host('qwerty')
|
|
32
|
+
}.to raise_error
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: dkim_parse
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- nicktitle
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: Search and retrieve DKIM records for any number of hosts
|
|
42
|
+
email:
|
|
43
|
+
- nick.esposito@trailofbits.com
|
|
44
|
+
executables:
|
|
45
|
+
- dkim
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- .gitignore
|
|
50
|
+
- .rspec
|
|
51
|
+
- .travis.yml
|
|
52
|
+
- Gemfile
|
|
53
|
+
- LICENSE.txt
|
|
54
|
+
- README.md
|
|
55
|
+
- Rakefile
|
|
56
|
+
- bin/dkim
|
|
57
|
+
- dkim_parse.gemspec
|
|
58
|
+
- lib/dkim_parse.rb
|
|
59
|
+
- lib/dkim_parse/version.rb
|
|
60
|
+
- spec/dkim_parse_spec.rb
|
|
61
|
+
- spec/spec_helper.rb
|
|
62
|
+
homepage: https://github.com/trailofbits/dkim_parse#readme
|
|
63
|
+
licenses:
|
|
64
|
+
- MIT
|
|
65
|
+
metadata: {}
|
|
66
|
+
post_install_message:
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - '>='
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 1.9.1
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - '>='
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
requirements: []
|
|
81
|
+
rubyforge_project:
|
|
82
|
+
rubygems_version: 2.2.2
|
|
83
|
+
signing_key:
|
|
84
|
+
specification_version: 4
|
|
85
|
+
summary: DKIM Retriever and Parser
|
|
86
|
+
test_files:
|
|
87
|
+
- spec/dkim_parse_spec.rb
|
|
88
|
+
- spec/spec_helper.rb
|
|
89
|
+
has_rdoc:
|