Antivirus wrapper

ClamAV wrapper to scan files for malware.

antivirus.antivirus.scan_file(path)[source]

Scan path for viruses using clamd or clamscan (depends on settings.USE_CLAMD.

Parameters:

path (str) – Relative or absolute path of file/directory you need to scan.

Returns:

{filename: ("FOUND", "virus type")} or blank dict.

Return type:

dict

Raises:
  • ValueError – When the server is not running.
  • AssertionError – When the internal file doesn’t exists.
antivirus.antivirus.save_and_scan(filename, b64_data)[source]

Save b64_data to temporary file and scan it for viruses.

Parameters:
  • filename (str) – Name of the file - used as basename for tmp file.
  • b64_data (str) – Content of the file encoded in base64.
Returns:

{filename: ("FOUND", "virus type")} or blank dict.

Return type:

dict