updates to score dao

This commit is contained in:
Greg DiCristofaro 2023-07-05 13:43:32 -04:00
parent 1333001b94
commit dab72e280c

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2021 Basis Technology Corp. * Copyright 2023 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -42,6 +42,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent;
@ -66,17 +67,31 @@ import org.sleuthkit.datamodel.Score.Priority;
import org.sleuthkit.datamodel.Score.Significance; import org.sleuthkit.datamodel.Score.Significance;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData;
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM; import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
/** /**
* Provides information to populate the results viewer for data in the views * Provides information to populate the results viewer for data in the views
* section. * section.
*/ */
@Messages({
"ScoreDAO_columns_sourceLbl=Source",
"ScoreDAO_columns_typeLbl=Type",
"ScoreDAO_columns_pathLbl=Path",
"ScoreDAO_columns_createdDateLbl=Created Date",
"ScoreDAO_columns_noDescription=No Description",
"ScoreDAO_types_filelbl=File"
})
public class ScoreDAO extends AbstractDAO { public class ScoreDAO extends AbstractDAO {
private static final Logger logger = Logger.getLogger(ScoreDAO.class.getName()); private static final Logger logger = Logger.getLogger(ScoreDAO.class.getName());
private static final List<ColumnKey> RESULT_SCORE_COLUMNS = Arrays.asList(
getFileColumnKey(Bundle.ScoreDAO_columns_sourceLbl()),
getFileColumnKey(Bundle.ScoreDAO_columns_typeLbl()),
getFileColumnKey(Bundle.ScoreDAO_columns_pathLbl()),
getFileColumnKey(Bundle.ScoreDAO_columns_createdDateLbl())
);
private static ScoreDAO instance = null; private static ScoreDAO instance = null;
synchronized static ScoreDAO getInstance() { synchronized static ScoreDAO getInstance() {
@ -91,6 +106,10 @@ public class ScoreDAO extends AbstractDAO {
= CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build(); = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build();
private final TreeCounts<DAOEvent> treeCounts = new TreeCounts<>(); private final TreeCounts<DAOEvent> treeCounts = new TreeCounts<>();
private static ColumnKey getFileColumnKey(String name) {
return new ColumnKey(name, name, Bundle.ScoreDAO_columns_noDescription());
}
private SleuthkitCase getCase() throws NoCurrentCaseException { private SleuthkitCase getCase() throws NoCurrentCaseException {
return Case.getCurrentCaseThrows().getSleuthkitCase(); return Case.getCurrentCaseThrows().getSleuthkitCase();
} }
@ -297,9 +316,6 @@ 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);
dataRows.add(new FileRowDTO( dataRows.add(new FileRowDTO(
file, file,
file.getId(), file.getId(),
@ -308,7 +324,12 @@ public class ScoreDAO extends AbstractDAO {
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)); Arrays.asList(
file.getName(), // source
Bundle.ScoreDAO_types_filelbl(),
file.getParentPath(),
file.getCrtime()
)));
} }
} }
@ -321,11 +342,12 @@ public class ScoreDAO extends AbstractDAO {
TableData artTableData = MainDAO.getInstance().getDataArtifactsDAO().createTableData(null, dataArtifacts); TableData artTableData = MainDAO.getInstance().getDataArtifactsDAO().createTableData(null, dataArtifacts);
dataRows.addAll(artTableData.rows); dataRows.addAll(artTableData.rows);
} }
// //
return new BaseSearchResultsDTO( return new BaseSearchResultsDTO(
SCORE_TYPE_ID, SCORE_TYPE_ID,
SCORE_DISPLAY_NAME, SCORE_DISPLAY_NAME,
SCORE_COLUMNS, RESULT_SCORE_COLUMNS,
dataRows, dataRows,
signature, signature,
startItem, startItem,