vstoykov / django-clamd Goto Github PK
View Code? Open in Web Editor NEWIntegrates python-clamd with Django for easy scanning files for viruses on upload
Integrates python-clamd with Django for easy scanning files for viruses on upload
Traceback (most recent call last):
src/django-clamd/src/django_clamd/validators.py", line 25, in validate_file_infection
result = scanner.instream(file)
lib/python3.10/site-packages/clamd/init.py", line 190, in instream
self.clamd_socket.send(size + chunk)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
src/django-clamd/src/django_clamd/tests/test.py", line 56, in test_infinite_stream
validate_file_infection(stream)
src/django-clamd/src/django_clamd/validators.py", line 33, in validate_file_infection
raise ValidationError(
django.core.exceptions.ValidationError: ['Malware scan could not completed. Please try again later.']
Ran 5 tests in 0.095s
FAILED (errors=1)
Hello, I am on currently on commit 989141f
(also f98c318)
When I run python manage.py test django_clamd.tests the test_infinite_stream is failing
Ubuntu (WSL and Ubuntu Server)
Clamd 0.103.9 (No Changes since initial install)
Python 3.10.12 (No Changes since initial install)
All tests passed sometime within the past month on 3 different machines
Now all 3 get this test failure
I appreciate any guidance in resolving this issue, please let me know if I can provide any more information
In document, it states the default configuration are
CLAMD_SOCKET = '/var/run/clamav/clamd.ctl'
CLAMD_USE_TCP = False
CLAMD_TCP_SOCKET = 3310
CLAMD_TCP_ADDR = '127.0.0.1'
But it should be
CLAMD_SOCKET = '/var/run/clamav/clamd.ctl'
CLAMD_USE_TCP = False
CLAMD_TCP_PORT = 3310
CLAMD_TCP_SOCKET = '127.0.0.1'
Thanks
Hi ๐
This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.
Once you have closed this issue, I'll create separate pull requests for every update as soon as I find one.
That's it for now!
Happy merging! ๐ค
My understanding of this:
https://github.com/vstoykov/django-clamd/blob/master/src/django_clamd/validators.py#L28
Is that validation will pass if Clam cannot process the file (ostensibly due to size). Does this not mean that I'd just need a very large virus? Would it be better to fail closed, or at least provide an option to do so?
Happy to implement this if desired.
I ran the code python3 manage.py test django_clamd.tests
======================================================================
FAIL: test_has_virus (django_clamd.tests.test.VirusValidatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/django_clamd/tests/test.py", line 23, in test_has_virus
self.assertFalse(form.is_valid())
AssertionError: True is not false
======================================================================
FAIL: test_infinite_stream (django_clamd.tests.test.VirusValidatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/django_clamd/tests/test.py", line 54, in test_infinite_stream
self.assertGreaterEqual(stream._read_bytes, 5 * 1024 * 1024)
AssertionError: 25600 not greater than or equal to 5242880
Ran 3 tests in 0.010s
FAILED (failures=2)
The validator appears to throw an exception when the submitted file is null - since a null / non-existing file is not an infected file, I would suggest wrapping the initial seek(0) with a try/except:
# Check if the file is not empty / exists
try:
file.seek(0)
except:
return
Thank you for the wonderful plugin! Can you possibly publish the current version to pypi? I see you have updated the validators.py to import gettext_lazy in place of ugettext_lazy, but pip3 still pulls the original version incompatible with the current Django. Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.