Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #197 from alphagov/clamav-errors
Browse files Browse the repository at this point in the history
fixing scanned_file.py to handle clamdscan errors
  • Loading branch information
roc committed Dec 13, 2013
2 parents 1415079 + 7adaa44 commit 8f60ebe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions backdrop/write/scanned_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ def _save_file_to_disk(self):
self.file_object.save(self._file_path)

def _scan_file(self):
self._virus_signature = self._virus_signature or self._clamscan(
self._file_path)
self._virus_signature = (self._virus_signature or
self._clamscan(self._file_path))

def _clamscan(self, filename):
return bool(subprocess.call(["clamdscan", filename]))
retcode = subprocess.call(["clamdscan", filename])
# 0 : No virus found.
# 1 : Virus(es) found.
# 2 : An error occured.
if retcode == 0:
return False
elif retcode == 1:
return True
elif retcode == 2:
raise SystemError('Error running the clamdscan virus scanner')

def _clean_up(self):
# Remove temporary file
Expand Down

0 comments on commit 8f60ebe

Please sign in to comment.