Skip to content

Commit

Permalink
Add ratonvirus gem for documents and message attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmhaig committed Jan 3, 2024
1 parent ba40c3a commit c3eaa1a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ gem 'active_storage_validations'
gem 'faraday', '~> 1.10'
gem 'faraday_middleware', '~> 1.2'
gem 'puma'
gem 'ratonvirus'
gem 'ratonvirus-clamby'

group :development, :test do
gem 'annotate'
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ GEM
case_transform (0.2)
activesupport
chartkick (5.0.5)
clamby (1.6.10)
cocoon (1.2.15)
coderay (1.1.3)
coercible (1.0.0)
Expand Down Expand Up @@ -512,6 +513,11 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (13.1.0)
ratonvirus (0.3.2)
activesupport (~> 6.0)
ratonvirus-clamby (0.3.0)
clamby (~> 1.6)
ratonvirus (~> 0.3.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -764,6 +770,8 @@ DEPENDENCIES
rack-livereload (~> 0.5.1)
rails (~> 6.1.7)
rails-controller-testing
ratonvirus
ratonvirus-clamby
redis (~> 5.0.8)
remotipart (~> 1.4)
rest-client (~> 2.1)
Expand Down
1 change: 1 addition & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Document < ApplicationRecord
image/bmp
image/x-bitmap
]
validates :document, antivirus: true

alias attachment document # to have a consistent interface to both Document and Message
delegate :provider_id, to: :external_user
Expand Down
1 change: 1 addition & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Message < ApplicationRecord
image/bmp
image/x-bitmap
]
validates :attachment, antivirus: true

validates :sender, presence: true
validates :body, presence: true
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/ratonvirus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ratonvirus.configure do |config|
config.scanner = :clamby
config.storage = :active_storage
end

0 comments on commit c3eaa1a

Please sign in to comment.