File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,14 +27,20 @@ pip install git+https://github.com/userlike/python-clamd.git
2727
2828``` python
2929import clamd
30+ from io import BytesIO
3031
3132# Connect via network
3233cd = clamd.ClamdNetworkSocket(host = ' 127.0.0.1' , port = 3310 )
3334
3435# Ping the daemon
35- cd.ping()
36+ cd.ping() # Returns PONG, otherwise raise ConnectionError or ResponseError
3637
37- # Scan a file
38+ # Scan content using instream (recommended - works with remote ClamAV)
39+ result = cd.instream(BytesIO(b ' file content here' ))
40+ # Returns: {'stream': ('OK', None)} for clean files
41+ # Returns: {'stream': ('FOUND', 'VirusName')} for infected files
42+
43+ # Scan a file by path (only works if ClamAV can access the path)
3844cd.scan(' /path/to/file' )
3945
4046# Get version info
Original file line number Diff line number Diff line change @@ -26,11 +26,14 @@ def test_reload(self):
2626 assert self .cd .reload () == 'RELOADING'
2727
2828
29- def test_instream (self ):
29+ def test_instream_found (self ):
30+ # Case: True positive
3031 expected = {'stream' : ('FOUND' , 'Eicar-Test-Signature' )}
3132 assert self .cd .instream (BytesIO (clamd .EICAR )) == expected
3233
33- def test_insteam_success (self ):
34+
35+ def test_instream_ok (self ):
36+ # Case True negative
3437 assert self .cd .instream (BytesIO (b"foo" )) == {'stream' : ('OK' , None )}
3538
3639
You can’t perform that action at this time.
0 commit comments