This commit is contained in:
Greg DiCristofaro 2023-07-05 08:57:33 -04:00
parent 6b683a5813
commit 1333001b94
4 changed files with 39 additions and 61 deletions

View File

@ -150,15 +150,16 @@ abstract class BlackboardArtifactDAO extends AbstractDAO {
return IGNORED_TYPES; return IGNORED_TYPES;
} }
TableData createTableData(BlackboardArtifact.Type artType, List<BlackboardArtifact> arts) throws TskCoreException, NoCurrentCaseException { TableData createTableData(BlackboardArtifact.Type artType, List<? extends BlackboardArtifact> arts) throws TskCoreException, NoCurrentCaseException {
// A linked hashmap is being used for artifactAttributes to ensure that artifact order // A linked hashmap is being used for artifactAttributes to ensure that artifact order
// as well as attribute orders within those artifacts are preserved. This is to maintain // as well as attribute orders within those artifacts are preserved. This is to maintain
// a consistent ordering of attribute columns as received from BlackboardArtifact.getAttributes // a consistent ordering of attribute columns as received from BlackboardArtifact.getAttributes
Map<Long, Map<BlackboardAttribute.Type, Object>> artifactAttributes = new LinkedHashMap<>(); Map<Long, Map<BlackboardAttribute.Type, Object>> artifactAttributes = new LinkedHashMap<>();
for (BlackboardArtifact art : arts) { for (BlackboardArtifact art : arts) {
BlackboardArtifact.Type thisArtType = artType != null ? artType : art.getType();
Map<BlackboardAttribute.Type, Object> attrs = art.getAttributes().stream() Map<BlackboardAttribute.Type, Object> attrs = art.getAttributes().stream()
.filter(attr -> isRenderedAttr(artType, attr.getAttributeType())) .filter(attr -> isRenderedAttr(thisArtType, attr.getAttributeType()))
.collect(Collectors.toMap(attr -> attr.getAttributeType(), attr -> getAttrValue(artType, attr), (attr1, attr2) -> attr1, LinkedHashMap::new)); .collect(Collectors.toMap(attr -> attr.getAttributeType(), attr -> getAttrValue(thisArtType, attr), (attr1, attr2) -> attr1, LinkedHashMap::new));
artifactAttributes.put(art.getId(), attrs); artifactAttributes.put(art.getId(), attrs);
} }
@ -205,7 +206,8 @@ abstract class BlackboardArtifactDAO extends AbstractDAO {
cellValues.add(dataSourceName); cellValues.add(dataSourceName);
AbstractFile linkedFile = null; AbstractFile linkedFile = null;
if (artType.getCategory().equals(BlackboardArtifact.Category.DATA_ARTIFACT)) { BlackboardArtifact.Type thisArtType = artType != null ? artType : artifact.getType();
if (thisArtType.getCategory().equals(BlackboardArtifact.Category.DATA_ARTIFACT)) {
// Note that we need to get the attribute from the original artifact since it is not displayed. // Note that we need to get the attribute from the original artifact since it is not displayed.
if (artifact.getAttribute(BlackboardAttribute.Type.TSK_PATH_ID) != null) { if (artifact.getAttribute(BlackboardAttribute.Type.TSK_PATH_ID) != null) {
long linkedId = artifact.getAttribute(BlackboardAttribute.Type.TSK_PATH_ID).getValueLong(); long linkedId = artifact.getAttribute(BlackboardAttribute.Type.TSK_PATH_ID).getValueLong();
@ -469,7 +471,7 @@ abstract class BlackboardArtifactDAO extends AbstractDAO {
return pagedArtsStream.collect(Collectors.toList()); return pagedArtsStream.collect(Collectors.toList());
} }
class TableData { static class TableData {
final List<ColumnKey> columnKeys; final List<ColumnKey> columnKeys;
final List<RowDTO> rows; final List<RowDTO> rows;

View File

@ -51,6 +51,7 @@ import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION; import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION_UNITS; import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_DURATION_UNITS;
import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_SIZE; import static org.sleuthkit.autopsy.mainui.datamodel.AbstractDAO.CACHE_SIZE;
import org.sleuthkit.autopsy.mainui.datamodel.BlackboardArtifactDAO.TableData;
import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO.TreeDisplayCount; import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO.TreeDisplayCount;
import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO.TreeItemDTO; import org.sleuthkit.autopsy.mainui.datamodel.TreeResultsDTO.TreeItemDTO;
import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEventUtils; import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEventUtils;
@ -232,13 +233,13 @@ public class ScoreDAO extends AbstractDAO {
String countQuery = " COUNT(art_files.obj_id) AS count\n" + baseQuery; String countQuery = " COUNT(art_files.obj_id) AS count\n" + baseQuery;
AtomicLong count = new AtomicLong(0); AtomicLong totalCountRef = new AtomicLong(0);
AtomicReference<SQLException> countException = new AtomicReference<>(null); AtomicReference<SQLException> countException = new AtomicReference<>(null);
getCase().getCaseDbAccessManager() getCase().getCaseDbAccessManager()
.select(countQuery, (rs) -> { .select(countQuery, (rs) -> {
try { try {
if (rs.next()) { if (rs.next()) {
count.set(rs.getLong("count")); totalCountRef.set(rs.getLong("count"));
} }
} catch (SQLException ex) { } catch (SQLException ex) {
countException.set(ex); countException.set(ex);
@ -295,20 +296,20 @@ public class ScoreDAO extends AbstractDAO {
List<AbstractFile> files = getCase().findAllFilesWhere("obj_id IN (" + joinedFileIds + ")"); List<AbstractFile> files = getCase().findAllFilesWhere("obj_id IN (" + joinedFileIds + ")");
// for (AbstractFile file : files) { for (AbstractFile file : files) {
//
// List<Object> cellValues = FileSystemColumnUtils.getCellValuesForAbstractFile(file); List<Object> cellValues = FileSystemColumnUtils.getCellValuesForAbstractFile(file);
//
// dataRows.add(new FileRowDTO( dataRows.add(new FileRowDTO(
// file, file,
// file.getId(), file.getId(),
// file.getName(), file.getName(),
// file.getNameExtension(), file.getNameExtension(),
// MediaTypeUtils.getExtensionMediaType(file.getNameExtension()), MediaTypeUtils.getExtensionMediaType(file.getNameExtension()),
// file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.ALLOC), file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.ALLOC),
// file.getType(), file.getType(),
// cellValues)); cellValues));
// } }
} }
if (!artifactIds.isEmpty()) { if (!artifactIds.isEmpty()) {
@ -317,14 +318,18 @@ public class ScoreDAO extends AbstractDAO {
.collect(Collectors.joining(", ")); .collect(Collectors.joining(", "));
List<DataArtifact> dataArtifacts = getCase().getBlackboard().getDataArtifactsWhere("obj_id IN (" + joinedArtifactIds + ")"); List<DataArtifact> dataArtifacts = getCase().getBlackboard().getDataArtifactsWhere("obj_id IN (" + joinedArtifactIds + ")");
// for (DataArtifact dataArt: dataArtifacts) { TableData artTableData = MainDAO.getInstance().getDataArtifactsDAO().createTableData(null, dataArtifacts);
// MainDAO.getInstance().getDataArtifactsDAO().create dataRows.addAll(artTableData.rows);
// dataRows.add(new DataArtifactRowDTO(dataArt, srcContent, linkedFile, isTimelineSupported, cellValues, id));
// }
} }
// //
return new BaseSearchResultsDTO(FILE_VIEW_EXT_TYPE_ID, displayName, FileSystemColumnUtils.getColumnKeysForAbstractfile(), fileRows, AbstractFile.class.getName(), startItem, totalResultsCount); return new BaseSearchResultsDTO(
SCORE_TYPE_ID,
SCORE_DISPLAY_NAME,
SCORE_COLUMNS,
dataRows,
signature,
startItem,
totalCountRef.get());
} }
private TreeItemDTO<?> createTreeItem(DAOEvent daoEvent, TreeDisplayCount count) { private TreeItemDTO<?> createTreeItem(DAOEvent daoEvent, TreeDisplayCount count) {

View File

@ -50,6 +50,7 @@ import org.sleuthkit.autopsy.mainui.datamodel.events.DAOAggregateEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.DAOEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.HostPersonEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.HostPersonEvent;
import org.sleuthkit.autopsy.mainui.datamodel.events.TreeEvent; import org.sleuthkit.autopsy.mainui.datamodel.events.TreeEvent;
import org.sleuthkit.autopsy.mainui.nodes.ScoreTypeFactory.ScoreParentNode;
import org.sleuthkit.autopsy.mainui.nodes.TreeNode.StaticTreeNode; import org.sleuthkit.autopsy.mainui.nodes.TreeNode.StaticTreeNode;
import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Host;
@ -194,6 +195,7 @@ public class RootFactory {
new AnalysisResultsRootNode(null), new AnalysisResultsRootNode(null),
new OsAccountsRootNode(null), new OsAccountsRootNode(null),
new TagsRootNode(null), new TagsRootNode(null),
new ReportsRootNode() new ReportsRootNode()
)); ));
} }
@ -505,6 +507,7 @@ public class RootFactory {
new DataArtifactsRootNode(dataSourceObjId), new DataArtifactsRootNode(dataSourceObjId),
new AnalysisResultsRootNode(dataSourceObjId), new AnalysisResultsRootNode(dataSourceObjId),
new OsAccountsRootNode(dataSourceObjId), new OsAccountsRootNode(dataSourceObjId),
new ScoreParentNode(dataSourceObjId),
new TagsRootNode(dataSourceObjId) new TagsRootNode(dataSourceObjId)
)); ));
} }
@ -722,38 +725,6 @@ public class RootFactory {
} }
} }
/**
* Root node for displaying "Score" for file types.
*/
@Messages({"RootFactory_ScoresRootNode_displayName=Score"})
public static class ScoresRootNode extends StaticTreeNode {
private static final String NAME_PREFIX = "VIEWS";
/**
* Returns the name prefix of this node.
*
* @return The name prefix.
*/
public static final String getNamePrefix() {
return NAME_PREFIX;
}
/**
* Main constructor.
*
* @param dataSourceObjId The data source object id or null for no
* filter.
*/
public ScoresRootNode(Long dataSourceObjId) {
super(NAME_PREFIX + "_" + getLongString(dataSourceObjId),
Bundle.RootFactory_ScoresRootNode_displayName(),
"org/sleuthkit/autopsy/images/red-circle-exclamation.png",
new ScoreTypeFactory.ScoreChildren(dataSourceObjId));
}
}
/** /**
* Root node for reports in the tree. * Root node for reports in the tree.
*/ */

View File

@ -54,10 +54,10 @@ public class ScoreTypeFactory {
} }
/** /**
* Parent of file size nodes in the tree. * Parent of score nodes in the tree.
*/ */
@Messages({"ScoreTypeFactory_ScoreParentNode_displayName=Score"}) @Messages({"ScoreTypeFactory_ScoreParentNode_displayName=Score"})
static class ScoreParentNode extends StaticTreeNode { public static class ScoreParentNode extends StaticTreeNode {
ScoreParentNode(Long dataSourceId) { ScoreParentNode(Long dataSourceId) {
super( super(