Skip to main content

Asynchronous client for virus scanning with ClamAV

Project description

aioclamd

aioclamd Build and Test Format and Lint Publish to pypi.org Publish to test.pypi.org

This package is an asynchronous version of the pleasant package python-clamd. It has the same external API, only all methods are coroutines and all communication is handled asynchronously using the asyncio framework.

The ClamdAsyncClient connects to a ClamAV antivirus instance and scans files and data for malicious threats. This package does not bundle ClamAV in any way, so a running instance of the clamd deamon is required.

Installation

pip install aioclamd

Usage

To scan a file (on the system where ClamAV is installed):

import asyncio

from aioclamd import ClamdAsyncClient

async def main(host, port):
    clamd = ClamdAsyncClient(host, port)
    print(await clamd.scan('/etc/clamav/clamd.conf'))

asyncio.run(main("127.0.0.1", 3310))

# Output:
# {'/etc/clamav/clamd.conf': ('OK', None)}

To scan a data stream:

import asyncio
import base64
from io import BytesIO

from aioclamd import ClamdAsyncClient

EICAR = BytesIO(
    base64.b64decode(
        b"WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNU"
        b"QU5EQVJELUFOVElWSVJVUy1URVNU\nLUZJTEUhJEgrSCo=\n"
    )
)

async def main(host, port):
    clamd = ClamdAsyncClient(host, port)
    print(await clamd.instream(EICAR))

asyncio.run(main("127.0.0.1", 3310))

# Output:
# {'stream': ('FOUND', 'Win.Test.EICAR_HDB-1')}

Development

A local instance of ClamAV can be had with Docker:

docker run -p 3310:3310 --rm clamav/clamav

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioclamd-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

aioclamd-1.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file aioclamd-1.0.0.tar.gz.

File metadata

  • Download URL: aioclamd-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.8.10 Linux/5.15.0-1019-azure

File hashes

Hashes for aioclamd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7b14e94e3a2285cc89e2f4d434e2a01f322d3cb95476ce2dda015a7980876047
MD5 97b03f6615b14b15f9b57926ba3ff2e9
BLAKE2b-256 6ee75abc85b9997cd5c2076ce9c76a6e5ed04f69a27ba2b79003f5951909c446

See more details on using hashes here.

File details

Details for the file aioclamd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aioclamd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.8.10 Linux/5.15.0-1019-azure

File hashes

Hashes for aioclamd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4727da3953a4b38be4c2de1acb6b3bb3c94c1c171dcac780b80234ee6253f3d9
MD5 9c9d92fb68357f2e671a94d45a26739d
BLAKE2b-256 3b2ea63a99e804349b011b99473a95be418c0bac2b06149ffe19c921963e89ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page