Skip to content

Commit 68533ef

Browse files
committed
Parse paths when included in the file name, #221
1 parent 1334f4f commit 68533ef

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

modules/base.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,20 @@ def enrich_files(entities):
293293

294294
for file in file_entities:
295295
raw_entity = data.coalesce(file.get('properties'), file)
296-
base_object.Files.append({'FileName': data.coalesce(file.get('properties',{}).get('friendlyName'), file.get('Name')),'RawEntity': raw_entity})
296+
file_field = data.coalesce(file.get('properties',{}).get('friendlyName'), file.get('Name'))
297+
file_name = file_field.split('/')[-1].split('\\')[-1]
298+
file_name_path_f = file_field.rsplit('/', 1)
299+
file_name_path_b = file_field.rsplit('\\', 1)
300+
301+
if len(file_name_path_f) > 1:
302+
file_name_path = file_name_path_f[0] + '/'
303+
elif len(file_name_path_b) > 1:
304+
file_name_path = file_name_path_b[0] + '\\'
305+
else:
306+
file_name_path = None
307+
308+
file_directory = data.coalesce(file.get('properties',{}).get('directory'), file.get('Directory'), file_name_path, '')
309+
base_object.Files.append({'FileName': file_name, 'FilePath': f'{file_directory}{file_name}', 'RawEntity': raw_entity})
297310

298311
def enrich_filehashes(entities):
299312
filehash_entities = list(filter(lambda x: x['kind'].lower() == 'filehash', entities))

modules/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"FunctionVersion": "2.2.3"
2+
"FunctionVersion": "2.2.6"
33
}

0 commit comments

Comments
 (0)