Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sleuthkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Sleuthkit
Commits
ee2ea70d
Commit
ee2ea70d
authored
4 years ago
by
apriestman
Browse files
Options
Downloads
Patches
Plain Diff
Cache the image the DSP opened
parent
f1589851
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+52
-2
52 additions, 2 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
with
52 additions
and
2 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+
52
−
2
View file @
ee2ea70d
...
...
@@ -35,6 +35,7 @@
import
java.util.UUID
;
import
java.util.concurrent.locks.ReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
java.util.logging.Level
;
import
org.apache.commons.lang3.StringUtils
;
import
org.sleuthkit.datamodel.TskData.TSK_FS_ATTR_TYPE_ENUM
;
import
org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction
;
...
...
@@ -855,7 +856,6 @@ public static long openImage(String[] imageFiles, int sSize, SleuthkitCase skCas
* TSK
*/
private
static
long
openImage
(
String
[]
imageFiles
,
int
sSize
,
boolean
useCache
,
String
caseIdentifer
)
throws
TskCoreException
{
getTSKReadLock
();
try
{
long
imageHandle
;
...
...
@@ -903,6 +903,55 @@ private static long openImage(String[] imageFiles, int sSize, boolean useCache,
}
}
/**
* This is a temporary measure to support opening an image at the beginning
* of the add image process. The open image handle is put into the normal image cache so
* it won't be opened a second time and it will be closed during case closing.
*
* This will change when all image opens are done by object ID and not paths.
*
* @param skCase The case the image belongs to.
* @param imagePaths The complete list of paths for the image.
* @param imageHandle The open image handle from TSK.
*/
private
static
void
cacheImageHandle
(
SleuthkitCase
skCase
,
List
<
String
>
imagePaths
,
long
imageHandle
)
{
// Construct the hash key from the image paths
StringBuilder
keyBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
imagePaths
.
size
();
++
i
)
{
keyBuilder
.
append
(
imagePaths
.
get
(
i
));
}
final
String
imageKey
=
keyBuilder
.
toString
();
// Get the case identifier
try
{
String
caseIdentifier
=
skCase
.
getUniqueCaseIdentifier
();
synchronized
(
HandleCache
.
cacheLock
)
{
HandleCache
.
getCaseHandles
(
caseIdentifier
).
fsHandleCache
.
put
(
imageHandle
,
new
HashMap
<>());
HandleCache
.
getCaseHandles
(
caseIdentifier
).
imageHandleCache
.
put
(
imageKey
,
imageHandle
);
}
}
catch
(
TskCoreException
ex
)
{
// getUniqueCaseIdentfier() will only fail if the case is closed
}
}
/**
* Add an image to the database and return the open image.
*
* @param skCase The current case.
* @param imagePaths The path(s) to the image (will just be the first for .e01, .001, etc).
* @param sectorSize The sector size (0 for auto-detect).
* @param timeZone The time zone.
* @param md5 MD5 hash (if known).
* @param sha1 SHA1 hash (if known).
* @param sha256 SHA256 hash (if known).
* @param deviceId Device ID.
*
* @return The Image object.
*
* @throws TskCoreException
*/
public
static
Image
addImageToDatabase
(
SleuthkitCase
skCase
,
String
[]
imagePaths
,
int
sectorSize
,
String
timeZone
,
String
md5
,
String
sha1
,
String
sha256
,
String
deviceId
)
throws
TskCoreException
{
...
...
@@ -939,7 +988,8 @@ public static Image addImageToDatabase(SleuthkitCase skCase, String[] imagePaths
}
transaction
.
commit
();
img
.
setImageHandle
(
imageHandle
);
// TODO cache this so we can close it
img
.
setImageHandle
(
imageHandle
);
cacheImageHandle
(
skCase
,
computedPaths
,
imageHandle
);
return
img
;
}
catch
(
TskCoreException
ex
)
{
transaction
.
rollback
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment