Skip to content
/ clamdpy Public

A Python wrapper around clamd, the ClamAV daemon

License

Notifications You must be signed in to change notification settings

Viicos/clamdpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a3208f5 · Jan 6, 2024

History

6 Commits
Oct 22, 2023
Jan 6, 2024
Oct 22, 2023
Oct 20, 2023
Jan 6, 2024
Oct 20, 2023
Oct 22, 2023
Jan 4, 2024
Oct 22, 2023
Oct 22, 2023

Repository files navigation

clamdpy

A Python wrapper around clamd, the ClamAV daemon.

This is a maintained and updated fork of https://github.com/graingert/python-clamd/, credit goes to the original developer(s).

Python versions PyPI version Code style: Black Ruff

Installation

Using pip:

pip install clamdpy

Usage

from io import BytesIO

from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(
    host="127.0.0.1",
    port=3310,
    timeout=15,
)

clamd.ping()
#> 'PONG'

clamd.version()
#> VersionInfo(version='ClamAV 0.103.9', signature=27065, signature_date=datetime(2023, 10, 18, 9, 49, 14))

# Raw response can be fetched as well:
clamd.version(raw=True)
#> 'ClamAV 0.103.9/27065/Wed Oct 18 09:49:14 2023'

clamd.instream(BytesIO(b"data"))
#> ScanResult(path='stream', reason=None, status='OK')

Most of the clamd commands are implemented (a couple ones are missing and should be implemented sooner or later).

It is possible to use UNIX sockets as well:

from clamdpy import ClamdUnixSocket

clamd = ClamdUnixSocket(path="/var/run/clamav/clamd.ctl")

Line delimitations

By default, \n will be used to terminate lines. Clamd also supports NULL characters:

from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(line_terminator="z")

Warning

Support for the NULL character isn't tested and may not work as it doesn't play well with Python. Use with caution.

About

A Python wrapper around clamd, the ClamAV daemon

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages