An Elm library that provides access to the ClamAV virus scanning API.
This library is built on top of the node
ClamAV
library, clamav.js, which uses ClamAV to provide its virus scanning functionality.
Since the Elm Package Manager doesn't allow for Native code and this uses Native code, you have to install it directly from GitHub, e.g. via elm-github-install or some equivalent mechanism.
ClamAV daemon must be installed at the clamavHost
and clamavPort
(see ClamAV Config
below).
You'll also need to install the dependent node modules at the root of your Application Directory. See the example package.json
for a list of the dependencies.
The installation can be done via npm install
command.
Purpose is to test the clamav.js
virus scanning API that this library supports . Use aBuild.sh
or build.sh
to build it and run it with node main.js
command (see main.js
for command line parameters).
Config
type alias Config =
{ clamavHost : String
, clamavPort : Int
, debug : Bool
}
clamavHost
is the host name where theClamAV
daemon is running.clamavPort
is the port where theClamAV
daemon is running.debug
is True if debug logging is desired, False otherwise
Usage
config : Config
config =
{ clamavHost = "clamavHost"
, clamavPort = 3310
, debug = False
}
Scan File for virus
Scan file for a virus using the ClamAV daemon.
scanFile : Config -> String -> ScannerCompleteTagger msg -> Cmd msg
scanFile config filename tagger =
Usage
scanFile config filename ScannerComplete
ScannerComplete
is your application's message to handle the different result scenariosconfig
has fields used to configure the requestfilename
is the name of the file to scan for a virus
Scan Buffer for virus
Scan a Buffer for a virus using the ClamAV daemon. This command uses Buffer
defined in elm-node/core.
scanBuffer : Config -> String -> Buffer -> ScannerCompleteTagger msg -> Cmd msg
scanBuffer config targetName targetBuffer tagger =
Usage
scanBuffer config targetName targetBuffer ScannerComplete
ScannerComplete
is your application's message to handle the different result scenariosconfig
has fields used to configure the requesttargetName
is the name used to identify this scan in theScannerComplete
msgtargetBuffer
is the buffer to scan for a virus
Scan String for virus
Scan a String for a virus using the ClamAV daemon. This command uses Encoding
defined in elm-node/core.
scanString : Config -> String -> String -> Encoding -> ScannerCompleteTagger msg -> Cmd msg
scanString config targetName targetString encoding tagger =
Usage
scanString config targetName targetString encoding ScannerComplete =
ScannerComplete
is your application's message to handle the different result scenariosconfig
has fields used to configure the requesttargetName
is the name used to identify this scan in theScannerComplete
msgtargetString
is the string to scan for a virusencoding
is the encoding of the targetString (seeEncoding
defined in elm-node/core)
There are no subscriptions.
Scan Name. This is filename
for the ScanFile
operation, and targetName
for ScanBuffer
and ScanString
operations.
type alias Name =
String
Error information from a scan.
type alias Error =
{ message : String
, virusName : Maybe String
}
message
is the error message returned from the scanvirusName
the name of the virus if a virus was found during the scan, otherwiseNothing
Returns an Elm Result indicating a successful call to one of the Scan
operations or an error consisting of (Name, Error)
.
type alias ScannerComplete msg =
Result ( Name, Error ) Name -> msg
Usage
ScannerComplete (Ok name) ->
let
l =
Debug.log "ScannerComplete" name
in
model ! []
ScannerComplete (Err (name, error)) ->
let
l =
Debug.log "ScannerComplete Error" (name, error)
in
model ! []