upload.clam - Scan for Malware with ClamAV

Malware and virus scanning with ClamAV.

upload.clam.get_clamd_socket() ClamdNetworkSocket | None

Return a socket that can be used to communicate with clamd over the network.

Returns:

None if CLAMAV_ENABLED is False, otherwise, the connection object

upload.clam.check_for_malware(file: File) None

Scan the file for malware.

If CLAMAV_ENABLED is False, return early.

Raises:
  • ValidationError – If the file contains malware.

  • ConnectionError – If the connection to ClamAV cannot be established or if there is a communication error.

  • ValueError – If the file is too large to be scanned.