Class: Ddr::Actions::VirusCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/ddr/actions/virus_check.rb

Class Method Summary collapse

Class Method Details

.call(file_path) ⇒ Hash

Returns result data.

Returns:

  • (Hash)

    result data



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ddr/actions/virus_check.rb', line 10

def self.call(file_path)
  unless File.exist?(file_path)
    raise Error, "File not found: #{file_path}"
  end
  result = {}
  begin
    scan_result = Ddr::Antivirus.scan(file_path)
  rescue Ddr::Antivirus::ScannerError => e
    result[:exception] = [e.class.name, e.to_s]
    scan_result = e.result
  end
  result[:event_date_time] = scan_result.scanned_at
  result[:software]        = scan_result.version
  result[:detail]          = scan_result.output
  result
end