19 package org.sleuthkit.autopsy.report.modules.stix;
21 import java.util.Arrays;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import org.apache.commons.lang3.StringUtils;
25 import org.openide.util.NbBundle.Messages;
32 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME;
36 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE;
43 class StixArtifactData {
45 private static final String MODULE_NAME =
"Stix";
47 private AbstractFile file;
48 private final String observableId;
49 private final String objType;
50 private static final Logger logger = Logger.getLogger(StixArtifactData.class.getName());
52 StixArtifactData(AbstractFile a_file, String a_observableId, String a_objType) {
54 observableId = a_observableId;
58 StixArtifactData(
long a_objId, String a_observableId, String a_objType) {
60 Case case1 = Case.getCurrentCaseThrows();
61 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
62 file = sleuthkitCase.getAbstractFileById(a_objId);
63 }
catch (TskCoreException | NoCurrentCaseException ex) {
66 observableId = a_observableId;
70 @Messages({
"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search.",
71 "StixArtifactData.noOpenCase.errMsg=No open case available."})
72 void createArtifact(String a_title)
throws TskCoreException {
73 Blackboard blackboard;
75 blackboard = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard();
76 }
catch (NoCurrentCaseException ex) {
77 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
81 String setName =
"STIX Indicator - " + StringUtils.defaultIfBlank(a_title,
"(no title)");
83 Collection<BlackboardAttribute> attributes = Arrays.asList(
84 new BlackboardAttribute(TSK_SET_NAME, MODULE_NAME, setName),
85 new BlackboardAttribute(TSK_TITLE, MODULE_NAME, observableId),
86 new BlackboardAttribute(TSK_CATEGORY, MODULE_NAME, objType));
89 if (!blackboard.artifactExists(file, TSK_INTERESTING_FILE_HIT, attributes)) {
90 BlackboardArtifact bba = file.newArtifact(TSK_INTERESTING_FILE_HIT);
91 bba.addAttributes(attributes);
98 blackboard.postArtifact(bba, MODULE_NAME);
99 }
catch (Blackboard.BlackboardException ex) {
100 logger.log(Level.SEVERE,
"Unable to index blackboard artifact " + bba.getArtifactID(), ex);