diff --git a/scripts/lavafuncs.py b/scripts/lavafuncs.py index 01ce0ba..55bf823 100644 --- a/scripts/lavafuncs.py +++ b/scripts/lavafuncs.py @@ -43,6 +43,7 @@ lava_db = None lava_db_name = '_lava_artifacts.db' lava_json_name = '_lava_data.lava' +LAVA_SCHEMA_VERSION = 2 def sanitize_sql_name(name): @@ -102,19 +103,20 @@ def get_sql_type(python_type): return type_map.get(python_type, 'TEXT') -def initialize_lava(input_path, output_path, input_type): +def initialize_lava(input_path, output_path, input_type, profile_filename=None): ''' Initialize the LAVA data. Args: input_path: The path to the input file. output_path: The path to the output file. input_type: The type of input file. - selected_artifacts: List of selected artifacts. + profile_filename: The profile file used for module selection, if any. ''' global lava_data, lava_db lava_data = { + "lava_schema_version": LAVA_SCHEMA_VERSION, "parser_info": { "leapp_name": "VLEAPP", "leapp_version": vleapp_version, @@ -126,6 +128,8 @@ def initialize_lava(input_path, output_path, input_type): "param_input": input_path, "param_output": output_path, "param_type": input_type, + "param_profile": profile_filename, + "profile_used": profile_filename is not None, "processing_status": "In Progress", "lava_db_name": lava_db_name, "modules": [], @@ -248,6 +252,7 @@ def lava_process_artifact( module_info['artifacts'].append(artifact_meta) artifact = { + "artifact_key": func_name, "name": artifact_name, "tablename": sanitized_table_name, "module": module_name, @@ -306,13 +311,14 @@ def lava_process_artifact( return sanitized_table_name, object_columns, column_map -def lava_add_module(module_name, module_status, file_count=None): +def lava_add_module(module_name, module_status, file_count=None, artifact_name=None): """ Adds a module to the global lava_data structure. Parameters: module_name (str): The name of the module to be added. module_status (str): The status of the module (e.g., 'active', 'inactive'). file_count (int, optional): The number of files associated with the module. Defaults to None. + artifact_name (str, optional): The selected artifact name when it differs from the module filename. Returns: None Global Variables: @@ -325,6 +331,8 @@ def lava_add_module(module_name, module_status, file_count=None): "module_name": module_name, "module_status": module_status } + if artifact_name is not None: + module["artifact_name"] = artifact_name if file_count is not None: module["file_count"] = file_count lava_data["modules"].append(module) diff --git a/vleapp.py b/vleapp.py index fbfa922..6016db4 100755 --- a/vleapp.py +++ b/vleapp.py @@ -298,7 +298,7 @@ def main(): out_params = OutputParameters(output_path, custom_output_folder) Context.set_output_params(out_params) - initialize_lava(input_path, out_params.output_folder_base, extracttype) + initialize_lava(input_path, out_params.output_folder_base, extracttype, profile_filename) # Record history if enabled history.record_input_path(input_path) @@ -417,6 +417,7 @@ def crunch_artifacts( except (FileExistsError, FileNotFoundError) as ex: logfunc('Error creating {} report directory at path {}'.format(plugin.name, category_folder)) logfunc('Error was {}'.format(str(ex))) + lava_add_module(plugin.module_name, "Error", len(files_found), plugin.name) continue # cannot do work try: plugin.method(files_found, category_folder, seeker, wrap_text) @@ -424,8 +425,11 @@ def crunch_artifacts( logfunc('Reading {} artifact had errors!'.format(plugin.name)) logfunc('Error was {}'.format(str(ex))) logfunc('Exception Traceback: {}'.format(traceback.format_exc())) + lava_add_module(plugin.module_name, "Error", len(files_found), plugin.name) continue # nope + lava_add_module(plugin.module_name, "Complete", len(files_found), plugin.name) else: + lava_add_module(plugin.module_name, "No files found", 0, plugin.name) logfunc(f"No file found") logfunc('{} [{}] artifact completed'.format(plugin.name, plugin.module_name)) parsed_modules += 1 diff --git a/vleappGUI.py b/vleappGUI.py index 25cc362..60ebcd2 100755 --- a/vleappGUI.py +++ b/vleappGUI.py @@ -492,7 +492,7 @@ def process(casedata): logtext_frame.pack(padx=8, pady=4, expand=True, fill='both') progress_bar_frame.pack(padx=2, pady=2, ipady=2, fill='x') - initialize_lava(input_path, out_params.output_folder_base, extracttype) + initialize_lava(input_path, out_params.output_folder_base, extracttype, profile_filename) # Record history if enabled history.record_input_path(input_path)