Skip to content

Commit e4d8ec1

Browse files
author
Tommy Beadle
committed
Fix return types in demux_sflock/demux_sample.
Also fix handling of one case where sample size was smaller than the limit but was still being reported as an error saying the sample is too big.
1 parent 432ca07 commit e4d8ec1

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

lib/cuckoo/common/demux.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def demux_sflock(filename: bytes, options: str, check_shellcode: bool = True):
208208
magic_type = file.get_type()
209209
platform = file.get_platform()
210210
file_size = file.get_size()
211-
return [filename, platform, magic_type, file_size], ""
211+
return [[filename, platform, magic_type, file_size]], ""
212212
if unpacked.package in blacklist_extensions:
213213
return [], "blacklisted package"
214214
for sf_child in unpacked.children:
@@ -253,7 +253,7 @@ def demux_sample(filename: bytes, package: str, options: str, use_sflock: bool =
253253
{
254254
os.path.basename(
255255
filename
256-
): "File too bit, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option"
256+
): "File too big, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option"
257257
}
258258
)
259259
return retlist, error_list
@@ -305,7 +305,7 @@ def demux_sample(filename: bytes, package: str, options: str, use_sflock: bool =
305305
error_list.append(
306306
{
307307
os.path.basename(filename),
308-
"File too bit, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option",
308+
"File too big, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option",
309309
}
310310
)
311311
return retlist, error_list
@@ -317,7 +317,7 @@ def demux_sample(filename: bytes, package: str, options: str, use_sflock: bool =
317317
check_shellcode = False
318318

319319
# all in one unarchiver
320-
retlist, error_msg = demux_sflock(filename, options, check_shellcode) if HAS_SFLOCK and use_sflock else []
320+
retlist, error_msg = demux_sflock(filename, options, check_shellcode) if HAS_SFLOCK and use_sflock else ([], "")
321321
# if it isn't a ZIP or an email, or we aren't able to obtain anything interesting from either, then just submit the
322322
# original file
323323
if not retlist:
@@ -331,20 +331,19 @@ def demux_sample(filename: bytes, package: str, options: str, use_sflock: bool =
331331
error_list.append({os.path.basename(filename): "Linux processing is disabled"})
332332
continue
333333

334-
if file_size > web_cfg.general.max_sample_size and not (
335-
web_cfg.general.allow_ignore_size and "ignore_size_check" in options
336-
):
337-
if web_cfg.general.enable_trim:
338-
# maybe identify here
339-
if trim_file(filename):
340-
filename = trimmed_path(filename)
341-
else:
342-
error_list.append(
343-
{
344-
os.path.basename(filename),
345-
"File too bit, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option",
346-
}
347-
)
334+
if file_size > web_cfg.general.max_sample_size:
335+
if web_cfg.general.allow_ignore_size and "ignore_size_check" in options:
336+
if web_cfg.general.enable_trim:
337+
# maybe identify here
338+
if trim_file(filename):
339+
filename = trimmed_path(filename)
340+
else:
341+
error_list.append(
342+
{
343+
os.path.basename(filename),
344+
"File too big, enable 'allow_ignore_size' in web.conf or use 'ignore_size_check' option",
345+
}
346+
)
348347
new_retlist.append((filename, platform))
349348

350349
return new_retlist[:10], error_list

0 commit comments

Comments
 (0)