Merge pull request #6634 from gdicristofaro/7212-xleappSources

7212 & 7222 xleapp sources
This commit is contained in:
Richard Cordovano 2021-01-20 09:33:47 -05:00 committed by GitHub
commit 67aa7d3c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 14 deletions

View File

@ -97,7 +97,7 @@ public class ALeappAnalyzerIngestModule implements DataSourceIngestModule {
} }
try { try {
aLeappFileProcessor = new LeappFileProcessor(XMLFILE); aLeappFileProcessor = new LeappFileProcessor(XMLFILE, ALeappAnalyzerModuleFactory.getModuleName());
} catch (IOException | IngestModuleException | NoCurrentCaseException ex) { } catch (IOException | IngestModuleException | NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.ALeappAnalyzerIngestModule_error_ileapp_file_processor_init(), ex); throw new IngestModuleException(Bundle.ALeappAnalyzerIngestModule_error_ileapp_file_processor_init(), ex);
} }

View File

@ -97,7 +97,7 @@ public class ILeappAnalyzerIngestModule implements DataSourceIngestModule {
} }
try { try {
iLeappFileProcessor = new LeappFileProcessor(XMLFILE); iLeappFileProcessor = new LeappFileProcessor(XMLFILE, ILeappAnalyzerModuleFactory.getModuleName());
} catch (IOException | IngestModuleException | NoCurrentCaseException ex) { } catch (IOException | IngestModuleException | NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.ILeappAnalyzerIngestModule_error_ileapp_file_processor_init(), ex); throw new IngestModuleException(Bundle.ILeappAnalyzerIngestModule_error_ileapp_file_processor_init(), ex);
} }

View File

@ -122,9 +122,8 @@ public final class LeappFileProcessor {
} }
private static final Logger logger = Logger.getLogger(LeappFileProcessor.class.getName()); private static final Logger logger = Logger.getLogger(LeappFileProcessor.class.getName());
private static final String MODULE_NAME = ILeappAnalyzerModuleFactory.getModuleName();
private final String xmlFile; //NON-NLS private final String xmlFile; //NON-NLS
private final String moduleName;
private final Map<String, String> tsvFiles; private final Map<String, String> tsvFiles;
private final Map<String, String> tsvFileArtifacts; private final Map<String, String> tsvFileArtifacts;
@ -133,12 +132,13 @@ public final class LeappFileProcessor {
Blackboard blkBoard; Blackboard blkBoard;
public LeappFileProcessor(String xmlFile) throws IOException, IngestModuleException, NoCurrentCaseException { public LeappFileProcessor(String xmlFile, String moduleName) throws IOException, IngestModuleException, NoCurrentCaseException {
this.tsvFiles = new HashMap<>(); this.tsvFiles = new HashMap<>();
this.tsvFileArtifacts = new HashMap<>(); this.tsvFileArtifacts = new HashMap<>();
this.tsvFileArtifactComments = new HashMap<>(); this.tsvFileArtifactComments = new HashMap<>();
this.tsvFileAttributes = new HashMap<>(); this.tsvFileAttributes = new HashMap<>();
this.xmlFile = xmlFile; this.xmlFile = xmlFile;
this.moduleName = moduleName;
blkBoard = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard(); blkBoard = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard();
@ -372,7 +372,7 @@ public final class LeappFileProcessor {
} }
if (tsvFileArtifactComments.containsKey(fileName)) { if (tsvFileArtifactComments.containsKey(fileName)) {
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME, tsvFileArtifactComments.get(fileName))); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_COMMENT, moduleName, tsvFileArtifactComments.get(fileName)));
} }
return bbattributes; return bbattributes;
@ -392,28 +392,30 @@ public final class LeappFileProcessor {
String columnValue = columnValues[columnNumber]; String columnValue = columnValues[columnNumber];
if (attrType.matches("STRING")) { if (attrType.matches("STRING")) {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, columnValue)); bbattributes.add(new BlackboardAttribute(attributeType, moduleName, columnValue));
} else if (attrType.matches("INTEGER")) { } else if (attrType.matches("INTEGER")) {
try { try {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, Integer.valueOf(columnValue))); // parse as double to handle values of format like '21.0' and then convert to int
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Double.valueOf(columnValue).intValue()));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an integer.", columnValue), ex); logger.log(Level.WARNING, String.format("Unable to format %s as an integer.", columnValue), ex);
} }
} else if (attrType.matches("LONG")) { } else if (attrType.matches("LONG")) {
try { try {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, Long.valueOf(columnValue))); // parse as double to handle values of format like '21.0' and then convert to long
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Double.valueOf(columnValue).longValue()));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an long.", columnValue), ex); logger.log(Level.WARNING, String.format("Unable to format %s as an long.", columnValue), ex);
} }
} else if (attrType.matches("DOUBLE")) { } else if (attrType.matches("DOUBLE")) {
try { try {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, Double.valueOf(columnValue))); bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Double.valueOf(columnValue)));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an double.", columnValue), ex); logger.log(Level.WARNING, String.format("Unable to format %s as an double.", columnValue), ex);
} }
} else if (attrType.matches("BYTE")) { } else if (attrType.matches("BYTE")) {
try { try {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, Byte.valueOf(columnValue))); bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Byte.valueOf(columnValue)));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an byte.", columnValue), ex); logger.log(Level.WARNING, String.format("Unable to format %s as an byte.", columnValue), ex);
} }
@ -424,7 +426,7 @@ public final class LeappFileProcessor {
try { try {
Date newDate = dateFormat.parse(columnValue); Date newDate = dateFormat.parse(columnValue);
dateLong = newDate.getTime() / 1000; dateLong = newDate.getTime() / 1000;
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, dateLong)); bbattributes.add(new BlackboardAttribute(attributeType, moduleName, dateLong));
} catch (ParseException ex) { } catch (ParseException ex) {
// catching error and displaying date that could not be parsed // catching error and displaying date that could not be parsed
// we set the timestamp to 0 and continue on processing // we set the timestamp to 0 and continue on processing
@ -432,7 +434,7 @@ public final class LeappFileProcessor {
} }
} else if (attrType.matches("JSON")) { } else if (attrType.matches("JSON")) {
bbattributes.add(new BlackboardAttribute(attributeType, MODULE_NAME, columnValue)); bbattributes.add(new BlackboardAttribute(attributeType, moduleName, columnValue));
} else { } else {
// Log this and continue on with processing // Log this and continue on with processing
logger.log(Level.WARNING, String.format("Attribute Type %s not defined.", attrType)); //NON-NLS logger.log(Level.WARNING, String.format("Attribute Type %s not defined.", attrType)); //NON-NLS
@ -686,7 +688,7 @@ public final class LeappFileProcessor {
} }
try { try {
Case.getCurrentCase().getSleuthkitCase().getBlackboard().postArtifacts(artifacts, MODULE_NAME); Case.getCurrentCase().getSleuthkitCase().getBlackboard().postArtifacts(artifacts, moduleName);
} catch (Blackboard.BlackboardException ex) { } catch (Blackboard.BlackboardException ex) {
logger.log(Level.SEVERE, Bundle.LeappFileProcessor_postartifacts_error(), ex); //NON-NLS logger.log(Level.SEVERE, Bundle.LeappFileProcessor_postartifacts_error(), ex); //NON-NLS
} }