virustotal_api 0.5.3 → 0.5.4

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: 549e10acf953216ded9295c21129e76fc737bd63f29703af799499c6feed2c6e
4
- data.tar.gz: d20c12d67d748d329e3b0e340a4857115d516d942af5e3a282bb72e80a90e373
3
+ metadata.gz: 8bf33b0c496e55c74969e71e323aa64c664a4e7090db4f849601829143ee976a
4
+ data.tar.gz: 13eed4b64f8923c637e2155c3ece40f9bf55378c3f3a4cc7a321e29f58d8a357
5
5
  SHA512:
6
- metadata.gz: 394ad7a9dbf0f4c59d7e286acd57974e042427f0f4c82d1c652195b0dca4d17a0eeed28cd82946da2a072679a824060bacf184c741ecd0578e383386295c328d
7
- data.tar.gz: 0f9b0e2bc76a11d1b496ac1b0fb266875ed36cbfb51b27396396b555c3e47d5e411073e8bef956e1e44d08ec395e1165a45df8e525b24af6a0ae915d2c9c1b79
6
+ metadata.gz: 168c48232321aecaa6ad6bf5d34d07eb417cbf82f4bcd9a69ed678bb1c28c23a0121a859151662d0e810ea1ca4d8cda2dc50a771d98eaf85f5c98f424b9c4458
7
+ data.tar.gz: '021498bfce536a34eadc04c7b12766ff605b1f3ae61163be4c88e72aba5e05f2ce4be692aaa601420bdc480327d81e6e5496fd4c293c60f6fdb11f9537d68363'
@@ -15,7 +15,7 @@ jobs:
15
15
  - name: Set up Ruby
16
16
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
17
17
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
18
- uses: ruby/setup-ruby@v1.46.0
18
+ uses: ruby/setup-ruby@v1
19
19
  with:
20
20
  ruby-version: 2.5
21
21
  - name: Install dependencies
@@ -1,5 +1,12 @@
1
1
  # VirusTotal API Changelog
2
2
 
3
+ ## [0.5.4] - 2020-12-10
4
+ * Manage bad requests like not found
5
+ * Use strict base64 encoding
6
+ * [@crondaemon](https://github.com/crondaemon)
7
+
8
+ ## [0.5.3] = 2020-10-12
9
+
3
10
  ## [0.5.2] - 2020-10-06
4
11
 
5
12
  * Fix Fix exists? check
@@ -37,7 +37,7 @@ module VirustotalAPI
37
37
  payload: options
38
38
  )
39
39
  JSON.parse(response.body)
40
- rescue RestClient::NotFound
40
+ rescue RestClient::NotFound, RestClient::BadRequest
41
41
  {}
42
42
  rescue RestClient::Unauthorized
43
43
  # Raise a custom exception not to expose the underlying
@@ -62,7 +62,7 @@ module VirustotalAPI
62
62
  # Generate a URL identifier.
63
63
  # @see https://developers.virustotal.com/v3.0/reference#url
64
64
  def self.url_identifier(url)
65
- Base64.encode64(url).strip.gsub('=', '')
65
+ Base64.strict_encode64(url).strip.gsub('=', '')
66
66
  end
67
67
  end
68
68
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module VirustotalAPI
4
4
  # The GEM version
5
- VERSION = '0.5.3'
5
+ VERSION = '0.5.4'
6
6
  end
@@ -4,6 +4,7 @@ require './test/test_helper'
4
4
 
5
5
  class VirustotalAPIBaseTest < Minitest::Test
6
6
  def setup
7
+ @domain = 'xpressco.za'
7
8
  @sha256 = '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b'
8
9
  @api_key = 'testapikey'
9
10
  end
@@ -43,5 +44,11 @@ class VirustotalAPIBaseTest < Minitest::Test
43
44
 
44
45
  assert !virustotal_report.exists?
45
46
  end
47
+
48
+ VCR.use_cassette('domain_bad_request') do
49
+ virustotal_report = VirustotalAPI::Domain.find(@domain, @api_key)
50
+
51
+ assert !virustotal_report.exists?
52
+ end
46
53
  end
47
54
  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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virustotal_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - pwelch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-12 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -211,6 +211,7 @@ files:
211
211
  - test/file_test.rb
212
212
  - test/fixtures/analysis.yml
213
213
  - test/fixtures/domain.yml
214
+ - test/fixtures/domain_bad_request.yml
214
215
  - test/fixtures/file_analyse.yml
215
216
  - test/fixtures/file_find.yml
216
217
  - test/fixtures/file_not_found.yml
@@ -263,6 +264,7 @@ test_files:
263
264
  - test/file_test.rb
264
265
  - test/fixtures/analysis.yml
265
266
  - test/fixtures/domain.yml
267
+ - test/fixtures/domain_bad_request.yml
266
268
  - test/fixtures/file_analyse.yml
267
269
  - test/fixtures/file_find.yml
268
270
  - test/fixtures/file_not_found.yml