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
bed5ba4c
Unverified
Commit
bed5ba4c
authored
4 years ago
by
Richard Cordovano
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2157 from APriestman/fixAccountTableCreationOrder
Fix ordering of table creation
parents
a470c805
f3fc9fc8
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/CaseDatabaseFactory.java
+20
-2
20 additions, 2 deletions
...java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java
with
20 additions
and
2 deletions
bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java
+
20
−
2
View file @
bed5ba4c
...
...
@@ -145,24 +145,30 @@ private void addDbInfo(Connection conn) throws TskCoreException {
*/
private
void
addTables
(
Connection
conn
)
throws
TskCoreException
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
createTskObjects
(
stmt
);
createHostTables
(
stmt
);
createAccountTables
(
stmt
);
createFileTables
(
stmt
);
createArtifactTables
(
stmt
);
createAnalysisResultsTables
(
stmt
);
createTagTables
(
stmt
);
createIngestTables
(
stmt
);
createAccountTables
(
stmt
);
createEventTables
(
stmt
);
createAttributeTables
(
stmt
);
createAccountInstancesAndArtifacts
(
stmt
);
}
catch
(
SQLException
ex
)
{
throw
new
TskCoreException
(
"Error initializing tables"
,
ex
);
}
}
private
void
createFileTables
(
Statement
stmt
)
throws
SQLException
{
// tsk_objects is referenced by many other tables and should be created first
private
void
createTskObjects
(
Statement
stmt
)
throws
SQLException
{
// The UNIQUE here on the object ID is to create an index
stmt
.
execute
(
"CREATE TABLE tsk_objects (obj_id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, par_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
", type INTEGER NOT NULL, UNIQUE (obj_id), FOREIGN KEY (par_obj_id) REFERENCES tsk_objects (obj_id) ON DELETE CASCADE)"
);
}
private
void
createFileTables
(
Statement
stmt
)
throws
SQLException
{
stmt
.
execute
(
"CREATE TABLE tsk_image_info (obj_id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, type INTEGER, ssize INTEGER, "
+
"tzone TEXT, size "
+
dbQueryHelper
.
getBigIntType
()
+
", md5 TEXT, sha1 TEXT, sha256 TEXT, display_name TEXT, "
...
...
@@ -405,15 +411,18 @@ private void createHostTables(Statement stmt) throws SQLException {
}
// Must be called after tsk_hosts and tsk_objects have been created.
private
void
createAccountTables
(
Statement
stmt
)
throws
SQLException
{
stmt
.
execute
(
"CREATE TABLE account_types (account_type_id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"type_name TEXT UNIQUE NOT NULL, display_name TEXT NOT NULL)"
);
// References account_types
stmt
.
execute
(
"CREATE TABLE accounts (account_id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"account_type_id INTEGER NOT NULL, account_unique_identifier TEXT NOT NULL, "
+
"UNIQUE(account_type_id, account_unique_identifier), "
+
"FOREIGN KEY(account_type_id) REFERENCES account_types(account_type_id))"
);
// References accounts, tsk_objects
stmt
.
execute
(
"CREATE TABLE account_relationships (relationship_id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"account1_id INTEGER NOT NULL, account2_id INTEGER NOT NULL, "
+
"relationship_source_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" NOT NULL, "
...
...
@@ -425,6 +434,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+
"FOREIGN KEY(relationship_source_obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE, "
+
"FOREIGN KEY(data_source_obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE)"
);
// References tsk_hosts
stmt
.
execute
(
"CREATE TABLE tsk_os_account_realms (id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"name TEXT NOT NULL, "
// realm name - host name or domain name
+
"realm_addr TEXT DEFAULT NULL, "
// a sid/uid or some some other identifier, may be null
...
...
@@ -433,6 +443,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+
"UNIQUE(name, host_id), "
+
"FOREIGN KEY(host_id) REFERENCES tsk_hosts(id) )"
);
// References tsk_objects, tsk_os_account_realms
stmt
.
execute
(
"CREATE TABLE tsk_os_accounts (os_account_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" PRIMARY KEY, "
+
"login_name TEXT DEFAULT NULL, "
// login name, if available, may be null
+
"full_name TEXT DEFAULT NULL, "
// full name, if available, may be null
...
...
@@ -447,6 +458,11 @@ private void createAccountTables(Statement stmt) throws SQLException {
+
"FOREIGN KEY(os_account_obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE, "
+
"FOREIGN KEY(realm_id) REFERENCES tsk_os_account_realms(id) )"
);
}
// Must be called after createAccountTables() and blackboard_attribute_types, blackboard_artifacts creation.
private
void
createAccountInstancesAndArtifacts
(
Statement
stmt
)
throws
SQLException
{
// References tsk_os_accounts, tsk_hosts, tsk_objects, blackboard_attribute_types
stmt
.
execute
(
"CREATE TABLE tsk_os_account_attributes (id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"os_account_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" NOT NULL, "
+
"host_id "
+
dbQueryHelper
.
getBigIntType
()
+
", "
...
...
@@ -462,6 +478,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+
"FOREIGN KEY(source_obj_id) REFERENCES tsk_objects(obj_id), "
+
"FOREIGN KEY(attribute_type_id) REFERENCES blackboard_attribute_types(attribute_type_id))"
);
// References tsk_os_accounts, tsk_objects, tsk_hosts
stmt
.
execute
(
"CREATE TABLE tsk_os_account_instances (id "
+
dbQueryHelper
.
getPrimaryKey
()
+
" PRIMARY KEY, "
+
"os_account_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" NOT NULL, "
+
"data_source_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" NOT NULL, "
...
...
@@ -472,6 +489,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+
"FOREIGN KEY(data_source_obj_id) REFERENCES tsk_objects(obj_id), "
+
"FOREIGN KEY(host_id) REFERENCES tsk_hosts(id))"
);
// References blackboard_artifacts, tsk_os_accounts
stmt
.
execute
(
"CREATE TABLE tsk_data_artifacts ( "
+
"artifact_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
" PRIMARY KEY, "
+
"os_account_obj_id "
+
dbQueryHelper
.
getBigIntType
()
+
", "
...
...
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