What steps will reproduce the bug?
- Normal Api Server Running
- When using the
/api/evidence/upload endpoint
- Most importantly: We upload a
CompressedDirectory.
What is the expected behavior?
When uploading a file called filestem.ext1.ext2, in the best case we should always expect the system to correctly split the extensions from the stem of the file and create something like this filestem_timestamp.ext1.ext2.
However as we are not in all cases able to know which extension is the real extension and which one is part of the file name we want to at least preserve all extensions at the end of the name so even if we end up with something like this filestem.ext1_timestamp.ext1.ext2, we would still be good.
What do you see instead?
When we upload a file with name test.E01 we end up with a proper file name test_timestamp.E01. However if we upload test.tar.gz we end up with test.tar_timestamp.gz.
Why is that a problem
ValidateTarFile only accepts the two extensions tgz or tar.gz the extension gz alone will make it throw errors.
Additional information
My suggestion:
Replace these lines:
|
file_name_without_ext, file_extension = os.path.splitext(file_name) |
|
current_time = datetime.now().strftime(turbinia_config.DATETIME_FORMAT) |
|
new_name = f'{file_name_without_ext}_{current_time}{file_extension}' |
with
from pathlib import Path
...
p = Path(file_name)
file_stem = p.stem
full_extension = ''.join(p.suffixes)
current_time = datetime.now().strftime(turbinia_config.DATETIME_FORMAT)
new_name = f"{file_stem}_{current_time}{full_extension}"
As I am the one who tried to fix this in #1459, i consider it my duty to clean my own mess :-)
What steps will reproduce the bug?
/api/evidence/uploadendpointCompressedDirectory.What is the expected behavior?
When uploading a file called
filestem.ext1.ext2, in the best case we should always expect the system to correctly split the extensions from the stem of the file and create something like thisfilestem_timestamp.ext1.ext2.However as we are not in all cases able to know which extension is the real extension and which one is part of the file name we want to at least preserve all extensions at the end of the name so even if we end up with something like this
filestem.ext1_timestamp.ext1.ext2, we would still be good.What do you see instead?
When we upload a file with name
test.E01we end up with a proper file nametest_timestamp.E01. However if we uploadtest.tar.gzwe end up withtest.tar_timestamp.gz.Why is that a problem
ValidateTarFileonly accepts the two extensionstgzortar.gzthe extensiongzalone will make it throw errors.Additional information
My suggestion:
Replace these lines:
turbinia/turbinia/api/routes/evidence.py
Lines 57 to 59 in 0905899
with
As I am the one who tried to fix this in #1459, i consider it my duty to clean my own mess :-)