From 4303329f1f0f3428255961a92d36f1438d8afa17 Mon Sep 17 00:00:00 2001 From: Raman Arora Date: Fri, 3 Apr 2020 15:04:08 -0400 Subject: [PATCH 1/2] 6229: SEVERE errors from CR failing to handle custom account types --- .../datamodel/CorrelationAttributeUtil.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java index 14724fafb7..ea295c35d4 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java @@ -215,7 +215,14 @@ public class CorrelationAttributeUtil { if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) == false) { // Get the corresponding CentralRepoAccountType from the database. - CentralRepoAccountType crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); + CentralRepoAccountType crAccountType; + try { + // @@TODO Vik-6136: CR currently does not know of custom account types. + // This try/catch prevents unnecessary exceptions, till CR handles implement custom account types + crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); + } catch (CentralRepoException ex) { + return; + } int corrTypeId = crAccountType.getCorrelationTypeId(); CorrelationAttributeInstance.Type corrType = CentralRepository.getInstance().getCorrelationTypeById(corrTypeId); From 27cd407d8676a90df77d9b85d5addc7459bc7159 Mon Sep 17 00:00:00 2001 From: Raman Arora Date: Mon, 6 Apr 2020 09:26:28 -0400 Subject: [PATCH 2/2] Search incoming account in the Account.PREDEFINED_ACCOUNT_TYPES list. --- .../datamodel/CorrelationAttributeUtil.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java index ea295c35d4..e5b0d7ab50 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java @@ -211,18 +211,15 @@ public class CorrelationAttributeUtil { BlackboardAttribute accountTypeAttribute = acctArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE)); String accountTypeStr = accountTypeAttribute.getValueString(); + // @@TODO Vik-6136: CR currently does not know of custom account types. + // Ensure there is a predefined account type for this account. + Account.Type predefinedAccountType = Account.Type.PREDEFINED_ACCOUNT_TYPES.stream().filter(type -> type.getTypeName().equalsIgnoreCase(accountTypeStr)).findAny().orElse(null); + // do not create any correlation attribute instance for a Device account - if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) == false) { + if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) == false && predefinedAccountType != null) { // Get the corresponding CentralRepoAccountType from the database. - CentralRepoAccountType crAccountType; - try { - // @@TODO Vik-6136: CR currently does not know of custom account types. - // This try/catch prevents unnecessary exceptions, till CR handles implement custom account types - crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); - } catch (CentralRepoException ex) { - return; - } + CentralRepoAccountType crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); int corrTypeId = crAccountType.getCorrelationTypeId(); CorrelationAttributeInstance.Type corrType = CentralRepository.getInstance().getCorrelationTypeById(corrTypeId);