Skip to content

Commit 43bde93

Browse files
authored
Merge pull request #3424 from sleuthkit/3536-contentviewers
3536 - Look at all Content in node so that artifacts are not shown
2 parents 93b3406 + 4cd548e commit 43bde93

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerHex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public void setNode(Node selectedNode) {
453453
return;
454454
}
455455

456-
Content content = (selectedNode).getLookup().lookup(Content.class);
456+
Content content = DataContentViewerUtility.getDefaultContent(selectedNode);
457457
if (content == null) {
458458
resetComponent();
459459
return;

Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerString.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ public void setNode(Node selectedNode) {
452452
return;
453453
}
454454

455-
Lookup lookup = selectedNode.getLookup();
456-
Content content = lookup.lookup(Content.class);
455+
Content content = DataContentViewerUtility.getDefaultContent(selectedNode);
457456
if (content != null) {
458457
this.setDataView(content, 0);
459458
return;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Autopsy Forensic Browser
3+
*
4+
* Copyright 2018 Basis Technology Corp.
5+
* Contact: carrier <at> sleuthkit <dot> org
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.sleuthkit.autopsy.corecomponents;
20+
21+
import org.sleuthkit.datamodel.Content;
22+
import org.openide.nodes.Node;
23+
import org.sleuthkit.datamodel.BlackboardArtifact;
24+
25+
/**
26+
* Utility classes for content viewers.
27+
* In theory, this would live in the contentviewer package,
28+
* but the initial method was needed only be viewers in
29+
* corecomponents and therefore can stay out of public API.
30+
*/
31+
class DataContentViewerUtility {
32+
/**
33+
* Returns the first non-Blackboard Artifact from a Node.
34+
* Needed for (at least) Hex and Strings that want to view
35+
* all types of content (not just AbstractFile), but don't want
36+
* to display an artifact unless that's the only thing there.
37+
* Scenario is hash hit or interesting item hit.
38+
*
39+
* @param node Node passed into content viewer
40+
* @return highest priority content or null if there is no content
41+
*/
42+
static Content getDefaultContent(Node node) {
43+
Content bbContentSeen = null;
44+
for (Content content : (node).getLookup().lookupAll(Content.class)) {
45+
if (content instanceof BlackboardArtifact) {
46+
bbContentSeen = content;
47+
}
48+
else {
49+
return content;
50+
}
51+
}
52+
return bbContentSeen;
53+
}
54+
}

0 commit comments

Comments
 (0)