mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #7178 from eugene7646/cli_multiple_report_configs_7887
Support processing of multiple reports (7887)
This commit is contained in:
commit
fa67d76ef9
@ -2,7 +2,7 @@ CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empt
|
||||
CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created.
|
||||
CommandListIngestSettingsPanel_Default_Report_DisplayName=Default
|
||||
CommandListIngestSettingsPanel_Make_Config=Make new profile...
|
||||
CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name:
|
||||
CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (commas not allowed):
|
||||
OpenIDE-Module-Name=CommandLineAutopsy
|
||||
OptionsCategory_Keywords_Command_Line_Ingest_Settings=Command Line Ingest Settings
|
||||
OptionsCategory_Keywords_General=Options
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2019-2020 Basis Technology Corp.
|
||||
* Copyright 2019-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -280,7 +280,7 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel {
|
||||
add(nodePanel, java.awt.BorderLayout.CENTER);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@Messages({
|
||||
"CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name:",
|
||||
"CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (commas not allowed):",
|
||||
"CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.",
|
||||
"CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created."
|
||||
})
|
||||
@ -289,6 +289,10 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel {
|
||||
if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Make_Config())) {
|
||||
reportName = JOptionPane.showInputDialog(this, Bundle.CommandListIngestSettingsPanel_Report_Name_Msg());
|
||||
|
||||
// sanitize report name. Remove all commas because in CommandLineOptionProcessor we use commas
|
||||
// to separate multiple report names
|
||||
reportName = reportName.replaceAll(",", "");
|
||||
|
||||
// User hit cancel
|
||||
if (reportName == null) {
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2019-2020 Basis Technology Corp.
|
||||
* Copyright 2019-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -20,12 +20,15 @@ package org.sleuthkit.autopsy.commandlineingest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.netbeans.api.sendopts.CommandException;
|
||||
import org.netbeans.spi.sendopts.Env;
|
||||
@ -291,7 +294,6 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
||||
}
|
||||
|
||||
// Add "GENERATE_REPORTS" command, if present
|
||||
String reportProfile = null;
|
||||
if (values.containsKey(generateReportsOption)) {
|
||||
|
||||
// 'caseDir' must only be specified if the case is not being created during the current run
|
||||
@ -300,24 +302,34 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
||||
handleError("'caseDir' argument is empty");
|
||||
}
|
||||
|
||||
List<String> reportProfiles;
|
||||
argDirs = values.get(generateReportsOption);
|
||||
if (argDirs.length > 0) {
|
||||
reportProfile = argDirs[0];
|
||||
}
|
||||
// use custom report configuration(s)
|
||||
reportProfiles = Stream.of(argDirs[0].split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// If the user doesn't supply an options for generateReports the
|
||||
// argsDirs length will be 0, so if reportProfile is empty
|
||||
// something is not right.
|
||||
if (reportProfile != null && reportProfile.isEmpty()) {
|
||||
if (reportProfiles == null || reportProfiles.isEmpty()) {
|
||||
handleError("'generateReports' argument is empty");
|
||||
}
|
||||
|
||||
for (String reportProfile : reportProfiles) {
|
||||
if (reportProfile.isEmpty()) {
|
||||
handleError("Empty report profile name");
|
||||
}
|
||||
CommandLineCommand newCommand = new CommandLineCommand(CommandLineCommand.CommandType.GENERATE_REPORTS);
|
||||
newCommand.addInputValue(CommandLineCommand.InputType.CASE_FOLDER_PATH.name(), caseDir);
|
||||
if (reportProfile != null) {
|
||||
newCommand.addInputValue(CommandLineCommand.InputType.REPORT_PROFILE_NAME.name(), reportProfile);
|
||||
}
|
||||
commands.add(newCommand);
|
||||
}
|
||||
} else {
|
||||
// use default report configuration
|
||||
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