ratonvirus-resty 0.1.1 → 0.1.3
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/lib/generators/{ratonviurs → ratonvirus}/resty/install_generator.rb +5 -3
- data/lib/generators/{ratonviurs → ratonvirus}/resty/templates/initializer.rb +2 -2
- data/lib/ratonvirus-resty.rb +1 -0
- data/lib/ratonvirus/resty.rb +9 -9
- data/lib/ratonvirus/resty/configuration.rb +1 -1
- data/lib/ratonvirus/resty/engine.rb +7 -0
- data/lib/ratonvirus/resty/version.rb +1 -1
- data/lib/ratonvirus/scanner/resty.rb +3 -1
- data/lib/ratonvirus/services/antivirus_check_service.rb +8 -4
- metadata +34 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15dd0661f5bc47ba5974958510bdb043f49bbdb5ffd29ac5495ea42c2c624630
|
4
|
+
data.tar.gz: db8e7fad6066f97c825ff8da1dfe1774e069fb8c485091cf358aa9f0854ffb62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc75b3e5e55c32314f2e57f9f820105f2799ac8bcd19f004e4ab70163d95fce2c3439b30c0ad87b801abd71aeb24be6f1f8412652ed38a9df26d66346d30b052
|
7
|
+
data.tar.gz: 69f714a9a6842e3443df38f176ee61809cee5caa4379e7c35977c751a043ce431aaa41bfd6174565645f04b2774eb1800bbceace4554d3f0e4b5c29bac61cbe5
|
@@ -1,15 +1,17 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
1
3
|
module Ratonvirus
|
2
4
|
module Resty
|
3
5
|
module Generators
|
4
|
-
class InstallGenerator
|
5
|
-
|
6
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
7
|
desc 'Generates the initializer'
|
7
8
|
|
8
9
|
source_root File.expand_path('../templates', __FILE__)
|
9
10
|
|
10
11
|
def generate_initializer
|
11
|
-
template 'initializer.rb', 'config/initializers/
|
12
|
+
template 'initializer.rb', 'config/initializers/ratonvirus-resty.rb'
|
12
13
|
end
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -7,9 +7,9 @@ Ratonvirus::Resty.configure do |config|
|
|
7
7
|
|
8
8
|
# Optional sets the username for api requests
|
9
9
|
#
|
10
|
-
# config.username = ENV.fetch('
|
10
|
+
# config.username = ENV.fetch('RESTY_USERNAME', nil)
|
11
11
|
#
|
12
|
-
config.username = ENV.fetch('
|
12
|
+
config.username = ENV.fetch('RESTY_USERNAME', nil)
|
13
13
|
# Optional sets the password for api requests
|
14
14
|
#
|
15
15
|
# config.password = ENV.fetch('RESTY_PASSWORD', nil)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'ratonvirus/resty'
|
data/lib/ratonvirus/resty.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require "faraday"
|
4
|
-
require "mimemagic"
|
1
|
+
require 'faraday'
|
2
|
+
require 'mimemagic'
|
5
3
|
require 'active_support'
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
require 'rails'
|
5
|
+
require 'ratonvirus/resty/version'
|
6
|
+
require 'ratonvirus/scanner/resty'
|
7
|
+
require 'ratonvirus/resty/configuration'
|
8
|
+
require 'ratonvirus/services/antivirus_check_service'
|
9
|
+
require 'ratonvirus/resty/engine' if defined?("Rails")
|
9
10
|
|
10
11
|
module Ratonvirus
|
11
|
-
autoload :AntivirusCheckService, 'ratonvirus/services/antivirus_check_service'
|
12
|
-
|
13
12
|
module Resty
|
14
13
|
extend Configuration
|
14
|
+
|
15
15
|
class Error < StandardError; end
|
16
16
|
end
|
17
17
|
end
|
@@ -9,7 +9,7 @@ module Ratonvirus
|
|
9
9
|
end
|
10
10
|
|
11
11
|
mattr_accessor(:service_url) { ENV.fetch('RESTY_SERVICE_URL', 'http://localhost:9000/scan') }
|
12
|
-
mattr_accessor(:username) { ENV.fetch('
|
12
|
+
mattr_accessor(:username) { ENV.fetch('RESTY_USERNAME', nil) }
|
13
13
|
mattr_accessor(:password) { ENV.fetch('RESTY_PASSWORD', nil) }
|
14
14
|
mattr_accessor(:proxy_url) { ENV.fetch('PROXY_URL') { nil } }
|
15
15
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'ratonvirus'
|
2
|
+
require "ratonvirus/services/antivirus_check_service"
|
2
3
|
|
3
4
|
module Ratonvirus
|
4
5
|
module Scanner
|
5
6
|
class Resty < Ratonvirus::Scanner::Base
|
7
|
+
|
6
8
|
class << self
|
7
9
|
def executable?
|
8
10
|
AntivirusCheckService.installed?
|
@@ -15,7 +17,7 @@ module Ratonvirus
|
|
15
17
|
if File.file?(path)
|
16
18
|
result = AntivirusCheckService.new(path).call
|
17
19
|
if result.virus?
|
18
|
-
errors << :
|
20
|
+
errors << :antivirus_virus_detected
|
19
21
|
end
|
20
22
|
else
|
21
23
|
errors << :antivirus_file_not_found
|
@@ -17,7 +17,7 @@ module Ratonvirus
|
|
17
17
|
@result = Result.new
|
18
18
|
end
|
19
19
|
|
20
|
-
def installed?
|
20
|
+
def self.installed?
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
@@ -31,7 +31,10 @@ module Ratonvirus
|
|
31
31
|
def perform_request
|
32
32
|
@logger.debug { "Performing request to #{base_url}" }
|
33
33
|
begin
|
34
|
-
@response = connection.post(base_url
|
34
|
+
@response = connection.post(base_url) do |request|
|
35
|
+
request.headers['Content-Type'] = 'multipart/form-data'
|
36
|
+
request.body = { file: initialize_upload_file }
|
37
|
+
end
|
35
38
|
@result.parsed_response = parse_response
|
36
39
|
unless @response.success?
|
37
40
|
@logger.debug { "API request respond with status code #{@response.status}: #{parse_response}"}
|
@@ -42,8 +45,9 @@ module Ratonvirus
|
|
42
45
|
end
|
43
46
|
|
44
47
|
def parse_response
|
45
|
-
@logger.debug { "Parsing response #{@response}"}
|
46
|
-
|
48
|
+
@logger.debug { "Parsing response #{@response.body}"}
|
49
|
+
string_to_parse = @response.body.gsub("Status","\"Status\"").gsub("Description","\"Description\"")
|
50
|
+
JSON.parse(string_to_parse).transform_keys(&:downcase)
|
47
51
|
end
|
48
52
|
|
49
53
|
def connection
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratonvirus-resty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Müller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 0.13.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: generator_spec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: simplecov
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,10 +173,12 @@ extensions: []
|
|
145
173
|
extra_rdoc_files: []
|
146
174
|
files:
|
147
175
|
- README.md
|
148
|
-
- lib/generators/
|
149
|
-
- lib/generators/
|
176
|
+
- lib/generators/ratonvirus/resty/install_generator.rb
|
177
|
+
- lib/generators/ratonvirus/resty/templates/initializer.rb
|
178
|
+
- lib/ratonvirus-resty.rb
|
150
179
|
- lib/ratonvirus/resty.rb
|
151
180
|
- lib/ratonvirus/resty/configuration.rb
|
181
|
+
- lib/ratonvirus/resty/engine.rb
|
152
182
|
- lib/ratonvirus/resty/version.rb
|
153
183
|
- lib/ratonvirus/scanner/resty.rb
|
154
184
|
- lib/ratonvirus/services/antivirus_check_service.rb
|