virustotal_api 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +26 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +12 -5
  5. data/CHANGELOG.md +7 -2
  6. data/README.md +48 -56
  7. data/lib/virustotal_api.rb +5 -7
  8. data/lib/virustotal_api/analysis.rb +24 -0
  9. data/lib/virustotal_api/base.rb +35 -10
  10. data/lib/virustotal_api/domain.rb +24 -0
  11. data/lib/virustotal_api/exceptions.rb +3 -0
  12. data/lib/virustotal_api/file.rb +56 -0
  13. data/lib/virustotal_api/ip.rb +24 -0
  14. data/lib/virustotal_api/uri.rb +2 -1
  15. data/lib/virustotal_api/url.rb +46 -0
  16. data/lib/virustotal_api/version.rb +2 -1
  17. data/test/analysis_test.rb +23 -0
  18. data/test/base_test.rb +8 -28
  19. data/test/domain_test.rb +32 -0
  20. data/test/exceptions_test.rb +14 -0
  21. data/test/file_test.rb +68 -0
  22. data/test/fixtures/analysis.yml +544 -0
  23. data/test/fixtures/domain.yml +830 -0
  24. data/test/fixtures/file_analyse.yml +52 -0
  25. data/test/fixtures/file_find.yml +1236 -0
  26. data/test/fixtures/file_unauthorized.yml +51 -0
  27. data/test/fixtures/file_upload.yml +54 -0
  28. data/test/fixtures/ip.yml +716 -0
  29. data/test/fixtures/unscanned_url_find.yml +44 -0
  30. data/test/fixtures/url_analyse.yml +52 -0
  31. data/test/fixtures/url_find.yml +599 -0
  32. data/test/{ip_report_test.rb → ip_test.rb} +4 -4
  33. data/test/uri_test.rb +1 -1
  34. data/test/url_test.rb +65 -0
  35. data/test/version_test.rb +1 -1
  36. data/virustotal_api.gemspec +10 -8
  37. metadata +86 -70
  38. data/.github/workflows/gem_publish.yml +0 -38
  39. data/lib/virustotal_api/domain_report.rb +0 -36
  40. data/lib/virustotal_api/file_report.rb +0 -37
  41. data/lib/virustotal_api/file_rescan.rb +0 -36
  42. data/lib/virustotal_api/file_scan.rb +0 -38
  43. data/lib/virustotal_api/ip_report.rb +0 -36
  44. data/lib/virustotal_api/url_report.rb +0 -41
  45. data/lib/virustotal_api/url_scan.rb +0 -36
  46. data/test/domain_report_test.rb +0 -32
  47. data/test/file_report_test.rb +0 -36
  48. data/test/file_rescan_test.rb +0 -32
  49. data/test/file_scan_test.rb +0 -30
  50. data/test/fixtures/domain_report.yml +0 -311
  51. data/test/fixtures/ip_report.yml +0 -1323
  52. data/test/fixtures/queue_unscanned_url_report.yml +0 -46
  53. data/test/fixtures/report.yml +0 -110
  54. data/test/fixtures/report_not_found.yml +0 -42
  55. data/test/fixtures/request_forbidden.yml +0 -38
  56. data/test/fixtures/rescan.yml +0 -47
  57. data/test/fixtures/scan.yml +0 -49
  58. data/test/fixtures/unscanned_url_report.yml +0 -43
  59. data/test/fixtures/url_report.yml +0 -95
  60. data/test/fixtures/url_scan.yml +0 -48
  61. data/test/url_report_test.rb +0 -57
  62. data/test/url_scan_test.rb +0 -30
@@ -1,48 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://www.virustotal.com/vtapi/v2/url/scan
6
- body:
7
- encoding: UTF-8
8
- string: apikey=testapikey&url=http%3A%2F%2Fwww.google.com
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (linux-gnu x86_64) ruby/2.5.1p57
16
- Content-Length:
17
- - '103'
18
- Content-Type:
19
- - application/x-www-form-urlencoded
20
- Host:
21
- - www.virustotal.com
22
- response:
23
- status:
24
- code: 200
25
- message: OK
26
- headers:
27
- Cache-Control:
28
- - no-cache
29
- Content-Type:
30
- - application/json
31
- X-Cloud-Trace-Context:
32
- - 3e75d46007d403e053ab2dea60a4aa71
33
- Date:
34
- - Wed, 10 Jul 2019 09:49:10 GMT
35
- Server:
36
- - Google Frontend
37
- Content-Length:
38
- - '433'
39
- body:
40
- encoding: UTF-8
41
- string: '{"permalink": "https://www.virustotal.com/url/dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf/analysis/1562751553/",
42
- "resource": "http://www.google.com/", "url": "http://www.google.com/", "response_code":
43
- 1, "scan_date": "2019-07-10 09:39:13", "scan_id": "dd014af5ed6b38d9130e3f466f850e46d21b951199d53a18ef29ee9341614eaf-1562751553",
44
- "verbose_msg": "Scan request successfully queued, come back later for the
45
- report"}'
46
- http_version:
47
- recorded_at: Wed, 10 Jul 2019 09:48:46 GMT
48
- recorded_with: VCR 5.0.0
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require './test/test_helper'
4
-
5
- class VirustotalAPIURLReportTest < Minitest::Test
6
- def setup
7
- @unscanned_url = 'http://www.unscanned.com'
8
- @url = 'http://www.google.com'
9
- @api_key = 'testapikey'
10
- end
11
-
12
- def test_class_exists
13
- assert VirustotalAPI::URLReport
14
- end
15
-
16
- def test_report_response
17
- VCR.use_cassette('url_report') do
18
- vturl_report = VirustotalAPI::URLReport.find(@url, @api_key)
19
-
20
- # Make sure that the JSON was parsed
21
- assert vturl_report.is_a?(VirustotalAPI::URLReport)
22
- assert vturl_report.report.is_a?(Hash)
23
- end
24
- end
25
-
26
- def test_report_url
27
- VCR.use_cassette('url_report') do
28
- vturl_report = VirustotalAPI::URLReport.find(@url, @api_key)
29
-
30
- assert vturl_report.report_url.is_a?(String)
31
- end
32
- end
33
-
34
- def test_scan_url
35
- VCR.use_cassette('url_report') do
36
- vturl_report = VirustotalAPI::URLReport.find(@url, @api_key)
37
-
38
- assert vturl_report.scan_id.is_a?(String)
39
- end
40
- end
41
-
42
- def test_scan_unscanned_url
43
- VCR.use_cassette('unscanned_url_report') do
44
- vturl_report = VirustotalAPI::URLReport.find(@unscanned_url, @api_key)
45
-
46
- assert vturl_report.report['response_code'].zero?
47
- end
48
- end
49
-
50
- def test_queue_unscanned_url
51
- VCR.use_cassette('queue_unscanned_url_report') do
52
- vturl_report = VirustotalAPI::URLReport.find(@unscanned_url, @api_key, 1)
53
-
54
- assert vturl_report.report['response_code'] == 1
55
- end
56
- end
57
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require './test/test_helper'
4
-
5
- class VirustotalAPIURLScanTest < Minitest::Test
6
- def setup
7
- @url = 'http://www.google.com'
8
- @api_key = 'testapikey'
9
- end
10
-
11
- def test_class_exists
12
- assert VirustotalAPI::URLScan
13
- end
14
-
15
- def test_scan_response
16
- VCR.use_cassette('url_scan') do
17
- vturl_scan = VirustotalAPI::URLScan.scan(@url, @api_key)
18
-
19
- assert vturl_scan.report.is_a?(Hash)
20
- end
21
- end
22
-
23
- def test_scan_url
24
- VCR.use_cassette('url_scan') do
25
- vturl_scan = VirustotalAPI::URLScan.scan(@url, @api_key)
26
-
27
- assert vturl_scan.scan_id.is_a?(String)
28
- end
29
- end
30
- end