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
5313b36c
Unverified
Commit
5313b36c
authored
4 years ago
by
Richard Cordovano
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2265 from jayaramcs/develop
OsAccount Add attribute event bug fix
parents
d5d60558
fbec6ff6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
+8
-12
8 additions, 12 deletions
bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java
+58
-55
58 additions, 55 deletions
...gs/java/src/org/sleuthkit/datamodel/OsAccountManager.java
with
66 additions
and
67 deletions
bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
+
8
−
12
View file @
5313b36c
...
@@ -64,6 +64,7 @@ public final class OsAccount extends AbstractContent {
...
@@ -64,6 +64,7 @@ public final class OsAccount extends AbstractContent {
private
boolean
isDirty
=
false
;
// indicates that some member value has changed since construction and it should be updated in the database.
private
boolean
isDirty
=
false
;
// indicates that some member value has changed since construction and it should be updated in the database.
/**
/**
* Encapsulates status of an account - whether is it active or disabled or
* Encapsulates status of an account - whether is it active or disabled or
* deleted.
* deleted.
...
@@ -371,18 +372,13 @@ void resetDirty() {
...
@@ -371,18 +372,13 @@ void resetDirty() {
}
}
/**
/**
* Adds account attributes to the account. Attributes can be at a host-level
* This function is used by OsAccountManger to update the list of
* or domain-level (for domain-scoped accounts).
* OsAccount attributes.
*
*
* @param osAccountAttributes List of attributes to add.
* @param osAccountAttribute The osAccount Attribute that is to be added.
*
* @throws TskCoreException
*
* @throws org.sleuthkit.datamodel.TskCoreException
*/
*/
public
void
addAttributes
(
List
<
OsAccountAttribute
>
osAccountAttributes
)
throws
TskCoreException
{
void
setAttributesInternal
(
List
<
OsAccountAttribute
>
osAccountAttributes
)
{
sleuthkitCase
.
getOsAccountManager
().
addOsAccountAttributes
(
this
,
osAccountAttributes
);
this
.
osAccountAttributes
=
osAccountAttributes
;
osAccountAttributes
.
addAll
(
osAccountAttributes
);
}
}
/**
/**
...
@@ -485,7 +481,7 @@ public OsAccountDbStatus getOsAccountDbStatus() {
...
@@ -485,7 +481,7 @@ public OsAccountDbStatus getOsAccountDbStatus() {
*
*
* @throws TskCoreException
* @throws TskCoreException
*/
*/
public
List
<
OsAccountAttribute
>
getOsAccountAttributes
()
throws
TskCoreException
{
public
synchronized
List
<
OsAccountAttribute
>
getOsAccountAttributes
()
throws
TskCoreException
{
if
(
osAccountAttributes
==
null
)
{
if
(
osAccountAttributes
==
null
)
{
osAccountAttributes
=
sleuthkitCase
.
getOsAccountManager
().
getOsAccountAttributes
(
this
);
osAccountAttributes
=
sleuthkitCase
.
getOsAccountManager
().
getOsAccountAttributes
(
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java
+
58
−
55
View file @
5313b36c
...
@@ -964,74 +964,77 @@ public Optional<OsAccount> getWindowsOsAccount(String sid, String loginName, Str
...
@@ -964,74 +964,77 @@ public Optional<OsAccount> getWindowsOsAccount(String sid, String loginName, Str
*
*
* @throws TskCoreException,
* @throws TskCoreException,
*/
*/
void
addOsAccountAttributes
(
OsAccount
account
,
List
<
OsAccountAttribute
>
accountAttributes
)
throws
TskCoreException
{
public
void
addOsAccountAttributes
(
OsAccount
account
,
List
<
OsAccountAttribute
>
accountAttributes
)
throws
TskCoreException
{
synchronized
(
account
)
{
// synchronized to prevent multiple threads trying to add osAccount attributes concurrently to the same osAccount.
db
.
acquireSingleUserCaseWriteLock
();
db
.
acquireSingleUserCaseWriteLock
();
try
(
CaseDbConnection
connection
=
db
.
getConnection
())
{
for
(
OsAccountAttribute
accountAttribute
:
accountAttributes
)
{
try
(
CaseDbConnection
connection
=
db
.
getConnection
())
{
String
attributeInsertSQL
=
"INSERT INTO tsk_os_account_attributes(os_account_obj_id, host_id, source_obj_id, attribute_type_id, value_type, value_byte, value_text, value_int32, value_int64, value_double)"
for
(
OsAccountAttribute
accountAttribute
:
accountAttributes
)
{
+
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
;
// NON-NLS
String
attributeInsertSQL
=
"INSERT INTO tsk_os_account_attributes(os_account_obj_id, host_id, source_obj_id, attribute_type_id, value_type, value_byte, value_text, value_int32, value_int64, value_double)"
PreparedStatement
preparedStatement
=
connection
.
getPreparedStatement
(
attributeInsertSQL
,
Statement
.
RETURN_GENERATED_KEYS
);
+
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
;
// NON-NLS
preparedStatement
.
clearParameters
();
PreparedStatement
preparedStatement
=
connection
.
getPreparedStatement
(
attributeInsertSQL
,
Statement
.
RETURN_GENERATED_KEYS
);
preparedStatement
.
setLong
(
1
,
account
.
getId
());
preparedStatement
.
clearParameters
();
if
(
accountAttribute
.
getHostId
().
isPresent
())
{
preparedStatement
.
setLong
(
2
,
accountAttribute
.
getHostId
().
get
());
}
else
{
preparedStatement
.
setNull
(
2
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getSourceObjectId
().
isPresent
())
{
preparedStatement
.
setLong
(
3
,
accountAttribute
.
getSourceObjectId
().
get
());
}
else
{
preparedStatement
.
setNull
(
3
,
java
.
sql
.
Types
.
NULL
);
}
preparedStatement
.
setLong
(
1
,
account
.
getId
());
preparedStatement
.
setLong
(
4
,
accountAttribute
.
getAttributeType
().
getTypeID
());
if
(
accountAttribute
.
getHostId
().
isPresent
())
{
preparedStatement
.
setLong
(
5
,
accountAttribute
.
getAttributeType
().
getValueType
().
getType
());
preparedStatement
.
setLong
(
2
,
accountAttribute
.
getHostId
().
get
());
}
else
{
preparedStatement
.
setNull
(
2
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getSourceObjectId
().
isPresent
())
{
preparedStatement
.
setLong
(
3
,
accountAttribute
.
getSourceObjectId
().
get
());
}
else
{
preparedStatement
.
setNull
(
3
,
java
.
sql
.
Types
.
NULL
);
}
preparedStatement
.
setLong
(
4
,
accountAttribute
.
getAttributeType
().
getTypeID
());
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
BYTE
)
{
preparedStatement
.
setLong
(
5
,
accountAttribute
.
getAttributeType
().
getValueType
().
getType
());
preparedStatement
.
setBytes
(
6
,
accountAttribute
.
getValueBytes
());
}
else
{
preparedStatement
.
setBytes
(
6
,
null
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
BYTE
)
{
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
STRING
preparedStatement
.
setBytes
(
6
,
accountAttribute
.
getValueBytes
());
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
JSON
)
{
}
else
{
preparedStatement
.
setString
(
7
,
accountAttribute
.
getValueString
());
preparedStatement
.
setBytes
(
6
,
null
);
}
else
{
}
preparedStatement
.
setString
(
7
,
null
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
INTEGER
)
{
preparedStatement
.
setInt
(
8
,
accountAttribute
.
getValueInt
());
}
else
{
preparedStatement
.
setNull
(
8
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
STRING
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DATETIME
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
JSON
)
{
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
LONG
)
{
preparedStatement
.
setString
(
7
,
accountAttribute
.
getValueString
());
preparedStatement
.
setLong
(
9
,
accountAttribute
.
getValueLong
());
}
else
{
}
else
{
preparedStatement
.
setString
(
7
,
null
);
preparedStatement
.
setNull
(
9
,
java
.
sql
.
Types
.
NULL
);
}
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
INTEGER
)
{
preparedStatement
.
setInt
(
8
,
accountAttribute
.
getValueInt
());
}
else
{
preparedStatement
.
setNull
(
8
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DATETIME
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DOUBLE
)
{
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
LONG
)
{
preparedStatement
.
setDouble
(
10
,
accountAttribute
.
getValueDouble
());
preparedStatement
.
setLong
(
9
,
accountAttribute
.
getValueLong
());
}
else
{
}
else
{
preparedStatement
.
setNull
(
10
,
java
.
sql
.
Types
.
NULL
);
preparedStatement
.
setNull
(
9
,
java
.
sql
.
Types
.
NULL
);
}
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DOUBLE
)
{
connection
.
executeUpdate
(
preparedStatement
);
preparedStatement
.
setDouble
(
10
,
accountAttribute
.
getValueDouble
());
}
else
{
preparedStatement
.
setNull
(
10
,
java
.
sql
.
Types
.
NULL
);
}
}
}
catch
(
SQLException
ex
)
{
connection
.
executeUpdate
(
preparedStatement
);
throw
new
TskCoreException
(
String
.
format
(
"Error adding OS Account attribute for account id = %d"
,
account
.
getId
()),
ex
);
}
finally
{
db
.
releaseSingleUserCaseWriteLock
();
}
}
}
catch
(
SQLException
ex
)
{
List
<
OsAccountAttribute
>
currentAttribsList
=
getOsAccountAttributes
(
account
);
throw
new
TskCoreException
(
String
.
format
(
"Error adding OS Account attribute for account id = %d"
,
account
.
getId
()),
ex
);
currentAttribsList
.
addAll
(
accountAttributes
);
}
finally
{
account
.
setAttributesInternal
(
currentAttribsList
);
db
.
releaseSingleUserCaseWriteLock
();
}
}
fireChangeEvent
(
account
);
fireChangeEvent
(
account
);
}
}
...
...
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