]> git.parisson.com Git - teleforma.git/commitdiff
Auto reject script if file is too large
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 10 Feb 2015 09:50:18 +0000 (10:50 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 10 Feb 2015 09:50:18 +0000 (10:50 +0100)
teleforma/exam/models.py

index 73bf468af147fa5fc6e17851b4beaf464cf7d40a..b27815035459154824c10022a41682c8765e01fd 100644 (file)
@@ -78,6 +78,8 @@ REJECT_REASON = (('unreadable', _('unreadable')),
 cache_path = settings.MEDIA_ROOT + 'cache/'
 script_path = settings.MEDIA_ROOT + 'scripts/'
 
+SCRIPT_MAX_SIZE = 50000000
+
 
 def sha1sum_file(filename):
     '''
@@ -379,6 +381,10 @@ class Script(BaseResource):
             self.auto_reject('wrong format')
             return
 
+        if os.stat(self.file.path).st_size > SCRIPT_MAX_SIZE:
+            self.auto_reject('file too large')
+            return
+
         if not self.status == 0 and self.file:
             if not self.box_uuid:
                 self.uuid_link()