130 LOGGER.log(Level.INFO,
"Job processing task started");
131 int errorCode = CL_SUCCESS;
135 LOGGER.log(Level.INFO,
"Autopsy is running from command line");
136 List<CommandLineCommand> commands =
null;
139 Collection<? extends OptionProcessor> optionProcessors = Lookup.getDefault().lookupAll(OptionProcessor.class);
140 Iterator<? extends OptionProcessor> optionsIterator = optionProcessors.iterator();
141 while (optionsIterator.hasNext()) {
143 OptionProcessor processor = optionsIterator.next();
150 if (commands ==
null || commands.isEmpty()) {
151 LOGGER.log(Level.SEVERE,
"No command line commands specified");
152 System.out.println(
"No command line commands specified");
153 errorCode = CL_RUN_FAILURE;
158 for (CommandLineCommand command : commands) {
163 LOGGER.log(Level.INFO,
"Processing 'Create Case' command");
164 System.out.println(
"Processing 'Create Case' command");
165 Map<String, String> inputs = command.getInputs();
166 String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
167 String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
169 String caseTypeString = inputs.get(CommandLineCommand.InputType.CASE_TYPE.name());
173 caseForJob = createCase(baseCaseName, rootOutputDirectory, caseType);
175 String outputDirPath = getOutputDirPath(
caseForJob);
176 OutputGenerator.saveCreateCaseOutput(
caseForJob, outputDirPath, baseCaseName);
178 String baseCaseName = command.getInputs().get(CommandLineCommand.InputType.CASE_NAME.name());
179 LOGGER.log(Level.SEVERE,
"Error creating or opening case " + baseCaseName, ex);
180 System.out.println(
"Error creating or opening case " + baseCaseName);
182 errorCode = CL_RUN_FAILURE;
186 case ADD_DATA_SOURCE:
188 LOGGER.log(Level.INFO,
"Processing 'Add Data Source' command");
189 System.out.println(
"Processing 'Add Data Source' command");
190 Map<String, String> inputs = command.getInputs();
195 String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
196 String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
197 caseForJob = openExistingCase(baseCaseName, rootOutputDirectory);
200 String dataSourcePath = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name());
201 String password = inputs.get(CommandLineCommand.InputType.BITLOCKER_KEY.name());
205 String outputDirPath = getOutputDirPath(
caseForJob);
208 String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name());
209 LOGGER.log(Level.SEVERE,
"Error adding data source " + dataSourcePath, ex);
210 System.out.println(
"Error adding data source " + dataSourcePath);
212 errorCode = CL_RUN_FAILURE;
218 LOGGER.log(Level.INFO,
"Processing 'Run Ingest' command");
219 System.out.println(
"Processing 'Run Ingest' command");
220 Map<String, String> inputs = command.getInputs();
225 String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
226 String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
227 caseForJob = openExistingCase(baseCaseName, rootOutputDirectory);
233 String dataSourceId = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_ID.name());
234 Long dataSourceObjId = Long.valueOf(dataSourceId);
237 Content content =
null;
240 }
catch (TskCoreException ex) {
241 LOGGER.log(Level.SEVERE,
"Exception while trying to find data source with object ID " + dataSourceId, ex);
242 System.out.println(
"Exception while trying to find data source with object ID " + dataSourceId);
244 errorCode = CL_RUN_FAILURE;
248 if (content ==
null) {
249 LOGGER.log(Level.SEVERE,
"Unable to find data source with object ID {0}", dataSourceId);
250 System.out.println(
"Unable to find data source with object ID " + dataSourceId);
257 List<Content> contentList = Arrays.asList(
new Content[]{content});
258 List<String> errorList =
new ArrayList<>();
259 dataSource.setDataSourceProcessorOutput(NO_ERRORS, errorList, contentList);
263 String ingestProfile = inputs.get(CommandLineCommand.InputType.INGEST_PROFILE_NAME.name());
266 String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name());
267 LOGGER.log(Level.SEVERE,
"Error running ingest on data source " + dataSourcePath, ex);
268 System.out.println(
"Error running ingest on data source " + dataSourcePath);
270 errorCode = CL_RUN_FAILURE;
275 case LIST_ALL_DATA_SOURCES:
277 LOGGER.log(Level.INFO,
"Processing 'List All Data Sources' command");
278 System.out.println(
"Processing 'List All Data Sources' command");
279 Map<String, String> inputs = command.getInputs();
284 String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
285 String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
286 caseForJob = openExistingCase(baseCaseName, rootOutputDirectory);
289 String outputDirPath = getOutputDirPath(
caseForJob);
290 OutputGenerator.listAllDataSources(
caseForJob, outputDirPath);
292 String baseCaseName = command.getInputs().get(CommandLineCommand.InputType.CASE_NAME.name());
293 String rootOutputDirectory = command.getInputs().get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
294 String msg =
"Error opening case " + baseCaseName +
" in directory: " + rootOutputDirectory;
295 LOGGER.log(Level.SEVERE, msg, ex);
296 System.out.println(msg);
297 errorCode = CL_RUN_FAILURE;
303 case GENERATE_REPORTS:
305 LOGGER.log(Level.INFO,
"Processing 'Generate Reports' command");
306 System.out.println(
"Processing 'Generate Reports' command");
307 Map<String, String> inputs = command.getInputs();
312 String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
313 String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
314 caseForJob = openExistingCase(baseCaseName, rootOutputDirectory);
317 String reportName = inputs.get(CommandLineCommand.InputType.REPORT_PROFILE_NAME.name());
318 if (reportName ==
null) {
327 String baseCaseName = command.getInputs().get(CommandLineCommand.InputType.CASE_NAME.name());
328 String rootOutputDirectory = command.getInputs().get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name());
329 String msg =
"Error opening case " + baseCaseName +
" in directory: " + rootOutputDirectory;
330 LOGGER.log(Level.SEVERE, msg, ex);
331 System.out.println(msg);
332 errorCode = CL_RUN_FAILURE;
335 }
catch (Exception ex) {
336 String msg =
"An exception occurred while generating report: " + ex.getMessage();
337 LOGGER.log(Level.WARNING, msg, ex);
338 System.out.println(msg);
339 errorCode = CL_RUN_FAILURE;
344 case LIST_ALL_INGEST_PROFILES:
346 GsonBuilder gb =
new GsonBuilder();
347 System.out.println(
"Listing ingest profiles");
349 String jsonText = gb.create().toJson(profile);
350 System.out.println(jsonText);
352 System.out.println(
"Ingest profile list complete");
358 }
catch (Throwable ex) {
366 LOGGER.log(Level.SEVERE,
"Unexpected error", ex);
367 System.out.println(
"Unexpected error. Exiting...");
368 errorCode = CL_RUN_FAILURE;
373 LOGGER.log(Level.WARNING,
"Exception while closing case", ex);
374 System.out.println(
"Exception while closing case");
379 LOGGER.log(Level.INFO,
"Job processing task finished");
380 System.out.println(
"Job processing task finished");
514 LOGGER.log(Level.INFO,
"Starting ingest modules analysis for {0} ",
dataSource.getPath());
519 if (!ingestProfileName.isEmpty()) {
521 if (selectedProfile ==
null) {
523 LOGGER.log(Level.SEVERE,
"Unable to find ingest profile: {0}. Ingest cancelled!", ingestProfileName);
524 System.out.println(
"Unable to find ingest profile: " + ingestProfileName +
". Ingest cancelled!");
530 if (selectedFileSet ==
null) {
532 LOGGER.log(Level.SEVERE,
"Unable to find file filter {0} for ingest profile: {1}. Ingest cancelled!",
new Object[]{selectedProfile.getFileIngestFilter(), ingestProfileName});
533 System.out.println(
"Unable to find file filter " + selectedProfile.getFileIngestFilter() +
" for ingest profile: " + ingestProfileName +
". Ingest cancelled!");
534 throw new AnalysisStartupException(
"Unable to find file filter " + selectedProfile.getFileIngestFilter() +
" for ingest profile: " + ingestProfileName +
". Ingest cancelled!");
543 if (selectedProfile ==
null || selectedFileSet ==
null) {
552 List<String> settingsWarnings = ingestJobSettings.
getWarnings();
553 if (settingsWarnings.isEmpty()) {
556 if (
null != ingestJob) {
569 LOGGER.log(Level.INFO,
"Finished ingest modules analysis for {0} ",
dataSource.getPath());
572 if (!snapshot.isCancelled()) {
573 List<String> cancelledModules = snapshot.getCancelledDataSourceIngestModules();
574 if (!cancelledModules.isEmpty()) {
575 LOGGER.log(Level.WARNING, String.format(
"Ingest module(s) cancelled for %s",
dataSource.getPath()));
576 for (String module : snapshot.getCancelledDataSourceIngestModules()) {
577 LOGGER.log(Level.WARNING, String.format(
"%s ingest module cancelled for %s", module,
dataSource.getPath()));
580 LOGGER.log(Level.INFO,
"Analysis of data source completed");
582 LOGGER.log(Level.WARNING,
"Analysis of data source cancelled");
590 LOGGER.log(Level.SEVERE, String.format(
"%s ingest module startup error for %s", error.getModuleDisplayName(),
dataSource.getPath()), error.getThrowable());
592 LOGGER.log(Level.SEVERE,
"Failed to analyze data source due to ingest job startup error");
599 for (String warning : settingsWarnings) {
600 LOGGER.log(Level.SEVERE,
"Ingest job settings error for {0}: {1}",
new Object[]{dataSource.getPath(), warning});
602 LOGGER.log(Level.SEVERE,
"Failed to analyze data source due to settings errors");