diff --git a/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java b/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java index a5e5297f351307688b4d934900323355c76c730a..078a276ee31efb5f168ccd6bdc280647bd746ede 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/AbstractFile.java @@ -892,21 +892,30 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE * read() will read the file in the local path. * * @param localPath local path to be set - * @param isAbsolute true if the path is absolute, false if relative to the - * case db */ - void setLocalFilePath(String localPath, boolean isAbsolute) { + void setLocalFilePath(String localPath) { if (localPath == null || localPath.equals("")) { this.localPath = ""; localAbsPath = null; localPathSet = false; } else { + // It should always be the case that absolute paths start with slashes or a windows drive letter + // and relative paths do not, but some older versions of modules created derived file paths + // starting with slashes. So we first check if this file is a DerivedFile before looking at the path. this.localPath = localPath; - if (isAbsolute) { - this.localAbsPath = localPath; + if (this instanceof DerivedFile) { + // DerivedFiles always have relative paths + this.localAbsPath = getSleuthkitCase().getDbDirPath() + java.io.File.separator + localPath; } else { - this.localAbsPath = getSleuthkitCase().getDbDirPath() + java.io.File.separator + this.localPath; + // If a path starts with a slash or with a Windows drive letter, then it is + // absolute. Otherwise it is relative. + if (localPath.startsWith("/") || localPath.startsWith("\\") + || localPath.matches("[A-Za-z]:[/\\\\].*")) { + this.localAbsPath = localPath; + } else { + this.localAbsPath = getSleuthkitCase().getDbDirPath() + java.io.File.separator + localPath; + } } this.localPathSet = true; } @@ -1251,7 +1260,7 @@ public short getAttrId() { */ @Deprecated protected void setLocalPath(String localPath, boolean isAbsolute) { - setLocalFilePath(localPath, isAbsolute); + setLocalFilePath(localPath); } /* diff --git a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java index 9f61fbd6b0553c43f8945dd3f8fe6cfd12bfdc3b..aa010acd623c27ae32097c2732c50624de7f2e4e 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java +++ b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java @@ -1146,38 +1146,34 @@ public enum ARTIFACT_TYPE implements SleuthkitVisitableItem { TSK_OBJECT_DETECTED(41, "TSK_OBJECT_DETECTED", //NON-NLS bundle.getString("BlackboardArtifact.tskObjectDetected.text")), /** - * A wireless network. + * A wireless network. */ - - - - TSK_WIFI_NETWORK(42, "TSK_WIFI_NETWORK", //NON-NLS + TSK_WIFI_NETWORK(42, "TSK_WIFI_NETWORK", //NON-NLS bundle.getString("BlackboardArtifact.tskWIFINetwork.text")), /** * Information related to a device. */ - TSK_DEVICE_INFO(43, "TSK_DEVICE_INFO", //NON-NLS + TSK_DEVICE_INFO(43, "TSK_DEVICE_INFO", //NON-NLS bundle.getString("BlackboardArtifact.tskDeviceInfo.text")), /** * A SIM card. */ - TSK_SIM_ATTACHED(44, "TSK_SIM_ATTACHED", //NON-NLS + TSK_SIM_ATTACHED(44, "TSK_SIM_ATTACHED", //NON-NLS bundle.getString("BlackboardArtifact.tskSimAttached.text")), /** * A bluetooth adapter. */ - TSK_BLUETOOTH_ADAPTER(45, "TSK_BLUETOOTH_ADAPTER", //NON-NLS + TSK_BLUETOOTH_ADAPTER(45, "TSK_BLUETOOTH_ADAPTER", //NON-NLS bundle.getString("BlackboardArtifact.tskBluetoothAdapter.text")), /** * A wireless network adapter. */ - TSK_WIFI_NETWORK_ADAPTER(46, "TSK_WIFI_NETWORK_ADAPTER", //NON-NLS + TSK_WIFI_NETWORK_ADAPTER(46, "TSK_WIFI_NETWORK_ADAPTER", //NON-NLS bundle.getString("BlackboardArtifact.tskWIFINetworkAdapter.text")), - /** * Indicates a verification failure */ - TSK_VERIFICATION_FAILED(47, "TSK_VERIFICATION_FAILED", //NON-NLS + TSK_VERIFICATION_FAILED(47, "TSK_VERIFICATION_FAILED", //NON-NLS bundle.getString("BlackboardArtifact.tskVerificationFailed.text")), /** * Categorization information for a data source. @@ -1187,18 +1183,17 @@ public enum ARTIFACT_TYPE implements SleuthkitVisitableItem { /** * Indicates auto fill data from a Web form */ - TSK_WEB_FORM_AUTOFILL(49, "TSK_WEB_FORM_AUTOFILL", //NON-NLS + TSK_WEB_FORM_AUTOFILL(49, "TSK_WEB_FORM_AUTOFILL", //NON-NLS bundle.getString("BlackboardArtifact.tskWebFormAutofill.text")), /** * Indicates an person's address filled in a web form */ - TSK_WEB_FORM_ADDRESS (50, "TSK_WEB_FORM_ADDRESSES ", //NON-NLS - bundle.getString("BlackboardArtifact.tskWebFormAddresses.text")); - -/** + TSK_WEB_FORM_ADDRESS(50, "TSK_WEB_FORM_ADDRESSES ", //NON-NLS + bundle.getString("BlackboardArtifact.tskWebFormAddresses.text")), + /** * A generic (timeline) event. */ - TSK_TL_EVENT(48, "TSK_TL_EVENT", //NON-NLS + TSK_TL_EVENT(51, "TSK_TL_EVENT", //NON-NLS bundle.getString("BlackboardArtifact.tskTLEvent.text")); private final String label; private final int typeId; @@ -1254,9 +1249,9 @@ static public ARTIFACT_TYPE fromLabel(String label) { /** * Gets the artifact type enum value that corresponds to a given type - * id. - * This method should only be used when the id is known to be one of the - * built-in types - otherwise use getArtifactType() in SleuthkitCase. + * id. This method should only be used when the id is known to be one of + * the built-in types - otherwise use getArtifactType() in + * SleuthkitCase. * * @param id The type id. * diff --git a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java index ce60113e4c540c4f6fe987be7279c8bd8f1da200..629a624323569cb4e6d28e29a2561db075752417 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java @@ -103,7 +103,7 @@ public class DerivedFile extends AbstractFile { 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, knownState, parentPath, mimeType, extension); - setLocalFilePath(localPath, false); + setLocalFilePath(localPath); setEncodingType(encodingType); } diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java index d5fd6eac39f2a888da8110d685caa2451e307eff..b174a5cd1c652dab00c36d41f6bbf100e9f802a8 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java @@ -98,7 +98,7 @@ public class LocalFile extends AbstractFile { if (parentId > 0) { setParentId(parentId); } - super.setLocalFilePath(localPath, true); + super.setLocalFilePath(localPath); setEncodingType(encodingType); } diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index a70c04d04ccaadd830aa2f75050f4b5eb5bdc60d..21f667abda35ac7056a2d16b8a2e58cd4694afe2 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -1782,7 +1782,7 @@ private CaseDbSchemaVersionNumber updateFromSchema8dot1toSchema8dot2(CaseDbSchem releaseSingleUserCaseWriteLock(); } } - + /** * Extract the extension from a file name. * @@ -5961,7 +5961,9 @@ public DerivedFile addDerivedFile(String fileName, String localPath, boolean isFile, Content parentObj, String rederiveDetails, String toolName, String toolVersion, String otherDetails, TskData.EncodingType encodingType) throws TskCoreException { - + // Strip off any leading slashes from the local path (leading slashes indicate absolute paths) + localPath = localPath.replaceAll("^[/\\\\]+", ""); + acquireSingleUserCaseWriteLock(); TimelineManager timelineManager = getTimelineManager(); @@ -6090,6 +6092,10 @@ public DerivedFile updateDerivedFile(DerivedFile derivedFile, String localPath, boolean isFile, String mimeType, String rederiveDetails, String toolName, String toolVersion, String otherDetails, TskData.EncodingType encodingType) throws TskCoreException { + + // Strip off any leading slashes from the local path (leading slashes indicate absolute paths) + localPath = localPath.replaceAll("^[/\\\\]+", ""); + CaseDbConnection connection = connections.getConnection(); acquireSingleUserCaseWriteLock(); ResultSet rs = null; diff --git a/tsk/auto/db_postgresql.cpp b/tsk/auto/db_postgresql.cpp index 873eef1e7ce07d8c0ef84daf021caacece8e968f..7a6941372ad653f9ad4e024b935274d26f4f1e73 100755 --- a/tsk/auto/db_postgresql.cpp +++ b/tsk/auto/db_postgresql.cpp @@ -636,14 +636,14 @@ int TskDbPostgreSQL::initialize() { "Error creating accounts table: %s\n") || attempt_exec - ("CREATE TABLE account_relationships (relationship_id BIGSERIAL PRIMARY KEY, account1_id INTEGER NOT NULL, account2_id INTEGER NOT NULL, relationship_source_obj_id BIGINT NOT NULL, date_time BIGINT, relationship_type INTEGER NOT NULL, data_source_obj_id BIGINT NOT NULL, UNIQUE(account1_id, account2_id, relationship_source_obj_id), FOREIGN KEY(account1_id) REFERENCES accounts(account_id), FOREIGN KEY(account2_id) REFERENCES accounts(account_id), FOREIGN KEY(relationship_source_obj_id) REFERENCES tsk_objects(obj_id), FOREIGN KEY(data_source_obj_id) REFERENCES tsk_objects(obj_id))", + ("CREATE TABLE account_relationships (relationship_id BIGSERIAL PRIMARY KEY, account1_id INTEGER NOT NULL, account2_id INTEGER NOT NULL, relationship_source_obj_id BIGINT NOT NULL, date_time BIGINT, relationship_type INTEGER NOT NULL, data_source_obj_id BIGINT NOT NULL, UNIQUE(account1_id, account2_id, relationship_source_obj_id), FOREIGN KEY(account1_id) REFERENCES accounts(account_id), FOREIGN KEY(account2_id) REFERENCES accounts(account_id), FOREIGN KEY(relationship_source_obj_id) REFERENCES tsk_objects(obj_id), FOREIGN KEY(data_source_obj_id) REFERENCES tsk_objects(obj_id))", "Error creating relationships table: %s\n") || attempt_exec( "CREATE TABLE tsk_event_types (" " event_type_id BIGSERIAL PRIMARY KEY," " display_name TEXT UNIQUE NOT NULL , " - " super_type_id INTEGER REFERENCES tsk_event_types(event_type_id) )" + " super_type_id INTEGER REFERENCES tsk_event_types(event_type_id) )" , "Error creating tsk_event_types table: %s\n") || attempt_exec( @@ -653,47 +653,46 @@ int TskDbPostgreSQL::initialize() { "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(3, 'Misc Types', 0);" "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(4, 'Modified', 1);" "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(5, 'Accessed', 1);" - "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(6, 'Created', 1);" - "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(7, 'Changed', 1);" - , "Error initializing tsk_event_types table rows: %s\n") || - attempt_exec( - "CREATE TABLE tsk_event_descriptions ( " - " event_description_id BIGSERIAL PRIMARY KEY, " - " full_description TEXT NOT NULL, " - " med_description TEXT, " - " short_description TEXT," - " data_source_obj_id BIGINT NOT NULL, " - " file_obj_id BIGINT NOT NULL, " - " artifact_id BIGINT, " - " hash_hit INTEGER NOT NULL, " //boolean - " tagged INTEGER NOT NULL, " //boolean - " FOREIGN KEY(data_source_obj_id) REFERENCES data_source_info(obj_id), " - " FOREIGN KEY(file_obj_id) REFERENCES tsk_files(obj_id), " - " FOREIGN KEY(artifact_id) REFERENCES blackboard_artifacts(artifact_id))", - "Error creating tsk_event_descriptions table: %s\n") - || - attempt_exec( - "CREATE TABLE tsk_events (" - " event_id BIGSERIAL PRIMARY KEY, " - " event_type_id BIGINT NOT NULL REFERENCES tsk_event_types(event_type_id) ," - " event_description_id BIGINT NOT NULL REFERENCES tsk_event_descriptions(event_description_id) ," - " time INTEGER NOT NULL) " - , "Error creating tsk_events table: %s\n") - - || - attempt_exec - ("CREATE TABLE tsk_examiners (examiner_id BIGSERIAL PRIMARY KEY, login_name TEXT NOT NULL, display_name TEXT, UNIQUE(login_name))", - "Error creating tsk_examiners table: %s\n") - || - attempt_exec - ("CREATE TABLE content_tags (tag_id BIGSERIAL PRIMARY KEY, obj_id BIGINT NOT NULL, tag_name_id BIGINT NOT NULL, comment TEXT NOT NULL, begin_byte_offset BIGINT NOT NULL, end_byte_offset BIGINT NOT NULL, examiner_id BIGINT, " - "FOREIGN KEY(examiner_id) REFERENCES tsk_examiners(examiner_id), FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id), FOREIGN KEY(tag_name_id) REFERENCES tag_names(tag_name_id))", - "Error creating content_tags table: %s\n") - || - attempt_exec - ("CREATE TABLE blackboard_artifact_tags (tag_id BIGSERIAL PRIMARY KEY, artifact_id BIGINT NOT NULL, tag_name_id BIGINT NOT NULL, comment TEXT NOT NULL, examiner_id BIGINT, " - "FOREIGN KEY(examiner_id) REFERENCES tsk_examiners(examiner_id), FOREIGN KEY(artifact_id) REFERENCES blackboard_artifacts(artifact_id), FOREIGN KEY(tag_name_id) REFERENCES tag_names(tag_name_id))", - "Error creating blackboard_artifact_tags table: %s\n")){ + "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(6, 'Created', 1);" + "insert into tsk_event_types(event_type_id, display_name, super_type_id) values(7, 'Changed', 1);" + , "Error initializing tsk_event_types table rows: %s\n") || + attempt_exec( + "CREATE TABLE tsk_event_descriptions ( " + " event_description_id BIGSERIAL PRIMARY KEY, " + " full_description TEXT NOT NULL, " + " med_description TEXT, " + " short_description TEXT," + " data_source_obj_id BIGINT NOT NULL, " + " file_obj_id BIGINT NOT NULL, " + " artifact_id BIGINT, " + " hash_hit INTEGER NOT NULL, " //boolean + " tagged INTEGER NOT NULL, " //boolean + " FOREIGN KEY(data_source_obj_id) REFERENCES data_source_info(obj_id), " + " FOREIGN KEY(file_obj_id) REFERENCES tsk_files(obj_id), " + " FOREIGN KEY(artifact_id) REFERENCES blackboard_artifacts(artifact_id))", + "Error creating tsk_event_descriptions table: %s\n") + || + attempt_exec( + "CREATE TABLE tsk_events (" + " event_id BIGSERIAL PRIMARY KEY, " + " event_type_id BIGINT NOT NULL REFERENCES tsk_event_types(event_type_id) ," + " event_description_id BIGINT NOT NULL REFERENCES tsk_event_descriptions(event_description_id) ," + " time INTEGER NOT NULL) " + , "Error creating tsk_events table: %s\n") + || + attempt_exec + ("CREATE TABLE tsk_examiners (examiner_id BIGSERIAL PRIMARY KEY, login_name TEXT NOT NULL, display_name TEXT, UNIQUE(login_name))", + "Error creating tsk_examiners table: %s\n") + || + attempt_exec + ("CREATE TABLE content_tags (tag_id BIGSERIAL PRIMARY KEY, obj_id BIGINT NOT NULL, tag_name_id BIGINT NOT NULL, comment TEXT NOT NULL, begin_byte_offset BIGINT NOT NULL, end_byte_offset BIGINT NOT NULL, examiner_id BIGINT, " + "FOREIGN KEY(examiner_id) REFERENCES tsk_examiners(examiner_id), FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id), FOREIGN KEY(tag_name_id) REFERENCES tag_names(tag_name_id))", + "Error creating content_tags table: %s\n") + || + attempt_exec + ("CREATE TABLE blackboard_artifact_tags (tag_id BIGSERIAL PRIMARY KEY, artifact_id BIGINT NOT NULL, tag_name_id BIGINT NOT NULL, comment TEXT NOT NULL, examiner_id BIGINT, " + "FOREIGN KEY(examiner_id) REFERENCES tsk_examiners(examiner_id), FOREIGN KEY(artifact_id) REFERENCES blackboard_artifacts(artifact_id), FOREIGN KEY(tag_name_id) REFERENCES tag_names(tag_name_id))", + "Error creating blackboard_artifact_tags table: %s\n")){ return 1; }