spysex 0.1.0 → 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: 349d1252d038b09b7042965cc022bb33dbaf841699d76b4403a8ede215b667fd
4
- data.tar.gz: b98c60bde0e6dc5272e1d5e6a52fa1d96292c5fc42c6c0e6763c3db803de4a9a
3
+ metadata.gz: 635106e499dc0d83bc33a25797da7d4842fad74a7c814d265511bf42a8539fd1
4
+ data.tar.gz: 688abe7c89b9fa57d5085e59f85fee972b1380cd9a052ff71e4e32e60f817592
5
5
  SHA512:
6
- metadata.gz: 993f76ca091a2d04ea35614100c25bd0fcfc94c74ee92a8cea874d81669705f2c1b6551e7e38ae086290af98e21650d9f5e48673638e1e20eece617830452cbf
7
- data.tar.gz: 0b96be9c75d50bb6f68fca1473b14b6c7727b911b3045d206149454ba8edf7641071afda4b972bb0f55f59b0bb717466e195968ebe7f2687b503229d01b12b2a
6
+ metadata.gz: 15842f9a0de44b85cda75f795b85814f1428e7fe810411bbe5799efe10ad5a9689740a2f9ecde9cd98b4ae9cc38a860695e2f3e81c9ddef39bca751aae676096
7
+ data.tar.gz: 54e9c5fb0d408848845af326dc30f31ee322baa3284550fdaff84be68eb28e3d485f8126e087d299400fe5715cf9bd6e22b613732a99a6c56c67b74f44b2d5f5
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [2.7, "3.0"]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ bundler-cache: true
20
+
21
+ - name: Run the default task
22
+ env:
23
+ COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
24
+ run: |
25
+ gem install bundler -v 2.2.23
26
+ bundle install
27
+ bundle exec rake
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # spysex
2
2
 
3
- [![Build Status](https://travis-ci.com/ninoseki/spysex.svg?branch=master)](https://travis-ci.com/ninoseki/spysex)
3
+ [![Ruby](https://github.com/ninoseki/spysex/actions/workflows/test.yml/badge.svg)](https://github.com/ninoseki/spysex/actions/workflows/test.yml)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/ninoseki/spysex/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/spysex?branch=master)
5
5
  [![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/spysex/badge)](https://www.codefactor.io/repository/github/ninoseki/spysex)
6
6
 
7
7
  A dead simple [Spyse](https://spyse.com) API wrapper for Ruby.
8
8
 
9
- Note: this wrapper does not support all the API endpoints.
9
+ - Notes:
10
+ - API v4 is supported.
11
+ - This wrapper does not support all the API endpoints.
10
12
 
11
13
  ## Installation
12
14
 
@@ -19,7 +21,7 @@ gem install spysex
19
21
  ```ruby
20
22
  require "spysex"
21
23
 
22
- # when given nothing, it tries to load your usernamem & API key via ENV["SPYSE_API_KEY"]
24
+ # when given nothing, it tries to load your API key via ENV["SPYSE_API_KEY"]
23
25
  api = Spyse::API.new
24
26
  # or you can set them manually
25
27
  api = Spyse::API.new("foo bar")
data/lib/spyse/api.rb CHANGED
@@ -26,5 +26,19 @@ module Spyse
26
26
  def ip
27
27
  @ip ||= Client::IP.new(@api_key)
28
28
  end
29
+
30
+ def get(path, params = {})
31
+ base._get(path, params) { |json| json }
32
+ end
33
+
34
+ def post(path, params = {})
35
+ base._post(path, params) { |json| json }
36
+ end
37
+
38
+ private
39
+
40
+ def base
41
+ @base ||= Client::Base.new(@api_key)
42
+ end
29
43
  end
30
44
  end
@@ -10,11 +10,8 @@ module Spyse
10
10
  #
11
11
  # @return [Hash]
12
12
  #
13
- def get(asn, limit: nil, offset: nil)
14
- params = {
15
- asn: asn, limit: limit, offset: offset,
16
- }.compact
17
- _get("/as", params) { |json| json }
13
+ def get(asn)
14
+ _get("/as/#{asn}") { |json| json }
18
15
  end
19
16
 
20
17
  #
@@ -8,13 +8,29 @@ module Spyse
8
8
  module Client
9
9
  class Base
10
10
  HOST = "api.spyse.com"
11
- VERSION = "v3"
11
+ VERSION = "v4"
12
12
  BASE_URL = "https://#{HOST}/#{VERSION}/data"
13
13
 
14
14
  def initialize(api_key)
15
15
  @api_key = api_key
16
16
  end
17
17
 
18
+ def _get(path, params = {}, &block)
19
+ uri = url_for(path)
20
+ uri.query = URI.encode_www_form(params)
21
+ get = Net::HTTP::Get.new(uri)
22
+
23
+ request(get, &block)
24
+ end
25
+
26
+ def _post(path, params = {}, &block)
27
+ post = Net::HTTP::Post.new(url_for(path))
28
+ post.body = JSON.generate(params)
29
+ post["Content-Type"] = "application/json"
30
+
31
+ request(post, &block)
32
+ end
33
+
18
34
  private
19
35
 
20
36
  def url_for(path)
@@ -54,22 +70,6 @@ module Spyse
54
70
  end
55
71
  end
56
72
  end
57
-
58
- def _get(path, params = {}, &block)
59
- uri = url_for(path)
60
- uri.query = URI.encode_www_form(params)
61
- get = Net::HTTP::Get.new(uri)
62
-
63
- request(get, &block)
64
- end
65
-
66
- def _post(path, params = {}, &block)
67
- post = Net::HTTP::Post.new(url_for(path))
68
- post.body = JSON.generate(params)
69
- post["Content-Type"] = "application/json"
70
-
71
- request(post, &block)
72
- end
73
73
  end
74
74
  end
75
75
  end
@@ -4,21 +4,18 @@ module Spyse
4
4
  module Client
5
5
  class Cert < Base
6
6
  #
7
- # Lists Certificate
7
+ # Returns the current data about the given certificate.
8
8
  #
9
- # @see https://spyse.com/api#/certificate/certificate
9
+ # @param [String] hash The SHA256 fingerprint of the certificate.
10
10
  #
11
11
  # @return [Hash]
12
12
  #
13
- def get(hash, limit: nil, offset: nil)
14
- params = {
15
- hash: hash, limit: limit, offset: offset,
16
- }.compact
17
- _get("/cert", params) { |json| json }
13
+ def get(hash)
14
+ _get("/certificate/#{hash}") { |json| json }
18
15
  end
19
16
 
20
17
  #
21
- # Lists certificates
18
+ # Returns a list of certificates that matched the search query.
22
19
  #
23
20
  # @see https://spyse.com/api#/certificate/cert_search
24
21
  #
@@ -28,7 +25,7 @@ module Spyse
28
25
  params = {
29
26
  search_params: search_params, limit: limit, offset: offset,
30
27
  }.compact
31
- _post("/cert/search", params) { |json| json }
28
+ _post("/certificate/search", params) { |json| json }
32
29
  end
33
30
  end
34
31
  end
@@ -8,27 +8,12 @@ module Spyse
8
8
  #
9
9
  # @see https://spyse.com/api#/cve/cve
10
10
  #
11
- # @return [Hash]
12
- #
13
- def get(cve_id, limit: nil, offset: nil)
14
- params = {
15
- cve_id: cve_id, limit: limit, offset: offset,
16
- }.compact
17
- _get("/cve", params) { |json| json }
18
- end
19
-
20
- #
21
- # Lists IPs, that vulnerable by provided CVE
22
- #
23
- # @see https://spyse.com/api#/cve/vulnerable_ip_by_cve
11
+ # @param [String] cve_id MITRE CVE unique identifier.
24
12
  #
25
13
  # @return [Hash]
26
14
  #
27
- def vulnerable_ip(cve, limit: nil, offset: nil)
28
- params = {
29
- cve: cve, limit: limit, offset: offset,
30
- }.compact
31
- _get("/cve/vulnerable-ip", params) { |json| json }
15
+ def get(cve_id)
16
+ _get("/cve/#{cve_id}") { |json| json }
32
17
  end
33
18
 
34
19
  #
@@ -8,61 +8,12 @@ module Spyse
8
8
  #
9
9
  # @see https://spyse.com/api#/domain/domain
10
10
  #
11
- # @return [Hash]
12
- #
13
- def get(name, limit: nil, offset: nil, cert: nil, using_as_mx: nil, using_as_ns: nil, is_mx: nil, is_ns: nil, ip: nil )
14
- params = {
15
- limit: limit, offset: offset, name: name, cert: cert, using_as_mx: using_as_mx, using_as_ns: using_as_ns, is_mx: is_mx, is_ns: is_ns, ip: ip
16
- }.compact
17
- _get("/domain", params) { |json| json }
18
- end
19
-
20
- #
21
- # Lists subdomains of a domain
22
- #
23
- # @see https://spyse.com/api#/domain/subdomain
24
- #
25
- # @return [Hash]
26
- #
27
- def subdomain(domain, limit: nil, offset: nil)
28
- params = {
29
- domain: domain,
30
- limit: limit,
31
- offset: offset
32
- }.compact
33
- _get("/domain/subdomain", params) { |json| json }
34
- end
35
-
36
- #
37
- # Lists of related domains
38
- #
39
- # @see https://spyse.com/api#/related/domain_related_domain
40
- #
41
- # @return [Hash]
42
- #
43
- def related_domains(domain, limit: nil, offset: nil)
44
- params = {
45
- domain: domain,
46
- limit: limit,
47
- offset: offset
48
- }.compact
49
- _get("/domain/related/domain", params) { |json| json }
50
- end
51
-
52
- #
53
- # Lists of related IPs by domain
54
- #
55
- # @see https://spyse.com/api#/related/domain_related_ip
11
+ # @param [String] name The domain name.
56
12
  #
57
13
  # @return [Hash]
58
14
  #
59
- def related_ips(domain, limit: nil, offset: nil)
60
- params = {
61
- domain: domain,
62
- limit: limit,
63
- offset: offset
64
- }.compact
65
- _get("/domain/related/ip", params) { |json| json }
15
+ def get(name)
16
+ _get("/domain/#{name}") { |json| json }
66
17
  end
67
18
 
68
19
  #
@@ -4,22 +4,16 @@ module Spyse
4
4
  module Client
5
5
  class IP < Base
6
6
  #
7
- # Lists ips
7
+ # Returns the current data about the given IP address.
8
8
  #
9
9
  # @see https://spyse.com/api#/ip/ip
10
10
  #
11
+ # @param [String] ip A valid IPv4 address.
12
+ #
11
13
  # @return [Hash]
12
14
  #
13
- def get(ip, limit: nil, offset: nil, as_org: nil, country: nil, as_num: nil)
14
- params = {
15
- limit: limit,
16
- offset: offset,
17
- ip: ip,
18
- as_org: as_org,
19
- country: country,
20
- as_num: as_num
21
- }.compact
22
- _get("/ip", params) { |json| json }
15
+ def get(ip)
16
+ _get("/ip/#{ip}") { |json| json }
23
17
  end
24
18
 
25
19
  #
data/lib/spyse/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spyse
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
data/spysex.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = 'Spyse API wrapper for Ruby'
11
11
  spec.homepage = "https://github.com/ninoseki/spysex"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
14
14
 
15
15
  # Specify which files should be added to the gem when it is released.
16
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 2.0"
25
- spec.add_development_dependency "coveralls", "~> 0.8"
24
+ spec.add_development_dependency "bundler", "~> 2.2"
25
+ spec.add_development_dependency "coveralls_reborn", "~> 0.22"
26
26
  spec.add_development_dependency "rake", "~> 13.0"
27
- spec.add_development_dependency "rspec", "~> 3.9"
28
- spec.add_development_dependency "vcr", "~> 5.0"
29
- spec.add_development_dependency "webmock", "~> 3.7"
27
+ spec.add_development_dependency "rspec", "~> 3.10"
28
+ spec.add_development_dependency "vcr", "~> 6.0"
29
+ spec.add_development_dependency "webmock", "~> 3.13"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spysex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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: 2020-08-15 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.2'
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: '2.0'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: coveralls
28
+ name: coveralls_reborn
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '0.22'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.8'
40
+ version: '0.22'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.9'
61
+ version: '3.10'
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: '3.9'
68
+ version: '3.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.0'
75
+ version: '6.0'
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: '5.0'
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.7'
89
+ version: '3.13'
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: '3.7'
96
+ version: '3.13'
97
97
  description: Spyse API wrapper for Ruby
98
98
  email:
99
99
  - manabu.niseki@gmail.com
@@ -101,9 +101,9 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/test.yml"
104
105
  - ".gitignore"
105
106
  - ".rspec"
106
- - ".travis.yml"
107
107
  - Gemfile
108
108
  - LICENSE
109
109
  - README.md
@@ -133,14 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 2.3.0
136
+ version: '2.7'
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.1.2
143
+ rubygems_version: 3.2.22
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Spyse API wrapper for Ruby
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7
6
- before_install: gem install bundler -v 2.1