virus_total 0.0.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 308097c5810248bccc4c3e783656b80fc22ba05d
4
- data.tar.gz: 95daa10ff9a9263248c8c664a63ffbc766af731f
3
+ metadata.gz: bce4c85fc1ba3ddd93b273d188bd4fb496f80741
4
+ data.tar.gz: dbfdef518da67d37ac217f41a94f9f55862f5a82
5
5
  SHA512:
6
- metadata.gz: 19a0ea7eab3ebc523f4e71a78c97487d6e443b382ef676ab192e10f8a537d54a1049fdf9a6ee82d532bacc7d2cef0603515f4cc44b3fa6241104105a864f3622
7
- data.tar.gz: 5e74412cd54ccf0471b422f4d0c376cc2cc9a4f1142f4a864570c1443b93a87b475ad5954ce55dddfc9a0e88c5118fb6cb8e52a59d8019823919205f6d878881
6
+ metadata.gz: 116a92dfe662d13cb56588012545c2d2f6531fb99c68d54256c92ea8ded6e656350f77482d67b19cf0948320f0ac310445ce747a045bb72543ab6f2b067fce8d
7
+ data.tar.gz: a150d306705ef3cf4f61eb0695b7f6004d7f8f084ae5e2a5abb22cff69caa7d3ded64ab8f504fc854079ec8c4c3b3b95cb83ddcf3cb90720edceb66ec3a4f6b7
data/README.md CHANGED
@@ -41,34 +41,33 @@ file.report # response from POST "file/report"
41
41
  file.rescan # response from POST "file/rescan"
42
42
  ```
43
43
 
44
- #### Parse response string
44
+ #### Using response
45
45
  ```ruby
46
46
  # for example url.report
47
47
  response = url.report
48
- parser = Parser.new(response)
49
- # <VirusTotal::Parser:0x0000000252eac0 @json_resp={
48
+ # <VirusTotal::Response:0x0000000252eac0 @response={
50
49
  # "permalink"=>"https://www.virustotal.com/url/.../",
51
50
  # "resource"=>"https://www.example.com",...,
52
51
  # "scans"=>{"CLEAN MX"=>{"detected"=>true, "result"=>"clean site"},...}}>
53
52
 
54
- parser.response_code #=> 1: OK, 0: result doesn't exist, -2: still queued
53
+ response.response_code #=> 1: OK, 0: result doesn't exist, -2: still queued
55
54
 
56
55
  # general info from response
57
- parser.info #=> {"permalink"=>"https://www.virustotal.com/url/.../", "resource"=>"..."}
56
+ response.info #=> {"permalink"=>"https://www.virustotal.com/url/.../", "resource"=>"..."}
58
57
 
59
58
  # scanning info
60
- parser.scans #=> {"CLEAN MX"=>{"detected"=>true, "result"=>"clean site"},...}
59
+ response.scans #=> {"CLEAN MX"=>{"detected"=>true, "result"=>"clean site"},...}
61
60
 
62
61
  # information about positive threats
63
- parser.dangers #=> {"CLEAN MX"=>{"detected"=>true, "result"=>"clean site"}}
62
+ response.dangers #=> {"CLEAN MX"=>{"detected"=>true, "result"=>"clean site"}}
64
63
 
65
64
  # antiviruses which found positive threats
66
- parser.danger_brands #=> ["CLEAN MX"]
65
+ response.danger_brands #=> ["CLEAN MX"]
67
66
  ```
68
67
  Also we can get any key/value pair from response hash. If key (it is a string) from response has a whitespaces use underscore between words.
69
68
  ```ruby
70
- parser.scans.CLEAN_MX #=> {"detected"=>true, "result"=>"clean site"}
71
- parser.scans.CLEAN_MX.detected #=> true
69
+ response.scans.CLEAN_MX #=> {"detected"=>true, "result"=>"clean site"}
70
+ response.scans.CLEAN_MX.detected #=> true
72
71
  ```
73
72
  ### Implemented but not testing yet (needs a private apikey)
74
73
  #### Scanning IP-Address
@@ -85,8 +84,13 @@ domain = VirusTotal::Domain.new("example.com", "-- PRIVATE API KEY--")
85
84
 
86
85
  domain.report # response from GET "domain/report"
87
86
  ```
88
- ### Unsupported
89
- * "comments/puts"
87
+ ### Commenting
88
+ ```ruby
89
+ # initialize
90
+ comment = VirusTotal::Comment.new("-- Hash of file --", "-- PUBLIC API KEY --")
91
+
92
+ comment.put "-- Comment text here --" # post a comment on the resource
93
+ ```
90
94
 
91
95
  ## Contributing
92
96
 
@@ -4,6 +4,7 @@ require "virus_total/url"
4
4
  require "virus_total/file"
5
5
  require "virus_total/ip"
6
6
  require "virus_total/domain"
7
- require "virus_total/parser"
7
+ require "virus_total/comment"
8
+ require "virus_total/response"
8
9
  require "virus_total/exception"
9
10
  require "virus_total/version"
@@ -21,7 +21,8 @@ module VirusTotal
21
21
  full_url = BASE_URL + url
22
22
  params = default_params.merge(params)
23
23
 
24
- api_request(full_url, params)
24
+ resp = api_request(full_url, params)
25
+ Response.new(resp)
25
26
  end
26
27
 
27
28
  private
@@ -0,0 +1,7 @@
1
+ module VirusTotal
2
+ class Comment < Base
3
+ def put(text)
4
+ api_response('comments/put', resource: resource, comment: text)
5
+ end
6
+ end
7
+ end
@@ -2,7 +2,7 @@ module VirusTotal
2
2
  # to use this feature you must have a private apikey!
3
3
  class Domain < Base
4
4
  def report
5
- api_response('domain/report', resource: @resource.to_s, method: :get)
5
+ api_response('domain/report', resource: resource, method: :get)
6
6
  end
7
7
  end
8
8
  end
@@ -16,7 +16,7 @@ module VirusTotal
16
16
 
17
17
  def get_file
18
18
  tmp = Tempfile.open('tmp')
19
- tmp.write(IO::File.read(resource))
19
+ tmp.write(::File.read(resource))
20
20
  tmp
21
21
  end
22
22
  end
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  module VirusTotal
4
- class Parser
4
+ class Response
5
5
 
6
6
  attr_reader :response
7
7
 
@@ -1,3 +1,3 @@
1
1
  module VirusTotal
2
- VERSION = "0.0.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,12 @@
1
+ ruby_version: 1.9.3-p545
2
+ bundler_version: 1.7.8
3
+
4
+ test_pattern:
5
+ - spec/**_spec.rb
6
+
7
+ notify:
8
+ - channel: email
9
+ trigger-on: failed
10
+ branch: master/*
11
+ message: "Build failed with %error-count% error(s)"
12
+ recipients: "saychuk.andriy@gmail.com"
@@ -1,5 +1,5 @@
1
1
  shared_examples_for 'single resource' do
2
- let(:response) { JSON.parse(subject) }
2
+ let(:response) { subject.instance_variable_get("@response") }
3
3
 
4
4
  it 'should returns correct response' do
5
5
  response.should be_a_kind_of(Hash)
@@ -7,7 +7,7 @@ shared_examples_for 'single resource' do
7
7
  end
8
8
 
9
9
  shared_examples_for 'multiply resources' do
10
- let(:response) { JSON.parse(subject) }
10
+ let(:response) { subject.instance_variable_get("@response") }
11
11
 
12
12
  it 'should returns correct response' do
13
13
  response.should be_a_kind_of(Array)
@@ -0,0 +1,13 @@
1
+ require "virus_total"
2
+
3
+ describe VirusTotal::Comment do
4
+ let(:api_key) { "b9f4c087d347d244685fa1ba067b3863"\
5
+ "59dd9f46e88558a3f95061e5d4673d5e" }
6
+ let(:resource) { "da39a3ee5e6b4b0d3255bfef95601890afd80709" }
7
+ let(:comment) { VirusTotal::Comment.new(resource, api_key) }
8
+
9
+ context "for 'comments/put'" do
10
+ subject { comment.put "This is a test comment" }
11
+ it_should_behave_like 'single resource'
12
+ end
13
+ end
@@ -5,7 +5,7 @@ describe VirusTotal::Domain do
5
5
  let(:api_key) { "--YOUR_PRIVATE_KEY--" }
6
6
  let(:domain) { VirusTotal::Domain.new("heroku.com", api_key) }
7
7
 
8
- skip "for single domain" do
8
+ pending "for single domain" do
9
9
  context "for 'domain/report'" do
10
10
  subject { domain.report }
11
11
  it_should_behave_like 'single resource'
@@ -5,7 +5,7 @@ describe VirusTotal::Ip do
5
5
  let(:api_key) { "--YOUR_PRIVATE_KEY--" }
6
6
  let(:ip) { VirusTotal::Ip.new("128.0.0.1", api_key) }
7
7
 
8
- skip "for single ip address" do
8
+ pending "for single ip address" do
9
9
  context "for 'ip-address/report'" do
10
10
  subject { ip.report }
11
11
  it_should_behave_like 'single resource'
@@ -1,32 +1,32 @@
1
1
  require "virus_total"
2
2
 
3
- describe VirusTotal::Parser do
3
+ describe VirusTotal::Response do
4
4
  let(:response) {
5
5
  "{\"permalink\":\"https://www.virustotal.com/url\","\
6
6
  "\"resource\":\"https://www.example.com\","\
7
7
  "\"response_code\":1,"\
8
8
  "\"scans\":{\"CLEAN MX\":{\"detected\":true}}}"
9
9
  }
10
- let(:parser) { VirusTotal::Parser.new(response) }
10
+ let(:response_str) { VirusTotal::Response.new(response) }
11
11
 
12
12
  it "parse response correctly" do
13
- parser.instance_variable_get("@response").should_not be_nil
13
+ response_str.instance_variable_get("@response").should_not be_nil
14
14
  end
15
15
 
16
16
  it "returns info correctly" do
17
- parser.info.should_not match(/scans/)
17
+ response_str.info.should_not match(/scans/)
18
18
  end
19
19
 
20
20
  it "returns dangers correctly" do
21
- parser.dangers.should == {"CLEAN MX"=>{"detected"=>true}}
21
+ response_str.dangers.should == {"CLEAN MX"=>{"detected"=>true}}
22
22
  end
23
23
 
24
24
  it "returns danger brands correctly" do
25
- parser.danger_brands.should == ["CLEAN MX"]
25
+ response_str.danger_brands.should == ["CLEAN MX"]
26
26
  end
27
27
 
28
28
  it "returns hash value correctly" do
29
- parser.response_code.should == 1
29
+ response_str.response_code.should == 1
30
30
  end
31
31
  end
32
32
 
@@ -32,7 +32,7 @@ describe VirusTotal::Url do
32
32
  end
33
33
 
34
34
  # url/report not working for multiply urls.
35
- skip "for 'url/report'" do
35
+ pending "for 'url/report'" do
36
36
  subject { resource.report }
37
37
  it_should_behave_like 'multiply resources'
38
38
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virus_total
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubycop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-15 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
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
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
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
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.6'
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
54
  version: '2.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rest-client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.6.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.6.7
69
69
  description: gem for VirusTotal API version 2.0.
@@ -73,7 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".gitignore"
76
+ - .gitignore
77
77
  - Gemfile
78
78
  - LICENSE.txt
79
79
  - README.md
@@ -81,19 +81,22 @@ files:
81
81
  - lib/core_extentions.rb
82
82
  - lib/virus_total.rb
83
83
  - lib/virus_total/base.rb
84
+ - lib/virus_total/comment.rb
84
85
  - lib/virus_total/domain.rb
85
86
  - lib/virus_total/exception.rb
86
87
  - lib/virus_total/file.rb
87
88
  - lib/virus_total/ip.rb
88
- - lib/virus_total/parser.rb
89
+ - lib/virus_total/response.rb
89
90
  - lib/virus_total/url.rb
90
91
  - lib/virus_total/version.rb
92
+ - solano.yml
91
93
  - spec/shared_examples_spec.rb
92
94
  - spec/virus_total/base_spec.rb
95
+ - spec/virus_total/comment_spec.rb
93
96
  - spec/virus_total/domain_spec.rb
94
97
  - spec/virus_total/file_spec.rb
95
98
  - spec/virus_total/ip_spec.rb
96
- - spec/virus_total/parser_spec.rb
99
+ - spec/virus_total/response_spec.rb
97
100
  - spec/virus_total/url_spec.rb
98
101
  - virus_total.gemspec
99
102
  homepage: https://github.com/rubycop/virus_total
@@ -106,25 +109,26 @@ require_paths:
106
109
  - lib
107
110
  required_ruby_version: !ruby/object:Gem::Requirement
108
111
  requirements:
109
- - - ">="
112
+ - - '>='
110
113
  - !ruby/object:Gem::Version
111
114
  version: '0'
112
115
  required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  requirements:
114
- - - ">="
117
+ - - '>='
115
118
  - !ruby/object:Gem::Version
116
119
  version: '0'
117
120
  requirements: []
118
121
  rubyforge_project:
119
- rubygems_version: 2.4.5
122
+ rubygems_version: 2.0.3
120
123
  signing_key:
121
124
  specification_version: 4
122
125
  summary: gem for VirusTotal API version 2.0.
123
126
  test_files:
124
127
  - spec/shared_examples_spec.rb
125
128
  - spec/virus_total/base_spec.rb
129
+ - spec/virus_total/comment_spec.rb
126
130
  - spec/virus_total/domain_spec.rb
127
131
  - spec/virus_total/file_spec.rb
128
132
  - spec/virus_total/ip_spec.rb
129
- - spec/virus_total/parser_spec.rb
133
+ - spec/virus_total/response_spec.rb
130
134
  - spec/virus_total/url_spec.rb