Clamex v0.2.2 Clamex View Source

Clamex is a thin wrapper for ClamAV.

Link to this section Summary

Functions

Check if file is safe

Perform file scan

Check if file is infected

Link to this section Functions

Specs

safe?(path :: Path.t()) :: boolean()

Check if file is safe

Examples

iex> Clamex.safe?("virus.txt")
false

iex> Clamex.safe?("safe.txt")
true

Specs

scan(path :: Path.t()) :: :ok | {:error, atom()} | {:error, String.t()}

Perform file scan

Examples

iex> Clamex.scan("virus.txt")
{:error, :virus_found}

iex> Clamex.scan("safe.txt")
:ok

Error reasons

  • :virus_found - file is infected
  • :cannot_access_file - file specified as path cannot be accessed
  • :scanner_not_available - scanner is not available at executable_path
  • :cannot_connect_to_clamd - ClamAV daemon is not running in background
  • any other error reported by the scanner will be returned as is (as String)

Specs

virus?(path :: Path.t()) :: boolean()

Check if file is infected

Examples

iex> Clamex.virus?("virus.txt")
true

iex> Clamex.virus?("safe.txt")
false