opendns-dnsdb 0.1.0

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +4 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE +20 -0
  6. data/README.md +64 -0
  7. data/Rakefile +6 -0
  8. data/THANKS +1 -0
  9. data/docs/Makefile +177 -0
  10. data/docs/_themes/LICENSE +45 -0
  11. data/docs/_themes/README.rst +25 -0
  12. data/docs/_themes/flask_theme_support.py +86 -0
  13. data/docs/_themes/kr/layout.html +32 -0
  14. data/docs/_themes/kr/relations.html +19 -0
  15. data/docs/_themes/kr/static/flasky.css_t +469 -0
  16. data/docs/_themes/kr/static/small_flask.css +70 -0
  17. data/docs/_themes/kr/theme.conf +7 -0
  18. data/docs/_themes/kr_small/layout.html +22 -0
  19. data/docs/_themes/kr_small/static/flasky.css_t +287 -0
  20. data/docs/_themes/kr_small/theme.conf +10 -0
  21. data/docs/conf.py +261 -0
  22. data/docs/index.rst +101 -0
  23. data/docs/make.bat +242 -0
  24. data/docs/operations/by_ip.rst +229 -0
  25. data/docs/operations/by_name.rst +256 -0
  26. data/docs/operations/label.rst +217 -0
  27. data/docs/operations/related.rst +127 -0
  28. data/docs/operations/traffic.rst +126 -0
  29. data/lib/opendns-dnsdb.rb +5 -0
  30. data/lib/opendns-dnsdb/dnsdb.rb +58 -0
  31. data/lib/opendns-dnsdb/dnsdb/by_ip.rb +69 -0
  32. data/lib/opendns-dnsdb/dnsdb/by_name.rb +93 -0
  33. data/lib/opendns-dnsdb/dnsdb/label.rb +105 -0
  34. data/lib/opendns-dnsdb/dnsdb/related.rb +92 -0
  35. data/lib/opendns-dnsdb/dnsdb/response.rb +41 -0
  36. data/lib/opendns-dnsdb/dnsdb/rrutils.rb +11 -0
  37. data/lib/opendns-dnsdb/dnsdb/siphash.rb +94 -0
  38. data/lib/opendns-dnsdb/dnsdb/traffic.rb +80 -0
  39. data/lib/opendns-dnsdb/version.rb +5 -0
  40. data/opendns-dnsdb.gemspec +20 -0
  41. data/spec/by_ip_spec.rb +54 -0
  42. data/spec/by_name_spec.rb +88 -0
  43. data/spec/label_spec.rb +88 -0
  44. data/spec/related_spec.rb +92 -0
  45. data/spec/spec_helper.rb +5 -0
  46. data/spec/traffic_spec.rb +36 -0
  47. metadata +123 -0
@@ -0,0 +1,54 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe "by_ip" do
5
+ subject do
6
+ OpenDNS::DNSDB::new(sslcert: CERT_FILE, sslcertpasswd: CERT_PASSWD)
7
+ end
8
+
9
+ it "returns names for a nameserver" do
10
+ s = subject.names_by_nameserver_ip('208.69.39.2')
11
+ expect(s).to be_a_kind_of(Enumerable)
12
+ expect(s).not_to be_empty
13
+ end
14
+
15
+ it "returns names for multiple nameservers" do
16
+ s = subject.names_by_nameserver_ip(['208.69.39.2', '208.69.39.3'])
17
+ expect(s).to be_a_kind_of(Hash)
18
+ expect(s).not_to be_empty
19
+ s.each do |t|
20
+ expect(t).to be_a_kind_of(Enumerable)
21
+ expect(t).not_to be_empty
22
+ end
23
+ end
24
+
25
+ it "returns distinct names for multiple nameservers" do
26
+ s = subject.distinct_names_by_nameserver_ip(['208.69.39.2', '208.69.39.3'])
27
+ expect(s).to be_a_kind_of(Enumerable)
28
+ expect(s).not_to be_empty
29
+ expect(s.uniq - s).to be_empty
30
+ end
31
+
32
+ it "returns names for an ip" do
33
+ s = subject.names_by_ip('192.30.252.131')
34
+ expect(s).to be_a_kind_of(Enumerable)
35
+ expect(s).not_to be_empty
36
+ end
37
+
38
+ it "returns names for multiple ips" do
39
+ s = subject.names_by_ip(['192.30.252.131', '208.69.39.3'])
40
+ expect(s).to be_a_kind_of(Hash)
41
+ expect(s).not_to be_empty
42
+ s.each do |t|
43
+ expect(t).to be_a_kind_of(Enumerable)
44
+ expect(t).not_to be_empty
45
+ end
46
+ end
47
+
48
+ it "returns distinct names for multiple ips" do
49
+ s = subject.distinct_names_by_ip(['208.69.39.2', '208.69.39.3'])
50
+ expect(s).to be_a_kind_of(Enumerable)
51
+ expect(s).not_to be_empty
52
+ expect(s.uniq - s).to be_empty
53
+ end
54
+ end
@@ -0,0 +1,88 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe "by_name" do
5
+ subject do
6
+ OpenDNS::DNSDB::new(sslcert: CERT_FILE, sslcertpasswd: CERT_PASSWD)
7
+ end
8
+
9
+ it "returns nameservers ips for a name" do
10
+ s = subject.nameservers_ips_by_name('github.com')
11
+ expect(s).to be_a_kind_of(Enumerable)
12
+ expect(s).not_to be_empty
13
+ end
14
+
15
+ it "returns nameservers ips for multiple names" do
16
+ s = subject.nameservers_ips_by_name(['github.com', 'github.io'])
17
+ expect(s).to be_a_kind_of(Hash)
18
+ expect(s).not_to be_empty
19
+ s.each do |t|
20
+ expect(t).to be_a_kind_of(Enumerable)
21
+ expect(t).not_to be_empty
22
+ end
23
+ end
24
+
25
+ it "returns distinct nameservers ips for multiple names" do
26
+ s = subject.distinct_nameservers_ips_by_name(['github.com', 'github.io'])
27
+ expect(s).to be_a_kind_of(Enumerable)
28
+ expect(s).not_to be_empty
29
+ expect(s.uniq - s).to be_empty
30
+ end
31
+
32
+ it "returns ips for a name" do
33
+ s = subject.ips_by_name('github.com')
34
+ expect(s).to be_a_kind_of(Enumerable)
35
+ expect(s).not_to be_empty
36
+ end
37
+
38
+ it "returns ips for multiple names" do
39
+ s = subject.ips_by_name(['github.com', 'github.io'])
40
+ expect(s).to be_a_kind_of(Hash)
41
+ expect(s).not_to be_empty
42
+ s.each do |t|
43
+ expect(t).to be_a_kind_of(Enumerable)
44
+ expect(t).not_to be_empty
45
+ end
46
+ end
47
+
48
+ it "returns distinct ips for multiple names" do
49
+ s = subject.distinct_ips_by_name(['github.com', 'github.io'])
50
+ expect(s).to be_a_kind_of(Enumerable)
51
+ expect(s).not_to be_empty
52
+ expect(s.uniq - s).to be_empty
53
+ end
54
+
55
+ it "returns mxs for multiple names" do
56
+ s = subject.mxs_by_name(['github.com', 'github.io'])
57
+ expect(s).to be_a_kind_of(Hash)
58
+ expect(s).not_to be_empty
59
+ s.each do |t|
60
+ expect(t).to be_a_kind_of(Enumerable)
61
+ expect(t).not_to be_empty
62
+ end
63
+ end
64
+
65
+ it "returns distinct mxs for multiple names" do
66
+ s = subject.distinct_mxs_by_name(['github.com', 'github.io'])
67
+ expect(s).to be_a_kind_of(Enumerable)
68
+ expect(s).not_to be_empty
69
+ expect(s.uniq - s).to be_empty
70
+ end
71
+
72
+ it "returns cnames for multiple names" do
73
+ s = subject.cnames_by_name(['www.skyrock.com', 'apple.com'])
74
+ expect(s).to be_a_kind_of(Hash)
75
+ expect(s).not_to be_empty
76
+ s.each do |t|
77
+ expect(t).to be_a_kind_of(Enumerable)
78
+ expect(t).not_to be_empty
79
+ end
80
+ end
81
+
82
+ it "returns distinct cnames for multiple names" do
83
+ s = subject.distinct_cnames_by_name(['www.skyrock.com', 'apple.com'])
84
+ expect(s).to be_a_kind_of(Enumerable)
85
+ expect(s).not_to be_empty
86
+ expect(s.uniq - s).to be_empty
87
+ end
88
+ end
@@ -0,0 +1,88 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe "label" do
5
+ subject do
6
+ OpenDNS::DNSDB::new(sslcert: CERT_FILE, sslcertpasswd: CERT_PASSWD)
7
+ end
8
+
9
+ it "returns the label for github.com" do
10
+ s = subject.labels_by_name('github.com')
11
+ expect(s).to eq(:benign)
12
+ end
13
+
14
+ it "returns the labels for github.com and skyrock.com" do
15
+ s = subject.labels_by_name(['github.com', 'skyrock.com'])
16
+ expect(s).to be_a_kind_of(Hash)
17
+ expect(s).not_to be_empty
18
+ expect(s['github.com']).to eq(:benign)
19
+ expect(s['skyrock.com']).to eq(:benign)
20
+ end
21
+
22
+ it "returns distinct labels for a set of names" do
23
+ s = subject.distinct_labels_by_name(['github.com', 'skyrock.com'])
24
+ expect(s).to be_a_kind_of(Enumerable)
25
+ expect(s).to eq([:benign])
26
+ end
27
+
28
+ it "returns whether a set of names contain suspicious ones" do
29
+ s = subject.include_suspicious?(['github.com', 'skyrock.com'])
30
+ expect(s).to be_false
31
+ end
32
+
33
+ it "returns whether github.com is suspicious" do
34
+ s = subject.is_suspicious?('github.com')
35
+ expect(s).to be_false
36
+ end
37
+
38
+ it "returns whether a set of names contain benign ones" do
39
+ s = subject.include_benign?(['github.com', 'skyrock.com'])
40
+ expect(s).to be_true
41
+ end
42
+
43
+ it "returns whether github.com is benign" do
44
+ s = subject.is_benign?('github.com')
45
+ expect(s).to be_true
46
+ end
47
+
48
+ it "returns whether example.com.x is unknown" do
49
+ s = subject.is_unknown?('example.com.x')
50
+ expect(s).to be_true
51
+ end
52
+
53
+ it "returns the subset of names, flagged as suspicious" do
54
+ s = subject.suspicious_names(['excue.ru', 'github.com'])
55
+ expect(s).to include('excue.ru')
56
+ expect(s).not_to include('github.com')
57
+ end
58
+
59
+ it "returns the subset of names, not flagged as suspicious" do
60
+ s = subject.not_suspicious_names(['excue.ru', 'github.com'])
61
+ expect(s).not_to include('excue.ru')
62
+ expect(s).to include('github.com')
63
+ end
64
+
65
+ it "returns the subset of names, flagged as benign" do
66
+ s = subject.benign_names(['excue.ru', 'github.com'])
67
+ expect(s).not_to include('excue.ru')
68
+ expect(s).to include('github.com')
69
+ end
70
+
71
+ it "returns the subset of names, not flagged as benign" do
72
+ s = subject.not_benign_names(['excue.ru', 'github.com'])
73
+ expect(s).to include('excue.ru')
74
+ expect(s).not_to include('github.com')
75
+ end
76
+
77
+ it "returns the subset of names, flagged as unknown" do
78
+ s = subject.unknown_names(['excue.ru.z', 'github.com'])
79
+ expect(s).to include('excue.ru.z')
80
+ expect(s).not_to include('github.com')
81
+ end
82
+
83
+ it "returns the subset of names, not flagged as unknown" do
84
+ s = subject.not_unknown_names(['excue.ru', 'github.com'])
85
+ expect(s).not_to include('excue.ru.z')
86
+ expect(s).to include('github.com')
87
+ end
88
+ end
@@ -0,0 +1,92 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe "related" do
5
+ subject do
6
+ OpenDNS::DNSDB::new(sslcert: CERT_FILE, sslcertpasswd: CERT_PASSWD)
7
+ end
8
+
9
+ it "returns weighted related domains for www.github.com" do
10
+ s = subject.related_names_with_score('www.github.com')
11
+ expect(s).to be_a_kind_of(Hash)
12
+ expect(s).not_to be_empty
13
+ expect(s.include?('www.github.com')).to be_false
14
+ end
15
+
16
+ it "returns weighted related domains for www.github.com and mozilla.org" do
17
+ s = subject.related_names_with_score(['www.github.com', 'mozilla.org'])
18
+ expect(s).to be_a_kind_of(Hash)
19
+ expect(s['www.github.com']).to be_a_kind_of(Hash)
20
+ expect(s['mozilla.org']).to be_a_kind_of(Hash)
21
+ expect(s).not_to be_empty
22
+ expect(s['www.github.com'].include?('www.github.com')).to be_false
23
+ expect(s['mozilla.org'].include?('mozilla.org')).to be_false
24
+ end
25
+
26
+ it "returns related domains for www.github.com" do
27
+ s = subject.related_names('www.github.com')
28
+ expect(s).to be_a_kind_of(Enumerable)
29
+ expect(s).not_to be_empty
30
+ expect(s.include?('www.github.com')).to be_false
31
+ end
32
+
33
+ it "returns related domains for www.github.com and mozilla.org" do
34
+ s = subject.related_names(['www.github.com', 'mozilla.org'])
35
+ expect(s).to be_a_kind_of(Hash)
36
+ expect(s).not_to be_empty
37
+ expect(s['www.github.com']).to be_a_kind_of(Enumerable)
38
+ expect(s['mozilla.org']).to be_a_kind_of(Enumerable)
39
+ expect(s['www.github.com'].include?('www.github.com')).to be_false
40
+ expect(s['mozilla.org'].include?('mozilla.org')).to be_false
41
+ end
42
+
43
+ it "returns related domains with a maximum number of names" do
44
+ s = subject.related_names(['www.github.com', 'mozilla.org'], max_names: 1)
45
+ expect(s).to be_a_kind_of(Hash)
46
+ expect(s).not_to be_empty
47
+ expect(s['www.github.com']).to be_a_kind_of(Enumerable)
48
+ expect(s['mozilla.org']).to be_a_kind_of(Enumerable)
49
+ expect(s['www.github.com'].size).to be 1
50
+ expect(s['mozilla.org'].size).to be 1
51
+ end
52
+
53
+ it "returns distinct related names for www.github.com and mozilla.org" do
54
+ s = subject.distinct_related_names(['www.github.com', 'mozilla.org'])
55
+ expect(s).to be_a_kind_of(Enumerable)
56
+ expect(s).not_to be_empty
57
+ end
58
+
59
+ it "returns distinct related names with a maximum number of names" do
60
+ s = subject.distinct_related_names(['www.github.com', 'mozilla.org'],
61
+ max_names: 1)
62
+ expect(s).to be_a_kind_of(Enumerable)
63
+ expect(s).not_to be_empty
64
+ expect(s.size).to be 1
65
+ end
66
+
67
+ it "returns distinct related names, with a block" do
68
+ s = subject.distinct_related_names(['www.github.com',
69
+ 'mozilla.org']) { |name| true }
70
+ expect(s).to be_a_kind_of(Enumerable)
71
+ expect(s).not_to be_empty
72
+
73
+ s = subject.distinct_related_names(['www.github.com',
74
+ 'mozilla.org']) { |name| false }
75
+ expect(s).to be_a_kind_of(Enumerable)
76
+ expect(s).to be_empty
77
+ end
78
+
79
+ it "returns the result of a deep traversal on www.github.com" do
80
+ s = subject.distinct_related_names('www.github.com',
81
+ max_depth: 2, max_names: 1000)
82
+ expect(s).to be_a_kind_of(Enumerable)
83
+ expect(s).not_to be_empty
84
+ end
85
+
86
+ it "returns the result of a deep traversal on www.github.com with a filter" do
87
+ s = subject.distinct_related_names('www.github.com',
88
+ max_depth: 2, max_names: 1000) { |name| false }
89
+ expect(s).to be_a_kind_of(Enumerable)
90
+ expect(s).to be_empty
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+
2
+ require 'opendns-dnsdb'
3
+
4
+ CERT_FILE = '/tmp/client.p12'
5
+ CERT_PASSWD = 'opendns'
@@ -0,0 +1,36 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe "traffic" do
5
+ subject do
6
+ OpenDNS::DNSDB::new(sslcert: CERT_FILE, sslcertpasswd: CERT_PASSWD)
7
+ end
8
+
9
+ it "returns the daily traffic for the past 5 days" do
10
+ s = subject.daily_traffic_by_name('www.github.com', days_back: 5)
11
+ expect(s).to be_a_kind_of(Enumerable)
12
+ expect(s.size).to be 5
13
+ expect(s.first).to be > 0
14
+ end
15
+
16
+ it "returns the daily traffic for the past 5 days for a vector" do
17
+ s = subject.daily_traffic_by_name(['www.github.com', 'github.com'], days_back: 5)
18
+ expect(s).to be_a_kind_of(Hash)
19
+ expect(s['www.github.com'].size).to be 5
20
+ expect(s['www.github.com'].first).to be > 0
21
+ expect(s['github.com'] == s['www.github.com'])
22
+ end
23
+
24
+ it "returns the relative standard deviation for a name" do
25
+ s = subject.daily_traffic_by_name('www.github.com')
26
+ rsd = subject.relative_standard_deviation(s)
27
+ expect(rsd).to be_a_kind_of(Float)
28
+ expect(rsd).to be >= 0.0
29
+ expect(rsd).to be <= 100.0
30
+ end
31
+
32
+ it "returns a vector after a high pass filter" do
33
+ s = subject.high_pass_filter([1.0, 3.0, 5.0, 7.0, 9.0], cutoff: 5.0)
34
+ expect(s).to eq [0.0, 0.0, 5.0, 7.0, 9.0]
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opendns-dnsdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Frank Denis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.14'
41
+ description: Client library for the OpenDNS Security Graph
42
+ email:
43
+ - frank@opendns.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - THANKS
55
+ - docs/Makefile
56
+ - docs/_themes/LICENSE
57
+ - docs/_themes/README.rst
58
+ - docs/_themes/flask_theme_support.py
59
+ - docs/_themes/kr/layout.html
60
+ - docs/_themes/kr/relations.html
61
+ - docs/_themes/kr/static/flasky.css_t
62
+ - docs/_themes/kr/static/small_flask.css
63
+ - docs/_themes/kr/theme.conf
64
+ - docs/_themes/kr_small/layout.html
65
+ - docs/_themes/kr_small/static/flasky.css_t
66
+ - docs/_themes/kr_small/theme.conf
67
+ - docs/conf.py
68
+ - docs/index.rst
69
+ - docs/make.bat
70
+ - docs/operations/by_ip.rst
71
+ - docs/operations/by_name.rst
72
+ - docs/operations/label.rst
73
+ - docs/operations/related.rst
74
+ - docs/operations/traffic.rst
75
+ - lib/opendns-dnsdb.rb
76
+ - lib/opendns-dnsdb/dnsdb.rb
77
+ - lib/opendns-dnsdb/dnsdb/by_ip.rb
78
+ - lib/opendns-dnsdb/dnsdb/by_name.rb
79
+ - lib/opendns-dnsdb/dnsdb/label.rb
80
+ - lib/opendns-dnsdb/dnsdb/related.rb
81
+ - lib/opendns-dnsdb/dnsdb/response.rb
82
+ - lib/opendns-dnsdb/dnsdb/rrutils.rb
83
+ - lib/opendns-dnsdb/dnsdb/siphash.rb
84
+ - lib/opendns-dnsdb/dnsdb/traffic.rb
85
+ - lib/opendns-dnsdb/version.rb
86
+ - opendns-dnsdb.gemspec
87
+ - spec/by_ip_spec.rb
88
+ - spec/by_name_spec.rb
89
+ - spec/label_spec.rb
90
+ - spec/related_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/traffic_spec.rb
93
+ homepage: https://github.com/jedisct1/opendns-dnsdb-ruby
94
+ licenses: []
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.1.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Client library for the OpenDNS Security Graph
116
+ test_files:
117
+ - spec/by_ip_spec.rb
118
+ - spec/by_name_spec.rb
119
+ - spec/label_spec.rb
120
+ - spec/related_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/traffic_spec.rb
123
+ has_rdoc: