19 package org.sleuthkit.autopsy.modules.stix;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.mitre.cybox.common_2.ConditionApplicationEnum;
24 import org.mitre.cybox.common_2.ConditionTypeEnum;
25 import org.mitre.cybox.objects.DomainName;
35 class EvalDomainObj
extends EvaluatableObject {
37 private final DomainName obj;
39 public EvalDomainObj(DomainName a_obj, String a_id, String a_spacing) {
46 public synchronized ObservableResult evaluate() {
50 if (obj.getValue() == null) {
51 return new ObservableResult(
id,
"DomainObject: No domain value field found",
52 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
56 if (!((obj.getValue().getApplyCondition() == null)
57 || (obj.getValue().getApplyCondition() == ConditionApplicationEnum.ANY))) {
58 return new ObservableResult(
id,
"DomainObject: Can not process apply condition " + obj.getValue().getApplyCondition().toString()
59 +
" on Domain object", spacing, ObservableResult.ObservableState.INDETERMINATE, null);
63 if ((obj.getValue().getCondition() != null)
64 && (obj.getValue().getCondition() != ConditionTypeEnum.CONTAINS)) {
65 addWarning(
"Warning: Ignoring condition " + obj.getValue().getCondition().toString()
66 +
" on DomainName - using substring comparison");
69 Case case1 = Case.getCurrentCase();
70 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
74 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
77 List<BlackboardArtifact> artList
78 = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT);
80 for (BlackboardArtifact art : artList) {
82 for (BlackboardAttribute attr : art.getAttributes()) {
83 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
84 String url = attr.getValueString();
88 if (compareStringObject(obj.getValue().getValue().toString(), ConditionTypeEnum.CONTAINS,
89 obj.getValue().getApplyCondition(), url)) {
96 if (!finalHits.isEmpty()) {
97 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
98 for (BlackboardArtifact a : finalHits) {
99 artData.add(
new StixArtifactData(a.getObjectID(), id,
"DomainNameObject"));
101 return new ObservableResult(
id,
"DomainNameObject: Found a match for " + obj.getValue().getValue().toString()
102 +
" " + getPrintableWarnings(),
103 spacing, ObservableResult.ObservableState.TRUE, artData);
106 return new ObservableResult(
id,
"DomainNameObject: Found no matches for " + obj.getValue().getValue().toString()
107 +
" " + getPrintableWarnings(),
108 spacing, ObservableResult.ObservableState.FALSE, null);
109 }
catch (TskCoreException ex) {
110 return new ObservableResult(
id,
"DomainNameObject: Exception during evaluation: " + ex.getLocalizedMessage(),
111 spacing, ObservableResult.ObservableState.INDETERMINATE, null);