securitytrails 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5483c4d6c38eab1e5221427e34e881e56ee96a598803428b6b1eb3e434b0d451
4
- data.tar.gz: 8105cc7a9dac696435ecdde62239c4e3c1abf67ff193f7953545d2629ef96e1e
3
+ metadata.gz: 1a98a7e435666d8e24c6fc43e321f0c830666b5bad72624a889aa9127ed05002
4
+ data.tar.gz: 208fa1488c86ad91b7a8985c44bb5bf0641c0052612b2e0af112590981025f5b
5
5
  SHA512:
6
- metadata.gz: c20d328670f8c6c76c3f57bca2933e58ca8360dc7bceed3b3faff1efbf2f6badb19be1b444dbccc3c46fff1dede6f3adae5d3e04cdffcaef7b32b59e9528adb8
7
- data.tar.gz: '09efa1c991dca18805fdaba19fc21625ebf776aae32d144364ce0d5b6807fddde6dbb3eaeaa40418ae68904e4323c88d307ed39142ce8f2a0af51a71745ebff6'
6
+ metadata.gz: 5d0716e4993ce48071046aa9fb0758a9e7dde0a5863926f71d39e637ffc960625a099946fcb87f76c8f8d3f3d0b0f1a7d63943ad3a7f94b4ef7be9b9ceb42784
7
+ data.tar.gz: 6825a21d343225b5d07f88d084de0d62afad3e5d78c2c1d9721406c02723eac9d11a975048125ad9f68ce91ffd7bce11651963d841311e35d5d0b1db31371b7a
@@ -3,5 +3,5 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.2
7
- before_install: gem install bundler -v 1.17.1
6
+ - 2.6
7
+ before_install: gem install bundler -v 2.0.1
data/README.md CHANGED
@@ -59,12 +59,16 @@ api.history.get_dns_history("github.com", "a")
59
59
  api.history.get_all_dns_history("github.com", "a")
60
60
  api.history.get_whois_history("github.com")
61
61
 
62
-
63
62
  # IPs
64
63
  # https://docs.securitytrails.com/v1.0/reference#ips
65
64
  api.ips.explore("8.8.8.8")
66
65
  api.ips.search("ptr_part = 'ns1'")
67
66
  api.ips.stats("ptr_part = 'amazon.com'")
67
+
68
+ # Feeds
69
+ # https://docs.securitytrails.com/v1.0/reference#feeds
70
+ api.feeds.domain("new")
71
+ api.feeds.domain("new", tld: "jp")
68
72
  ```
69
73
 
70
74
  All the API response (JSON / Hash) is wrapped by [OpenStruct](https://github.com/ruby/ostruct).
@@ -2,12 +2,15 @@
2
2
 
3
3
  require "securitytrails/version"
4
4
 
5
+ require "securitytrails/utility"
6
+
5
7
  require "securitytrails/api"
6
8
  require "securitytrails/response"
7
9
  require "securitytrails/client"
8
10
 
9
11
  require "securitytrails/clients/domain"
10
12
  require "securitytrails/clients/domains"
13
+ require "securitytrails/clients/feeds"
11
14
  require "securitytrails/clients/history"
12
15
  require "securitytrails/clients/ips"
13
16
 
@@ -6,6 +6,7 @@ module SecurityTrails
6
6
  attr_reader :domains
7
7
  attr_reader :history
8
8
  attr_reader :ips
9
+ attr_reader :feeds
9
10
 
10
11
  def initialize(api_key = ENV["SECURITYTRAILS_API_KEY"])
11
12
  raise(ArgumentError, "'api_key' argument is required") unless api_key
@@ -14,6 +15,7 @@ module SecurityTrails
14
15
  @domains = Clients::Domains.new(api_key)
15
16
  @history = Clients::History.new(api_key)
16
17
  @ips = Clients::IPs.new(api_key)
18
+ @feeds = Clients::Feeds.new(api_key)
17
19
  end
18
20
  end
19
21
  end
@@ -39,10 +39,12 @@ module SecurityTrails
39
39
  def request(req)
40
40
  Net::HTTP.start(HOST, 443, https_options) do |http|
41
41
  response = http.request(req)
42
- if response.code == '200'
42
+ raise(Error, "unsupported response code returned: #{response.code}") unless response.code == "200"
43
+
44
+ if response["Content-Type"].to_s.include? "application/json"
43
45
  yield JSON.parse(response.body, object_class: Response)
44
46
  else
45
- raise(Error, "unsupported response code returned: #{response.code}")
47
+ yield response.body
46
48
  end
47
49
  end
48
50
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SecurityTrails
4
+ module Clients
5
+ class Feeds < Client
6
+ def domains(type, filter: nil, tld: nil, ns: nil, date: nil)
7
+ params = { filter: filter, tld: tld, ns: ns, date: date }.compact
8
+
9
+ get("/feeds/domains/#{type}", params) do |csv_gz|
10
+ unziped_text = Utility.ungzip(csv_gz)
11
+ unziped_text.lines.map(&:chomp)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zlib"
4
+
5
+ module SecurityTrails
6
+ class Utility
7
+ def self.ungzip(text)
8
+ sio = StringIO.new(text)
9
+ gz = Zlib::GzipReader.new(sio)
10
+ gz.read
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SecurityTrails
4
- VERSION = "0.1.5"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
- spec.add_development_dependency "dotenv", "~> 2.5"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.0"
32
- spec.add_development_dependency "vcr", "~> 4.0"
33
- spec.add_development_dependency "webmock", "~> 3.4"
29
+ spec.add_development_dependency "dotenv", "~> 2.7"
30
+ spec.add_development_dependency "rake", "~> 12.3"
31
+ spec.add_development_dependency "rspec", "~> 3.8"
32
+ spec.add_development_dependency "vcr", "~> 5.0"
33
+ spec.add_development_dependency "webmock", "~> 3.6"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: securitytrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-03 00:00:00.000000000 Z
11
+ date: 2019-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,70 +44,70 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.5'
47
+ version: '2.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.5'
54
+ version: '2.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '3.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '3.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: vcr
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.0'
89
+ version: '5.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.0'
96
+ version: '5.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.4'
103
+ version: '3.6'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.4'
110
+ version: '3.6'
111
111
  description: SecurityTrails API wrapper for Ruby
112
112
  email:
113
113
  - manabu.niseki@gmail.com
@@ -130,9 +130,11 @@ files:
130
130
  - lib/securitytrails/client.rb
131
131
  - lib/securitytrails/clients/domain.rb
132
132
  - lib/securitytrails/clients/domains.rb
133
+ - lib/securitytrails/clients/feeds.rb
133
134
  - lib/securitytrails/clients/history.rb
134
135
  - lib/securitytrails/clients/ips.rb
135
136
  - lib/securitytrails/response.rb
137
+ - lib/securitytrails/utility.rb
136
138
  - lib/securitytrails/version.rb
137
139
  - securitytrails.gemspec
138
140
  homepage: https://github.com/ninoseki/securitytrails
@@ -154,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  - !ruby/object:Gem::Version
155
157
  version: '0'
156
158
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.7.6
159
+ rubygems_version: 3.0.2
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: SecurityTrails API wrapper for Ruby