vigilion-rails 2.0.0 → 2.1.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 +4 -4
- data/app/jobs/vigilion_rails/application_job.rb +9 -0
- data/app/jobs/vigilion_rails/vigilion_scan_job.rb +10 -0
- data/lib/vigilion-rails/configuration.rb +1 -0
- data/lib/vigilion-rails/version.rb +1 -1
- data/lib/vigilion-rails.rb +7 -1
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/config/application.rb +0 -4
- data/spec/dummy/config/initializers/vigilion.rb +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +10018 -0
- data/spec/jobs/vigilion_rails/vigilion_scan_job_spec.rb +26 -0
- data/spec/lib/integrations/local_integration_spec.rb +2 -2
- data/spec/lib/vigilion_rails_spec.rb +35 -1
- data/spec/vigilion_rails_helper.rb +2 -0
- metadata +34 -9
@@ -0,0 +1,26 @@
|
|
1
|
+
require "vigilion_rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe VigilionRails::VigilionScanJob do
|
4
|
+
disable_loopback
|
5
|
+
it "matches with performed job" do
|
6
|
+
ActiveJob::Base.queue_adapter = :test
|
7
|
+
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
|
8
|
+
document = CarrierwaveDocument.create
|
9
|
+
key = { model: document.class.name, column: 'attachment', id: document.id }
|
10
|
+
|
11
|
+
stub_request(:post, "https://api.vigilion.com/scans").
|
12
|
+
with(
|
13
|
+
body: "{\"scan\":{\"key\":{\"model\":\"CarrierwaveDocument\",\"column\":\"attachment\",\"id\":1},\"url\":null}}",
|
14
|
+
headers: {
|
15
|
+
'Accept'=>'*/*',
|
16
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
17
|
+
'Content-Type'=>'application/json',
|
18
|
+
'User-Agent'=>'Vigilion 1.0.4 (x86_64-darwin19, Ruby 2.7.1)',
|
19
|
+
'X-Api-Key'=>'test'
|
20
|
+
}).
|
21
|
+
to_return(status: 200, body: "", headers: {})
|
22
|
+
|
23
|
+
VigilionRails::VigilionScanJob.perform_later("VigilionRails::UrlIntegration", document.class.name, document.id, key, 'attachment')
|
24
|
+
expect(VigilionRails::VigilionScanJob).to have_been_performed
|
25
|
+
end
|
26
|
+
end
|
@@ -5,9 +5,9 @@ describe VigilionRails::LocalIntegration do
|
|
5
5
|
|
6
6
|
describe "#scan" do
|
7
7
|
it "calls vigilion scanner" do
|
8
|
-
document = CarrierwaveDocument.
|
8
|
+
document = CarrierwaveDocument.create
|
9
9
|
expect(Vigilion).to receive(:scan_path)
|
10
10
|
document.scan_attachment!
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "vigilion_rails_helper"
|
2
2
|
|
3
3
|
describe VigilionRails do
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
4
6
|
describe "#clean?" do
|
5
7
|
context "without scan results" do
|
6
8
|
it "is not clean" do
|
@@ -32,7 +34,7 @@ describe VigilionRails do
|
|
32
34
|
disable_loopback
|
33
35
|
|
34
36
|
it "calls vigilion scanner" do
|
35
|
-
document = AgnosticDocument.
|
37
|
+
document = AgnosticDocument.create
|
36
38
|
expect(Vigilion).to receive(:scan_url)
|
37
39
|
document.scan_attachment!
|
38
40
|
end
|
@@ -119,4 +121,36 @@ describe VigilionRails do
|
|
119
121
|
end
|
120
122
|
end
|
121
123
|
end
|
124
|
+
|
125
|
+
describe "#active_job" do
|
126
|
+
before do
|
127
|
+
Vigilion::Configuration.loopback = false
|
128
|
+
Vigilion::Configuration.active_job = true
|
129
|
+
Vigilion::Configuration.integration = :url
|
130
|
+
end
|
131
|
+
|
132
|
+
it "enqueues a job" do
|
133
|
+
document = AgnosticDocument.create
|
134
|
+
expect {
|
135
|
+
document.scan_attachment!
|
136
|
+
}.to have_enqueued_job(::VigilionRails::VigilionScanJob)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'calls proper integration' do
|
140
|
+
document = AgnosticDocument.create
|
141
|
+
key = { model: document.class.name, column: 'attachment', id: document.id }.to_json
|
142
|
+
expect_any_instance_of(
|
143
|
+
::VigilionRails::UrlIntegration
|
144
|
+
).to receive(:scan).with(key, document, :attachment)
|
145
|
+
perform_enqueued_jobs do
|
146
|
+
document.scan_attachment!
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'sets default status' do
|
151
|
+
document = AgnosticDocument.create
|
152
|
+
document.scan_attachment!
|
153
|
+
expect(document.reload.attachment_scan_results).to eq "pending"
|
154
|
+
end
|
155
|
+
end
|
122
156
|
end
|
@@ -4,8 +4,10 @@ require 'spec_helper'
|
|
4
4
|
require File.expand_path('../dummy/config/environment', __FILE__)
|
5
5
|
require 'rspec/rails'
|
6
6
|
require 'helper_methods'
|
7
|
+
require 'webmock/rspec'
|
7
8
|
|
8
9
|
ActiveRecord::Migration.maintain_test_schema!
|
10
|
+
ActiveJob::Base.queue_adapter = :test
|
9
11
|
|
10
12
|
RSpec.configure do |config|
|
11
13
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigilion-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bit Zesty Ltd
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.3.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.3.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: vigilion
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
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
|
description: Rails engine for Vigilion Anti-Virus & Malware file scanning service.
|
84
98
|
email:
|
85
99
|
- help@vigilion.com
|
@@ -90,6 +104,8 @@ files:
|
|
90
104
|
- MIT-LICENSE
|
91
105
|
- Rakefile
|
92
106
|
- app/controllers/vigilion/vigilion_controller.rb
|
107
|
+
- app/jobs/vigilion_rails/application_job.rb
|
108
|
+
- app/jobs/vigilion_rails/vigilion_scan_job.rb
|
93
109
|
- config/routes.rb
|
94
110
|
- lib/generators/vigilion/install_generator.rb
|
95
111
|
- lib/generators/vigilion/scan/USAGE
|
@@ -104,6 +120,7 @@ files:
|
|
104
120
|
- lib/vigilion-rails/version.rb
|
105
121
|
- spec/dummy/README.rdoc
|
106
122
|
- spec/dummy/Rakefile
|
123
|
+
- spec/dummy/app/assets/config/manifest.js
|
107
124
|
- spec/dummy/app/assets/javascripts/application.js
|
108
125
|
- spec/dummy/app/assets/stylesheets/application.css
|
109
126
|
- spec/dummy/app/controllers/application_controller.rb
|
@@ -133,6 +150,7 @@ files:
|
|
133
150
|
- spec/dummy/config/initializers/inflections.rb
|
134
151
|
- spec/dummy/config/initializers/mime_types.rb
|
135
152
|
- spec/dummy/config/initializers/session_store.rb
|
153
|
+
- spec/dummy/config/initializers/vigilion.rb
|
136
154
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
137
155
|
- spec/dummy/config/locales/en.yml
|
138
156
|
- spec/dummy/config/routes.rb
|
@@ -142,11 +160,14 @@ files:
|
|
142
160
|
- spec/dummy/db/migrate/20150616144235_create_dragonfly_documents.rb
|
143
161
|
- spec/dummy/db/migrate/20150616144544_create_agnostic_documents.rb
|
144
162
|
- spec/dummy/db/schema.rb
|
163
|
+
- spec/dummy/db/test.sqlite3
|
164
|
+
- spec/dummy/log/test.log
|
145
165
|
- spec/dummy/public/404.html
|
146
166
|
- spec/dummy/public/422.html
|
147
167
|
- spec/dummy/public/500.html
|
148
168
|
- spec/dummy/public/favicon.ico
|
149
169
|
- spec/helper_methods.rb
|
170
|
+
- spec/jobs/vigilion_rails/vigilion_scan_job_spec.rb
|
150
171
|
- spec/lib/integrations/local_integration_spec.rb
|
151
172
|
- spec/lib/vigilion_rails_spec.rb
|
152
173
|
- spec/routing/vigilion_routing_spec.rb
|
@@ -156,7 +177,7 @@ homepage: https://github.com/vigilion/vigilion-rails
|
|
156
177
|
licenses:
|
157
178
|
- MIT
|
158
179
|
metadata: {}
|
159
|
-
post_install_message:
|
180
|
+
post_install_message:
|
160
181
|
rdoc_options: []
|
161
182
|
require_paths:
|
162
183
|
- lib
|
@@ -171,9 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
192
|
- !ruby/object:Gem::Version
|
172
193
|
version: '0'
|
173
194
|
requirements: []
|
174
|
-
|
175
|
-
|
176
|
-
signing_key:
|
195
|
+
rubygems_version: 3.1.2
|
196
|
+
signing_key:
|
177
197
|
specification_version: 4
|
178
198
|
summary: Rails engine for Vigilion Anti-Virus & Malware file scanning service.
|
179
199
|
test_files:
|
@@ -186,6 +206,7 @@ test_files:
|
|
186
206
|
- spec/dummy/app/models/dragonfly_document.rb
|
187
207
|
- spec/dummy/app/controllers/application_controller.rb
|
188
208
|
- spec/dummy/app/views/layouts/application.html.erb
|
209
|
+
- spec/dummy/app/assets/config/manifest.js
|
189
210
|
- spec/dummy/app/assets/javascripts/application.js
|
190
211
|
- spec/dummy/app/assets/stylesheets/application.css
|
191
212
|
- spec/dummy/app/helpers/application_helper.rb
|
@@ -210,6 +231,7 @@ test_files:
|
|
210
231
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
211
232
|
- spec/dummy/config/initializers/assets.rb
|
212
233
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
234
|
+
- spec/dummy/config/initializers/vigilion.rb
|
213
235
|
- spec/dummy/config/initializers/inflections.rb
|
214
236
|
- spec/dummy/config.ru
|
215
237
|
- spec/dummy/Rakefile
|
@@ -218,12 +240,15 @@ test_files:
|
|
218
240
|
- spec/dummy/public/500.html
|
219
241
|
- spec/dummy/public/404.html
|
220
242
|
- spec/dummy/db/schema.rb
|
243
|
+
- spec/dummy/db/test.sqlite3
|
221
244
|
- spec/dummy/db/migrate/20150616144235_create_dragonfly_documents.rb
|
222
245
|
- spec/dummy/db/migrate/20150616144544_create_agnostic_documents.rb
|
223
246
|
- spec/dummy/db/migrate/20150616144227_create_paperclip_documents.rb
|
224
247
|
- spec/dummy/db/migrate/20150616144220_create_carrierwave_documents.rb
|
248
|
+
- spec/dummy/log/test.log
|
225
249
|
- spec/dummy/README.rdoc
|
226
250
|
- spec/helper_methods.rb
|
227
251
|
- spec/lib/vigilion_rails_spec.rb
|
228
252
|
- spec/lib/integrations/local_integration_spec.rb
|
229
253
|
- spec/routing/vigilion_routing_spec.rb
|
254
|
+
- spec/jobs/vigilion_rails/vigilion_scan_job_spec.rb
|