virustotal_api 0.5.2 → 0.5.6

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
2
  SHA256:
3
- metadata.gz: 1bed8beb641ac85649be4628d37065079d3f2c881499a67065200eeba57f2176
4
- data.tar.gz: a55ce4ed4bdc573607389e20578efd53f10d7ab1597b3deb05644571dac752c6
3
+ metadata.gz: bee3cd27ce8111b538905c1946c0ce5937c64852d8b7c2220727dd3d8720e3b3
4
+ data.tar.gz: be167894fbbe3a4ca1c6915aaab6796c350ef0115b6a7b1a9c13dbbf8ba1d068
5
5
  SHA512:
6
- metadata.gz: 13c8674a48591fd1c063a4d76040555aeace01a19981feb558241ff1843984f2e8052c6169bec8a1ec4f63519e14bf9b3a109fcf7f8fc667d8a1e0cbfe7f99aa
7
- data.tar.gz: b64cfe0bfa5fa79927d22d591534f2b7db2b3ca7f572e8360b0423c3de5def7948f3264381e001596c095c66ec04187fe5fddf1d4148ad21bcf66a08eaf981ac
6
+ metadata.gz: f43f121b8b44967792d9ebaa7e047658b5f16b355cc9c74eb6474b061b43717a5675768a99ae8bcd6bbeb6e645b924fa09f647145dcd43275acf69685cdb86dc
7
+ data.tar.gz: efcd01e2d34e0ca29c7bfe2aeac95af54d9e97d0e2fc55611c84059379df95322fb82fd4e7b8e834bd196aa09b2c24b9b3bff2272b7f81e1ac615ab904dc82c8
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,11 @@
1
+ CHANGELOG: no-impact/Added/Changed/Deprecated/Removed/Fixed/Security
2
+
3
+ ## Summary
4
+
5
+ ## Testing
6
+
7
+ 1. _Describe how to test this change_
8
+
9
+ ## Other Information
10
+
11
+ _Include screenshots, GIFs, and/or API responses as appropriate._
@@ -7,17 +7,56 @@ on:
7
7
  branches: [ master ]
8
8
 
9
9
  jobs:
10
- Test:
10
+ Test-Ruby-2-5:
11
11
  runs-on: ubuntu-latest
12
-
13
12
  steps:
14
13
  - uses: actions/checkout@v2
15
14
  - name: Set up Ruby
16
15
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
17
16
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
18
- uses: ruby/setup-ruby@v1.46.0
17
+ uses: ruby/setup-ruby@v1.70.1
19
18
  with:
20
19
  ruby-version: 2.5
20
+ - name: Show Ruby Version
21
+ run: ruby --version
22
+ - name: Install dependencies
23
+ run: bundle install
24
+ - name: Lint
25
+ run: bundle exec rake rubocop
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+
29
+ Test-Ruby-2-7:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - name: Set up Ruby
34
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
35
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
36
+ uses: ruby/setup-ruby@v1.70.1
37
+ with:
38
+ ruby-version: 2.7
39
+ - name: Show Ruby Version
40
+ run: ruby --version
41
+ - name: Install dependencies
42
+ run: bundle install
43
+ - name: Lint
44
+ run: bundle exec rake rubocop
45
+ - name: Run tests
46
+ run: bundle exec rake
47
+
48
+ Test-Ruby-3-0:
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - uses: actions/checkout@v2
52
+ - name: Set up Ruby
53
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
54
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
55
+ uses: ruby/setup-ruby@v1.70.1
56
+ with:
57
+ ruby-version: 3.0
58
+ - name: Show Ruby Version
59
+ run: ruby --version
21
60
  - name: Install dependencies
22
61
  run: bundle install
23
62
  - name: Lint
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # VirusTotal API Changelog
2
2
 
3
+ ## [0.5.6] - 2021-09-20
4
+
5
+ * Use urlsafe base64 encoding
6
+ * Fix changelog
7
+ * [@jonnynux](https://github.com/jonnynux)
8
+
9
+ ## [0.5.5] - 2021-05-10
10
+
11
+ * Add support for larger files
12
+ * [@Grandman](https://github.com/Grandman)
13
+
14
+ ## [0.5.4] - 2020-12-10
15
+
16
+ * Manage bad requests like not found
17
+ * Use strict base64 encoding
18
+ * [@crondaemon](https://github.com/crondaemon)
19
+
20
+ ## [0.5.3] = 2020-10-12
21
+
3
22
  ## [0.5.2] - 2020-10-06
4
23
 
5
24
  * Fix Fix exists? check
data/README.md CHANGED
@@ -65,7 +65,10 @@ require 'virustotal_api'
65
65
  file = '/path/to/file'
66
66
  api_key = 'MY_API_KEY'
67
67
 
68
+ # for upload file
68
69
  vtscan = VirustotalAPI::File.upload(file, api_key)
70
+ # or large file (more than 32MB)
71
+ vtscan = VirustotalAPI::File.upload_large(file, api_key)
69
72
 
70
73
  # Virustotal ID of file
71
74
  vtscan.id
@@ -117,7 +120,7 @@ vturl_report.exists?
117
120
 
118
121
  # URL for Report (if it exists)
119
122
  vturl_report.report_url
120
- # => "https://www.virustotal.com/api/v3/urls/dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf/"
123
+ # => "https://www.virustotal.com/api/v3/urls/dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf"
121
124
 
122
125
  # Report results (if they exist) are available via #report
123
126
  vturl_report.report['data']['attributes']['last_analysis_results']['Avira']
@@ -161,6 +164,10 @@ vtip_report = VirustotalAPI::IP.find(ip, api_key)
161
164
  vtip_report.exists?
162
165
  # => true
163
166
 
167
+ # URL for Report (if it exists)
168
+ vtip_report.report_url
169
+ # => "https://www.virustotal.com/api/v3/ip_addresses/8.8.8.8"
170
+
164
171
  # Report results (if they exist) are available via #report
165
172
  vtip_report.report
166
173
  # => Hash of report results
@@ -180,6 +187,10 @@ vtdomain_report = VirustotalAPI::Domain.find(domain, api_key)
180
187
  vtdomain_report.exists?
181
188
  # => true
182
189
 
190
+ # URL for Report (if it exists)
191
+ vtdomain_report.report_url
192
+ # => "https://www.virustotal.com/api/v3/domains/virustotal.com"
193
+
183
194
  # Report results (if they exist) are available via #report
184
195
  vtdomain_report.report
185
196
  # => Hash of report results
@@ -225,10 +236,11 @@ vtgroup_report.report
225
236
 
226
237
  ## Contributors
227
238
 
228
- - [@postmodern](https://github.com/postmodern)
229
- - [@mkunkel](https://github.com/mkunkel)
230
239
  - [@jonnynux](https://github.com/jonnynux)
231
240
  - [@crondaemon](https://github.com/crondaemon/)
241
+ - [@postmodern](https://github.com/postmodern)
242
+ - [@mkunkel](https://github.com/mkunkel)
243
+ - [@Grandman](https://github.com/Grandman)
232
244
 
233
245
  ## Contributing
234
246
 
@@ -5,13 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/analyses' API
7
7
  class Analysis < Base
8
- attr_reader :report
9
-
10
- # rubocop:disable Lint/MissingSuper
11
- def initialize(report)
12
- @report = report
13
- end
14
-
15
8
  # @param [String] id The Virustotal ID to get the report for.
16
9
  # @param [String] api_key The key for virustotal
17
10
  # @return [VirustotalAPI::IP] Report
@@ -21,4 +14,3 @@ module VirustotalAPI
21
14
  end
22
15
  end
23
16
  end
24
- # rubocop:enable Lint/MissingSuper
@@ -9,10 +9,12 @@ require 'base64'
9
9
  module VirustotalAPI
10
10
  # The base class implementing the raw calls to Virustotal API V3.
11
11
  class Base
12
- attr_reader :report
12
+ attr_reader :report, :report_url, :id
13
13
 
14
14
  def initialize(report)
15
- @report = report
15
+ @report = report
16
+ @report_url = report&.dig('data', 'links', 'self')
17
+ @id = report&.dig('data', 'id')
16
18
  end
17
19
 
18
20
  # @return [String] string of API URI class method
@@ -20,6 +22,14 @@ module VirustotalAPI
20
22
  VirustotalAPI::URI
21
23
  end
22
24
 
25
+ def self.perform(path, api_key, method = :get, options = {})
26
+ base_perform(api_uri + path, api_key, method, options)
27
+ end
28
+
29
+ def self.perform_absolute(url, api_key, method = :get, options = {})
30
+ base_perform(url, api_key, method, options)
31
+ end
32
+
23
33
  # The actual method performing a call to Virustotal
24
34
  #
25
35
  # @param [String] url The url of the API
@@ -27,15 +37,15 @@ module VirustotalAPI
27
37
  # @param [String] method The HTTP method to use
28
38
  # @param [Hash] options Options to pass as payload
29
39
  # @return [VirustotalAPI::Domain] Report Search Result
30
- def self.perform(url, api_key, method = :get, options = {})
40
+ def self.base_perform(url, api_key, method = :get, options = {})
31
41
  response = RestClient::Request.execute(
32
42
  method: method,
33
- url: api_uri + url,
43
+ url: url,
34
44
  headers: { 'x-apikey': api_key },
35
45
  payload: options
36
46
  )
37
47
  JSON.parse(response.body)
38
- rescue RestClient::NotFound
48
+ rescue RestClient::NotFound, RestClient::BadRequest
39
49
  {}
40
50
  rescue RestClient::Unauthorized
41
51
  # Raise a custom exception not to expose the underlying
@@ -47,6 +57,8 @@ module VirustotalAPI
47
57
  raise VirustotalAPI::RateLimitError
48
58
  end
49
59
 
60
+ private_class_method :base_perform
61
+
50
62
  # @return [String] string of API URI instance method
51
63
  def api_uri
52
64
  self.class.api_uri
@@ -60,7 +72,7 @@ module VirustotalAPI
60
72
  # Generate a URL identifier.
61
73
  # @see https://developers.virustotal.com/v3.0/reference#url
62
74
  def self.url_identifier(url)
63
- Base64.encode64(url).strip.gsub('=', '')
75
+ Base64.urlsafe_encode64(url).strip.gsub('=', '')
64
76
  end
65
77
  end
66
78
  end
@@ -5,11 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/domains' API
7
7
  class Domain < Base
8
- # rubocop:disable Lint/UselessMethodDefinition
9
- def initialize(report)
10
- super(report)
11
- end
12
-
13
8
  # Find a domain.
14
9
  #
15
10
  # @param [String] domain The domain to search
@@ -21,4 +16,3 @@ module VirustotalAPI
21
16
  end
22
17
  end
23
18
  end
24
- # rubocop:enable Lint/UselessMethodDefinition
@@ -5,14 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/files' API
7
7
  class File < Base
8
- attr_reader :id, :report_url
9
-
10
- def initialize(report)
11
- super(report)
12
- @id = report&.dig('data', 'id')
13
- @report_url = report&.dig('data', 'links', 'self')
14
- end
15
-
16
8
  # Find a hash.
17
9
  #
18
10
  # @param [String] resource file as a md5/sha1/sha256 hash
@@ -31,7 +23,20 @@ module VirustotalAPI
31
23
  # @return [VirusotalAPI::File] Report
32
24
  def self.upload(file_path, api_key, opts = {})
33
25
  filename = opts.fetch('filename') { ::File.basename(file_path) }
34
- report = perform('/files', api_key, :post, filename: filename, file: ::File.open(file_path, 'r'))
26
+ report = perform('/files', api_key, :post, filename: filename, file: ::File.open(file_path, 'r'))
27
+ new(report)
28
+ end
29
+
30
+ # Upload a new file with size more than 32MB.
31
+ #
32
+ # @param [String] file_path for file to be sent for scan
33
+ # @param [String] api_key The key for virustotal
34
+ # @param [Hash] opts hash for additional options
35
+ # @return [VirusotalAPI::File] Report
36
+ def self.upload_large(file_path, api_key, opts = {})
37
+ filename = opts.fetch('filename') { ::File.basename(file_path) }
38
+ url = upload_url(api_key)
39
+ report = perform_absolute(url, api_key, :post, filename: filename, file: ::File.open(file_path, 'r'))
35
40
  new(report)
36
41
  end
37
42
 
@@ -45,6 +50,12 @@ module VirustotalAPI
45
50
  new(report)
46
51
  end
47
52
 
53
+ # @return [String] url for upload file
54
+ def self.upload_url(api_key)
55
+ data = perform('/files/upload_url', api_key)
56
+ data&.dig('data')
57
+ end
58
+
48
59
  # Check if the submitted hash is detected by an AV engine.
49
60
  #
50
61
  # @param [String] engine The engine to check.
@@ -5,14 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/groups' API
7
7
  class Group < Base
8
- attr_reader :report_url, :id
9
-
10
- def initialize(report)
11
- super(report)
12
- @report_url = report&.dig('data', 'links', 'self')
13
- @id = report&.dig('data', 'id')
14
- end
15
-
16
8
  # Find a Group.
17
9
  #
18
10
  # @param [String] group_id to find
@@ -5,11 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/ip_addresses' API
7
7
  class IP < Base
8
- # rubocop:disable Lint/UselessMethodDefinition
9
- def initialize(report)
10
- super(report)
11
- end
12
-
13
8
  # Find an IP.
14
9
  #
15
10
  # @param [String] ip address The IP to find.
@@ -21,4 +16,3 @@ module VirustotalAPI
21
16
  end
22
17
  end
23
18
  end
24
- # rubocop:enable Lint/UselessMethodDefinition
@@ -5,14 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/urls' API
7
7
  class URL < Base
8
- attr_reader :report_url, :id
9
-
10
- def initialize(report)
11
- super(report)
12
- @report_url = report&.dig('data', 'links', 'self')
13
- @id = report&.dig('data', 'id')
14
- end
15
-
16
8
  # Find a URL.
17
9
  #
18
10
  # @param [String] resource as an ip/domain/url
@@ -5,14 +5,6 @@ require_relative 'base'
5
5
  module VirustotalAPI
6
6
  # A class for '/users' API
7
7
  class User < Base
8
- attr_reader :report_url, :id
9
-
10
- def initialize(report)
11
- super(report)
12
- @report_url = report&.dig('data', 'links', 'self')
13
- @id = report&.dig('data', 'id')
14
- end
15
-
16
8
  # Find a User.
17
9
  #
18
10
  # @param [String] user_key with id or api_key
@@ -2,5 +2,5 @@
2
2
 
3
3
  module VirustotalAPI
4
4
  # The GEM version
5
- VERSION = '0.5.2'
5
+ VERSION = '0.5.6'
6
6
  end
@@ -11,13 +11,16 @@ class VirustotalAPIAnalysisTest < Minitest::Test
11
11
  def test_todo
12
12
  VCR.use_cassette('url_find') do
13
13
  vtreport = VirustotalAPI::URL.find(@url, @api_key)
14
+
14
15
  @id = vtreport.id
15
- assert @id
16
+ assert @id.is_a?(String)
16
17
  end
17
18
 
18
19
  VCR.use_cassette('analysis') do
19
20
  analysis = VirustotalAPI::Analysis.find(@id, @api_key)
21
+
20
22
  assert analysis.exists?
23
+ assert analysis.id.is_a?(String)
21
24
  end
22
25
  end
23
26
  end
data/test/base_test.rb CHANGED
@@ -4,7 +4,9 @@ require './test/test_helper'
4
4
 
5
5
  class VirustotalAPIBaseTest < Minitest::Test
6
6
  def setup
7
+ @domain = 'xpressco.za'
7
8
  @sha256 = '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
9
+ @url = 'https://www.dropbox.com/s/qmi112rc4ns75eb/Confidential_123.xls?dl=1'
8
10
  @api_key = 'testapikey'
9
11
  end
10
12
 
@@ -43,5 +45,19 @@ class VirustotalAPIBaseTest < Minitest::Test
43
45
 
44
46
  assert !virustotal_report.exists?
45
47
  end
48
+
49
+ VCR.use_cassette('domain_bad_request') do
50
+ virustotal_report = VirustotalAPI::Domain.find(@domain, @api_key)
51
+
52
+ assert !virustotal_report.exists?
53
+ end
54
+ end
55
+
56
+ def test_url_encoding
57
+ VCR.use_cassette('url_encoding_find') do
58
+ virustotal_report = VirustotalAPI::URL.find(@url, @api_key)
59
+
60
+ assert virustotal_report.exists?
61
+ end
46
62
  end
47
63
  end
data/test/domain_test.rb CHANGED
@@ -17,16 +17,11 @@ class VirustotalAPIDomainTest < Minitest::Test
17
17
  vtdomain_report = VirustotalAPI::Domain.find(@domain, @api_key)
18
18
 
19
19
  # Make sure that the JSON was parsed
20
+ assert vtdomain_report.exists?
20
21
  assert vtdomain_report.is_a?(VirustotalAPI::Domain)
21
22
  assert vtdomain_report.report.is_a?(Hash)
22
- end
23
- end
24
-
25
- def test_exists?
26
- VCR.use_cassette('domain') do
27
- vtdomain_report = VirustotalAPI::Domain.find(@domain, @api_key)
28
-
29
- assert vtdomain_report.exists?
23
+ assert vtdomain_report.id.is_a?(String)
24
+ assert vtdomain_report.report_url.is_a?(String)
30
25
  end
31
26
  end
32
27
  end
data/test/file_test.rb CHANGED
@@ -4,9 +4,9 @@ require './test/test_helper'
4
4
 
5
5
  class VirustotalAPIFileTest < Minitest::Test
6
6
  def setup
7
- @sha256 = '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
7
+ @sha256 = '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
8
8
  @file_path = File.expand_path('test/fixtures/null_file')
9
- @api_key = 'testapikey'
9
+ @api_key = 'testapikey'
10
10
  end
11
11
 
12
12
  def test_class_exists
@@ -15,57 +15,59 @@ class VirustotalAPIFileTest < Minitest::Test
15
15
 
16
16
  def test_report_response
17
17
  VCR.use_cassette('file_find') do
18
- virustotal_report = VirustotalAPI::File.find(@sha256, @api_key)
18
+ vt_file_report = VirustotalAPI::File.find(@sha256, @api_key)
19
19
 
20
20
  # Make sure that the JSON was parsed
21
- assert virustotal_report.is_a?(VirustotalAPI::File)
22
- assert virustotal_report.report.is_a?(Hash)
21
+ assert vt_file_report.exists?
22
+ assert vt_file_report.is_a?(VirustotalAPI::File)
23
+ assert vt_file_report.report.is_a?(Hash)
24
+ assert vt_file_report.id.is_a?(String)
25
+ assert vt_file_report.report_url.is_a?(String)
23
26
  end
24
27
  end
25
28
 
26
29
  def test_find
27
- permalink = 'https://www.virustotal.com/api/v3/files/' \
28
- '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
30
+ id = '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
31
+ permalink = "https://www.virustotal.com/api/v3/files/#{id}"
32
+
29
33
  VCR.use_cassette('file_find') do
30
- virustotal_report = VirustotalAPI::File.find(@sha256, @api_key)
34
+ vt_file_report = VirustotalAPI::File.find(@sha256, @api_key)
31
35
 
32
- assert virustotal_report.report_url.is_a?(String)
33
- assert_equal permalink, virustotal_report.report_url
34
- assert virustotal_report.detected_by('Avira')
35
- assert !virustotal_report.detected_by('Acronis')
36
- assert !virustotal_report.detected_by('Yeyeyeye') # not present in file
36
+ assert_equal permalink, vt_file_report.report_url
37
+ assert_equal id, vt_file_report.id
38
+ assert vt_file_report.detected_by('Avira')
39
+ assert !vt_file_report.detected_by('Acronis')
40
+ assert !vt_file_report.detected_by('Yeyeyeye') # not present in file
37
41
  end
38
42
  end
39
43
 
40
44
  def test_upload
41
45
  VCR.use_cassette('file_upload') do
42
- virustotal_upload = VirustotalAPI::File.upload(@file_path, @api_key)
46
+ vt_file_upload = VirustotalAPI::File.upload(@file_path, @api_key)
43
47
 
44
- assert virustotal_upload.report.is_a?(Hash)
48
+ assert vt_file_upload.exists?
49
+ assert vt_file_upload.report.is_a?(Hash)
50
+ assert vt_file_upload.id.is_a?(String)
45
51
  end
46
52
  end
47
53
 
48
- def test_upload_id
49
- VCR.use_cassette('file_upload') do
50
- virustotal_upload = VirustotalAPI::File.upload(@file_path, @api_key)
54
+ def test_upload_large
55
+ VCR.use_cassette('large_file_upload') do
56
+ vt_file_upload = VirustotalAPI::File.upload_large(@file_path, @api_key)
51
57
 
52
- assert virustotal_upload.id.is_a?(String)
58
+ assert vt_file_upload.exists?
59
+ assert vt_file_upload.report.is_a?(Hash)
60
+ assert vt_file_upload.id.is_a?(String)
53
61
  end
54
62
  end
55
63
 
56
64
  def test_analyse
57
65
  VCR.use_cassette('file_analyse') do
58
- virustotal_analyse = VirustotalAPI::File.analyse(@sha256, @api_key)
59
-
60
- assert virustotal_analyse.report.is_a?(Hash)
61
- end
62
- end
63
-
64
- def test_analyse_id
65
- VCR.use_cassette('file_analyse') do
66
- virustotal_analyse = VirustotalAPI::File.analyse(@sha256, @api_key)
66
+ vt_file_analyse = VirustotalAPI::File.analyse(@sha256, @api_key)
67
67
 
68
- assert virustotal_analyse.id.is_a?(String)
68
+ assert vt_file_analyse.exists?
69
+ assert vt_file_analyse.report.is_a?(Hash)
70
+ assert vt_file_analyse.id.is_a?(String)
69
71
  end
70
72
  end
71
73
  end
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.virustotal.com/api/v3/domains/xpressco.za
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (linux-gnu x86_64) ruby/2.5.1p57
14
+ X-Apikey:
15
+ - testapikey
16
+ Content-Length:
17
+ - '0'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ Accept-Encoding:
21
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
22
+ Host:
23
+ - www.virustotal.com
24
+ response:
25
+ status:
26
+ code: 400
27
+ message: Bad Request
28
+ headers:
29
+ Cache-Control:
30
+ - no-cache
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ X-Cloud-Trace-Context:
34
+ - f9f5f005efc95b0390a91fb6306201d6
35
+ Date:
36
+ - Mon, 28 Dec 2020 13:56:50 GMT
37
+ Server:
38
+ - Google Frontend
39
+ Content-Length:
40
+ - '138'
41
+ body:
42
+ encoding: UTF-8
43
+ string: |-
44
+ {
45
+ "error": {
46
+ "code": "InvalidArgumentError",
47
+ "message": "Domain \"xpressco.za\" is not a valid domain pattern"
48
+ }
49
+ }
50
+ http_version:
51
+ recorded_at: Mon, 28 Dec 2020 13:56:50 GMT
52
+ recorded_with: VCR 5.0.0