Module: Common::VirusScan

Defined in:
lib/common/virus_scan.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.mock_enabled?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/common/virus_scan.rb', line 21

def mock_enabled?
  Settings.clamav.mock
end

.scan(file_path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/common/virus_scan.rb', line 10

def scan(file_path)
  # `clamd` runs within service group, needs group read
  File.chmod(0o640, file_path)

  if mock_enabled?
    true
  else
    ClamAV::PatchClient.new.safe?(file_path) # patch to call our class
  end
end

Instance Method Details

#mock_enabled?Object (private)



21
22
23
# File 'lib/common/virus_scan.rb', line 21

def mock_enabled?
  Settings.clamav.mock
end

#scan(file_path) ⇒ Object (private)



10
11
12
13
14
15
16
17
18
19
# File 'lib/common/virus_scan.rb', line 10

def scan(file_path)
  # `clamd` runs within service group, needs group read
  File.chmod(0o640, file_path)

  if mock_enabled?
    true
  else
    ClamAV::PatchClient.new.safe?(file_path) # patch to call our class
  end
end