From 4d2662b708f9ccf7c52537894a1f73511886b4ab Mon Sep 17 00:00:00 2001 From: Philipp Mayer Date: Tue, 29 Aug 2023 14:03:58 +0200 Subject: [PATCH 1/2] fix(clamav): catch BufferTooLongError --- src/media_server/clamav.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/media_server/clamav.py b/src/media_server/clamav.py index d57ae5c5..2dff761c 100644 --- a/src/media_server/clamav.py +++ b/src/media_server/clamav.py @@ -31,6 +31,10 @@ def validate_file_infection(file): logger.warning(f'The file is too large for ClamD to scan it. Bytes Read {file.tell()}') file.seek(0) return + except clamd.BufferTooLongError as e: + logger.warning(f'ClamD: {str(e)}') + file.seek(0) + return if result and result['stream'][0] == 'FOUND': raise ValidationError(_('File is infected with malware'), code='infected') From 106b4cc73f3e302204bc934900b0add43fe42b26 Mon Sep 17 00:00:00 2001 From: Philipp Mayer Date: Tue, 29 Aug 2023 14:30:28 +0200 Subject: [PATCH 2/2] change(clamav): adapt logging message to same style --- src/media_server/clamav.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/media_server/clamav.py b/src/media_server/clamav.py index 2dff761c..1004fdd0 100644 --- a/src/media_server/clamav.py +++ b/src/media_server/clamav.py @@ -28,7 +28,7 @@ def validate_file_infection(file): # Ping the server if it fails than the server is down scanner.ping() # Server is up. This means that the file is too big. - logger.warning(f'The file is too large for ClamD to scan it. Bytes Read {file.tell()}') + logger.warning(f'ClamD: The file is too large for ClamD to scan it. Bytes Read {file.tell()}') file.seek(0) return except clamd.BufferTooLongError as e: