Skip to content

Commit

Permalink
Adding support of artifact_icon in Artifact Info Block Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-PLW committed Nov 17, 2024
1 parent e3a1ed1 commit 2df936b
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 12 deletions.
22 changes: 17 additions & 5 deletions admin/scripts/module_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def extract_v2_info(module_content):
"name": "Error parsing v2 artifact",
"description": clean_string(str(e)),
"paths": "",
"output_types": ""
"output_types": "",
"artifact_icon": ""
}]

results = []
Expand All @@ -55,12 +56,14 @@ def extract_v2_info(module_content):
else:
output_types = ""

artifact_icon = details.get("artifact_icon", "")
results.append({
"artifact": artifact_name,
"name": clean_string(details.get("name", "")),
"description": clean_string(details.get("description", "")),
"paths": paths,
"output_types": output_types
"output_types": output_types,
"artifact_icon": artifact_icon
})
return results

Expand Down Expand Up @@ -92,8 +95,8 @@ def parse_module_file(module_path):

def generate_v2_markdown_table(artifact_data):
"""Generate a markdown table for v2 artifacts."""
table = "| Module | Artifact | Name | Output Types | Description | Paths |\n"
table += "|--------|----------|------|--------------|-------------|-------|\n"
table = "| Module | Artifact | Name | Output Types | Icon | Description | Paths |\n"
table += "|--------|----------|------|--------------|------|-------------|-------|\n"
for module, artifacts in artifact_data.items():
module_link = f"[{module}](https://github.com/abrignoni/iLEAPP/blob/main/scripts/artifacts/{module})"
for artifact in artifacts:
Expand All @@ -105,7 +108,8 @@ def generate_v2_markdown_table(artifact_data):
else:
paths = f'`{paths}`'
output_types = artifact.get('output_types', '-')
table += f"| {module_link} | {artifact['artifact']} | {name} | {output_types} | {description} | {paths} |\n"
artifact_icon = artifact.get('artifact_icon', '')
table += f"| {module_link} | {artifact['artifact']} | {name} | {output_types} | {artifact_icon} | {description} | {paths} |\n"

return table

Expand Down Expand Up @@ -142,6 +146,13 @@ def update_markdown_file(v1_data, v2_data, error_data):
if artifact.get('output_types')
)

# Count modules using 'artifact_icon'
artifact_icon_count = sum(
1 for artifacts in v2_data.values()
for artifact in artifacts
if artifact.get('artifact_icon')
)

with open(MD_FILE_PATH, 'r') as md_file:
content = md_file.read()

Expand All @@ -155,6 +166,7 @@ def update_markdown_file(v1_data, v2_data, error_data):
new_module_info += f"Number of v1 artifacts: {v1_count} \n"
new_module_info += f"Number of v2 artifacts: {v2_count} \n"
new_module_info += f"Number of modules with 'lava output': {lava_output_count} \n"
new_module_info += f"Number of modules using 'artifact_icon': {artifact_icon_count} \n"
new_module_info += f"Number of modules with errors or no recognized artifacts: {error_count} \n\n"

if v2_data:
Expand Down
3 changes: 1 addition & 2 deletions ileapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ def crunch_artifacts(
if input_path.startswith('\\\\?\\'):
input_path = input_path[4:]


report.generate_report(out_params.report_folder_base, run_time_secs, run_time_HMS, extracttype, input_path, casedata, profile_filename)
report.generate_report(out_params.report_folder_base, run_time_secs, run_time_HMS, extracttype, input_path, casedata, profile_filename, icons)
logfunc('Report generation Completed.')
logfunc('')
logfunc(f'Report location: {out_params.report_folder_base}')
Expand Down
3 changes: 2 additions & 1 deletion scripts/artifacts/lastBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"category": "IOS Build",
"notes": "",
"paths": ('*LastBuildInfo.plist',),
"output_types": ["html", "tsv", "lava"]
"output_types": ["html", "tsv", "lava"],
"artifact_icon": "git-commit"
}
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/ilapfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
thumb_size = 256, 256

identifiers = {}
icons = {}

def strip_tuple_from_headers(data_headers):
return [header[0] if isinstance(header, tuple) else header for header in data_headers]
Expand All @@ -60,6 +61,7 @@ def wrapper(files_found, report_folder, seeker, wrap_text, timezone_offset):
artifact_name = artifact_info.get('name', func_name)
category = artifact_info.get('category', '')
description = artifact_info.get('description', '')
icon = artifact_info.get('artifact_icon', '')
output_types = artifact_info.get('output_types', ['html', 'tsv', 'timeline', 'lava', 'kml'])

data_headers, data_list, source_path = func(files_found, report_folder, seeker, wrap_text, timezone_offset)
Expand All @@ -79,6 +81,7 @@ def wrapper(files_found, report_folder, seeker, wrap_text, timezone_offset):
report.add_script()
report.write_artifact_data_table(stripped_headers, data_list, source_path)
report.end_artifact_report()
icons[category] = {artifact_name: icon}

if check_output_types('tsv', output_types):
tsv(report_folder, stripped_headers, data_list, artifact_name)
Expand Down
11 changes: 7 additions & 4 deletions scripts/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scripts.html_parts import *
from scripts.ilapfuncs import logfunc
from scripts.version_info import ileapp_version, ileapp_contributors
from scripts.report_icons import icon_mappings
from scripts.report_icons import icon_mappings, feather_icon_names

def get_icon_name(category, artifact):
"""
Expand Down Expand Up @@ -64,7 +64,7 @@ def get_search_mode_categories():
search_set = get_search_mode_categories()


def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path, casedata, profile_filename):
def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path, casedata, profile_filename, icons):
control = None
side_heading = \
"""
Expand Down Expand Up @@ -92,6 +92,7 @@ def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, i
if file.endswith(".temphtml"):
fullpath = (os.path.join(root, file))
head, tail = os.path.split(fullpath)
filename = tail.replace(".temphtml", "")
p = pathlib.Path(fullpath)
SectionHeader = (p.parts[-2])
if SectionHeader == '_elements':
Expand All @@ -102,9 +103,11 @@ def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, i
side_list[SectionHeader] = []
nav_list_data += side_heading.format(SectionHeader)
side_list[SectionHeader].append(fullpath)
icon = get_icon_name(SectionHeader, tail.replace(".temphtml", ""))
icon_name = icons.get(SectionHeader, {}).get(filename, "")
icon = icon_name if icon_name else get_icon_name(SectionHeader, filename)
icon = icon if icon in feather_icon_names else 'alert-triangle'
nav_list_data += list_item.format('', tail.replace(".temphtml", ".html").replace(" ", "_"),
icon, tail.replace(".temphtml", "").replace("_", " "))
icon, filename.replace("_", " "))

# Now that we have all the file paths, start writing the files

Expand Down
Loading

0 comments on commit 2df936b

Please sign in to comment.