Class: Hyrax::VirusCheckerService
- Inherits:
-
Object
- Object
- Hyrax::VirusCheckerService
- Defined in:
- app/services/hyrax/virus_checker_service.rb
Overview
Responsible for checking if the given file is a virus. Coordinates with the underlying system virus scanner.
Instance Attribute Summary collapse
-
#original_file ⇒ Object
Returns the value of attribute original_file.
-
#system_virus_scanner ⇒ Object
Returns the value of attribute system_virus_scanner.
Class Method Summary collapse
-
.file_has_virus?(original_file) ⇒ Boolean
True or false result from system_virus_scanner.
Instance Method Summary collapse
-
#file_has_virus? ⇒ Boolean
Default behavior is to raise a validation error and halt the save if a virus is found.
-
#initialize(original_file, system_virus_scanner = Hyrax.config.virus_scanner) ⇒ VirusCheckerService
constructor
A new instance of VirusCheckerService.
Constructor Details
#initialize(original_file, system_virus_scanner = Hyrax.config.virus_scanner) ⇒ VirusCheckerService
Returns a new instance of VirusCheckerService.
15 16 17 18 |
# File 'app/services/hyrax/virus_checker_service.rb', line 15 def initialize(original_file, system_virus_scanner = Hyrax.config.virus_scanner) self.original_file = original_file self.system_virus_scanner = system_virus_scanner end |
Instance Attribute Details
#original_file ⇒ Object
Returns the value of attribute original_file.
6 7 8 |
# File 'app/services/hyrax/virus_checker_service.rb', line 6 def original_file @original_file end |
#system_virus_scanner ⇒ Object
Returns the value of attribute system_virus_scanner.
6 7 8 |
# File 'app/services/hyrax/virus_checker_service.rb', line 6 def system_virus_scanner @system_virus_scanner end |
Class Method Details
.file_has_virus?(original_file) ⇒ Boolean
Returns true or false result from system_virus_scanner.
11 12 13 |
# File 'app/services/hyrax/virus_checker_service.rb', line 11 def self.file_has_virus?(original_file) new(original_file).file_has_virus? end |
Instance Method Details
#file_has_virus? ⇒ Boolean
Default behavior is to raise a validation error and halt the save if a virus is found
21 22 23 24 |
# File 'app/services/hyrax/virus_checker_service.rb', line 21 def file_has_virus? path = original_file.is_a?(String) ? original_file : local_path_for_file(original_file) system_virus_scanner.infected?(path) end |