19 package org.sleuthkit.autopsy.report.testfixtures;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.logging.Level;
24 import javax.xml.bind.DatatypeConverter;
34 import org.openide.util.NbBundle;
41 "ErrorCreatingCustomBlackBoardType=Error creating custom blackboard type."
45 private static final Logger logger =
Logger.
getLogger(CustomArtifactsCreatorIngestModule.class.getName());
47 private static final String ARTIFACT_TYPE_NAME =
"AUT_ARTIFACT";
48 private static final String ARTIFACT_DISPLAY_NAME =
"Autopsy Artifact";
49 private static final String INT_ATTR_TYPE_NAME =
"AUT_INT_ATTRIBUTE";
50 private static final String INT_ATTR_DISPLAY_NAME =
"Autopsy Integer";
51 private static final String DOUBLE_ATTR_TYPE_NAME =
"AUT_DOUBLE_ATTRIBUTE";
52 private static final String DOUBLE_ATTR_DISPLAY_NAME =
"Autopsy Double";
53 private static final String LONG_ATTR_TYPE_NAME =
"AUT_LONG_ATTRIBUTE";
54 private static final String LONG_ATTR_DISPLAY_NAME =
"Autopsy Long";
55 private static final String DATETIME_ATTR_TYPE_NAME =
"AUT_DATETIME_ATTRIBUTE";
56 private static final String DATETIME_ATTR_DISPLAY_NAME =
"Autopsy Datetime";
57 private static final String BYTES_ATTR_TYPE_NAME =
"AUT_BYTES_ATTRIBUTE";
58 private static final String BYTES_ATTR_DISPLAY_NAME =
"Autopsy Bytes";
59 private static final String STRING_ATTR_TYPE_NAME =
"AUT_STRING_ATTRIBUTE";
60 private static final String STRING_ATTR_DISPLAY_NAME =
"Autopsy String";
61 private BlackboardArtifact.Type artifactType;
62 private BlackboardAttribute.Type intAttrType;
63 private BlackboardAttribute.Type doubleAttrType;
64 private BlackboardAttribute.Type longAttributeType;
65 private BlackboardAttribute.Type dateTimeAttrType;
66 private BlackboardAttribute.Type bytesAttrType;
67 private BlackboardAttribute.Type stringAttrType;
74 intAttrType = blackboard.
getOrAddAttributeType(INT_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER, INT_ATTR_DISPLAY_NAME);
75 doubleAttrType = blackboard.
getOrAddAttributeType(DOUBLE_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE, DOUBLE_ATTR_DISPLAY_NAME);
76 longAttributeType = blackboard.
getOrAddAttributeType(LONG_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG, LONG_ATTR_DISPLAY_NAME);
77 dateTimeAttrType = blackboard.
getOrAddAttributeType(DATETIME_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME, DATETIME_ATTR_DISPLAY_NAME);
78 bytesAttrType = blackboard.
getOrAddAttributeType(BYTES_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE, BYTES_ATTR_DISPLAY_NAME);
79 stringAttrType = blackboard.
getOrAddAttributeType(STRING_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING, STRING_ATTR_DISPLAY_NAME);
81 throw new IngestModuleException(Bundle.ErrorCreatingCustomBlackBoardType(), ex);
86 public ProcessResult process(AbstractFile file) {
90 if (file.isDir() || file.isVirtual()) {
91 return ProcessResult.OK;
98 BlackboardArtifact artifact = file.newArtifact(artifactType.getTypeID());
99 List<BlackboardAttribute> attributes =
new ArrayList<>();
100 attributes.add(
new BlackboardAttribute(intAttrType, moduleName, 0));
101 attributes.add(
new BlackboardAttribute(doubleAttrType, moduleName, 0.0));
102 attributes.add(
new BlackboardAttribute(longAttributeType, moduleName, 0L));
103 attributes.add(
new BlackboardAttribute(dateTimeAttrType, moduleName, 60L));
104 attributes.add(
new BlackboardAttribute(bytesAttrType, moduleName, DatatypeConverter.parseHexBinary(
"ABCD")));
105 attributes.add(
new BlackboardAttribute(stringAttrType, moduleName,
"Zero"));
106 artifact.addAttributes(attributes);
107 }
catch (TskCoreException ex) {
108 logger.log(Level.SEVERE, String.format(
"Failed to process file (obj_id = %d)", file.getId()), ex);
109 return ProcessResult.ERROR;
112 return ProcessResult.OK;
synchronized BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName)
synchronized BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName)
Blackboard getBlackboard()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)