Fixed content panel and osAccount

This commit is contained in:
Kelly Kelly 2021-03-25 17:40:05 -04:00
parent 333d7247f5
commit bef9e117e2
5 changed files with 66 additions and 24 deletions

View File

@ -82,6 +82,24 @@ public class OsAccountDataPanel extends JPanel {
* @param account OsAccount to display, if null is passed the panel will * @param account OsAccount to display, if null is passed the panel will
* appear blank. * appear blank.
*/ */
// void setOsAccount(OsAccount account) {
void setOsAccountId(Long osAccountId) {
removeAll();
revalidate();
if (osAccountId != null) {
setLayout(new BorderLayout());
add(new JLabel("Loading OsAccount Data..."), BorderLayout.NORTH);
if (dataFetcher != null && !dataFetcher.isDone()) {
dataFetcher.cancel(true);
}
dataFetcher = new PanelDataFetcher(osAccountId);
dataFetcher.execute();
}
}
void setOsAccount(OsAccount account) { void setOsAccount(OsAccount account) {
removeAll(); removeAll();
revalidate(); revalidate();
@ -319,15 +337,22 @@ public class OsAccountDataPanel extends JPanel {
*/ */
private class PanelDataFetcher extends SwingWorker<WorkerResults, Void> { private class PanelDataFetcher extends SwingWorker<WorkerResults, Void> {
private final OsAccount account; private final Long accountId;
private OsAccount account;
/** /**
* Construct a new worker for the given account. * Construct a new worker for the given account.
* *
* @param account * @param account
*/ */
PanelDataFetcher(Long accountId) {
this.accountId = accountId;
this.account = null;
}
PanelDataFetcher(OsAccount account) { PanelDataFetcher(OsAccount account) {
this.account = account; this.account = account;
this.accountId = null;
} }
@Override @Override
@ -335,6 +360,11 @@ public class OsAccountDataPanel extends JPanel {
Map<Host, List<OsAccountAttribute>> hostMap = new HashMap<>(); Map<Host, List<OsAccountAttribute>> hostMap = new HashMap<>();
Map<Host, DataSource> instanceMap = new HashMap<>(); Map<Host, DataSource> instanceMap = new HashMap<>();
OsAccountManager osAccountManager = Case.getCurrentCase().getSleuthkitCase().getOsAccountManager(); OsAccountManager osAccountManager = Case.getCurrentCase().getSleuthkitCase().getOsAccountManager();
if(account == null) {
account = osAccountManager.getOsAccount(accountId);
}
List<Host> hosts = osAccountManager.getHosts(account); List<Host> hosts = osAccountManager.getHosts(account);
List<OsAccountAttribute> attributeList = account.getOsAccountAttributes(); List<OsAccountAttribute> attributeList = account.getOsAccountAttributes();

View File

@ -53,26 +53,29 @@ public class OsAccountViewer extends javax.swing.JPanel implements DataContentVi
@Override @Override
public void setNode(Node node) { public void setNode(Node node) {
OsAccount osAccount = null; Long osAccountId = null;
try { try {
osAccount = node.getLookup().lookup(OsAccount.class); OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
if (osAccount == null) { if (osAccount != null) {
Optional<OsAccount> optional; dataPanel.setOsAccount(osAccount);
AbstractFile file = node.getLookup().lookup(AbstractFile.class); return;
if (file != null) { }
optional = file.getOsAccount();
if (optional.isPresent()) { Optional<Long> optional;
osAccount = optional.get(); AbstractFile file = node.getLookup().lookup(AbstractFile.class);
} if (file != null) {
optional = file.getOsAccountObjectId();
if (optional.isPresent()) {
osAccountId = optional.get();
} }
} }
if (osAccount == null) { if (osAccountId == null) {
DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class); DataArtifact dataArtifact = node.getLookup().lookup(DataArtifact.class);
if (dataArtifact != null) { if (dataArtifact != null) {
Optional<OsAccount> optional = dataArtifact.getOsAccount(); optional = dataArtifact.getOsAccountObjectId();
if (optional.isPresent()) { if (optional.isPresent()) {
osAccount = optional.get(); osAccountId = optional.get();
} }
} }
@ -81,8 +84,8 @@ public class OsAccountViewer extends javax.swing.JPanel implements DataContentVi
logger.log(Level.SEVERE, String.format("Failed to get OsAccount for node %s", node.getDisplayName()), ex); logger.log(Level.SEVERE, String.format("Failed to get OsAccount for node %s", node.getDisplayName()), ex);
} }
if (osAccount != null) { if (osAccountId != null) {
dataPanel.setOsAccount(osAccount); dataPanel.setOsAccountId(osAccountId);
} }
} }
@ -125,8 +128,8 @@ public class OsAccountViewer extends javax.swing.JPanel implements DataContentVi
try { try {
return osAccount != null return osAccount != null
|| (file != null && file.getOsAccount().isPresent()) || (file != null && file.getOsAccountObjectId().isPresent())
|| (dataArtifact != null && dataArtifact.getOsAccount().isPresent()); || (dataArtifact != null && dataArtifact.getOsAccountObjectId().isPresent());
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Failed to determine if node %s is Supported for OsAccountViewer", node.getDisplayName()), ex); logger.log(Level.SEVERE, String.format("Failed to determine if node %s is Supported for OsAccountViewer", node.getDisplayName()), ex);
return false; return false;

View File

@ -538,8 +538,12 @@ 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<OsAccount> optional = cacheEntryFile.getOsAccount(); Optional<Long> optional = cacheEntryFile.getOsAccountObjectId();
BlackboardArtifact webCacheArtifact = cacheEntryFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_WEB_CACHE), webAttr, optional.isPresent() ? optional.get() : null); OsAccount account = null;
if(optional.isPresent()) {
account = currentCase.getSleuthkitCase().getOsAccountManager().getOsAccount(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

@ -533,7 +533,11 @@ abstract class Extract {
Optional<OsAccount> getOsAccount(Content content) throws TskCoreException { Optional<OsAccount> getOsAccount(Content content) throws TskCoreException {
if(content instanceof AbstractFile) { if(content instanceof AbstractFile) {
if(osAccountCache == null) { if(osAccountCache == null) {
return ((AbstractFile)content).getOsAccount(); Optional<Long> accountId = ((AbstractFile)content).getOsAccountObjectId();
if(accountId.isPresent()) {
return Optional.ofNullable(tskCase.getOsAccountManager().getOsAccount(accountId.get()));
}
return Optional.empty();
} }
return osAccountCache.getOsAccount(((AbstractFile)content)); return osAccountCache.getOsAccount(((AbstractFile)content));

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Host;
@ -71,18 +72,18 @@ final class RAOsAccountCache {
* @throws TskCoreException * @throws TskCoreException
*/ */
Optional<OsAccount> getOsAccount(AbstractFile file) throws TskCoreException { Optional<OsAccount> getOsAccount(AbstractFile file) throws TskCoreException {
Optional<OsAccount> optional = file.getOsAccount(); Optional<Long> optional = file.getOsAccountObjectId();
if (!optional.isPresent()) { if (!optional.isPresent()) {
return getAccountForPath(file.getParentPath()); return getAccountForPath(file.getParentPath());
} }
OsAccount osAccount = optional.get(); OsAccount osAccount = Case.getCurrentCase().getSleuthkitCase().getOsAccountManager().getOsAccount(optional.get());
if (osAccount.getName().equals("S-1-5-32-544")) { if (osAccount.getName().equals("S-1-5-32-544")) {
return getAccountForPath(file.getParentPath()); return getAccountForPath(file.getParentPath());
} }
return optional; return Optional.ofNullable(osAccount);
} }
/** /**