commenting out stuff in experimental to run jackson

This commit is contained in:
Greg DiCristofaro 2020-10-19 16:32:04 -04:00
parent cbaf804ec7
commit 92b87b738e
4 changed files with 219 additions and 225 deletions

View File

@ -8,7 +8,6 @@
<dependency conf="experimental->default" org="com.github.lgooddatepicker" name="LGoodDatePicker" rev="10.3.1"/> <dependency conf="experimental->default" org="com.github.lgooddatepicker" name="LGoodDatePicker" rev="10.3.1"/>
<dependency conf="experimental->default" org="org.postgresql" name="postgresql" rev="9.4-1201-jdbc41"/> <dependency conf="experimental->default" org="org.postgresql" name="postgresql" rev="9.4-1201-jdbc41"/>
<dependency conf="experimental->default" org="com.mchange" name="c3p0" rev="0.9.5"/> <dependency conf="experimental->default" org="com.mchange" name="c3p0" rev="0.9.5"/>
<dependency conf="experimental->default" org="com.fasterxml.jackson.core" name="jackson-core" rev="2.7.0"/>
<dependency conf="experimental->default" org="org.swinglabs.swingx" name="swingx-all" rev="1.6.4"/> <dependency conf="experimental->default" org="org.swinglabs.swingx" name="swingx-all" rev="1.6.4"/>
</dependencies> </dependencies>
</ivy-module> </ivy-module>

View File

@ -1,5 +1,4 @@
file.reference.c3p0-0.9.5.jar=release/modules/ext/c3p0-0.9.5.jar file.reference.c3p0-0.9.5.jar=release/modules/ext/c3p0-0.9.5.jar
file.reference.jackson-core-2.7.0.jar=release/modules/ext/jackson-core-2.7.0.jar
file.reference.LGoodDatePicker-10.3.1.jar=release/modules/ext/LGoodDatePicker-10.3.1.jar file.reference.LGoodDatePicker-10.3.1.jar=release/modules/ext/LGoodDatePicker-10.3.1.jar
file.reference.mchange-commons-java-0.2.9.jar=release/modules/ext/mchange-commons-java-0.2.9.jar file.reference.mchange-commons-java-0.2.9.jar=release/modules/ext/mchange-commons-java-0.2.9.jar
file.reference.postgresql-9.4-1201-jdbc41.jar=release/modules/ext/postgresql-9.4-1201-jdbc41.jar file.reference.postgresql-9.4-1201-jdbc41.jar=release/modules/ext/postgresql-9.4-1201-jdbc41.jar

View File

@ -177,10 +177,6 @@
<runtime-relative-path>ext/mchange-commons-java-0.2.9.jar</runtime-relative-path> <runtime-relative-path>ext/mchange-commons-java-0.2.9.jar</runtime-relative-path>
<binary-origin>release/modules/ext/mchange-commons-java-0.2.9.jar</binary-origin> <binary-origin>release/modules/ext/mchange-commons-java-0.2.9.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/jackson-core-2.7.0.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jackson-core-2.7.0.jar</binary-origin>
</class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/c3p0-0.9.5.jar</runtime-relative-path> <runtime-relative-path>ext/c3p0-0.9.5.jar</runtime-relative-path>
<binary-origin>release/modules/ext/c3p0-0.9.5.jar</binary-origin> <binary-origin>release/modules/ext/c3p0-0.9.5.jar</binary-origin>

View File

@ -18,9 +18,9 @@
*/ */
package org.sleuthkit.autopsy.experimental.autoingest; package org.sleuthkit.autopsy.experimental.autoingest;
import com.fasterxml.jackson.core.JsonEncoding; //import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory; //import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator; //import com.fasterxml.jackson.core.JsonGenerator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -62,9 +62,9 @@ final class FileExporter {
private FileExportSettings settings; private FileExportSettings settings;
private Path filesDirPath; private Path filesDirPath;
private Path reportsDirPath; private Path reportsDirPath;
private JsonFactory jsonGeneratorFactory; // private JsonFactory jsonGeneratorFactory;
private JsonGenerator masterCatalog; // private JsonGenerator masterCatalog;
private Map<String, JsonGenerator> ruleNamesToCatalogs; // private Map<String, JsonGenerator> ruleNamesToCatalogs;
private List<Path> flagFilePaths; private List<Path> flagFilePaths;
FileExporter() throws FileExportException { FileExporter() throws FileExportException {
@ -110,7 +110,7 @@ final class FileExporter {
} }
exportFiles(fileIdsToRuleNames, cancelCheck); exportFiles(fileIdsToRuleNames, cancelCheck);
} }
closeCatalogs(); // closeCatalogs();
writeFlagFiles(); writeFlagFiles();
} catch (FileExportSettings.PersistenceException | FileExportRuleSet.ExportRulesException | TskCoreException | IOException | NoCurrentCaseException ex) { } catch (FileExportSettings.PersistenceException | FileExportRuleSet.ExportRulesException | TskCoreException | IOException | NoCurrentCaseException ex) {
throw new FileExportException("Error occurred during file export", ex); throw new FileExportException("Error occurred during file export", ex);
@ -212,49 +212,49 @@ final class FileExporter {
* generator. * generator.
*/ */
private void setUp() throws FileExportSettings.PersistenceException, IOException { private void setUp() throws FileExportSettings.PersistenceException, IOException {
/* // /*
* Create the file export and report root directory paths. // * Create the file export and report root directory paths.
*/ // */
filesDirPath = settings.getFilesRootDirectory(); // filesDirPath = settings.getFilesRootDirectory();
filesDirPath = filesDirPath.resolve(deviceId); // filesDirPath = filesDirPath.resolve(deviceId);
reportsDirPath = settings.getReportsRootDirectory(); // reportsDirPath = settings.getReportsRootDirectory();
reportsDirPath = reportsDirPath.resolve(deviceId); // reportsDirPath = reportsDirPath.resolve(deviceId);
//
/* // /*
* Delete the results of a previous run, if any. Results deletion cleans // * Delete the results of a previous run, if any. Results deletion cleans
* up for a crashed auto ingest job. // * up for a crashed auto ingest job.
*/ // */
FileUtil.deleteDir(reportsDirPath.toFile()); // FileUtil.deleteDir(reportsDirPath.toFile());
FileUtil.deleteDir(filesDirPath.toFile()); // FileUtil.deleteDir(filesDirPath.toFile());
//
/* // /*
* Create the file export and report root directories. // * Create the file export and report root directories.
*/ // */
Files.createDirectories(filesDirPath); // Files.createDirectories(filesDirPath);
Files.createDirectories(reportsDirPath); // Files.createDirectories(reportsDirPath);
//
/* // /*
* Create the JSON generator for the master catalog of exported files // * Create the JSON generator for the master catalog of exported files
* and a map to hold the JSON generators for the rule catalogs. // * and a map to hold the JSON generators for the rule catalogs.
*/ // */
jsonGeneratorFactory = new JsonFactory(); // jsonGeneratorFactory = new JsonFactory();
jsonGeneratorFactory.setRootValueSeparator("\r\n"); // jsonGeneratorFactory.setRootValueSeparator("\r\n");
String catalogName = settings.getMasterCatalogName(); // String catalogName = settings.getMasterCatalogName();
String catalogDir = catalogName.substring(0, 1).toUpperCase() + catalogName.substring(1); // String catalogDir = catalogName.substring(0, 1).toUpperCase() + catalogName.substring(1);
Path catalogPath = Paths.get(reportsDirPath.toString(), catalogDir, catalogName + ".json"); // Path catalogPath = Paths.get(reportsDirPath.toString(), catalogDir, catalogName + ".json");
Files.createDirectories(catalogPath.getParent()); // Files.createDirectories(catalogPath.getParent());
File catalogFile = catalogPath.toFile(); // File catalogFile = catalogPath.toFile();
masterCatalog = jsonGeneratorFactory.createGenerator(catalogFile, JsonEncoding.UTF8); // masterCatalog = jsonGeneratorFactory.createGenerator(catalogFile, JsonEncoding.UTF8);
ruleNamesToCatalogs = new HashMap<>(); // ruleNamesToCatalogs = new HashMap<>();
//
/* // /*
* Set up the paths for the flag files that are written to signal export // * Set up the paths for the flag files that are written to signal export
* is complete for thsi device. // * is complete for thsi device.
*/ // */
flagFilePaths = new ArrayList<>(); // flagFilePaths = new ArrayList<>();
flagFilePaths.add(Paths.get(filesDirPath.toString(), settings.getExportCompletedFlagFileName())); // flagFilePaths.add(Paths.get(filesDirPath.toString(), settings.getExportCompletedFlagFileName()));
flagFilePaths.add(Paths.get(reportsDirPath.toString(), catalogDir, settings.getExportCompletedFlagFileName())); // flagFilePaths.add(Paths.get(reportsDirPath.toString(), catalogDir, settings.getExportCompletedFlagFileName()));
flagFilePaths.add(Paths.get(reportsDirPath.toString(), settings.getRulesEvaluatedFlagFileName())); // flagFilePaths.add(Paths.get(reportsDirPath.toString(), settings.getRulesEvaluatedFlagFileName()));
} }
/** /**
@ -341,31 +341,31 @@ final class FileExporter {
* storage. * storage.
*/ */
private void exportFile(Long fileId, List<String> ruleNames, Supplier<Boolean> cancelCheck) throws TskCoreException, IOException, NoCurrentCaseException { private void exportFile(Long fileId, List<String> ruleNames, Supplier<Boolean> cancelCheck) throws TskCoreException, IOException, NoCurrentCaseException {
AbstractFile file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(fileId); // AbstractFile file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(fileId);
if (!shouldExportFile(file)) { // if (!shouldExportFile(file)) {
return; // return;
} // }
Map<BlackboardArtifact, List<BlackboardAttribute>> artifactsToAttributes = new HashMap<>(); // Map<BlackboardArtifact, List<BlackboardAttribute>> artifactsToAttributes = new HashMap<>();
List<BlackboardArtifact> artifacts = file.getAllArtifacts(); // List<BlackboardArtifact> artifacts = file.getAllArtifacts();
for (BlackboardArtifact artifact : artifacts) { // for (BlackboardArtifact artifact : artifacts) {
artifactsToAttributes.put(artifact, artifact.getAttributes()); // artifactsToAttributes.put(artifact, artifact.getAttributes());
} // }
Path filePath = exportFileToSecondaryStorage(file, cancelCheck); // Path filePath = exportFileToSecondaryStorage(file, cancelCheck);
if (filePath == null) { // if (filePath == null) {
return; // return;
} // }
addFileToCatalog(file, artifactsToAttributes, filePath, masterCatalog); // addFileToCatalog(file, artifactsToAttributes, filePath, masterCatalog);
for (String ruleName : ruleNames) { // for (String ruleName : ruleNames) {
JsonGenerator ruleCatalog = this.ruleNamesToCatalogs.get(ruleName); // JsonGenerator ruleCatalog = this.ruleNamesToCatalogs.get(ruleName);
if (null == ruleCatalog) { // if (null == ruleCatalog) {
Path catalogPath = Paths.get(reportsDirPath.toString(), ruleName, "catalog.json"); // Path catalogPath = Paths.get(reportsDirPath.toString(), ruleName, "catalog.json");
Files.createDirectories(catalogPath.getParent()); // Files.createDirectories(catalogPath.getParent());
File catalogFile = catalogPath.toFile(); // File catalogFile = catalogPath.toFile();
ruleCatalog = jsonGeneratorFactory.createGenerator(catalogFile, JsonEncoding.UTF8); // ruleCatalog = jsonGeneratorFactory.createGenerator(catalogFile, JsonEncoding.UTF8);
ruleNamesToCatalogs.put(ruleName, ruleCatalog); // ruleNamesToCatalogs.put(ruleName, ruleCatalog);
} // }
addFileToCatalog(file, artifactsToAttributes, filePath, ruleCatalog); // addFileToCatalog(file, artifactsToAttributes, filePath, ruleCatalog);
} // }
} }
/** /**
@ -470,150 +470,150 @@ final class FileExporter {
return exportFilePath; return exportFilePath;
} }
/** // /**
* Adds an exported file to a catalog. // * Adds an exported file to a catalog.
* // *
* @param file The file. // * @param file The file.
* @param artifactsToAttributes The artifacts associated with the file. // * @param artifactsToAttributes The artifacts associated with the file.
* @param filePath The path to the exported file. // * @param filePath The path to the exported file.
* @param catalog The catalog. // * @param catalog The catalog.
* // *
* @throws IOException If there is an error while writing to the // * @throws IOException If there is an error while writing to the
* catalog. // * catalog.
* @throws TskCoreExceptiion If there is a problem querying the case // * @throws TskCoreExceptiion If there is a problem querying the case
* database. // * database.
*/ // */
private void addFileToCatalog(AbstractFile file, Map<BlackboardArtifact, List<BlackboardAttribute>> artifactsToAttributes, Path filePath, JsonGenerator catalog) throws IOException, TskCoreException { // private void addFileToCatalog(AbstractFile file, Map<BlackboardArtifact, List<BlackboardAttribute>> artifactsToAttributes, Path filePath, JsonGenerator catalog) throws IOException, TskCoreException {
catalog.writeStartObject(); // catalog.writeStartObject();
String md5 = file.getMd5Hash().toUpperCase(); // String md5 = file.getMd5Hash().toUpperCase();
catalog.writeFieldName(md5); // catalog.writeFieldName(md5);
catalog.writeStartObject(); // catalog.writeStartObject();
catalog.writeStringField("Filename", filePath.toString()); // catalog.writeStringField("Filename", filePath.toString());
catalog.writeStringField("Type", file.getMIMEType()); // catalog.writeStringField("Type", file.getMIMEType());
catalog.writeStringField("MD5", md5); // catalog.writeStringField("MD5", md5);
catalog.writeFieldName("File data"); // catalog.writeFieldName("File data");
catalog.writeStartObject(); // catalog.writeStartObject();
//
catalog.writeFieldName("Modified"); // catalog.writeFieldName("Modified");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getMtimeAsDate()); // catalog.writeString(file.getMtimeAsDate());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Changed"); // catalog.writeFieldName("Changed");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getCtimeAsDate()); // catalog.writeString(file.getCtimeAsDate());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Accessed"); // catalog.writeFieldName("Accessed");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getAtimeAsDate()); // catalog.writeString(file.getAtimeAsDate());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Created"); // catalog.writeFieldName("Created");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getCrtimeAsDate()); // catalog.writeString(file.getCrtimeAsDate());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Extension"); // catalog.writeFieldName("Extension");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getNameExtension()); // catalog.writeString(file.getNameExtension());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Filename"); // catalog.writeFieldName("Filename");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getName()); // catalog.writeString(file.getName());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Size"); // catalog.writeFieldName("Size");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(Long.toString(file.getSize())); // catalog.writeString(Long.toString(file.getSize()));
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Source Path"); // catalog.writeFieldName("Source Path");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getParentPath() + "/" + file.getName()); // catalog.writeString(file.getParentPath() + "/" + file.getName());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Flags (Dir)"); // catalog.writeFieldName("Flags (Dir)");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getDirFlagAsString()); // catalog.writeString(file.getDirFlagAsString());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Flags (Meta)"); // catalog.writeFieldName("Flags (Meta)");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getMetaFlagsAsString()); // catalog.writeString(file.getMetaFlagsAsString());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Mode"); // catalog.writeFieldName("Mode");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getModesAsString()); // catalog.writeString(file.getModesAsString());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("User ID"); // catalog.writeFieldName("User ID");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(Integer.toString(file.getUid())); // catalog.writeString(Integer.toString(file.getUid()));
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Group ID"); // catalog.writeFieldName("Group ID");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(Integer.toString(file.getGid())); // catalog.writeString(Integer.toString(file.getGid()));
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Meta Addr"); // catalog.writeFieldName("Meta Addr");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(Long.toString(file.getMetaAddr())); // catalog.writeString(Long.toString(file.getMetaAddr()));
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Attr Addr"); // catalog.writeFieldName("Attr Addr");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(Long.toString(file.getAttrType().getValue()) + "-" + file.getAttributeId()); // catalog.writeString(Long.toString(file.getAttrType().getValue()) + "-" + file.getAttributeId());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Dir Type"); // catalog.writeFieldName("Dir Type");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getDirType().getLabel()); // catalog.writeString(file.getDirType().getLabel());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Meta Type"); // catalog.writeFieldName("Meta Type");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getMetaType().toString()); // catalog.writeString(file.getMetaType().toString());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeFieldName("Known"); // catalog.writeFieldName("Known");
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(file.getKnown().getName()); // catalog.writeString(file.getKnown().getName());
catalog.writeEndArray(); // catalog.writeEndArray();
//
catalog.writeEndObject(); // catalog.writeEndObject();
//
for (Map.Entry<BlackboardArtifact, List<BlackboardAttribute>> entry : artifactsToAttributes.entrySet()) { // for (Map.Entry<BlackboardArtifact, List<BlackboardAttribute>> entry : artifactsToAttributes.entrySet()) {
for (BlackboardAttribute attr : entry.getValue()) { // for (BlackboardAttribute attr : entry.getValue()) {
catalog.writeFieldName(entry.getKey().getArtifactTypeName()); // catalog.writeFieldName(entry.getKey().getArtifactTypeName());
catalog.writeStartObject(); // catalog.writeStartObject();
catalog.writeFieldName(attr.getAttributeType().getTypeName()); // catalog.writeFieldName(attr.getAttributeType().getTypeName());
catalog.writeStartArray(); // catalog.writeStartArray();
catalog.writeString(attr.getDisplayString()); // catalog.writeString(attr.getDisplayString());
catalog.writeEndArray(); // catalog.writeEndArray();
catalog.writeEndObject(); // catalog.writeEndObject();
} // }
} // }
//
catalog.writeEndObject(); // catalog.writeEndObject();
catalog.writeEndObject(); // catalog.writeEndObject();
} // }
//
/** // /**
* Closes all catalogs opened during export. // * Closes all catalogs opened during export.
* // *
* @throws IOException If there is a problem closing a catalog. // * @throws IOException If there is a problem closing a catalog.
*/ // */
private void closeCatalogs() throws IOException { // private void closeCatalogs() throws IOException {
masterCatalog.close(); // masterCatalog.close();
for (JsonGenerator catalog : this.ruleNamesToCatalogs.values()) { // for (JsonGenerator catalog : this.ruleNamesToCatalogs.values()) {
catalog.close(); // catalog.close();
} // }
//
} // }
/** /**
* Writes the flag files that signal export is completed. * Writes the flag files that signal export is completed.