Skip to content
 
 

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Asynchronous client for virus scanning with ClamAV

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages