@@ -54,9 +54,9 @@ files with the mime type ``image/svg+xml``. Those files are dangerous since
5454they are executed by a browser without any warnings.
5555
5656Validation hooks do not restrict the upload of other executable files
57- (like ``*.exe `` or shell scripts). ** Those are not automatically executed
57+ (like ``*.exe `` or shell scripts). Those are not automatically executed
5858by the browser but still present a point of attack, if a user saves them
59- to disk and executes them locally. **
59+ to disk and executes them locally.
6060
6161You can release validation restrictions by setting
6262``FILER_REMOVE_FILE_VALIDATORS `` to a list of mime types to be removed from
@@ -111,7 +111,7 @@ This just rejects any file for upload. By default this happens for HTML files
111111
112112 This validator rejects any SVG file that contains the bytes ``<script `` or
113113``javascript: ``. This probably is a too strict criteria, since those bytes
114- might be part of a legitimate string. The above code is a simplification
114+ might be part of a legitimate say string. The above code is a simplification
115115the actual code also checks for occurrences of event attribute like
116116``onclick="..." ``.
117117
@@ -144,11 +144,10 @@ a malicious file unknowingly.
144144 FILER_REMOVE_FILE_VALIDATORS = [
145145 " text/html" ,
146146 " image/svg+xml" ,
147- " application/octet-stream" ,
148147 ]
149148
150- No HTML upload and restricted SVG upload, no binary or unknown file upload
151- ...........................................................................
149+ No HTML upload and restricted SVG upload
150+ ........................................
152151
153152This is the default setting. It will deny any SVG file that might contain
154153Javascript. It is prone to false positives (i.e. files being rejected that
@@ -177,8 +176,6 @@ in the user's browser.
177176 " image/svg+xml" : [" filer.validation.deny" ],
178177 }
179178
180- (Still not binary or unknown file upload)
181-
182179 Experimental SVG sanitization
183180.............................
184181
@@ -262,38 +259,3 @@ You can use it to distinguish validation for certain user groups if needed.
262259
263260If you distinguish validation by the mime type, remember to register the
264261validator function for all relevant mime types.
265-
266-
267- Checking uploads for viruses using ClamAV
268- -----------------------------------------
269-
270- If you have ClamAV installed and use `django-clamd <https://github.com/vstoykov/django-clamd >`_
271- you can add a validator that checks for viruses in uploaded files.
272-
273- .. code-block :: python
274-
275- FILER_REMOVE_FILE_VALIDATORS = [" application/octet-stream" ]
276- FILER_ADD_FILE_VALIDATORS = {
277- " application/octet-stream" : [" my_validator_app.validators.validate_octet_stream" ],
278- }
279-
280-
281- .. code-block :: python
282-
283- def validate_octet_stream (file_name : str , file : typing.IO , owner : User, mime_type : str ) -> None :
284- """ Octet streams are binary files without a specific mime type. They are run through
285- a virus check."""
286- try :
287- from django_clamd.validators import validate_file_infection
288-
289- validate_file_infection(file )
290- except (ModuleNotFoundError , ImportError ):
291- raise FileValidationError(
292- _(' File "{file_name} ": Virus check for binary/unknown file not available' ).format(file_name = file_name)
293- )
294-
295- .. note ::
296-
297- Virus-checked files still might contain executable code. While the code is not
298- executed by the browser, a user might still download the file and execute it
299- manually.
0 commit comments