Merdge in wills fixes

This commit is contained in:
Kelly Kelly 2021-05-14 13:37:56 -04:00
commit a0a2f18f7f
8 changed files with 803 additions and 555 deletions

View File

@ -29,6 +29,7 @@ import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.InvalidPathException; import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -1214,9 +1215,7 @@ public class Case {
/** /**
* Update the GUI to to reflect the current case. * Update the GUI to to reflect the current case.
*/ */
private static void updateGUIForCaseOpened(Case newCurrentCase) { private static void updateGUIForCaseOpened(Case newCurrentCase) {
if (RuntimeProperties.runningWithGUI()) {
SwingUtilities.invokeLater(() -> {
/* /*
* If the case database was upgraded for a new schema and a * If the case database was upgraded for a new schema and a
* backup database was created, notify the user. * backup database was created, notify the user.
@ -1242,17 +1241,31 @@ public class Case {
String path = entry.getValue(); String path = entry.getValue();
boolean fileExists = (new File(path).isFile() || DriveUtils.driveExists(path)); boolean fileExists = (new File(path).isFile() || DriveUtils.driveExists(path));
if (!fileExists) { if (!fileExists) {
int response = JOptionPane.showConfirmDialog( try {
mainFrame, // Using invokeAndWait means that the dialog will
NbBundle.getMessage(Case.class, "Case.checkImgExist.confDlg.doesntExist.msg", path), // open on the EDT but this thread will wait for an
NbBundle.getMessage(Case.class, "Case.checkImgExist.confDlg.doesntExist.title"), // answer. Using invokeLater would cause this loop to
JOptionPane.YES_NO_OPTION); // end before all of the dialogs appeared.
if (response == JOptionPane.YES_OPTION) { SwingUtilities.invokeAndWait(new Runnable() {
MissingImageDialog.makeDialog(obj_id, caseDb); @Override
} else { public void run() {
logger.log(Level.SEVERE, "User proceeding with missing image files"); //NON-NLS int response = JOptionPane.showConfirmDialog(
mainFrame,
NbBundle.getMessage(Case.class, "Case.checkImgExist.confDlg.doesntExist.msg", path),
NbBundle.getMessage(Case.class, "Case.checkImgExist.confDlg.doesntExist.title"),
JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
MissingImageDialog.makeDialog(obj_id, caseDb);
} else {
logger.log(Level.SEVERE, "User proceeding with missing image files"); //NON-NLS
} }
}
});
} catch (InterruptedException | InvocationTargetException ex) {
logger.log(Level.SEVERE, "Failed to show missing image confirmation dialog", ex); //NON-NLS
}
} }
} }
@ -1270,14 +1283,16 @@ public class Case {
CallableSystemAction.get(CommonAttributeSearchAction.class).setEnabled(true); CallableSystemAction.get(CommonAttributeSearchAction.class).setEnabled(true);
CallableSystemAction.get(OpenOutputFolderAction.class).setEnabled(false); CallableSystemAction.get(OpenOutputFolderAction.class).setEnabled(false);
CallableSystemAction.get(OpenDiscoveryAction.class).setEnabled(true); CallableSystemAction.get(OpenDiscoveryAction.class).setEnabled(true);
/* /*
* Add the case to the recent cases tracker that supplies a list * Add the case to the recent cases tracker that supplies a list
* of recent cases to the recent cases menu item and the * of recent cases to the recent cases menu item and the
* open/create case dialog. * open/create case dialog.
*/ */
RecentCases.getInstance().addRecentCase(newCurrentCase.getDisplayName(), newCurrentCase.getMetadata().getFilePath().toString()); RecentCases.getInstance().addRecentCase(newCurrentCase.getDisplayName(), newCurrentCase.getMetadata().getFilePath().toString());
final boolean hasData = newCurrentCase.hasData();
SwingUtilities.invokeLater(() -> {
/* /*
* Open the top components (windows within the main application * Open the top components (windows within the main application
* window). * window).
@ -1286,7 +1301,7 @@ public class Case {
* opened via the DirectoryTreeTopComponent 'propertyChange()' * opened via the DirectoryTreeTopComponent 'propertyChange()'
* method on a DATA_SOURCE_ADDED event. * method on a DATA_SOURCE_ADDED event.
*/ */
if (newCurrentCase.hasData()) { if (hasData) {
CoreComponentControl.openCoreWindows(); CoreComponentControl.openCoreWindows();
} else { } else {
//ensure that the DirectoryTreeTopComponent is open so that it's listener can open the core windows including making it visible. //ensure that the DirectoryTreeTopComponent is open so that it's listener can open the core windows including making it visible.
@ -1300,7 +1315,6 @@ public class Case {
*/ */
mainFrame.setTitle(newCurrentCase.getDisplayName() + " - " + getNameForTitle()); mainFrame.setTitle(newCurrentCase.getDisplayName() + " - " + getNameForTitle());
}); });
}
} }
/* /*

View File

@ -97,12 +97,13 @@ class OtherOccurrenceOneTypeWorker extends SwingWorker<OneTypeData, Void> {
// - the data source device ID is different // - the data source device ID is different
// - the file path is different // - the file path is different
if (artifactInstance.getCorrelationCase().getCaseUUID().equals(caseUUID) if (artifactInstance.getCorrelationCase().getCaseUUID().equals(caseUUID)
|| (!StringUtils.isBlank(dataSourceName) && artifactInstance.getCorrelationDataSource().getName().equals(dataSourceName)) && (!StringUtils.isBlank(dataSourceName) && artifactInstance.getCorrelationDataSource().getName().equals(dataSourceName))
|| (!StringUtils.isBlank(deviceId) && artifactInstance.getCorrelationDataSource().getDeviceID().equals(deviceId)) && (!StringUtils.isBlank(deviceId) && artifactInstance.getCorrelationDataSource().getDeviceID().equals(deviceId))
|| (file != null && artifactInstance.getFilePath().equalsIgnoreCase(file.getParentPath() + file.getName()))) { && (file != null && artifactInstance.getFilePath().equalsIgnoreCase(file.getParentPath() + file.getName()))) {
correlationAttributesToAdd.add(artifactInstance);
continue; continue;
} }
correlationAttributesToAdd.add(artifactInstance);
OtherOccurrenceNodeInstanceData newNode = new OtherOccurrenceNodeInstanceData(artifactInstance, aType, value); OtherOccurrenceNodeInstanceData newNode = new OtherOccurrenceNodeInstanceData(artifactInstance, aType, value);
UniquePathKey uniquePathKey = new UniquePathKey(newNode); UniquePathKey uniquePathKey = new UniquePathKey(newNode);
nodeDataMap.put(uniquePathKey, newNode); nodeDataMap.put(uniquePathKey, newNode);

View File

@ -122,7 +122,7 @@ public final class OtherOccurrencesPanel extends javax.swing.JPanel {
exportToCSVMenuItem.addActionListener(actList); exportToCSVMenuItem.addActionListener(actList);
showCaseDetailsMenuItem.addActionListener(actList); showCaseDetailsMenuItem.addActionListener(actList);
showCommonalityMenuItem.addActionListener(actList); showCommonalityMenuItem.addActionListener(actList);
filesTable.setComponentPopupMenu(rightClickPopupMenu);
// Configure column sorting. // Configure column sorting.
TableRowSorter<TableModel> sorter = new TableRowSorter<>(filesTable.getModel()); TableRowSorter<TableModel> sorter = new TableRowSorter<>(filesTable.getModel());
filesTable.setRowSorter(sorter); filesTable.setRowSorter(sorter);

View File

@ -389,8 +389,8 @@ public final class FileTypes implements AutopsyVisitableItem {
} }
@Override @Override
public DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection<BlackboardAttribute> attributesList, OsAccount osAccount) throws TskCoreException { public DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection<BlackboardAttribute> attributesList, Long osAccountId) throws TskCoreException {
return content.newDataArtifact(artifactType, attributesList, osAccount); return content.newDataArtifact(artifactType, attributesList, osAccountId);
} }
@Override @Override

View File

@ -540,12 +540,7 @@ final class ChromeCacheExtractor {
webAttr.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID, webAttr.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID,
moduleName, cachedItemFile.getId())); moduleName, cachedItemFile.getId()));
Optional<Long> optional = cacheEntryFile.getOsAccountObjectId(); BlackboardArtifact webCacheArtifact = cacheEntryFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_WEB_CACHE), webAttr);
OsAccount account = null;
if(optional.isPresent()) {
account = currentCase.getSleuthkitCase().getOsAccountManager().getOsAccountByObjectId(optional.get());
}
BlackboardArtifact webCacheArtifact = cacheEntryFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_WEB_CACHE), webAttr, account);
artifactsAdded.add(webCacheArtifact); artifactsAdded.add(webCacheArtifact);
// Create a TSK_ASSOCIATED_OBJECT on the f_XXX or derived file file back to the CACHE entry // Create a TSK_ASSOCIATED_OBJECT on the f_XXX or derived file file back to the CACHE entry

View File

@ -159,9 +159,10 @@ abstract class Extract {
* @throws TskCoreException * @throws TskCoreException
*/ */
BlackboardArtifact createArtifactWithAttributes(BlackboardArtifact.Type type, Content content, Collection<BlackboardAttribute> attributes) throws TskCoreException { BlackboardArtifact createArtifactWithAttributes(BlackboardArtifact.Type type, Content content, Collection<BlackboardAttribute> attributes) throws TskCoreException {
Optional<OsAccount> optional = getOsAccount(content); if (type.getCategory() == BlackboardArtifact.Category.DATA_ARTIFACT) {
if (optional.isPresent() && type.getCategory() == BlackboardArtifact.Category.DATA_ARTIFACT) { return (content instanceof AbstractFile)
return content.newDataArtifact(type, attributes, optional.get()); ? ((AbstractFile) content).newDataArtifact(type, attributes)
: content.newDataArtifact(type, attributes, null);
} else { } else {
BlackboardArtifact bbart = content.newArtifact(type.getTypeID()); BlackboardArtifact bbart = content.newArtifact(type.getTypeID());
bbart.addAttributes(attributes); bbart.addAttributes(attributes);
@ -537,28 +538,4 @@ abstract class Extract {
return tempFile; return tempFile;
} }
/**
* Return the appropriate OsAccount for the given file.
*
* @param file
*
* @return An Optional OsACcount object.
*
* @throws TskCoreException
*/
Optional<OsAccount> getOsAccount(Content content) throws TskCoreException {
if(content instanceof AbstractFile) {
if(osAccountCache == null) {
Optional<Long> accountId = ((AbstractFile)content).getOsAccountObjectId();
if(accountId.isPresent()) {
return Optional.ofNullable(tskCase.getOsAccountManager().getOsAccountByObjectId(accountId.get()));
}
return Optional.empty();
}
return osAccountCache.getOsAccount(((AbstractFile)content));
}
return Optional.empty();
}
} }

View File

@ -742,7 +742,7 @@ class ExtractRegistry extends Extract {
} else { } else {
results.get(0).addAttributes(bbattributes); results.get(0).addAttributes(bbattributes);
} }
for (Map.Entry userMap : userNameMap.entrySet()) { for (Map.Entry userMap : getUserNameMap().entrySet()) {
String sid = ""; String sid = "";
try{ try{
sid = (String)userMap.getKey(); sid = (String)userMap.getKey();
@ -1116,17 +1116,6 @@ class ExtractRegistry extends Extract {
accountMgr.newOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.LAUNCHED); accountMgr.newOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.LAUNCHED);
updateOsAccount(osAccount, userInfo, groupMap.get(userInfo.get(SID_KEY)), regAbstractFile); updateOsAccount(osAccount, userInfo, groupMap.get(userInfo.get(SID_KEY)), regAbstractFile);
} }
// Get a mapping of user sids to user names and save globally so it can be used for other areas
// of the registry, ie: BAM key
try {
userNameMap = makeUserNameMap(dataSource);
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Unable to create OS Account user name map", ex);
// This is not the end of the world we will just continue without
// user names
userNameMap = new HashMap<>();
}
return true; return true;
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
logger.log(Level.WARNING, "Error finding the registry file.", ex); //NON-NLS logger.log(Level.WARNING, "Error finding the registry file.", ex); //NON-NLS
@ -1261,7 +1250,7 @@ class ExtractRegistry extends Extract {
// We can add the S- back to the string that we split on since S- is a valid beginning of a User SID // We can add the S- back to the string that we split on since S- is a valid beginning of a User SID
String fileNameSid[] = tokens[4].split("\\s+\\(S-"); String fileNameSid[] = tokens[4].split("\\s+\\(S-");
String userSid = "S-" + fileNameSid[1].substring(0, fileNameSid[1].length() - 1); String userSid = "S-" + fileNameSid[1].substring(0, fileNameSid[1].length() - 1);
String userName = userNameMap.get(userSid); String userName = getUserNameMap().get(userSid);
if (userName == null) { if (userName == null) {
userName = userSid; userName = userSid;
} }
@ -1738,6 +1727,28 @@ class ExtractRegistry extends Extract {
return map; return map;
} }
/**
* Returns a mapping of user sids to user names.
*
* @return username man or empty list if none where found.
*/
private Map<String, String> getUserNameMap() {
if(userNameMap == null) {
// Get a mapping of user sids to user names and save globally so it can be used for other areas
// of the registry, ie: BAM key
try {
userNameMap = makeUserNameMap(dataSource);
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Unable to create OS Account user name map", ex);
// This is not the end of the world we will just continue without
// user names
userNameMap = new HashMap<>();
}
}
return userNameMap;
}
/** /**
* Gets the attribute for the given type from the given artifact. * Gets the attribute for the given type from the given artifact.

File diff suppressed because it is too large Load Diff