mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
adjusted the sql query to select all the data needed to display common files, passed new data down to nodes
This commit is contained in:
parent
0d7d68af50
commit
0c82f1637c
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.commonfilesearch;
|
package org.sleuthkit.autopsy.commonfilesearch;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
@ -29,17 +30,28 @@ import org.sleuthkit.autopsy.datamodel.CommonFileNode;
|
|||||||
*/
|
*/
|
||||||
final class CommonFilesChildren extends Children.Keys<AbstractFile> {
|
final class CommonFilesChildren extends Children.Keys<AbstractFile> {
|
||||||
|
|
||||||
CommonFilesChildren(boolean lazy, List<AbstractFile> fileList) {
|
private final java.util.Map<String, Integer> instanceCountMap;
|
||||||
|
private final java.util.Map<String, String> dataSourceMap;
|
||||||
|
|
||||||
|
CommonFilesChildren(boolean lazy, List<AbstractFile> fileList, java.util.Map<String, Integer> instanceCountMap, java.util.Map<String, String> dataSourceMap) {
|
||||||
super(lazy);
|
super(lazy);
|
||||||
this.setKeys(fileList);
|
this.setKeys(fileList);
|
||||||
|
|
||||||
|
this.instanceCountMap = instanceCountMap;
|
||||||
|
this.dataSourceMap = dataSourceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Node[] createNodes(AbstractFile t) {
|
protected Node[] createNodes(AbstractFile t) {
|
||||||
|
|
||||||
|
final String md5Hash = t.getMd5Hash();
|
||||||
|
|
||||||
|
int instanceCount = this.instanceCountMap.get(md5Hash);
|
||||||
|
String dataSources = this.dataSourceMap.get(md5Hash);
|
||||||
|
|
||||||
Node[] node = new Node[1];
|
Node[] node = new Node[1];
|
||||||
|
node[0] = new CommonFileNode(t, instanceCount, dataSources);
|
||||||
//TODO replace FileNode with our own subclass of its base type or similar (use CommonFileNode once its finished)
|
|
||||||
node[0] = new CommonFileNode(t);
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
//TODO this is sort of a misues of the findAllFilesWhere function and seems brittle...
|
//TODO this is sort of a misues of the findAllFilesWhere function and seems brittle...
|
||||||
//...consider doing something else
|
//...consider doing something else
|
||||||
//TODO verify that this works with postgres
|
//TODO verify that this works with postgres
|
||||||
return tskDb.findAllFilesWhere("1 == 1 AND (known != 1 OR known IS NULL) GROUP BY md5 HAVING COUNT(*) > 1;");
|
return tskDb.findAllFilesWhere("md5 in (select md5 from tsk_files where (known != 1 OR known IS NULL) GROUP BY md5 HAVING COUNT(*) > 1) order by md5");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +100,9 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
List<AbstractFile> contentList = get();
|
List<AbstractFile> contentList = get();
|
||||||
|
|
||||||
CommonFilesSearchNode contentFilesNode = new CommonFilesSearchNode(contentList);
|
CommonFilesMetaData metadata = CommonFilesMetaData.DeDupeFiles(contentList);
|
||||||
|
|
||||||
|
CommonFilesSearchNode contentFilesNode = new CommonFilesSearchNode(metadata.dedupedFiles, metadata.instanceCountMap, metadata.dataSourceMap);
|
||||||
|
|
||||||
TopComponent component = DataResultTopComponent.createInstance(
|
TopComponent component = DataResultTopComponent.createInstance(
|
||||||
title,
|
title,
|
||||||
|
@ -18,21 +18,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.commonfilesearch;
|
package org.sleuthkit.autopsy.commonfilesearch;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates data used to display common files search results in the top right pane.
|
* Encapsulates data used to display common files search results in the top
|
||||||
|
* right pane.
|
||||||
*/
|
*/
|
||||||
//TODO rename to CommonFilesSearchNode
|
//TODO rename to CommonFilesSearchNode
|
||||||
final class CommonFilesSearchNode extends AbstractNode {
|
final class CommonFilesSearchNode extends AbstractNode {
|
||||||
|
|
||||||
private CommonFilesChildren children;
|
private CommonFilesChildren children;
|
||||||
|
|
||||||
CommonFilesSearchNode(List<AbstractFile> keys) {
|
CommonFilesSearchNode(List<AbstractFile> keys, java.util.Map<String, Integer> instanceCountMap, java.util.Map<String, String> dataSourceMap) {
|
||||||
super(new CommonFilesChildren(true, keys));
|
super(new CommonFilesChildren(true, keys, instanceCountMap, dataSourceMap));
|
||||||
this.children = (CommonFilesChildren) this.getChildren();
|
this.children = (CommonFilesChildren) this.getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +34,27 @@ public class CommonFileNode extends AbstractNode {
|
|||||||
|
|
||||||
private final AbstractFile content;
|
private final AbstractFile content;
|
||||||
|
|
||||||
public CommonFileNode(AbstractFile fsContent) {
|
private final int commonFileCount;
|
||||||
|
|
||||||
|
private final String dataSources;
|
||||||
|
|
||||||
|
public CommonFileNode(AbstractFile fsContent, int commonFileCount, String dataSources) {
|
||||||
super(Children.LEAF);
|
super(Children.LEAF);
|
||||||
this.content = fsContent;
|
this.content = fsContent;
|
||||||
|
this.commonFileCount = commonFileCount;
|
||||||
|
this.dataSources = dataSources;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCommonFileCount(){
|
||||||
|
return this.commonFileCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractFile getContent(){
|
||||||
|
return this.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDataSources(){
|
||||||
|
return this.dataSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,7 +67,7 @@ public class CommonFileNode extends AbstractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
fillPropertyMap(map, content);
|
fillPropertyMap(map, this);
|
||||||
|
|
||||||
final String NO_DESCR = Bundle.AbstractFsContentNode_noDesc_text();
|
final String NO_DESCR = Bundle.AbstractFsContentNode_noDesc_text();
|
||||||
for (CommonFilePropertyType propType : CommonFilePropertyType.values()) {
|
for (CommonFilePropertyType propType : CommonFilePropertyType.values()) {
|
||||||
@ -63,25 +81,31 @@ public class CommonFileNode extends AbstractNode {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill map with AbstractFile properties
|
* Fill map with AbstractFile properties
|
||||||
*
|
*
|
||||||
* @param map map with preserved ordering, where property names/values
|
* @param map map with preserved ordering, where property names/values
|
||||||
* are put
|
* are put
|
||||||
* @param content The content to get properties for.
|
* @param node The item to get properties for.
|
||||||
*/
|
*/
|
||||||
static public void fillPropertyMap(Map<String, Object> map, AbstractFile content) {
|
static public void fillPropertyMap(Map<String, Object> map, CommonFileNode node) {
|
||||||
map.put(CommonFilePropertyType.Name.toString(), content.getName());
|
map.put(CommonFilePropertyType.Name.toString(), node.getContent().getName());
|
||||||
map.put(CommonFilePropertyType.Md5Hash.toString(), StringUtils.defaultString(content.getMd5Hash()));
|
map.put(CommonFilePropertyType.InstanceCount.toString(), node.getCommonFileCount());
|
||||||
|
map.put(CommonFilePropertyType.Md5Hash.toString(), StringUtils.defaultString(node.getContent().getMd5Hash()));
|
||||||
|
map.put(CommonFilePropertyType.DataSources.toString(), node.getDataSources());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NbBundle.Messages({
|
@NbBundle.Messages({
|
||||||
"CommonFilePropertyType.nameColLbl=Name",
|
"CommonFilePropertyType.nameColLbl=Name",
|
||||||
"CommonFilePropertyType.md5HashColLbl=MD5 Hash"})
|
"CommonFilePropertyType.instanceColLbl1=Instance Count",
|
||||||
|
"CommonFilePropertyType.md5HashColLbl=MD5 Hash",
|
||||||
|
"CommonFilePropertyType.dataSourcesColLbl=Data Sources"})
|
||||||
public enum CommonFilePropertyType {
|
public enum CommonFilePropertyType {
|
||||||
|
|
||||||
Name(Bundle.CommonFilePropertyType_nameColLbl()),
|
Name(Bundle.CommonFilePropertyType_nameColLbl()),
|
||||||
Md5Hash(Bundle.CommonFilePropertyType_md5HashColLbl());
|
InstanceCount(Bundle.CommonFilePropertyType_instanceColLbl1()),
|
||||||
|
Md5Hash(Bundle.CommonFilePropertyType_md5HashColLbl()),
|
||||||
|
DataSources(Bundle.CommonFilePropertyType_dataSourcesColLbl());
|
||||||
|
|
||||||
final private String displayString;
|
final private String displayString;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user