virustotal_api 0.4.0 → 0.4.1

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: d5cb4002cc7336dab43ad9cad54f42f646428c80b80bdd9c21c54d16dfa971a4
4
- data.tar.gz: 2e4091e0944e2ae0e4038574964035690e43eaf5aab0f69e26cb51ce1f6d36aa
3
+ metadata.gz: 59f51d8dce27daace930afc9786485d497e79b3ba9afc6b82bffbb1ac1c98b36
4
+ data.tar.gz: 1fe1adf06f5135342dd48cade1d28c78a97530885e51e6d0993d0a971e31cec4
5
5
  SHA512:
6
- metadata.gz: 3635ade214ad1a803a85a7169c84eedc085a5793bc3973aebe73e30f9f7b54cb4f6d46b79d66403441f02729f9f74ea52b70e147cdcee4a1181539c8a393a47d
7
- data.tar.gz: 27ae5dffc0d0fbbaa379b9dd96daab5a4fe513c406a5234d4d481bcd25016084c2a589e3fa01ad0792d2ee2eda71d9e5884144b9198bb305e5c80f5e6a22c3cf
6
+ metadata.gz: 30985ac7e3aec76bf9fd6ab41f9b1b1ec46edb96ba5e3ab12e9d1c993aeff665cc41fb5644db97afb26d41605208f4b0a116856fed5cfe22872571da429e3882
7
+ data.tar.gz: ea9be7f207a5805fecc1e1e321c07ade17cafc1eb0b1c85416117985f54837b6951c6285562f0ffffac32933fd9ff0bd66e1561f0d15ccb6555f0998d6d8a0de
@@ -1,6 +1,6 @@
1
1
  version: 2
2
2
  jobs:
3
- build:
3
+ test:
4
4
  docker:
5
5
  - image: circleci/ruby:2.5.3-stretch
6
6
  steps:
@@ -16,4 +16,8 @@ jobs:
16
16
  - run:
17
17
  name: Run Tests
18
18
  command: bundle exec rake test
19
-
19
+ workflows:
20
+ version: 2
21
+ test:
22
+ jobs:
23
+ - test
@@ -0,0 +1,38 @@
1
+ name: Ruby Gem
2
+
3
+ on: release
4
+
5
+ jobs:
6
+ build:
7
+ name: Build + Publish
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@master
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ version: 2.6.x
16
+
17
+ - name: Publish to GPR
18
+ run: |
19
+ mkdir -p $HOME/.gem
20
+ touch $HOME/.gem/credentials
21
+ chmod 0600 $HOME/.gem/credentials
22
+ printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
23
+ gem build *.gemspec
24
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
25
+ env:
26
+ GEM_HOST_API_KEY: ${{secrets.GITHUB_TOKEN}}
27
+ OWNER: username
28
+
29
+ - name: Publish to RubyGems
30
+ run: |
31
+ mkdir -p $HOME/.gem
32
+ touch $HOME/.gem/credentials
33
+ chmod 0600 $HOME/.gem/credentials
34
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
35
+ gem build *.gemspec
36
+ gem push *.gem
37
+ env:
38
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -1,21 +1,29 @@
1
1
  # VirusTotal API Changelog
2
2
 
3
- ## 0.4.0
3
+ ## [0.4.1] - 2019-09-04
4
4
 
5
- * Add ReScan [#15](https://github.com/pwelch/virustotal_api/pull/15)
6
- * Add URL Scan [#16](https://github.com/pwelch/virustotal_api/pull/16)
5
+ * Fixed Reponse Parsing
7
6
  * [@jonnynux](https://github.com/jonnynux)
8
7
 
9
- ## 0.3.0
10
8
 
11
- * Add optional scan param for url report API [#5](https://github.com/pwelch/virustotal_api/pull/5)
9
+ ## [0.4.0] - 2019-07-23
10
+
11
+ * Added ReScan [#15](https://github.com/pwelch/virustotal_api/pull/15)
12
+ * Added URL Scan [#16](https://github.com/pwelch/virustotal_api/pull/16)
13
+ * [@jonnynux](https://github.com/jonnynux)
14
+
15
+ ## [0.3.0] - 2018-03-31
16
+
17
+ * Added optional scan param for url report API [#5](https://github.com/pwelch/virustotal_api/pull/5)
12
18
  * [@mkunkel ](https://github.com/mkunkel)
13
19
 
14
- ## 0.2.0
20
+ ## [0.2.0] - 2015-12-19
15
21
 
16
- * Check if the respone is 204 [#2](https://github.com/pwelch/virustotal_api/pull/2)
17
- * Check if the respone is 204 (No Content) and raise an exception. [@postmodern](https://github.com/postmodern)
22
+ * Added Check if the respone is 204 [#2](https://github.com/pwelch/virustotal_api/pull/2)
23
+ * [@postmodern](https://github.com/postmodern)
18
24
 
19
- ## 0.1.0
25
+ ## [0.1.0] - 2014-12-26
20
26
 
21
27
  * First Release
28
+
29
+ https://keepachangelog.com
data/README.md CHANGED
@@ -65,7 +65,7 @@ vtscan.scan_id
65
65
  # => "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b-1419454668"
66
66
 
67
67
  # Response results are available via #response
68
- vtscan.response
68
+ vtscan.report
69
69
  # =>
70
70
  {
71
71
  "scan_id"=>"01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b-1419454668",
@@ -94,7 +94,7 @@ vtrescan.rescan_id
94
94
  # => "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b-1562684247"
95
95
 
96
96
  # Response results are available via #response
97
- vtrescan.response
97
+ vtrescan.report
98
98
  # =>
99
99
  {
100
100
  "permalink": "https://www.virustotal.com/file/01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b/analysis/1562684247/",
@@ -143,7 +143,7 @@ vturl_scan.scan_id
143
143
  # => "dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf-1562751553"
144
144
 
145
145
  # Response results are available via #response
146
- vturl_scan.response
146
+ vturl_scan.report
147
147
  # =>
148
148
  {
149
149
  "permalink": "https://www.virustotal.com/url/dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf/analysis/1562751553/",
@@ -4,30 +4,31 @@ require_relative 'base'
4
4
 
5
5
  module VirustotalAPI
6
6
  class FileRescan < Base
7
- attr_reader :response, :rescan_id
7
+ attr_reader :report, :rescan_id
8
8
 
9
- def initialize(response)
10
- @response = JSON.parse(response)
11
- @rescan_id = @response.fetch('scan_id') { nil }
9
+ def initialize(report)
10
+ @report = report
11
+ @rescan_id = @report.fetch('scan_id') { nil }
12
12
  end
13
13
 
14
14
  # @param [String] resource file as a md5/sha1/sha256 hash
15
15
  # @param [String] api_key for virustotal
16
- # @return [VirustotalAPI::FileRescan] Reponse
16
+ # @return [VirustotalAPI::FileRescan] Report
17
17
  def self.rescan(resource, api_key)
18
18
  response = RestClient.post(
19
19
  api_uri + '/file/rescan',
20
20
  apikey: api_key,
21
21
  resource: resource
22
22
  )
23
+ report = parse(response)
23
24
 
24
- new(response)
25
+ new(report)
25
26
  end
26
27
 
27
28
  # @return [Boolean] if file was queued
28
29
  # 0 => not_present, 1 => exists, -2 => queued_for_analysis
29
30
  def queued_for_analysis?
30
- response_code = report.fetch('response_code') { nil }
31
+ response_code = @report.fetch('response_code') { nil }
31
32
 
32
33
  response_code == -2
33
34
  end
@@ -4,17 +4,17 @@ require_relative 'base'
4
4
 
5
5
  module VirustotalAPI
6
6
  class FileScan < Base
7
- attr_reader :response, :scan_id
7
+ attr_reader :report, :scan_id
8
8
 
9
- def initialize(response)
10
- @response = JSON.parse(response)
11
- @scan_id = @response.fetch('scan_id') { nil }
9
+ def initialize(report)
10
+ @report = report
11
+ @scan_id = @report.fetch('scan_id') { nil }
12
12
  end
13
13
 
14
14
  # @param [String] file_path for file to be sent for scan
15
15
  # @param [String] api_key for virustotal
16
16
  # @param [Hash] opts hash for additional options
17
- # @return [VirusotalAPIFileScan] Reponse
17
+ # @return [VirusotalAPI::FileScan] Report
18
18
  def self.scan(file_path, api_key, opts = {})
19
19
  response = RestClient.post(
20
20
  api_uri + '/file/scan',
@@ -22,14 +22,15 @@ module VirustotalAPI
22
22
  filename: opts.fetch('filename') { File.basename(file_path) },
23
23
  file: File.open(file_path, 'r')
24
24
  )
25
+ report = parse(response)
25
26
 
26
- new(response)
27
+ new(report)
27
28
  end
28
29
 
29
30
  # @return [Boolean] if file was queued
30
31
  # 0 => not_present, 1 => exists, -2 => queued_for_analysis
31
32
  def queued_for_analysis?
32
- response_code = report.fetch('response_code') { nil }
33
+ response_code = @report.fetch('response_code') { nil }
33
34
 
34
35
  response_code == -2
35
36
  end
@@ -4,30 +4,31 @@ require_relative 'base'
4
4
 
5
5
  module VirustotalAPI
6
6
  class URLScan < Base
7
- attr_reader :response, :scan_id
7
+ attr_reader :report, :scan_id
8
8
 
9
- def initialize(response)
10
- @response = JSON.parse(response)
11
- @scan_id = @response.fetch('scan_id') { nil }
9
+ def initialize(report)
10
+ @report = report
11
+ @scan_id = @report.fetch('scan_id') { nil }
12
12
  end
13
13
 
14
14
  # @param [String] url
15
15
  # @param [String] api_key for virustotal
16
- # @return [VirustotalAPI::URLScan] Reponse
16
+ # @return [VirustotalAPI::URLScan] Report
17
17
  def self.scan(url, api_key)
18
18
  response = RestClient.post(
19
19
  api_uri + '/url/scan',
20
20
  apikey: api_key,
21
21
  url: url
22
22
  )
23
+ report = parse(response)
23
24
 
24
- new(response)
25
+ new(report)
25
26
  end
26
27
 
27
28
  # @return [Boolean] if file was queued
28
29
  # 0 => not_present, 1 => exists, -2 => queued_for_analysis
29
30
  def queued_for_analysis?
30
- response_code = report.fetch('response_code') { nil }
31
+ response_code = @report.fetch('response_code') { nil }
31
32
 
32
33
  response_code == -2
33
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VirustotalAPI
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
@@ -17,7 +17,7 @@ class VirustotalAPIFileRescanTest < Minitest::Test
17
17
  VCR.use_cassette('rescan') do
18
18
  virustotal_rescan = VirustotalAPI::FileRescan.rescan(@sha256, @api_key)
19
19
 
20
- assert virustotal_rescan.response.is_a?(Hash)
20
+ assert virustotal_rescan.report.is_a?(Hash)
21
21
  end
22
22
  end
23
23
 
@@ -16,7 +16,7 @@ class VirustotalAPIFileScanTest < Minitest::Test
16
16
  VCR.use_cassette('scan') do
17
17
  virustotal_scan = VirustotalAPI::FileScan.scan(@file_path, @api_key)
18
18
 
19
- assert virustotal_scan.response.is_a?(Hash)
19
+ assert virustotal_scan.report.is_a?(Hash)
20
20
  end
21
21
  end
22
22
 
@@ -5,8 +5,8 @@ require './test/test_helper'
5
5
  class VirustotalAPIURLReportTest < Minitest::Test
6
6
  def setup
7
7
  @unscanned_url = 'http://www.unscanned.com'
8
- @url = 'http://www.google.com'
9
- @api_key = 'testapikey'
8
+ @url = 'http://www.google.com'
9
+ @api_key = 'testapikey'
10
10
  end
11
11
 
12
12
  def test_class_exists
@@ -16,7 +16,7 @@ class VirustotalAPIURLScanTest < Minitest::Test
16
16
  VCR.use_cassette('url_scan') do
17
17
  vturl_scan = VirustotalAPI::URLScan.scan(@url, @api_key)
18
18
 
19
- assert vturl_scan.response.is_a?(Hash)
19
+ assert vturl_scan.report.is_a?(Hash)
20
20
  end
21
21
  end
22
22
 
@@ -5,6 +5,5 @@ require './test/test_helper'
5
5
  class VirustotalAPIVTReportTest < Minitest::Test
6
6
  def test_version
7
7
  assert VirustotalAPI::VERSION.is_a?(String)
8
- assert VirustotalAPI::VERSION, '0.2.0'
9
8
  end
10
9
  end
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pwelch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-23 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -161,6 +161,7 @@ files:
161
161
  - ".github/CODE_OF_CONDUCT.md"
162
162
  - ".github/CONTRIBUTING.md"
163
163
  - ".github/ISSUE_TEMPLATE.md"
164
+ - ".github/workflows/gem_publish.yml"
164
165
  - ".gitignore"
165
166
  - ".rubocop.yml"
166
167
  - CHANGELOG.md
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  - !ruby/object:Gem::Version
225
226
  version: '0'
226
227
  requirements: []
227
- rubygems_version: 3.0.3
228
+ rubygems_version: 3.0.2
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Gem for VirusTotal.com API