virustotal_api 0.1.0 → 0.2.0
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 +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +10 -0
- data/README.md +5 -0
- data/lib/virustotal_api/base.rb +11 -0
- data/lib/virustotal_api/domain_report.rb +1 -1
- data/lib/virustotal_api/exceptions.rb +4 -0
- data/lib/virustotal_api/file_report.rb +1 -1
- data/lib/virustotal_api/ip_report.rb +1 -1
- data/lib/virustotal_api/url_report.rb +1 -1
- data/lib/virustotal_api/version.rb +1 -1
- data/test/base_test.rb +20 -2
- data/test/exceptions_test.rb +8 -0
- data/test/version_test.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08639ee03219b15575d468fd157eda539bc3897e
|
4
|
+
data.tar.gz: 2c281969e78d7fbcf5d665b392ab16bf11c7abc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63fb4449337880642ae44ce0c1fa483835fa21c7a8f5a38e456aae569322ab26b1e9f7a22362e9b1bef65503a4f652b5154594e2be01c947003d2dc441eefdfc
|
7
|
+
data.tar.gz: 365ba31b29a47e37f34565c97ce45a08105865ffd531bc5bfabfa305ab89b297b1aa9a465515d79f3fb96a2052e7e69e895d625b4ddadbae53439aa1399ea613
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# VirusTotal API Changelog
|
2
|
+
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
* Check if the respone is 204 [#2](https://github.com/pwelch/virustotal_api/pull/2)
|
6
|
+
* Check if the respone is 204 (No Content) and raise an exception. [@postmodern](https://github.com/postmodern)
|
7
|
+
|
8
|
+
## 0.1.0
|
9
|
+
|
10
|
+
* First Release
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby Gem for [VirusTotal](https://www.virustotal.com) [V2 API](https://www.virustotal.com/en/documentation/public-api/)
|
4
4
|
|
5
|
+
[](http://badge.fury.io/rb/virustotal_api)
|
5
6
|
[](http://travis-ci.org/pwelch/virustotal_api)
|
6
7
|
|
7
8
|
## Installation
|
@@ -22,6 +23,10 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
26
|
+
VirusTotal only allows 4 queries per minute for their Public API. https://www.virustotal.com/en/faq/
|
27
|
+
|
28
|
+
You will need a Private API Key if you require more queries per minute.
|
29
|
+
|
25
30
|
### File Report
|
26
31
|
|
27
32
|
```ruby
|
data/lib/virustotal_api/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'virustotal_api/exceptions'
|
1
2
|
require 'rest-client'
|
2
3
|
require 'json'
|
3
4
|
|
@@ -8,6 +9,16 @@ module VirustotalAPI
|
|
8
9
|
VirustotalAPI::URI
|
9
10
|
end
|
10
11
|
|
12
|
+
# @param [RestClient::Response] response
|
13
|
+
# @return [Hash] the parsed JSON.
|
14
|
+
def self.parse(response)
|
15
|
+
if response.code == 204
|
16
|
+
fail(RateLimitError, 'maximum number of 4 requests per minute reached')
|
17
|
+
end
|
18
|
+
|
19
|
+
JSON.parse(response.body)
|
20
|
+
end
|
21
|
+
|
11
22
|
# @return [String] string of API URI instance method
|
12
23
|
def api_uri
|
13
24
|
self.class.api_uri
|
data/test/base_test.rb
CHANGED
@@ -13,7 +13,7 @@ class VirustotalAPIBaseTest < Minitest::Test
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Instance Method
|
16
|
-
def
|
16
|
+
def test_api_uri_instance_method
|
17
17
|
base_uri = 'https://www.virustotal.com/vtapi/v2'
|
18
18
|
vt_base = VirustotalAPI::Base.new
|
19
19
|
|
@@ -22,13 +22,31 @@ class VirustotalAPIBaseTest < Minitest::Test
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Class Method
|
25
|
-
def
|
25
|
+
def test_api_uri_class_method
|
26
26
|
base_uri = 'https://www.virustotal.com/vtapi/v2'
|
27
27
|
|
28
28
|
assert VirustotalAPI::Base.api_uri.is_a?(String)
|
29
29
|
assert VirustotalAPI::Base.api_uri, base_uri
|
30
30
|
end
|
31
31
|
|
32
|
+
def test_parse_code_200
|
33
|
+
mock_response_200 = Minitest::Mock.new
|
34
|
+
mock_response_200.expect(:code, 200)
|
35
|
+
mock_response_200.expect(:body, '{}')
|
36
|
+
|
37
|
+
assert VirustotalAPI::Base.parse(mock_response_200), {}
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_parse_code_204
|
41
|
+
mock_response_204 = Minitest::Mock.new
|
42
|
+
mock_response_204.expect(:code, 204)
|
43
|
+
mock_response_204.expect(:body, '{}')
|
44
|
+
|
45
|
+
assert_raises VirustotalAPI::RateLimitError do
|
46
|
+
VirustotalAPI::Base.parse(mock_response_204)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
32
50
|
# Test using FileReport
|
33
51
|
def test_exists?
|
34
52
|
VCR.use_cassette('report') do
|
data/test/version_test.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pwelch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- ".gitignore"
|
161
161
|
- ".rubocop.yml"
|
162
162
|
- ".travis.yml"
|
163
|
+
- CHANGELOG.md
|
163
164
|
- Gemfile
|
164
165
|
- LICENSE.txt
|
165
166
|
- README.md
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- lib/virustotal_api.rb
|
168
169
|
- lib/virustotal_api/base.rb
|
169
170
|
- lib/virustotal_api/domain_report.rb
|
171
|
+
- lib/virustotal_api/exceptions.rb
|
170
172
|
- lib/virustotal_api/file_report.rb
|
171
173
|
- lib/virustotal_api/file_scan.rb
|
172
174
|
- lib/virustotal_api/ip_report.rb
|
@@ -175,6 +177,7 @@ files:
|
|
175
177
|
- lib/virustotal_api/version.rb
|
176
178
|
- test/base_test.rb
|
177
179
|
- test/domain_report_test.rb
|
180
|
+
- test/exceptions_test.rb
|
178
181
|
- test/file_report_test.rb
|
179
182
|
- test/file_scan_test.rb
|
180
183
|
- test/fixtures/domain_report.yml
|
@@ -211,13 +214,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
214
|
version: '0'
|
212
215
|
requirements: []
|
213
216
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.5.1
|
215
218
|
signing_key:
|
216
219
|
specification_version: 4
|
217
220
|
summary: Gem for VirusTotal.com API
|
218
221
|
test_files:
|
219
222
|
- test/base_test.rb
|
220
223
|
- test/domain_report_test.rb
|
224
|
+
- test/exceptions_test.rb
|
221
225
|
- test/file_report_test.rb
|
222
226
|
- test/file_scan_test.rb
|
223
227
|
- test/fixtures/domain_report.yml
|