mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 02:07:42 +00:00
Added report generation to command line ingest
This commit is contained in:
parent
40aee7e839
commit
eec7b7b5eb
@ -33,7 +33,8 @@ class CommandLineCommand {
|
|||||||
CREATE_CASE,
|
CREATE_CASE,
|
||||||
ADD_DATA_SOURCE,
|
ADD_DATA_SOURCE,
|
||||||
RUN_INGEST,
|
RUN_INGEST,
|
||||||
LIST_ALL_DATA_SOURCES;
|
LIST_ALL_DATA_SOURCES,
|
||||||
|
GENERATE_REPORTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,13 +60,15 @@ import org.sleuthkit.autopsy.ingest.IngestModuleError;
|
|||||||
import org.sleuthkit.autopsy.ingest.IngestProfiles;
|
import org.sleuthkit.autopsy.ingest.IngestProfiles;
|
||||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSet;
|
import org.sleuthkit.autopsy.modules.interestingitems.FilesSet;
|
||||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager;
|
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager;
|
||||||
|
import org.sleuthkit.autopsy.report.ReportProgressLogger;
|
||||||
|
import org.sleuthkit.autopsy.report.ReportGenerator;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows Autopsy to be invoked with a command line arguments. Causes Autopsy to
|
* Allows Autopsy to be invoked with a command line arguments. Causes Autopsy to
|
||||||
* create a case, add a specified data source, run ingest on that data source,
|
* create a case, add a specified data source, run ingest on that data source,
|
||||||
* produce a CASE/UCO report and exit.
|
* list all data source in a case, generate reports.
|
||||||
*/
|
*/
|
||||||
public class CommandLineIngestManager {
|
public class CommandLineIngestManager {
|
||||||
|
|
||||||
@ -265,6 +267,30 @@ public class CommandLineIngestManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GENERATE_REPORTS:
|
||||||
|
try {
|
||||||
|
LOGGER.log(Level.INFO, "Processing 'Generate Reports' command");
|
||||||
|
System.out.println("Processing 'Generate Reports' command");
|
||||||
|
Map<String, String> inputs = command.getInputs();
|
||||||
|
|
||||||
|
// open the case, if it hasn't been already opened by previous command
|
||||||
|
if (caseForJob == null) {
|
||||||
|
String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name());
|
||||||
|
openCase(caseDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate reports
|
||||||
|
ReportGenerator generator = new ReportGenerator(CommandLineIngestSettingsPanel.REPORTING_CONFIGURATION_NAME, new ReportProgressLogger()); //NON-NLS
|
||||||
|
generator.generateReports();
|
||||||
|
} catch (CaseActionException ex) {
|
||||||
|
String caseDirPath = command.getInputs().get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name());
|
||||||
|
LOGGER.log(Level.SEVERE, "Error opening case in case directory: " + caseDirPath, ex);
|
||||||
|
System.err.println("Error opening case in case directory: " + caseDirPath);
|
||||||
|
// Do not process any other commands
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Logger logger = Logger.getLogger(CommandLineIngestSettingsPanel.class.getName());
|
private static final Logger logger = Logger.getLogger(CommandLineIngestSettingsPanel.class.getName());
|
||||||
|
|
||||||
private static final String REPORTING_CONFIGURATION_NAME = "CommandLineIngest";
|
static final String REPORTING_CONFIGURATION_NAME = "CommandLineIngest";
|
||||||
private static final boolean DISPLAY_CASE_SPECIFIC_DATA = false; // do not try to display case specific data as there is likely no case open
|
private static final boolean DISPLAY_CASE_SPECIFIC_DATA = false; // do not try to display case specific data as there is likely no case open
|
||||||
private static final boolean RUN_REPORTS = false; // do not generate reports as part of running the report wizard
|
private static final boolean RUN_REPORTS = false; // do not generate reports as part of running the report wizard
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
private final Option runIngestCommandOption = Option.withoutArgument('r', "runIngest");
|
private final Option runIngestCommandOption = Option.withoutArgument('r', "runIngest");
|
||||||
private final Option ingestProfileOption = Option.requiredArgument('p', "ingestProfile");
|
private final Option ingestProfileOption = Option.requiredArgument('p', "ingestProfile");
|
||||||
private final Option listAllDataSourcesCommandOption = Option.withoutArgument('l', "listAllDataSources");
|
private final Option listAllDataSourcesCommandOption = Option.withoutArgument('l', "listAllDataSources");
|
||||||
|
private final Option generateReportsOption = Option.withoutArgument('g', "generateReports");
|
||||||
|
|
||||||
private boolean runFromCommandLine = false;
|
private boolean runFromCommandLine = false;
|
||||||
|
|
||||||
@ -67,6 +68,7 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
set.add(runIngestCommandOption);
|
set.add(runIngestCommandOption);
|
||||||
set.add(ingestProfileOption);
|
set.add(ingestProfileOption);
|
||||||
set.add(listAllDataSourcesCommandOption);
|
set.add(listAllDataSourcesCommandOption);
|
||||||
|
set.add(generateReportsOption);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +80,8 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
|
|
||||||
// input arguments must contain at least one command
|
// input arguments must contain at least one command
|
||||||
if (!(values.containsKey(createCaseCommandOption) || values.containsKey(addDataSourceCommandOption)
|
if (!(values.containsKey(createCaseCommandOption) || values.containsKey(addDataSourceCommandOption)
|
||||||
|| values.containsKey(runIngestCommandOption) || values.containsKey(listAllDataSourcesCommandOption))) {
|
|| values.containsKey(runIngestCommandOption) || values.containsKey(listAllDataSourcesCommandOption)
|
||||||
|
|| values.containsKey(generateReportsOption))) {
|
||||||
// not running from command line
|
// not running from command line
|
||||||
logger.log(Level.INFO, "No command line commands passed in as inputs. Not running from command line."); //NON-NLS
|
logger.log(Level.INFO, "No command line commands passed in as inputs. Not running from command line."); //NON-NLS
|
||||||
System.err.println("No command line commands passed in as inputs. Not running from command line.");
|
System.err.println("No command line commands passed in as inputs. Not running from command line.");
|
||||||
@ -315,6 +318,24 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
commands.add(newCommand);
|
commands.add(newCommand);
|
||||||
runFromCommandLine = true;
|
runFromCommandLine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add "GENERATE_REPORTS" command, if present
|
||||||
|
if (values.containsKey(generateReportsOption)) {
|
||||||
|
|
||||||
|
// 'caseDir' must only be specified if the case is not being created during the current run
|
||||||
|
if (!values.containsKey(createCaseCommandOption) && caseDir.isEmpty()) {
|
||||||
|
// new case is not being created during this run, so 'caseDir' should have been specified
|
||||||
|
logger.log(Level.SEVERE, "'caseDir' argument is empty");
|
||||||
|
System.err.println("'caseDir' argument is empty");
|
||||||
|
runFromCommandLine = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandLineCommand newCommand = new CommandLineCommand(CommandLineCommand.CommandType.GENERATE_REPORTS);
|
||||||
|
newCommand.addInputValue(CommandLineCommand.InputType.CASE_FOLDER_PATH.name(), caseDir);
|
||||||
|
commands.add(newCommand);
|
||||||
|
runFromCommandLine = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user