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
No related branches found
No related tags found
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 {
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
* deleted.
...
...
@@ -371,18 +372,13 @@ void resetDirty() {
}
/**
* Adds account attributes to the account. Attributes can be at a host-level
* or domain-level (for domain-scoped accounts).
*
* @param osAccountAttributes List of attributes to add.
*
* @throws TskCoreException
*
* @throws org.sleuthkit.datamodel.TskCoreException
* This function is used by OsAccountManger to update the list of
* OsAccount attributes.
*
* @param osAccountAttribute The osAccount Attribute that is to be added.
*/
public
void
addAttributes
(
List
<
OsAccountAttribute
>
osAccountAttributes
)
throws
TskCoreException
{
sleuthkitCase
.
getOsAccountManager
().
addOsAccountAttributes
(
this
,
osAccountAttributes
);
osAccountAttributes
.
addAll
(
osAccountAttributes
);
void
setAttributesInternal
(
List
<
OsAccountAttribute
>
osAccountAttributes
)
{
this
.
osAccountAttributes
=
osAccountAttributes
;
}
/**
...
...
@@ -485,7 +481,7 @@ public OsAccountDbStatus getOsAccountDbStatus() {
*
* @throws TskCoreException
*/
public
List
<
OsAccountAttribute
>
getOsAccountAttributes
()
throws
TskCoreException
{
public
synchronized
List
<
OsAccountAttribute
>
getOsAccountAttributes
()
throws
TskCoreException
{
if
(
osAccountAttributes
==
null
)
{
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
*
* @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
())
{
for
(
OsAccountAttribute
accountAttribute
:
accountAttributes
)
{
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)"
+
" 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)"
+
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
;
// NON-NLS
PreparedStatement
preparedStatement
=
connection
.
getPreparedStatement
(
attributeInsertSQL
,
Statement
.
RETURN_GENERATED_KEYS
);
preparedStatement
.
clearParameters
();
PreparedStatement
preparedStatement
=
connection
.
getPreparedStatement
(
attributeInsertSQL
,
Statement
.
RETURN_GENERATED_KEYS
);
preparedStatement
.
clearParameters
();
preparedStatement
.
setLong
(
1
,
account
.
getId
());
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
());
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
(
4
,
accountAttribute
.
getAttributeType
().
getTypeID
());
preparedStatement
.
setLong
(
5
,
accountAttribute
.
getAttributeType
().
getValueType
().
getType
());
preparedStatement
.
setLong
(
4
,
accountAttribute
.
getAttributeType
().
getTypeID
());
preparedStatement
.
setLong
(
5
,
accountAttribute
.
getAttributeType
().
getValueType
().
getType
());
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
BYTE
)
{
preparedStatement
.
setBytes
(
6
,
accountAttribute
.
getValueBytes
());
}
else
{
preparedStatement
.
setBytes
(
6
,
null
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
BYTE
)
{
preparedStatement
.
setBytes
(
6
,
accountAttribute
.
getValueBytes
());
}
else
{
preparedStatement
.
setBytes
(
6
,
null
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
STRING
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
JSON
)
{
preparedStatement
.
setString
(
7
,
accountAttribute
.
getValueString
());
}
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
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
JSON
)
{
preparedStatement
.
setString
(
7
,
accountAttribute
.
getValueString
());
}
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
.
DATETIME
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
LONG
)
{
preparedStatement
.
setLong
(
9
,
accountAttribute
.
getValueLong
());
}
else
{
preparedStatement
.
setNull
(
9
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DATETIME
||
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
LONG
)
{
preparedStatement
.
setLong
(
9
,
accountAttribute
.
getValueLong
());
}
else
{
preparedStatement
.
setNull
(
9
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DOUBLE
)
{
preparedStatement
.
setDouble
(
10
,
accountAttribute
.
getValueDouble
());
}
else
{
preparedStatement
.
setNull
(
10
,
java
.
sql
.
Types
.
NULL
);
}
if
(
accountAttribute
.
getAttributeType
().
getValueType
()
==
TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE
.
DOUBLE
)
{
preparedStatement
.
setDouble
(
10
,
accountAttribute
.
getValueDouble
());
}
else
{
preparedStatement
.
setNull
(
10
,
java
.
sql
.
Types
.
NULL
);
connection
.
executeUpdate
(
preparedStatement
);
}
connection
.
executeUpdate
(
preparedStatement
);
}
catch
(
SQLException
ex
)
{
throw
new
TskCoreException
(
String
.
format
(
"Error adding OS Account attribute for account id = %d"
,
account
.
getId
()),
ex
);
}
finally
{
db
.
releaseSingleUserCaseWriteLock
();
}
}
catch
(
SQLException
ex
)
{
throw
new
TskCoreException
(
String
.
format
(
"Error adding OS Account attribute for account id = %d"
,
account
.
getId
()),
ex
);
}
finally
{
db
.
releaseSingleUserCaseWriteLock
();
List
<
OsAccountAttribute
>
currentAttribsList
=
getOsAccountAttributes
(
account
);
currentAttribsList
.
addAll
(
accountAttributes
);
account
.
setAttributesInternal
(
currentAttribsList
);
}
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