Skip to content

Commit

Permalink
Merge pull request sleuthkit#6954 from gdicristofaro/7576-useOsAccountId
Browse files Browse the repository at this point in the history
7576 use os account
  • Loading branch information
rcordovano authored May 7, 2021
2 parents 740390a + dbc0fba commit 2f3393f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Core/src/org/sleuthkit/autopsy/datamodel/FileTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ public BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type) thr
}

@Override
public DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection<BlackboardAttribute> attributesList, OsAccount osAccount) throws TskCoreException {
return content.newDataArtifact(artifactType, attributesList, osAccount);
public DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection<BlackboardAttribute> attributesList, Long osAccountId) throws TskCoreException {
return content.newDataArtifact(artifactType, attributesList, osAccountId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,7 @@ private void addArtifacts(CacheEntry cacheEntry, AbstractFile cacheEntryFile, Ab
webAttr.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID,
moduleName, cachedItemFile.getId()));

Optional<Long> optional = cacheEntryFile.getOsAccountObjectId();
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);
BlackboardArtifact webCacheArtifact = cacheEntryFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_WEB_CACHE), webAttr);
artifactsAdded.add(webCacheArtifact);

// Create a TSK_ASSOCIATED_OBJECT on the f_XXX or derived file file back to the CACHE entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ BlackboardArtifact createArtifactWithAttributes(BlackboardArtifact.ARTIFACT_TYPE
* @throws TskCoreException
*/
BlackboardArtifact createArtifactWithAttributes(BlackboardArtifact.Type type, Content content, Collection<BlackboardAttribute> attributes) throws TskCoreException {
Optional<OsAccount> optional = getOsAccount(content);
if (optional.isPresent() && type.getCategory() == BlackboardArtifact.Category.DATA_ARTIFACT) {
return content.newDataArtifact(type, attributes, optional.get());
if (type.getCategory() == BlackboardArtifact.Category.DATA_ARTIFACT) {
return (content instanceof AbstractFile)
? ((AbstractFile) content).newDataArtifact(type, attributes)
: content.newDataArtifact(type, attributes, null);
} else {
BlackboardArtifact bbart = content.newArtifact(type.getTypeID());
bbart.addAttributes(attributes);
Expand Down Expand Up @@ -537,28 +538,4 @@ protected File createTemporaryFile(IngestJobContext context, AbstractFile file,

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();
}
}

0 comments on commit 2f3393f

Please sign in to comment.