8
8
from assemblyline .common .dict_utils import flatten
9
9
from assemblyline .common .str_utils import safe_str
10
10
from assemblyline_ui .api .base import api_login , make_api_response , make_subapi_blueprint
11
- from assemblyline_ui .config import TEMP_SUBMIT_DIR , STORAGE , config
11
+ from assemblyline_ui .config import CLASSIFICATION , TEMP_SUBMIT_DIR , STORAGE , config
12
12
from assemblyline_ui .helper .service import ui_to_submission_params
13
13
from assemblyline_ui .helper .submission import safe_download , FileTooBigException , InvalidUrlException , \
14
14
ForbiddenLocation , submission_received
@@ -243,7 +243,7 @@ def ingest_single_file(**kwargs):
243
243
binary .save (out_file )
244
244
245
245
if os .path .getsize (out_file ) == 0 :
246
- return make_api_response ("" , err = "File empty. Ingestion failed" , status_code = 400 )
246
+ return make_api_response ({} , err = "File empty. Ingestion failed" , status_code = 400 )
247
247
248
248
# Load default user params
249
249
s_params = ui_to_submission_params (load_user_settings (user ))
@@ -284,9 +284,9 @@ def ingest_single_file(**kwargs):
284
284
# Validate file size
285
285
if fileinfo ['size' ] > MAX_SIZE and not s_params .get ('ignore_size' , False ):
286
286
msg = f"File too large ({ fileinfo ['size' ]} > { MAX_SIZE } ). Ingestion failed"
287
- return make_api_response ("" , err = msg , status_code = 413 )
287
+ return make_api_response ({} , err = msg , status_code = 413 )
288
288
elif fileinfo ['size' ] == 0 :
289
- return make_api_response ("" , err = "File empty. Ingestion failed" , status_code = 400 )
289
+ return make_api_response ({} , err = "File empty. Ingestion failed" , status_code = 400 )
290
290
291
291
# Decode cart if needed
292
292
extracted_path , fileinfo , al_meta = decode_file (out_file , fileinfo )
@@ -297,6 +297,11 @@ def ingest_single_file(**kwargs):
297
297
s_params ['classification' ] = al_meta .pop ('classification' , s_params ['classification' ])
298
298
name = al_meta .pop ('name' , name )
299
299
300
+ # Validate ingest classification
301
+ if not CLASSIFICATION .is_accessible (user ['classification' ], s_params ['classification' ]):
302
+ return make_api_response ({}, "You cannot start a submission with higher "
303
+ "classification then you're allowed to see" , 400 )
304
+
300
305
# Save the file to the filestore if needs be
301
306
sha256 = fileinfo ['sha256' ]
302
307
if not f_transport .exists (sha256 ):
@@ -338,7 +343,7 @@ def ingest_single_file(**kwargs):
338
343
"params" : s_params
339
344
})
340
345
except (ValueError , KeyError ) as e :
341
- return make_api_response ("" , err = str (e ), status_code = 400 )
346
+ return make_api_response ({} , err = str (e ), status_code = 400 )
342
347
343
348
# Send submission object for processing
344
349
ingest .push (submission_obj .as_primitives ())
0 commit comments