mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #7399 from gdicristofaro/8144-communicationsCounts
8144 communication counts
This commit is contained in:
commit
4884247552
@ -267,30 +267,32 @@ final public class Accounts implements AutopsyVisitableItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected long fetchChildCount(SleuthkitCase skCase) throws TskCoreException {
|
protected long fetchChildCount(SleuthkitCase skCase) throws TskCoreException {
|
||||||
long count = 0;
|
|
||||||
String dataSourceFilterClause = (filteringDSObjId > 0)
|
|
||||||
? " AND " + filteringDSObjId + " IN (SELECT art.data_source_obj_id FROM blackboard_artifacts art WHERE art.artifact_id = attr.artifact_id)"
|
|
||||||
: "";
|
|
||||||
|
|
||||||
String accountTypesInUseQuery
|
String accountTypesInUseQuery
|
||||||
= "SELECT COUNT(attr.value_text) AS count"
|
= "SELECT COUNT(*) AS count\n"
|
||||||
+ " FROM blackboard_attributes attr"
|
+ "FROM (\n"
|
||||||
+ " WHERE attr.attribute_type_id = " + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE.getTypeID()
|
+ " SELECT MIN(blackboard_attributes.value_text) AS account_type\n"
|
||||||
+ " AND attr.artifact_type_id = " + BlackboardArtifact.Type.TSK_ACCOUNT.getTypeID()
|
+ " FROM blackboard_artifacts\n"
|
||||||
+ dataSourceFilterClause
|
+ " LEFT JOIN blackboard_attributes ON blackboard_artifacts.artifact_id = blackboard_attributes.artifact_id\n"
|
||||||
+ " GROUP BY attr.value_text";
|
+ " WHERE blackboard_artifacts.artifact_type_id = " + TSK_ACCOUNT.getTypeID() + "\n"
|
||||||
|
+ " AND blackboard_attributes.attribute_type_id = " + BlackboardAttribute.Type.TSK_ACCOUNT_TYPE.getTypeID() + "\n"
|
||||||
|
+ " AND blackboard_attributes.value_text IS NOT NULL\n"
|
||||||
|
+ getFilterByDataSourceClause() + "\n"
|
||||||
|
+ " -- group by artifact_id to ensure only one account type per artifact\n"
|
||||||
|
+ " GROUP BY blackboard_artifacts.artifact_id\n"
|
||||||
|
+ ") res\n";
|
||||||
|
|
||||||
try (SleuthkitCase.CaseDbQuery executeQuery = skCase.executeQuery(accountTypesInUseQuery);
|
try (SleuthkitCase.CaseDbQuery executeQuery = skCase.executeQuery(accountTypesInUseQuery);
|
||||||
ResultSet resultSet = executeQuery.getResultSet()) {
|
ResultSet resultSet = executeQuery.getResultSet()) {
|
||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
count = resultSet.getLong("count");
|
return resultSet.getLong("count");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (TskCoreException | SQLException ex) {
|
} catch (TskCoreException | SQLException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error querying for count of all account types", ex);
|
LOGGER.log(Level.SEVERE, "Error querying for count of all account types", ex);
|
||||||
}
|
}
|
||||||
return count;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -334,13 +336,18 @@ final public class Accounts implements AutopsyVisitableItem {
|
|||||||
*/
|
*/
|
||||||
private void update() {
|
private void update() {
|
||||||
String accountTypesInUseQuery
|
String accountTypesInUseQuery
|
||||||
= "SELECT blackboard_attributes.value_text as account_type, COUNT(*) as count "
|
= "SELECT res.account_type, COUNT(*) AS count\n"
|
||||||
+ " FROM blackboard_artifacts " //NON-NLS
|
+ "FROM (\n"
|
||||||
+ " JOIN blackboard_attributes ON blackboard_artifacts.artifact_id = blackboard_attributes.artifact_id " //NON-NLS
|
+ " SELECT MIN(blackboard_attributes.value_text) AS account_type\n"
|
||||||
+ " WHERE blackboard_artifacts.artifact_type_id = " + TSK_ACCOUNT.getTypeID() //NON-NLS
|
+ " FROM blackboard_artifacts\n"
|
||||||
+ " AND blackboard_attributes.attribute_type_id = " + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE.getTypeID() //NON-NLS
|
+ " LEFT JOIN blackboard_attributes ON blackboard_artifacts.artifact_id = blackboard_attributes.artifact_id\n"
|
||||||
+ getFilterByDataSourceClause()
|
+ " WHERE blackboard_artifacts.artifact_type_id = " + TSK_ACCOUNT.getTypeID() + "\n"
|
||||||
+ " GROUP BY blackboard_attributes.value_text ";
|
+ " AND blackboard_attributes.attribute_type_id = " + BlackboardAttribute.Type.TSK_ACCOUNT_TYPE.getTypeID() + "\n"
|
||||||
|
+ getFilterByDataSourceClause() + "\n"
|
||||||
|
+ " -- group by artifact_id to ensure only one account type per artifact\n"
|
||||||
|
+ " GROUP BY blackboard_artifacts.artifact_id\n"
|
||||||
|
+ ") res\n"
|
||||||
|
+ "GROUP BY res.account_type";
|
||||||
|
|
||||||
try (SleuthkitCase.CaseDbQuery executeQuery = skCase.executeQuery(accountTypesInUseQuery);
|
try (SleuthkitCase.CaseDbQuery executeQuery = skCase.executeQuery(accountTypesInUseQuery);
|
||||||
ResultSet resultSet = executeQuery.getResultSet()) {
|
ResultSet resultSet = executeQuery.getResultSet()) {
|
||||||
@ -404,6 +411,7 @@ final public class Accounts implements AutopsyVisitableItem {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
Case.getCurrentCaseThrows();
|
Case.getCurrentCaseThrows();
|
||||||
|
accountTypeResults.update();
|
||||||
refresh(true);
|
refresh(true);
|
||||||
} catch (NoCurrentCaseException notUsed) {
|
} catch (NoCurrentCaseException notUsed) {
|
||||||
// Case is closed, do nothing.
|
// Case is closed, do nothing.
|
||||||
@ -1466,7 +1474,7 @@ final public class Accounts implements AutopsyVisitableItem {
|
|||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean context) {
|
public Action[] getActions(boolean context) {
|
||||||
Action[] actions = super.getActions(context);
|
Action[] actions = super.getActions(context);
|
||||||
ArrayList<Action> arrayList = new ArrayList<>();
|
ArrayList<Action> arrayList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
arrayList.addAll(DataModelActionsFactory.getActions(Accounts.this.skCase.getContentById(fileKey.getObjID()), false));
|
arrayList.addAll(DataModelActionsFactory.getActions(Accounts.this.skCase.getContentById(fileKey.getObjID()), false));
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user