diff --git a/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java b/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java index 8daf6c2266a7032e01934d1dbdbc836668889a39..3c3e1ef910d9fb77d8b29282f15ffe5ca8498a61 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java @@ -86,6 +86,7 @@ public abstract class AbstractFile extends AbstractContent { private boolean sha256HashDirty = false; private String mimeType; private boolean mimeTypeDirty = false; + protected TskData.FileLocation location; private static final Logger LOGGER = Logger.getLogger(AbstractFile.class.getName()); private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle"); private long dataSourceObjectId; @@ -124,6 +125,7 @@ public abstract class AbstractFile extends AbstractContent { * @param knownState knownState status of the file, or null if * unknown (default) * @param parentPath + * @param location * @param mimeType The MIME type of the file, can be null. * @param extension The extension part of the file name (not * including the '.'), can be null. @@ -143,6 +145,7 @@ public abstract class AbstractFile extends AbstractContent { int uid, int gid, String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, + TskData.FileLocation location, String mimeType, String extension) { super(db, objId, name); @@ -173,6 +176,7 @@ public abstract class AbstractFile extends AbstractContent { this.knownState = knownState; } this.parentPath = parentPath; + this.location = location; this.mimeType = mimeType; this.extension = extension == null ? "" : extension; this.encodingType = TskData.EncodingType.NONE; @@ -959,6 +963,15 @@ public String getLocalPath() { return localPath; } + /** + * Get the location of the file data + * + * @return file location + */ + public TskData.FileLocation getFileLocation() { + return location; + } + /** * Get local absolute path of the file, if localPath has been set * @@ -1087,6 +1100,7 @@ public String toString(boolean preserveState) { + "\t" + "parentPath " + parentPath + "\t" + "size " + size //NON-NLS + "\t" + "knownState " + knownState + "\t" + "md5Hash " + md5Hash + "\t" + "sha256Hash " + sha256Hash //NON-NLS + "\t" + "localPathSet " + localPathSet + "\t" + "localPath " + localPath //NON-NLS + + "\t" + "location " + location // NON-NLS + "\t" + "localAbsPath " + localAbsPath + "\t" + "localFile " + localFile //NON-NLS + "]\t"; } @@ -1222,7 +1236,7 @@ protected AbstractFile(SleuthkitCase db, long objId, TskData.TSK_FS_ATTR_TYPE_EN TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath) { - this(db, objId, db.getDataSourceObjectId(objId), attrType, (int) attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, null, null); + this(db, objId, db.getDataSourceObjectId(objId), attrType, (int) attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, null, null); } /** @@ -1267,7 +1281,7 @@ protected AbstractFile(SleuthkitCase db, long objId, TskData.TSK_FS_ATTR_TYPE_EN String name, TskData.TSK_DB_FILES_TYPE_ENUM fileType, long metaAddr, int metaSeq, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath, String mimeType) { - this(db, objId, dataSourceObjectId, attrType, (int) attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, null, null); + this(db, objId, dataSourceObjectId, attrType, (int) attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, null, null); } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java index eca9630950c463208eac5a2b6e5c4367ecebbc3f..4d7b38f01ed786a9c161b109162c44e5a6015bbf 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java @@ -204,7 +204,7 @@ private void createFileTables(Statement stmt) throws SQLException { + "crtime " + dbQueryHelper.getBigIntType() + ", atime " + dbQueryHelper.getBigIntType() + ", " + "mtime " + dbQueryHelper.getBigIntType() + ", mode INTEGER, uid INTEGER, gid INTEGER, md5 TEXT, sha256 TEXT, " + "known INTEGER, " - + "parent_path TEXT, mime_type TEXT, extension TEXT, " + + "parent_path TEXT, location INTEGER NOT NULL, mime_type TEXT, extension TEXT, " + "FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE, " + "FOREIGN KEY(fs_obj_id) REFERENCES tsk_fs_info(obj_id) ON DELETE CASCADE, " + "FOREIGN KEY(data_source_obj_id) REFERENCES data_source_info(obj_id) ON DELETE CASCADE)"); diff --git a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java index ef147fb10c980eb874594e42931342e0ba336dd2..346de5d11bfc94936835f7bf0614b4c3bbe871ab 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java @@ -76,6 +76,7 @@ public class DerivedFile extends AbstractFile { * @param parentPath The path of the parent of the file. * @param localPath The absolute path of the file in secondary * storage. + * @param location The location of the file. * @param parentId The object id of parent of the file. * @param mimeType The MIME type of the file, null if it has not * yet been determined. @@ -94,6 +95,7 @@ public class DerivedFile extends AbstractFile { String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, String localPath, + TskData.FileLocation location, long parentId, String mimeType, TskData.EncodingType encodingType, @@ -102,7 +104,7 @@ public class DerivedFile extends AbstractFile { // through the class hierarchy contructors. super(db, objId, dataSourceObjectId, TskData.TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, TSK_DB_FILES_TYPE_ENUM.LOCAL, 0L, 0, dirType, metaType, dirFlag, - metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension); + metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, extension); setLocalFilePath(localPath); setEncodingType(encodingType); } @@ -306,7 +308,7 @@ protected DerivedFile(SleuthkitCase db, this(db, objId, db.getDataSourceObjectId(objId), name, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, md5Hash, null, knownState, - parentPath, localPath, parentId, null, TskData.EncodingType.NONE, null); + parentPath, localPath, TskData.FileLocation.LOCAL, parentId, null, TskData.EncodingType.NONE, null); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/Directory.java b/bindings/java/src/org/sleuthkit/datamodel/Directory.java index 39b0c62188ef261354eedeb1596ba6f6f2fd0e6f..49e690cd1701ec2965200317773538c1c3dbf799 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Directory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Directory.java @@ -69,9 +69,12 @@ public class Directory extends FsContent { * @param gid The GID for the file. * @param md5Hash The MD5 hash of the file, null if not yet * calculated. + * @param sha256Hash The SHA-256 hash of the file, null if not yet + * calculated. * @param knownState The known state of the file from a hash * database lookup, null if not yet looked up. * @param parentPath The path of the parent of the file. + * @param location The location of the file. */ Directory(SleuthkitCase db, long objId, @@ -85,8 +88,8 @@ public class Directory extends FsContent { long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, - String md5Hash, String sha256Hash, FileKnown knownState, String parentPath) { - super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, null, null); + String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, TskData.FileLocation location) { + super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, location, null, null); } /** @@ -247,6 +250,6 @@ protected Directory(SleuthkitCase db, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath) { - this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath); + this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/File.java b/bindings/java/src/org/sleuthkit/datamodel/File.java index c6758c0ff88657acb513b55810acbc445b518df3..a0178482fb04a2eb17df9a20445a51daeb42d7fb 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/File.java +++ b/bindings/java/src/org/sleuthkit/datamodel/File.java @@ -72,6 +72,7 @@ public class File extends FsContent { * @param knownState The known state of the file from a hash * database lookup, null if not yet looked up. * @param parentPath The path of the parent of the file. + * @param location The location of the file data. * @param mimeType The MIME type of the file, null if it has not * yet been determined. * @param extension The extension part of the file name (not @@ -89,9 +90,9 @@ public class File extends FsContent { long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, - String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, String mimeType, + String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, TskData.FileLocation location, String mimeType, String extension) { - super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension); + super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, extension); } /** @@ -245,6 +246,6 @@ protected File(SleuthkitCase db, String name, long metaAddr, int metaSeq, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath, String mimeType) { - this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, mimeType, null); + this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, mimeType, null); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/FsContent.java b/bindings/java/src/org/sleuthkit/datamodel/FsContent.java index aa4bb739d06a0bad71b343ab9766c75f5f38511a..29f5158d1e29a9272d7cc0881d28f9eaf1e66fa9 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/FsContent.java +++ b/bindings/java/src/org/sleuthkit/datamodel/FsContent.java @@ -101,6 +101,7 @@ public abstract class FsContent extends AbstractFile { * @param knownState The known state of the file from a hash * database lookup, null if not yet looked up. * @param parentPath The path of the parent of the file. + * @param location The location of the file data. * @param mimeType The MIME type of the file, null if it has not * yet been determined. * @param extension The extension part of the file name (not @@ -122,9 +123,10 @@ public abstract class FsContent extends AbstractFile { short modes, int uid, int gid, String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, + TskData.FileLocation location, String mimeType, String extension) { - super(db, objId, dataSourceObjectId, attrType, attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension); + super(db, objId, dataSourceObjectId, attrType, attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, extension); this.fsObjId = fsObjId; } @@ -383,7 +385,7 @@ public String toString(boolean preserveState) { String name, long metaAddr, int metaSeq, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath) { - this(db, objId, db.getDataSourceObjectId(objId), fsObjId, attrType, (int) attrId, name, TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, null, null); + this(db, objId, db.getDataSourceObjectId(objId), fsObjId, attrType, (int) attrId, name, TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, null, null); } /** @@ -442,6 +444,6 @@ public String toString(boolean preserveState) { String name, long metaAddr, int metaSeq, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath, String mimeType) { - this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, mimeType, null); + this(db, objId, dataSourceObjectId, fsObjId, attrType, (int) attrId, name, TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, mimeType, null); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java b/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java index ab98c64e75a8ffc50219df350fbe2c63b2a539f6..9f8a0a8e4ed495fe9a12a7c565ec611e2df82a60 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java @@ -79,6 +79,7 @@ public class LayoutFile extends AbstractFile { * @param knownState The known state of the file from a hash * database lookup, null if not yet looked up. * @param parentPath The path of the parent of the file. + * @param location The location of the file. * @param mimeType The MIME type of the file, null if it has not * yet been determined. */ @@ -92,8 +93,8 @@ public class LayoutFile extends AbstractFile { long size, long ctime, long crtime, long atime, long mtime, String md5Hash, String sha256Hash, FileKnown knownState, - String parentPath, String mimeType) { - super(db, objId, dataSourceObjectId, TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, fileType, 0L, 0, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, mimeType, SleuthkitCase.extractExtension(name)); + String parentPath, TskData.FileLocation location, String mimeType) { + super(db, objId, dataSourceObjectId, TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, fileType, 0L, 0, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, SleuthkitCase.extractExtension(name)); } /** @@ -280,6 +281,6 @@ protected LayoutFile(SleuthkitCase db, long objId, String name, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, String md5Hash, FileKnown knownState, String parentPath) { - this(db, objId, db.getDataSourceObjectId(objId), name, fileType, dirType, metaType, dirFlag, metaFlags, size, 0L, 0L, 0L, 0L, md5Hash, null, knownState, parentPath, null); + this(db, objId, db.getDataSourceObjectId(objId), name, fileType, dirType, metaType, dirFlag, metaFlags, size, 0L, 0L, 0L, 0L, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL, null); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java b/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java index 8eafbefdbf6f4ea45cd4677d9107701fbf6ef4a3..92418608e1052f03025e213c35100d548947d726 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java @@ -55,6 +55,7 @@ public class LocalDirectory extends SpecialDirectory { * @param md5Hash The MD5 hash for the local directory. * @param knownState The known state for the local directory * @param parentPath The parent path for the local directory + * @param location The location of the directory. */ LocalDirectory(SleuthkitCase db, long objId, @@ -63,10 +64,10 @@ public class LocalDirectory extends SpecialDirectory { TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, String md5Hash, String sha256Hash, FileKnown knownState, - String parentPath) { + String parentPath, TskData.FileLocation location) { super(db, objId, dataSourceObjectId, TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, TskData.TSK_DB_FILES_TYPE_ENUM.LOCAL_DIR, 0L, 0, dirType, metaType, dirFlag, - metaFlags, 0L, 0L, 0L, 0L, 0L, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, null); + metaFlags, 0L, 0L, 0L, 0L, 0L, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, location, null); } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java index 99abf74e70cd7f77cbaa062e0fa1316072064611..f3ed981b0a0ae21abec95ec027be73ecda37d798 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java @@ -68,6 +68,7 @@ public class LocalFile extends AbstractFile { * database lookup, null if not yet looked up. * @param parentId The object id of parent of the file. * @param parentPath The path of the parent of the file. + * @param location The location of the file. * @param dataSourceObjectId The object id of the data source for the file. * @param localPath The absolute path of the file in secondary * storage. @@ -84,14 +85,15 @@ public class LocalFile extends AbstractFile { long size, long ctime, long crtime, long atime, long mtime, String mimeType, String md5Hash, String sha256Hash, FileKnown knownState, - long parentId, String parentPath, + long parentId, String parentPath, TskData.FileLocation location, long dataSourceObjectId, String localPath, TskData.EncodingType encodingType, String extension) { super(db, objId, dataSourceObjectId, TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, fileType, 0L, 0, dirType, metaType, dirFlag, - metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension); + metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, + location, mimeType, extension); // TODO (AUT-1904): The parent id should be passed to AbstractContent // through the class hierarchy contructors, using // AbstractContent.UNKNOWN_ID as needed. @@ -219,7 +221,7 @@ protected LocalFile(SleuthkitCase db, size, ctime, crtime, atime, mtime, null, md5Hash, null, knownState, - AbstractContent.UNKNOWN_ID, parentPath, + AbstractContent.UNKNOWN_ID, parentPath, TskData.FileLocation.LOCAL, db.getDataSourceObjectId(objId), localPath, TskData.EncodingType.NONE, null); diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java index 0572291890859ea7ecaa7a61236cde43b1c102e5..f34e58785d26ec198c105bf94f354498efa332dd 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -66,9 +66,12 @@ public class LocalFilesDataSource extends VirtualDirectory implements DataSource * @param parentPath The parent path for the virtual directory, * should be "/" if the virtual directory is a * data source. + * @param location The location of the file */ - public LocalFilesDataSource(SleuthkitCase db, long objId, long dataSourceObjectId, String deviceId, String name, TskData.TSK_FS_NAME_TYPE_ENUM dirType, TskData.TSK_FS_META_TYPE_ENUM metaType, TskData.TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, String timezone, String md5Hash, String sha256Hash, TskData.FileKnown knownState, String parentPath) { - super(db, objId, dataSourceObjectId, name, dirType, metaType, dirFlag, metaFlags, md5Hash, sha256Hash, knownState, parentPath); + public LocalFilesDataSource(SleuthkitCase db, long objId, long dataSourceObjectId, String deviceId, String name, TskData.TSK_FS_NAME_TYPE_ENUM dirType, + TskData.TSK_FS_META_TYPE_ENUM metaType, TskData.TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, String timezone, + String md5Hash, String sha256Hash, TskData.FileKnown knownState, String parentPath, TskData.FileLocation location) { + super(db, objId, dataSourceObjectId, name, dirType, metaType, dirFlag, metaFlags, md5Hash, sha256Hash, knownState, parentPath, location); this.objectId = objId; this.deviceId = deviceId; this.timezone = timezone; @@ -263,6 +266,6 @@ private static void closeStatement(Statement statement) { */ @Deprecated public LocalFilesDataSource(SleuthkitCase db, long objId, long dataSourceObjectId, String deviceId, String name, TskData.TSK_FS_NAME_TYPE_ENUM dirType, TskData.TSK_FS_META_TYPE_ENUM metaType, TskData.TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, String timezone, String md5Hash, TskData.FileKnown knownState, String parentPath) { - this(db, objId, dataSourceObjectId, deviceId, name, dirType, metaType, dirFlag, metaFlags, timezone, md5Hash, null, knownState, parentPath); + this(db, objId, dataSourceObjectId, deviceId, name, dirType, metaType, dirFlag, metaFlags, timezone, md5Hash, null, knownState, parentPath, TskData.FileLocation.LOCAL); } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java b/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java index df038e6021013a8f0a5b706e27721a721b2856d5..00ab42f5b5f4a9417a8349d569585b3c7765512f 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java @@ -72,6 +72,7 @@ public class SlackFile extends FsContent { * @param knownState The known state of the file from a hash * database lookup, null if not yet looked up. * @param parentPath The path of the parent of the file. + * @param location The location of the file, * @param mimeType The MIME type of the file, null if it has not * yet been determined. * @param extension The extension part of the file name (not @@ -89,9 +90,9 @@ public class SlackFile extends FsContent { long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, - String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, String mimeType, + String md5Hash, String sha256Hash, FileKnown knownState, String parentPath, TskData.FileLocation location, String mimeType, String extension) { - super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.SLACK, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension); + super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.SLACK, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, extension); } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index f380bc88aedeeeaa47004a371a6fd833317bb446..fe11d87b633a41a4f5325d0d1bfd182abbac6292 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -2205,6 +2205,7 @@ private CaseDbSchemaVersionNumber updateFromSchema8dot5toSchema8dot6(CaseDbSchem acquireSingleUserCaseWriteLock(); try { statement.execute("ALTER TABLE tsk_files ADD COLUMN sha256 TEXT"); + statement.execute("ALTER TABLE tsk_files ADD COLUMN location INTEGER NOT NULL DEFAULT " + TskData.FileLocation.LOCAL.getValue()); return new CaseDbSchemaVersionNumber(8, 6); @@ -2852,7 +2853,7 @@ public List<DataSource> getDataSources() throws TskCoreException { final short metaFlags = (short) (TSK_FS_META_FLAG_ENUM.ALLOC.getValue() | TSK_FS_META_FLAG_ENUM.USED.getValue()); String parentPath = "/"; //NON-NLS - dataSource = new LocalFilesDataSource(this, objectId, objectId, deviceId, dsName, dirType, metaType, dirFlag, metaFlags, timezone, null, null, FileKnown.UNKNOWN, parentPath); + dataSource = new LocalFilesDataSource(this, objectId, objectId, deviceId, dsName, dirType, metaType, dirFlag, metaFlags, timezone, null, null, FileKnown.UNKNOWN, parentPath, TskData.FileLocation.LOCAL); } else { /* * Data found in 'tsk_image_info', so we build an Image. @@ -2951,7 +2952,7 @@ public DataSource getDataSource(long objectId) throws TskDataException, TskCoreE final short metaFlags = (short) (TSK_FS_META_FLAG_ENUM.ALLOC.getValue() | TSK_FS_META_FLAG_ENUM.USED.getValue()); String parentPath = "/"; //NON-NLS - dataSource = new LocalFilesDataSource(this, objectId, objectId, deviceId, dsName, dirType, metaType, dirFlag, metaFlags, timezone, null, null, FileKnown.UNKNOWN, parentPath); + dataSource = new LocalFilesDataSource(this, objectId, objectId, deviceId, dsName, dirType, metaType, dirFlag, metaFlags, timezone, null, null, FileKnown.UNKNOWN, parentPath, TskData.FileLocation.LOCAL); } else { /* * Data found in 'tsk_image_info', so we build an Image. @@ -5618,8 +5619,8 @@ public VirtualDirectory addVirtualDirectory(long parentId, String directoryName, // Insert a row for the virtual directory into the tsk_files table. // INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, meta_type, - // dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, known, mime_type, parent_path, data_source_obj_id,extension) - // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) + // dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, known, mime_type, parent_path, location, data_source_obj_id,extension) + // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); statement.clearParameters(); statement.setLong(1, newObjId); @@ -5673,6 +5674,8 @@ public VirtualDirectory addVirtualDirectory(long parentId, String directoryName, // parent path statement.setString(19, parentPath); + statement.setLong(20, TskData.FileLocation.LOCAL.getValue()); + // data source object id (same as object id if this is a data source) long dataSourceObjectId; if (0 == parentId) { @@ -5680,15 +5683,15 @@ public VirtualDirectory addVirtualDirectory(long parentId, String directoryName, } else { dataSourceObjectId = getDataSourceObjectId(connection, parentId); } - statement.setLong(20, dataSourceObjectId); + statement.setLong(21, dataSourceObjectId); //extension, since this is not really file we just set it to null - statement.setString(21, null); + statement.setString(22, null); connection.executeUpdate(statement); return new VirtualDirectory(this, newObjId, dataSourceObjectId, directoryName, dirType, metaType, dirFlag, metaFlags, null, null, FileKnown.UNKNOWN, - parentPath); + parentPath, TskData.FileLocation.LOCAL); } catch (SQLException e) { throw new TskCoreException("Error creating virtual directory '" + directoryName + "'", e); } finally { @@ -5763,8 +5766,8 @@ public LocalDirectory addLocalDirectory(long parentId, String directoryName, Cas // Insert a row for the local directory into the tsk_files table. // INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, meta_type, - // dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, sha256, known, mime_type, parent_path, data_source_obj_id) - // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + // dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, sha256, known, mime_type, parent_path, location, data_source_obj_id) + // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); statement.clearParameters(); statement.setLong(1, newObjId); @@ -5808,19 +5811,21 @@ public LocalDirectory addLocalDirectory(long parentId, String directoryName, Cas // parent path statement.setString(19, parentPath); + + statement.setLong(20, TskData.FileLocation.LOCAL.getValue()); // data source object id long dataSourceObjectId = getDataSourceObjectId(connection, parentId); - statement.setLong(20, dataSourceObjectId); + statement.setLong(21, dataSourceObjectId); //extension, since this is a directory we just set it to null - statement.setString(21, null); + statement.setString(22, null); connection.executeUpdate(statement); return new LocalDirectory(this, newObjId, dataSourceObjectId, directoryName, dirType, metaType, dirFlag, metaFlags, null, null, FileKnown.UNKNOWN, - parentPath); + parentPath, TskData.FileLocation.LOCAL); } catch (SQLException e) { throw new TskCoreException("Error creating local directory '" + directoryName + "'", e); } finally { @@ -5867,8 +5872,8 @@ public LocalFilesDataSource addLocalFilesDataSource(String deviceId, String root // its own object id. // INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, // dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, - // atime, mtime, md5, known, mime_type, parent_path, data_source_obj_id, extension) - // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) + // atime, mtime, md5, sha256, known, mime_type, parent_path, location, data_source_obj_id, extension) + // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) PreparedStatement preparedStatement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); preparedStatement.clearParameters(); preparedStatement.setLong(1, newObjId); @@ -5896,11 +5901,12 @@ public LocalFilesDataSource addLocalFilesDataSource(String deviceId, String root preparedStatement.setNull(18, java.sql.Types.VARCHAR); // MIME type String parentPath = "/"; //NON-NLS preparedStatement.setString(19, parentPath); - preparedStatement.setLong(20, newObjId); - preparedStatement.setString(21, null); //extension, just set it to null + preparedStatement.setLong(20, TskData.FileLocation.LOCAL.getValue()); + preparedStatement.setLong(21, newObjId); + preparedStatement.setString(22, null); //extension, just set it to null connection.executeUpdate(preparedStatement); - return new LocalFilesDataSource(this, newObjId, newObjId, deviceId, rootDirectoryName, dirType, metaType, dirFlag, metaFlags, timeZone, null, null, FileKnown.UNKNOWN, parentPath); + return new LocalFilesDataSource(this, newObjId, newObjId, deviceId, rootDirectoryName, dirType, metaType, dirFlag, metaFlags, timeZone, null, null, FileKnown.UNKNOWN, parentPath, TskData.FileLocation.LOCAL); } catch (SQLException ex) { throw new TskCoreException(String.format("Error creating local files data source with device id %s and directory name %s", deviceId, rootDirectoryName), ex); @@ -6268,13 +6274,14 @@ public FsContent addFileSystemFile(long dataSourceObjId, long fsObjId, statement.setLong(18, atime); statement.setLong(19, mtime); statement.setString(20, parentPath); + statement.setLong(21, TskData.FileLocation.LOCAL.getValue()); final String extension = extractExtension(fileName); - statement.setString(21, extension); + statement.setString(22, extension); connection.executeUpdate(statement); DerivedFile derivedFile = new DerivedFile(this, objectId, dataSourceObjId, fileName, dirType, metaType, dirFlag, metaFlags, - size, ctime, crtime, atime, mtime, null, null, null, parentPath, null, parent.getId(), null, null, extension); + size, ctime, crtime, atime, mtime, null, null, null, parentPath, null, TskData.FileLocation.LOCAL, parent.getId(), null, null, extension); timelineManager.addEventsForNewFile(derivedFile, connection); @@ -6285,7 +6292,7 @@ public FsContent addFileSystemFile(long dataSourceObjId, long fsObjId, attrType, attrId, fileName, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, - (short) 0, 0, 0, null, null, null, parentPath, null, + (short) 0, 0, 0, null, null, null, parentPath, TskData.FileLocation.LOCAL, null, extension); } catch (SQLException ex) { @@ -6382,8 +6389,8 @@ public final List<LayoutFile> addLayoutFiles(Content parent, List<TskFileRange> * INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, * has_path, dir_type, meta_type, dir_flags, meta_flags, size, * ctime, crtime, atime, mtime, md5, known, mime_type, - * parent_path, data_source_obj_id,extension) VALUES (?, ?, ?, - * ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) + * parent_path, location, data_source_obj_id,extension) VALUES (?, ?, ?, + * ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) */ PreparedStatement prepStmt = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); prepStmt.clearParameters(); @@ -6406,10 +6413,11 @@ public final List<LayoutFile> addLayoutFiles(Content parent, List<TskFileRange> prepStmt.setByte(17, FileKnown.UNKNOWN.getFileKnownValue()); // Known prepStmt.setNull(18, java.sql.Types.VARCHAR); // MIME type prepStmt.setNull(19, java.sql.Types.VARCHAR); // parent path - prepStmt.setLong(20, parent.getId()); // data_source_obj_id + prepStmt.setLong(20, TskData.FileLocation.LOCAL.getValue()); // location + prepStmt.setLong(21, parent.getId()); // data_source_obj_id //extension, since this is not a FS file we just set it to null - prepStmt.setString(21, null); + prepStmt.setString(22, null); connection.executeUpdate(prepStmt); /* @@ -6441,7 +6449,7 @@ public final List<LayoutFile> addLayoutFiles(Content parent, List<TskFileRange> 0L, 0L, 0L, 0L, null, null, FileKnown.UNKNOWN, - parent.getUniquePath(), + parent.getUniquePath(), TskData.FileLocation.LOCAL, null)); } @@ -6563,8 +6571,8 @@ public final List<LayoutFile> addCarvedFiles(CarvingResult carvingResult) throws * INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, * has_path, dir_type, meta_type, dir_flags, meta_flags, size, * ctime, crtime, atime, mtime, md5, known, mime_type, - * parent_path, data_source_obj_id,extenion) VALUES (?, ?, ?, ?, - * ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) + * parent_path, location, data_source_obj_id,extenion) VALUES (?, ?, ?, ?, + * ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) */ PreparedStatement prepStmt = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); prepStmt.clearParameters(); @@ -6591,8 +6599,9 @@ public final List<LayoutFile> addCarvedFiles(CarvingResult carvingResult) throws prepStmt.setByte(17, FileKnown.UNKNOWN.getFileKnownValue()); // Known prepStmt.setNull(18, java.sql.Types.VARCHAR); // MIME type prepStmt.setString(19, parentPath); // parent path - prepStmt.setLong(20, carvedFilesDir.getDataSourceObjectId()); // data_source_obj_id - prepStmt.setString(21, extractExtension(carvedFile.getName())); //extension + prepStmt.setLong(20, TskData.FileLocation.LOCAL.getValue()); + prepStmt.setLong(21, carvedFilesDir.getDataSourceObjectId()); // data_source_obj_id + prepStmt.setString(22, extractExtension(carvedFile.getName())); //extension connection.executeUpdate(prepStmt); /* @@ -6626,7 +6635,7 @@ public final List<LayoutFile> addCarvedFiles(CarvingResult carvingResult) throws 0L, 0L, 0L, 0L, null, null, FileKnown.UNKNOWN, - parentPath, + parentPath, TskData.FileLocation.LOCAL, null)); } @@ -6762,13 +6771,15 @@ public DerivedFile addDerivedFile(String fileName, String localPath, //parent path statement.setString(19, parentPath); + + statement.setLong(20, TskData.FileLocation.LOCAL.getValue()); // root data source object id long dataSourceObjId = getDataSourceObjectId(connection, parentId); - statement.setLong(20, dataSourceObjId); + statement.setLong(21, dataSourceObjId); final String extension = extractExtension(fileName); //extension - statement.setString(21, extension); + statement.setString(22, extension); connection.executeUpdate(statement); @@ -6776,7 +6787,7 @@ public DerivedFile addDerivedFile(String fileName, String localPath, addFilePath(connection, newObjId, localPath, encodingType); DerivedFile derivedFile = new DerivedFile(this, newObjId, dataSourceObjId, fileName, dirType, metaType, dirFlag, metaFlags, - savedSize, ctime, crtime, atime, mtime, null, null, null, parentPath, localPath, parentId, null, encodingType, extension); + savedSize, ctime, crtime, atime, mtime, null, null, null, parentPath, localPath, TskData.FileLocation.LOCAL, parentId, null, encodingType, extension); timelineManager.addEventsForNewFile(derivedFile, connection); transaction.commit(); @@ -6886,7 +6897,7 @@ public DerivedFile updateDerivedFile(DerivedFile derivedFile, String localPath, long dataSourceObjId = getDataSourceObjectId(connection, parentId); final String extension = extractExtension(derivedFile.getName()); return new DerivedFile(this, derivedFile.getId(), dataSourceObjId, derivedFile.getName(), dirType, metaType, dirFlag, metaFlags, - savedSize, ctime, crtime, atime, mtime, null, null, null, parentPath, localPath, parentId, null, encodingType, extension); + savedSize, ctime, crtime, atime, mtime, null, null, null, parentPath, localPath, TskData.FileLocation.LOCAL, parentId, null, encodingType, extension); } catch (SQLException ex) { connection.rollbackTransaction(); throw new TskCoreException("Failed to add derived file to case database", ex); @@ -7017,8 +7028,8 @@ public LocalFile addLocalFile(String fileName, String localPath, // Insert a row for the local/logical file into the tsk_files table. // INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, meta_type, // dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, known, mime_type, - // parent_path, data_source_obj_id,extension) - // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) + // parent_path, location, data_source_obj_id,extension) + // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); statement.clearParameters(); statement.setLong(1, objectId); @@ -7065,9 +7076,10 @@ public LocalFile addLocalFile(String fileName, String localPath, dataSourceObjId = getDataSourceObjectId(connection, parent.getId()); } statement.setString(19, parentPath); - statement.setLong(20, dataSourceObjId); + statement.setLong(20, TskData.FileLocation.LOCAL.getValue()); + statement.setLong(21, dataSourceObjId); final String extension = extractExtension(fileName); - statement.setString(21, extension); + statement.setString(22, extension); connection.executeUpdate(statement); addFilePath(connection, objectId, localPath, encodingType); @@ -7082,7 +7094,7 @@ public LocalFile addLocalFile(String fileName, String localPath, savedSize, ctime, crtime, atime, mtime, mimeType, md5, sha256, known, - parent.getId(), parentPath, + parent.getId(), parentPath, TskData.FileLocation.LOCAL, dataSourceObjId, localPath, encodingType, extension); @@ -7196,8 +7208,8 @@ public LayoutFile addLayoutFile(String fileName, * Insert a row for the file into the tsk_files table: INSERT INTO * tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, * meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, - * mtime, md5, known, mime_type, parent_path, - * data_source_obj_id,extenion) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, + * mtime, md5, known, mime_type, parent_path, location, + * data_source_obj_id,extenion) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, * ?, ?, ?, ?, ?, ?, ?,?) */ PreparedStatement prepStmt = connection.getPreparedStatement(PREPARED_STATEMENT.INSERT_FILE); @@ -7234,9 +7246,10 @@ public LayoutFile addLayoutFile(String fileName, prepStmt.setByte(17, FileKnown.UNKNOWN.getFileKnownValue()); // Known prepStmt.setNull(18, java.sql.Types.VARCHAR); // MIME type prepStmt.setString(19, parentPath); // parent path - prepStmt.setLong(20, parent.getDataSource().getId()); // data_source_obj_id + prepStmt.setLong(20, TskData.FileLocation.LOCAL.getValue()); // location + prepStmt.setLong(21, parent.getDataSource().getId()); // data_source_obj_id - prepStmt.setString(21, extractExtension(fileName)); //extension + prepStmt.setString(22, extractExtension(fileName)); //extension connection.executeUpdate(prepStmt); /* @@ -7270,7 +7283,7 @@ public LayoutFile addLayoutFile(String fileName, ctime, crtime, atime, mtime, null, null, FileKnown.UNKNOWN, - parentPath, + parentPath, TskData.FileLocation.LOCAL, null); transaction.commit(); @@ -8570,7 +8583,8 @@ private List<AbstractFile> resultSetToAbstractFiles(ResultSet rs, CaseDbConnecti TSK_FS_NAME_FLAG_ENUM.valueOf(rs.getShort("dir_flags")), rs.getShort("meta_flags"), //NON-NLS rs.getLong("size"), //NON-NLS rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS - rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), parentPath, rs.getString("mime_type")); //NON-NLS + rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), parentPath, //NON-NLS + TskData.FileLocation.valueOf(rs.getByte("location")), rs.getString("mime_type")); //NON-NLS results.add(lf); } else if (type == TSK_DB_FILES_TYPE_ENUM.DERIVED.getFileType()) { final DerivedFile df; @@ -8616,7 +8630,8 @@ org.sleuthkit.datamodel.File file(ResultSet rs, FileSystem fs) throws SQLExcepti rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS (short) rs.getInt("mode"), rs.getInt("uid"), rs.getInt("gid"), //NON-NLS rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), //NON-NLS - rs.getString("parent_path"), rs.getString("mime_type"), rs.getString("extension")); //NON-NLS + rs.getString("parent_path"), TskData.FileLocation.valueOf(rs.getByte("location")), //NON-NLS + rs.getString("mime_type"), rs.getString("extension")); //NON-NLS f.setFileSystem(fs); return f; } @@ -8643,7 +8658,7 @@ Directory directory(ResultSet rs, FileSystem fs) throws SQLException { rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS rs.getShort("mode"), rs.getInt("uid"), rs.getInt("gid"), //NON-NLS rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), //NON-NLS - rs.getString("parent_path")); //NON-NLS + rs.getString("parent_path"), TskData.FileLocation.valueOf(rs.getByte("location"))); //NON-NLS dir.setFileSystem(fs); return dir; } @@ -8701,7 +8716,8 @@ VirtualDirectory virtualDirectory(ResultSet rs, CaseDbConnection connection) thr rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), - parentPath); + parentPath, + TskData.FileLocation.valueOf(rs.getByte("location"))); } else { final VirtualDirectory vd = new VirtualDirectory(this, objId, dsObjId, @@ -8710,7 +8726,8 @@ VirtualDirectory virtualDirectory(ResultSet rs, CaseDbConnection connection) thr TSK_FS_META_TYPE_ENUM.valueOf(rs.getShort("meta_type")), //NON-NLS TSK_FS_NAME_FLAG_ENUM.valueOf(rs.getShort("dir_flags")), //NON-NLS rs.getShort("meta_flags"), rs.getString("md5"), rs.getString("sha256"), //NON-NLS - FileKnown.valueOf(rs.getByte("known")), parentPath); //NON-NLS + FileKnown.valueOf(rs.getByte("known")), parentPath, //NON-NLS + TskData.FileLocation.valueOf(rs.getByte("location"))); //NON-NLS return vd; } } @@ -8735,7 +8752,7 @@ LocalDirectory localDirectory(ResultSet rs) throws SQLException { TSK_FS_META_TYPE_ENUM.valueOf(rs.getShort("meta_type")), //NON-NLS TSK_FS_NAME_FLAG_ENUM.valueOf(rs.getShort("dir_flags")), //NON-NLS rs.getShort("meta_flags"), rs.getString("md5"), rs.getString("sha256"), //NON-NLS - FileKnown.valueOf(rs.getByte("known")), parentPath); //NON-NLS + FileKnown.valueOf(rs.getByte("known")), parentPath, TskData.FileLocation.valueOf(rs.getByte("location"))); //NON-NLS return ld; } @@ -8788,7 +8805,7 @@ private DerivedFile derivedFile(ResultSet rs, CaseDbConnection connection, long rs.getLong("size"), //NON-NLS rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), //NON-NLS - parentPath, localPath, parentId, rs.getString("mime_type"), + parentPath, localPath, TskData.FileLocation.valueOf(rs.getByte("location")), parentId, rs.getString("mime_type"), encodingType, rs.getString("extension")); return df; } @@ -8841,7 +8858,7 @@ private LocalFile localFile(ResultSet rs, CaseDbConnection connection, long pare rs.getLong("size"), //NON-NLS rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS rs.getString("mime_type"), rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), //NON-NLS - parentId, parentPath, rs.getLong("data_source_obj_id"), + parentId, parentPath, TskData.FileLocation.valueOf(rs.getByte("location")), rs.getLong("data_source_obj_id"), localPath, encodingType, rs.getString("extension")); return file; } @@ -8869,7 +8886,8 @@ org.sleuthkit.datamodel.SlackFile slackFile(ResultSet rs, FileSystem fs) throws rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), //NON-NLS (short) rs.getInt("mode"), rs.getInt("uid"), rs.getInt("gid"), //NON-NLS rs.getString("md5"), rs.getString("sha256"), FileKnown.valueOf(rs.getByte("known")), //NON-NLS - rs.getString("parent_path"), rs.getString("mime_type"), rs.getString("extension")); //NON-NLS + rs.getString("parent_path"), TskData.FileLocation.valueOf(rs.getByte("location")), //NON-NLS + rs.getString("mime_type"), rs.getString("extension")); //NON-NLS f.setFileSystem(fs); return f; } @@ -8931,7 +8949,8 @@ List<Content> fileChildren(ResultSet rs, CaseDbConnection connection, long paren rs.getLong("size"), rs.getLong("ctime"), rs.getLong("crtime"), rs.getLong("atime"), rs.getLong("mtime"), rs.getString("md5"), rs.getString("sha256"), - FileKnown.valueOf(rs.getByte("known")), parentPath, rs.getString("mime_type")); + FileKnown.valueOf(rs.getByte("known")), parentPath, + TskData.FileLocation.valueOf(rs.getByte("location")), rs.getString("mime_type")); children.add(lf); break; } @@ -11203,10 +11222,10 @@ private enum PREPARED_STATEMENT { SELECT_FILE_DERIVATION_METHOD("SELECT tool_name, tool_version, other FROM tsk_files_derived_method WHERE derived_id = ?"), //NON-NLS SELECT_MAX_OBJECT_ID("SELECT MAX(obj_id) AS max_obj_id FROM tsk_objects"), //NON-NLS INSERT_OBJECT("INSERT INTO tsk_objects (par_obj_id, type) VALUES (?, ?)"), //NON-NLS - INSERT_FILE("INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, sha256, known, mime_type, parent_path, data_source_obj_id,extension) " //NON-NLS - + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"), //NON-NLS - INSERT_FILE_SYSTEM_FILE("INSERT INTO tsk_files(obj_id, fs_obj_id, data_source_obj_id, attr_type, attr_id, name, meta_addr, meta_seq, type, has_path, dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, mtime, parent_path, extension)" - + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"), // NON-NLS + INSERT_FILE("INSERT INTO tsk_files (obj_id, fs_obj_id, name, type, has_path, dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, mtime, md5, sha256, known, mime_type, parent_path, location, data_source_obj_id,extension) " //NON-NLS + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"), //NON-NLS + INSERT_FILE_SYSTEM_FILE("INSERT INTO tsk_files(obj_id, fs_obj_id, data_source_obj_id, attr_type, attr_id, name, meta_addr, meta_seq, type, has_path, dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, mtime, parent_path, location, extension)" + + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"), // NON-NLS UPDATE_DERIVED_FILE("UPDATE tsk_files SET type = ?, dir_type = ?, meta_type = ?, dir_flags = ?, meta_flags = ?, size= ?, ctime= ?, crtime= ?, atime= ?, mtime= ?, mime_type = ? " + "WHERE obj_id = ?"), //NON-NLS INSERT_LAYOUT_FILE("INSERT INTO tsk_file_layout (obj_id, byte_start, byte_len, sequence) " //NON-NLS diff --git a/bindings/java/src/org/sleuthkit/datamodel/SpecialDirectory.java b/bindings/java/src/org/sleuthkit/datamodel/SpecialDirectory.java index 5db5888d5b34d8a0ebbd926d18b1fa52559c2512..573ec25d756605f6fb6d5d064de308897af553ba 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SpecialDirectory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SpecialDirectory.java @@ -44,11 +44,11 @@ public abstract class SpecialDirectory extends AbstractFile { short modes, int uid, int gid, String md5Hash, String sha256Hash, FileKnown knownState, - String parentPath, + String parentPath, TskData.FileLocation location, String mimeType) { super(db, objId, dataSourceObjectId, attrType, attrId, name, fileType, metaAddr, metaSeq, dirType, metaType, dirFlag, - metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, mimeType, null); + metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, location, mimeType, null); } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java index c66755ac36cabafe5c6a2ba38df60417ecc73adc..d91aea2ed1cba28c862ef19b84fb9bcaf76b428a 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java @@ -789,8 +789,8 @@ private long addFileToDb(long parentObjId, // INSERT INTO tsk_objects (par_obj_id, type) VALUES (?, ?) long objectId = caseDb.addObject(parentObjId, TskData.ObjectType.ABSTRACTFILE.getObjectType(), connection); - String fileInsert = "INSERT INTO tsk_files (fs_obj_id, obj_id, data_source_obj_id, type, attr_type, attr_id, name, meta_addr, meta_seq, dir_type, meta_type, dir_flags, meta_flags, size, crtime, ctime, atime, mtime, mode, gid, uid, md5, known, parent_path, extension, has_layout)" - + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; // NON-NLS + String fileInsert = "INSERT INTO tsk_files (fs_obj_id, obj_id, data_source_obj_id, type, attr_type, attr_id, name, meta_addr, meta_seq, dir_type, meta_type, dir_flags, meta_flags, size, crtime, ctime, atime, mtime, mode, gid, uid, md5, known, parent_path, location, extension, has_layout)" + + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; // NON-NLS PreparedStatement preparedStatement = connection.getPreparedStatement(fileInsert, Statement.NO_GENERATED_KEYS); preparedStatement.clearParameters(); @@ -866,11 +866,12 @@ private long addFileToDb(long parentObjId, preparedStatement.setString(22, md5); // md5 preparedStatement.setInt(23, known.getFileKnownValue());// known preparedStatement.setString(24, escaped_path); // parent_path - preparedStatement.setString(25, extension); // extension + preparedStatement.setLong(25, TskData.FileLocation.LOCAL.getValue()); // location + preparedStatement.setString(26, extension); // extension if (hasLayout) { - preparedStatement.setInt(26, 1); // has_layout + preparedStatement.setInt(27, 1); // has_layout } else { - preparedStatement.setNull(26, java.sql.Types.INTEGER); + preparedStatement.setNull(27, java.sql.Types.INTEGER); } connection.executeUpdate(preparedStatement); @@ -884,7 +885,7 @@ private long addFileToDb(long parentObjId, TskData.TSK_FS_META_TYPE_ENUM.valueOf((short) metaType), TskData.TSK_FS_NAME_FLAG_ENUM.valueOf(dirFlags), (short) metaFlags, - size, ctime, crtime, atime, mtime, null, null, null, escaped_path, null, parentObjId, null, null, extension); + size, ctime, crtime, atime, mtime, null, null, null, escaped_path, null, TskData.FileLocation.LOCAL, parentObjId, null, null, extension); timelineManager.addEventsForNewFileQuiet(derivedFile, connection); } diff --git a/bindings/java/src/org/sleuthkit/datamodel/TskData.java b/bindings/java/src/org/sleuthkit/datamodel/TskData.java index 6ff21a0a03cb007cc49d3d6fe5fa3579307ce8c2..e83310ba21e83e924bf31a0b6842ac65ad2fff72 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TskData.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TskData.java @@ -878,4 +878,36 @@ public static EncodingType valueOf(int type) { MessageFormat.format(bundle.getString("TskData.encodingType.exception.msg1.text"), type)); } } + + /** + * TODO + */ + public enum FileLocation{ + LOCAL(0), + MICROSERVICE(1); + + private final int value; + + private FileLocation(int value){ + this.value = value; + } + + public int getValue(){ + return value; + } + + public static FileLocation valueOf(int value) { + for (FileLocation v : FileLocation.values()) { + if (v.value == value) { + return v; + } + } + throw new IllegalArgumentException( + // TODO TODO + "FIX THIS" + //MessageFormat.format(bundle.getString("TskData.encodingType.exception.msg1.text"), location)); + // TODO + ); + } + } } diff --git a/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java b/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java index 729707128e93f097312caca5a16222c30927943b..7fac11eb5a923ed83c305ce53f9752f9fa2ccb6c 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java @@ -63,10 +63,12 @@ public class VirtualDirectory extends SpecialDirectory { * directory. * @param metaFlags The meta flags for the virtual directory. * @param md5Hash The MD5 hash for the virtual directory. + * @param sha256Hash The SHA-256 hash for the virtual directory. * @param knownState The known state for the virtual directory * @param parentPath The parent path for the virtual directory, * should be "/" if the virtual directory is a * data source. + * @param location The location of the file. */ VirtualDirectory(SleuthkitCase db, long objId, @@ -75,10 +77,10 @@ public class VirtualDirectory extends SpecialDirectory { TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, String md5Hash, String sha256Hash, FileKnown knownState, - String parentPath) { + String parentPath, TskData.FileLocation location) { super(db, objId, dataSourceObjectId, TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0, name, TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR, 0L, 0, dirType, metaType, dirFlag, - metaFlags, 0L, 0L, 0L, 0L, 0L, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, null); + metaFlags, 0L, 0L, 0L, 0L, 0L, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, location, null); } /**