passivedns-client 2.1.11 → 2.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 41bb1d54d9a49eb1995dfdd9c78538dc91ed40d7
4
- data.tar.gz: c446107f1d435fcc1334b20d62c72ec18c495a3f
2
+ SHA256:
3
+ metadata.gz: d8ea3feed82ed9f049ef8d7cd6ac78c087b94a630449cdbb3560fc28364ffe41
4
+ data.tar.gz: 37056ad39c2d721a3b5e6ee9f0347c5f1f79686f75eb15da99e2f155fc7b22d0
5
5
  SHA512:
6
- metadata.gz: 4117587bbb9789a381696295a40d88fff86e0284e358ec8feeae64f1436de6f09d17db8f71f3add3d950f8fd6f4ce31b43bd19b7f8a2ff1fabd4e5a4d5e135b9
7
- data.tar.gz: da94f1292023be6bb0ec75a380ac3fa661e8ecfbe6cb2fc13ad327a9930a28d7cd23b81ab1d6715df817b85760ddaab14f90fd07c4bdb16634fab521de6a8823
6
+ metadata.gz: 61ca76c52991e1a9e131d51412f0a855301b9555cbd0d1d6e5fe9c0071c1bc2d0b1539926148c090ad31c7db1aaff544565537c4db2f59bfd449e6747786d655
7
+ data.tar.gz: 4bae5d3265ca1723c9170dc3e1ec726a6d855ff2324b4744692f0a9a486444751723fa907ce50ef9960900fa4236b53fdfb1484f04fc4a91c7dc1e6d61889756
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
File without changes
File without changes
@@ -256,6 +256,7 @@ module PassiveDNS # :nodoc:
256
256
  else
257
257
  state = PassiveDNS::PDNSToolState.new
258
258
  end
259
+ state
259
260
  end
260
261
 
261
262
  # main method, takes command-line arguments and performs the desired queries and outputs
File without changes
@@ -43,7 +43,7 @@ module PassiveDNS #:nodoc: don't document this
43
43
 
44
44
  # Takes a label (either a domain or an IP address) and returns
45
45
  # an array of PassiveDNS::PDNSResult instances with the answers to the query
46
- def lookup(label, limit=nil)
46
+ def lookup(label, limit=nil)
47
47
  $stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug
48
48
  Timeout::timeout(@timeout) {
49
49
  t1 = Time.now
@@ -60,7 +60,7 @@ module PassiveDNS #:nodoc: don't document this
60
60
  end
61
61
  end
62
62
  }
63
- rescue Timeout::Error => e
63
+ rescue Timeout::Error
64
64
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
65
65
  end
66
66
 
@@ -98,7 +98,7 @@ module PassiveDNS #:nodoc: don't document this
98
98
  recs
99
99
  end
100
100
  }
101
- rescue Timeout::Error => e
101
+ rescue Timeout::Error
102
102
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
103
103
  recs
104
104
  end
@@ -3,6 +3,7 @@ require 'net/https'
3
3
  require 'openssl'
4
4
  require 'json'
5
5
  require 'digest/md5'
6
+ require 'pp'
6
7
 
7
8
  module PassiveDNS #:nodoc: don't document this
8
9
  # The Provider module contains all the Passive DNS provider client code
@@ -85,7 +86,7 @@ module PassiveDNS #:nodoc: don't document this
85
86
  recs
86
87
  end
87
88
  }
88
- rescue Timeout::Error => e
89
+ rescue Timeout::Error
89
90
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
90
91
  recs
91
92
  end
@@ -96,20 +97,24 @@ module PassiveDNS #:nodoc: don't document this
96
97
  def parse_json(page,query,response_time=0)
97
98
  res = []
98
99
  data = JSON.parse(page)
100
+ if data.class == Hash and data['err']
101
+ raise "#{self.class.name} Error: #{data['err']}"
102
+ end
99
103
  data.each do |row|
100
- time_first = (row["time_first"]) ? Time.at(row["time_first"].to_i) : nil
101
- time_last = (row["time_last"]) ? Time.at(row["time_last"].to_i) : nil
104
+ time_first = (row["time_first"]) ? Time.at(row["time_first"]) : nil
105
+ time_last = (row["time_last"]) ? Time.at(row["time_last"]) : nil
102
106
  count = row["count"] || 0
103
107
  query = row["rrname"]
104
108
  answers = row["rdata"].gsub(/;$/,'').split(/;/)
105
109
  rrtype = row["rrtype"]
106
110
  answers.each do |answer|
107
- res << PDNSResult.new(self.class.name, response_time, query, answer, rrtype, time_first, time_last, count, 'yellow')
111
+ res << PDNSResult.new(self.class.name, response_time, query, answer, rrtype, nil, time_first, time_last, count, TLPSecurityControl.new('yellow'))
108
112
  end
109
113
  end
110
114
  res
111
115
  rescue Exception => e
112
116
  $stderr.puts "#{self.class.name} Exception: #{e}"
117
+ puts e.backtrace
113
118
  raise e
114
119
  end
115
120
  end
@@ -77,7 +77,7 @@ module PassiveDNS #:nodoc: don't document this
77
77
  $stderr.puts response.body if @debug
78
78
  parse_json(response.body,t2-t1)
79
79
  }
80
- rescue Timeout::Error => e
80
+ rescue Timeout::Error
81
81
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
82
82
  end
83
83
 
@@ -76,7 +76,7 @@ module PassiveDNS #:nodoc: don't document this
76
76
  recs
77
77
  end
78
78
  }
79
- rescue Timeout::Error => e
79
+ rescue Timeout::Error
80
80
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
81
81
  end
82
82
 
@@ -86,7 +86,7 @@ module PassiveDNS #:nodoc: don't document this
86
86
  recs
87
87
  end
88
88
  }
89
- rescue Timeout::Error => e
89
+ rescue Timeout::Error
90
90
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
91
91
  end
92
92
 
@@ -94,8 +94,12 @@ module PassiveDNS #:nodoc: don't document this
94
94
 
95
95
  # parses the response of passivetotals's JSON reply to generate an array of PDNSResult
96
96
  def parse_json(page,query,response_time=0)
97
- res = []
97
+ res = []
98
98
  data = JSON.parse(page)
99
+ pp data
100
+ if data['message']
101
+ raise "#{self.class.name} Error: #{data['message']}"
102
+ end
99
103
  query = data['queryValue']
100
104
  if data['results']
101
105
  data['results'].each do |row|
@@ -98,7 +98,7 @@ module PassiveDNS #:nodoc: don't document this
98
98
  recs
99
99
  end
100
100
  }
101
- rescue Timeout::Error => e
101
+ rescue Timeout::Error
102
102
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
103
103
  end
104
104
 
@@ -78,7 +78,7 @@ module PassiveDNS #:nodoc: don't document this
78
78
  recs
79
79
  end
80
80
  }
81
- rescue Timeout::Error => e
81
+ rescue Timeout::Error
82
82
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
83
83
  end
84
84
 
@@ -111,7 +111,7 @@ module PassiveDNS #:nodoc: don't document this
111
111
  when "domains"
112
112
  data.each do |rec|
113
113
  lastseen = (rec["updatedate"]) ? Date.parse(rec["updatedate"]) : nil
114
- recs << PDNSResult.new(self.class.name, delta, rec, question, "A", nil, nil, nil, nil, 'yellow')
114
+ recs << PDNSResult.new(self.class.name, delta, rec, question, "A", nil, nil, lastseen, nil, 'yellow')
115
115
  end
116
116
  end
117
117
  if add_records
@@ -84,7 +84,7 @@ module PassiveDNS #:nodoc: don't document this
84
84
  recs
85
85
  end
86
86
  }
87
- rescue Timeout::Error => e
87
+ rescue Timeout::Error
88
88
  $stderr.puts "#{self.class.name} lookup timed out: #{label}"
89
89
  end
90
90
 
@@ -205,11 +205,12 @@ module PassiveDNS # :nodoc:
205
205
  # creates an SQLite3-based Passive DNS Client state
206
206
  # only argument is the filename of the sqlite3 database
207
207
  def initialize(sqlitedb=nil)
208
+ @debug = false
208
209
  puts "PDNSToolState initialize #{sqlitedb}" if @debug
209
210
  @level = 0
210
211
  @sqlitedb = sqlitedb
211
212
  raise "Cannot use this class without a database file" unless @sqlitedb
212
- unless File.exists?(@sqlitedb)
213
+ unless File.exist?(@sqlitedb)
213
214
  newdb = true
214
215
  end
215
216
  @sqlitedbh = SQLite3::Database.new(@sqlitedb)
@@ -2,6 +2,6 @@ module PassiveDNS # :nodoc:
2
2
  # coodinates the lookups accross all configured PassiveDNS providers
3
3
  class Client
4
4
  # version of PassiveDNS::Client
5
- VERSION = "2.1.11"
5
+ VERSION = "2.1.12"
6
6
  end
7
7
  end
File without changes
File without changes
File without changes
@@ -1,9 +1,9 @@
1
1
  unless Kernel.respond_to?(:require_relative)
2
- module Kernel
3
- def require_relative(path)
4
- require File.join(File.dirname(caller[0]), path.to_str)
5
- end
6
- end
2
+ module Kernel
3
+ def require_relative(path)
4
+ require File.join(File.dirname(caller[0]), path.to_str)
5
+ end
6
+ end
7
7
  end
8
8
 
9
9
  require_relative 'helper'
@@ -22,37 +22,37 @@ class TestPassiveDnsQuery < Minitest::Test
22
22
  end
23
23
  end
24
24
 
25
- def test_instantiate_Nonexisting_Client
26
- assert_raises RuntimeError do
27
- PassiveDNS::Client.new(['doesnotexist'])
28
- end
29
- end
25
+ def test_instantiate_Nonexisting_Client
26
+ assert_raises RuntimeError do
27
+ PassiveDNS::Client.new(['doesnotexist'])
28
+ end
29
+ end
30
30
 
31
- def test_instantiate_All_Clients
32
- PassiveDNS::Client.new()
33
- end
34
-
35
- def test_instantiate_Passive_DNS_State
36
- refute_nil(PassiveDNS::PDNSToolState.new)
37
- end
38
-
39
- def test_instantiate_Passive_DNS_State_database
40
- if File.exists?("test/test.sqlite3")
41
- File.unlink("test/test.sqlite3")
42
- end
43
- refute_nil(PassiveDNS::PDNSToolStateDB.new("test/test.sqlite3"))
44
- if File.exists?("test/test.sqlite3")
45
- File.unlink("test/test.sqlite3")
46
- end
47
- end
48
-
49
- def test_BFK
31
+ def test_instantiate_All_Clients
32
+ PassiveDNS::Client.new()
33
+ end
34
+
35
+ def test_instantiate_Passive_DNS_State
36
+ refute_nil(PassiveDNS::PDNSToolState.new)
37
+ end
38
+
39
+ def test_instantiate_Passive_DNS_State_database
40
+ if File.exist?("test/test.sqlite3")
41
+ File.unlink("test/test.sqlite3")
42
+ end
43
+ refute_nil(PassiveDNS::PDNSToolStateDB.new("test/test.sqlite3"))
44
+ if File.exist?("test/test.sqlite3")
45
+ File.unlink("test/test.sqlite3")
46
+ end
47
+ end
48
+
49
+ def test_BFK
50
50
  assert_raises RuntimeError do
51
51
  PassiveDNS::Client.new(['bfk'])
52
52
  end
53
53
 
54
54
  assert_raises RuntimeError do
55
- d = PassiveDNS::Provider::BFK.new(@cp['bfk'] || {})
55
+ PassiveDNS::Provider::BFK.new(@cp['bfk'] || {})
56
56
  end
57
57
 
58
58
  # refute_nil(d)
@@ -69,18 +69,18 @@ class TestPassiveDnsQuery < Minitest::Test
69
69
  # refute_nil(rows.to_xml)
70
70
  # refute_nil(rows.to_json)
71
71
  # refute_nil(rows.to_yaml)
72
- end
73
-
74
- def test_DNSDB
75
- PassiveDNS::Client.new(['dnsdb'])
72
+ end
73
+
74
+ def test_DNSDB
75
+ PassiveDNS::Client.new(['dnsdb'])
76
76
  d = PassiveDNS::Provider::DNSDB.new(@cp['dnsdb'] || {})
77
77
  refute_nil(d)
78
- rows = d.lookup("example.org",3)
79
- refute_nil(rows)
80
- refute_nil(rows.to_s)
81
- refute_nil(rows.to_xml)
82
- refute_nil(rows.to_json)
83
- refute_nil(rows.to_yaml)
78
+ rows = d.lookup("example.org",3)
79
+ refute_nil(rows)
80
+ refute_nil(rows.to_s)
81
+ refute_nil(rows.to_xml)
82
+ refute_nil(rows.to_json)
83
+ refute_nil(rows.to_yaml)
84
84
  assert_equal(3, rows.length) # this will fail since DNSDB has an off by one error
85
85
  rows = d.lookup("8.8.8.8")
86
86
  refute_nil(rows)
@@ -88,18 +88,18 @@ class TestPassiveDnsQuery < Minitest::Test
88
88
  refute_nil(rows.to_xml)
89
89
  refute_nil(rows.to_json)
90
90
  refute_nil(rows.to_yaml)
91
- end
91
+ end
92
92
 
93
- def test_VirusTotal
94
- PassiveDNS::Client.new(['virustotal'])
93
+ def test_VirusTotal
94
+ PassiveDNS::Client.new(['virustotal'])
95
95
  d = PassiveDNS::Provider::VirusTotal.new(@cp['virustotal'] || {})
96
96
  refute_nil(d)
97
- rows = d.lookup("google.com",3)
98
- refute_nil(rows)
99
- refute_nil(rows.to_s)
100
- refute_nil(rows.to_xml)
101
- refute_nil(rows.to_json)
102
- refute_nil(rows.to_yaml)
97
+ rows = d.lookup("google.com",3)
98
+ refute_nil(rows)
99
+ refute_nil(rows.to_s)
100
+ refute_nil(rows.to_xml)
101
+ refute_nil(rows.to_json)
102
+ refute_nil(rows.to_yaml)
103
103
  assert_equal(3, rows.length)
104
104
  rows = d.lookup("8.8.8.8")
105
105
  refute_nil(rows)
@@ -107,7 +107,7 @@ class TestPassiveDnsQuery < Minitest::Test
107
107
  refute_nil(rows.to_xml)
108
108
  refute_nil(rows.to_json)
109
109
  refute_nil(rows.to_yaml)
110
- end
110
+ end
111
111
 
112
112
  def test_TCPIPUtils
113
113
  PassiveDNS::Client.new(['tcpiputils'])
@@ -157,105 +157,106 @@ class TestPassiveDnsQuery < Minitest::Test
157
157
  refute_nil(rows.to_xml)
158
158
  refute_nil(rows.to_json)
159
159
  refute_nil(rows.to_yaml)
160
- end
160
+ end
161
161
 
162
162
  def test_nmemonic
163
- PassiveDNS::Client.new(['mnemonic'])
163
+ PassiveDNS::Client.new(['mnemonic'])
164
164
  d = PassiveDNS::Provider::Mnemonic.new(@cp['mnemonic'] || {})
165
165
  refute_nil(d)
166
- rows = d.lookup("example.org")
167
- refute_nil(rows)
168
- refute_nil(rows.to_s)
169
- refute_nil(rows.to_xml)
170
- refute_nil(rows.to_json)
171
- refute_nil(rows.to_yaml)
172
- rows = d.lookup("example.org",3)
173
- refute_nil(rows)
174
- refute_nil(rows.to_s)
175
- refute_nil(rows.to_xml)
176
- refute_nil(rows.to_json)
177
- refute_nil(rows.to_yaml)
178
- assert_equal(3, rows.length)
179
- rows = d.lookup("8.8.8.8")
180
- refute_nil(rows)
181
- refute_nil(rows.to_s)
182
- refute_nil(rows.to_xml)
183
- refute_nil(rows.to_json)
184
- refute_nil(rows.to_yaml)
185
- end
166
+ rows = d.lookup("example.org")
167
+ refute_nil(rows)
168
+ refute_nil(rows.to_s)
169
+ refute_nil(rows.to_xml)
170
+ refute_nil(rows.to_json)
171
+ refute_nil(rows.to_yaml)
172
+ rows = d.lookup("example.org",3)
173
+ refute_nil(rows)
174
+ refute_nil(rows.to_s)
175
+ refute_nil(rows.to_xml)
176
+ refute_nil(rows.to_json)
177
+ refute_nil(rows.to_yaml)
178
+ assert_equal(3, rows.length)
179
+ rows = d.lookup("8.8.8.8")
180
+ refute_nil(rows)
181
+ refute_nil(rows.to_s)
182
+ refute_nil(rows.to_xml)
183
+ refute_nil(rows.to_json)
184
+ refute_nil(rows.to_yaml)
185
+ end
186
186
 
187
187
  def test_passivetotal
188
- PassiveDNS::Client.new(['passivetotal'])
188
+ PassiveDNS::Client.new(['passivetotal'])
189
189
  d = PassiveDNS::Provider::PassiveTotal.new(@cp['passivetotal'] || {})
190
190
  refute_nil(d)
191
- rows = d.lookup("example.org")
192
- refute_nil(rows)
193
- refute_nil(rows.to_s)
194
- refute_nil(rows.to_xml)
195
- refute_nil(rows.to_json)
196
- refute_nil(rows.to_yaml)
197
- rows = d.lookup("example.org",3)
198
- refute_nil(rows)
199
- refute_nil(rows.to_s)
200
- refute_nil(rows.to_xml)
201
- refute_nil(rows.to_json)
202
- refute_nil(rows.to_yaml)
203
- assert_equal(3, rows.length)
204
- rows = d.lookup("8.8.8.8")
205
- refute_nil(rows)
206
- refute_nil(rows.to_s)
207
- refute_nil(rows.to_xml)
208
- refute_nil(rows.to_json)
209
- refute_nil(rows.to_yaml)
210
- end
191
+ rows = d.lookup("example.org")
192
+ refute_nil(rows)
193
+ refute_nil(rows.to_s)
194
+ refute_nil(rows.to_xml)
195
+ refute_nil(rows.to_json)
196
+ refute_nil(rows.to_yaml)
197
+ rows = d.lookup("example.org", 3)
198
+ refute_nil(rows)
199
+ refute_nil(rows.to_s)
200
+ refute_nil(rows.to_xml)
201
+ refute_nil(rows.to_json)
202
+ refute_nil(rows.to_yaml)
203
+ puts(rows)
204
+ assert_equal(3, rows.length)
205
+ rows = d.lookup("8.8.8.8")
206
+ refute_nil(rows)
207
+ refute_nil(rows.to_s)
208
+ refute_nil(rows.to_xml)
209
+ refute_nil(rows.to_json)
210
+ refute_nil(rows.to_yaml)
211
+ end
211
212
 
212
213
  def test_circl
213
- PassiveDNS::Client.new(['circl'])
214
+ PassiveDNS::Client.new(['circl'])
214
215
  d = PassiveDNS::Provider::CIRCL.new(@cp['circl'] || {})
215
216
  refute_nil(d)
216
- rows = d.lookup("example.org")
217
- refute_nil(rows)
218
- refute_nil(rows.to_s)
219
- refute_nil(rows.to_xml)
220
- refute_nil(rows.to_json)
221
- refute_nil(rows.to_yaml)
222
- rows = d.lookup("example.org",3)
223
- refute_nil(rows)
224
- refute_nil(rows.to_s)
225
- refute_nil(rows.to_xml)
226
- refute_nil(rows.to_json)
227
- refute_nil(rows.to_yaml)
228
- assert_equal(3, rows.length)
229
- rows = d.lookup("8.8.8.8")
230
- refute_nil(rows)
231
- refute_nil(rows.to_s)
232
- refute_nil(rows.to_xml)
233
- refute_nil(rows.to_json)
234
- refute_nil(rows.to_yaml)
235
- end
217
+ rows = d.lookup("example.org")
218
+ refute_nil(rows)
219
+ refute_nil(rows.to_s)
220
+ refute_nil(rows.to_xml)
221
+ refute_nil(rows.to_json)
222
+ refute_nil(rows.to_yaml)
223
+ rows = d.lookup("example.org",3)
224
+ refute_nil(rows)
225
+ refute_nil(rows.to_s)
226
+ refute_nil(rows.to_xml)
227
+ refute_nil(rows.to_json)
228
+ refute_nil(rows.to_yaml)
229
+ assert_equal(3, rows.length)
230
+ rows = d.lookup("8.8.8.8")
231
+ refute_nil(rows)
232
+ refute_nil(rows.to_s)
233
+ refute_nil(rows.to_xml)
234
+ refute_nil(rows.to_json)
235
+ refute_nil(rows.to_yaml)
236
+ end
236
237
 
237
238
  def test_riskiq
238
- PassiveDNS::Client.new(['riskiq'])
239
+ PassiveDNS::Client.new(['riskiq'])
239
240
  d = PassiveDNS::Provider::RiskIQ.new(@cp['riskiq'] || {})
240
241
  refute_nil(d)
241
- rows = d.lookup("example.org")
242
- refute_nil(rows)
243
- refute_nil(rows.to_s)
244
- refute_nil(rows.to_xml)
245
- refute_nil(rows.to_json)
246
- refute_nil(rows.to_yaml)
247
- rows = d.lookup("example.org",3)
248
- refute_nil(rows)
249
- refute_nil(rows.to_s)
250
- refute_nil(rows.to_xml)
251
- refute_nil(rows.to_json)
252
- refute_nil(rows.to_yaml)
253
- assert_equal(3, rows.length)
254
- rows = d.lookup("8.8.8.8")
255
- refute_nil(rows)
256
- refute_nil(rows.to_s)
257
- refute_nil(rows.to_xml)
258
- refute_nil(rows.to_json)
259
- refute_nil(rows.to_yaml)
260
- end
242
+ rows = d.lookup("example.org")
243
+ refute_nil(rows)
244
+ refute_nil(rows.to_s)
245
+ refute_nil(rows.to_xml)
246
+ refute_nil(rows.to_json)
247
+ refute_nil(rows.to_yaml)
248
+ rows = d.lookup("example.org",3)
249
+ refute_nil(rows)
250
+ refute_nil(rows.to_s)
251
+ refute_nil(rows.to_xml)
252
+ refute_nil(rows.to_json)
253
+ refute_nil(rows.to_yaml)
254
+ assert_equal(3, rows.length)
255
+ rows = d.lookup("8.8.8.8")
256
+ refute_nil(rows)
257
+ refute_nil(rows.to_s)
258
+ refute_nil(rows.to_xml)
259
+ refute_nil(rows.to_json)
260
+ refute_nil(rows.to_yaml)
261
+ end
261
262
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passivedns-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.11
4
+ version: 2.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -161,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.4.6
164
+ rubygems_version: 3.1.2
166
165
  signing_key:
167
166
  specification_version: 4
168
167
  summary: Query passive DNS databases