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 +4 -4
- data/.circleci/config.yml +6 -2
- data/.github/workflows/gem_publish.yml +38 -0
- data/CHANGELOG.md +17 -9
- data/README.md +3 -3
- data/lib/virustotal_api/file_rescan.rb +8 -7
- data/lib/virustotal_api/file_scan.rb +8 -7
- data/lib/virustotal_api/url_scan.rb +8 -7
- data/lib/virustotal_api/version.rb +1 -1
- data/test/file_rescan_test.rb +1 -1
- data/test/file_scan_test.rb +1 -1
- data/test/url_report_test.rb +2 -2
- data/test/url_scan_test.rb +1 -1
- data/test/version_test.rb +0 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59f51d8dce27daace930afc9786485d497e79b3ba9afc6b82bffbb1ac1c98b36
|
4
|
+
data.tar.gz: 1fe1adf06f5135342dd48cade1d28c78a97530885e51e6d0993d0a971e31cec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30985ac7e3aec76bf9fd6ab41f9b1b1ec46edb96ba5e3ab12e9d1c993aeff665cc41fb5644db97afb26d41605208f4b0a116856fed5cfe22872571da429e3882
|
7
|
+
data.tar.gz: ea9be7f207a5805fecc1e1e321c07ade17cafc1eb0b1c85416117985f54837b6951c6285562f0ffffac32933fd9ff0bd66e1561f0d15ccb6555f0998d6d8a0de
|
data/.circleci/config.yml
CHANGED
@@ -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}}
|
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,29 @@
|
|
1
1
|
# VirusTotal API Changelog
|
2
2
|
|
3
|
-
## 0.4.
|
3
|
+
## [0.4.1] - 2019-09-04
|
4
4
|
|
5
|
-
*
|
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
|
-
|
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
|
-
*
|
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.
|
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.
|
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.
|
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 :
|
7
|
+
attr_reader :report, :rescan_id
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@rescan_id = @
|
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]
|
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(
|
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 :
|
7
|
+
attr_reader :report, :scan_id
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@scan_id
|
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 [
|
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(
|
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 :
|
7
|
+
attr_reader :report, :scan_id
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@scan_id
|
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]
|
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(
|
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
|
data/test/file_rescan_test.rb
CHANGED
@@ -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.
|
20
|
+
assert virustotal_rescan.report.is_a?(Hash)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
data/test/file_scan_test.rb
CHANGED
@@ -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.
|
19
|
+
assert virustotal_scan.report.is_a?(Hash)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
data/test/url_report_test.rb
CHANGED
@@ -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
|
9
|
-
@api_key
|
8
|
+
@url = 'http://www.google.com'
|
9
|
+
@api_key = 'testapikey'
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_class_exists
|
data/test/url_scan_test.rb
CHANGED
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.
|
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-
|
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.
|
228
|
+
rubygems_version: 3.0.2
|
228
229
|
signing_key:
|
229
230
|
specification_version: 4
|
230
231
|
summary: Gem for VirusTotal.com API
|