Skip to content

Atbash-Labs/clamproxy

Repository files navigation

clamproxy

Clamproxy is a lighweight API on top of ClamAV that allows you to scan files for viruses via HTTP requests.

It was designed to be used as a microservice in containerized environments, making it easy to integrate virus scanning into your applications without the need to directly interact with ClamAV.

Features

  • Simple HTTP API for scanning files
  • It requires the files to be present on the local filesystem. In containerized environments, this can be achieved using shared volumes.
  • Returns JSON responses with scan results

Installing

You can download linux statically linked binaries or RPM packages from the releases page.

Example Usage

Start clamproxy, it will start the HTTP server after 10-12 seconds to allow ClamAV to initialize.

$ clamproxy api

It needs clamav databases, so make sure you have them available. You can use freshclam to download them.

Example:

$ freshclam

Optionally it can be configured using -d flag to point to the ClamAV database directory.

Getting a scan result:

$ curl -XPOST -d '{"filename":"/path/to/internal/fixtures/eicar.com"}' http://localhost:3311/api/v1/scan | python3 -mjson.tool
{
    "FileName": "eicar.com",
    "FileType": "CL_TYPE_TEXT_ASCII",
    "FileSize": 68,
    "FileMD5": "44d88612fea8a8f36de82e1278abb02f",
    "Viruses": [
        "Win.Test.EICAR_HDB-1",
        "Win.Test.EICAR_HSB-1",
        "Eicar-Signature"
    ],
    "Magic": "CLAMJSONv0",
    "RootFileType": "CL_TYPE_TEXT_ASCII",
    "Status": false
}

Building

To build the Clamproxy Docker image, use the following command:

bazel build //...

This will create a static linked binary including the HTTP API and the ClamAV engine.

License

Clamproxy is licensed under the GNU General Public License v2.0. See the LICENSE file for details.