Merge pull request #7294 from kellykelly3/8037-fixed-os-account-content-panel

8037 - OS account panel will not list all hosts
This commit is contained in:
Richard Cordovano 2021-09-29 17:10:56 -04:00 committed by GitHub
commit d81e89b402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,8 +140,12 @@ public class OsAccountDataPanel extends JPanel {
String key = rowData.getKey(); String key = rowData.getKey();
String value = rowData.getValue(); String value = rowData.getValue();
addPropertyName(key, rowCnt); if(value != null) {
addPropertyValue(value, rowCnt++); addPropertyName(key, rowCnt);
addPropertyValue(value, rowCnt++);
} else {
addLabel(key, rowCnt++);
}
} }
} }
@ -240,24 +244,28 @@ public class OsAccountDataPanel extends JPanel {
}) })
private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) { private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) {
SectionData data = new SectionData(Bundle.OsAccountDataPanel_host_section_title(host.getName())); SectionData data = new SectionData(Bundle.OsAccountDataPanel_host_section_title(host.getName()));
for (OsAccountAttribute attribute : attributeList) { if(attributeList != null) {
String displayName = attribute.getAttributeType().getDisplayName(); for (OsAccountAttribute attribute : attributeList) {
String value = attribute.getDisplayString(); String displayName = attribute.getAttributeType().getDisplayName();
String value = attribute.getDisplayString();
if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COUNT.getTypeID()) { if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COUNT.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_host_count_title(); displayName = Bundle.OsAccountDataPanel_host_count_title();
} else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_IS_ADMIN.getTypeID()) { } else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_IS_ADMIN.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_administrator_title(); displayName = Bundle.OsAccountDataPanel_administrator_title();
if(attribute.getValueInt() == 0) { if(attribute.getValueInt() == 0) {
value = "False"; value = "False";
} else { } else {
value = "True"; value = "True";
}
} else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_data_accessed_title();
} }
} else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_data_accessed_title();
}
data.addData(displayName, value); data.addData(displayName, value);
}
} else {
data.addData("No details available", null);
} }
return data; return data;
@ -287,6 +295,18 @@ public class OsAccountDataPanel extends JPanel {
add(label, getPropertyNameContraints(row)); add(label, getPropertyNameContraints(row));
} }
/**
* Adds a simple label to the given row.
*
* @param text The text to show.
* @param row The row in the layout.
*/
private void addLabel(String text, int row) {
JLabel label = new JLabel(text);
add(label, getPropertyNameContraints(row));
addPropertyValue("", row);
}
/** /**
* Add the property value at the given row in the layout. * Add the property value at the given row in the layout.
* *
@ -402,52 +422,49 @@ public class OsAccountDataPanel extends JPanel {
List<Host> hosts = osAccountManager.getHosts(account); List<Host> hosts = osAccountManager.getHosts(account);
List<OsAccountAttribute> attributeList = account.getExtendedOsAccountAttributes(); List<OsAccountAttribute> attributeList = account.getExtendedOsAccountAttributes();
// Organize the attributes by hostId
Map<Long, List<OsAccountAttribute>> idMap = new HashMap<>();
if (attributeList != null) { if (attributeList != null) {
if (hosts != null) { for (OsAccountAttribute attribute : attributeList) {
// Organize the attributes by hostId List<OsAccountAttribute> atList = null;
Map<Long, List<OsAccountAttribute>> idMap = new HashMap<>(); Optional<Long> optionalId = attribute.getHostId();
for (OsAccountAttribute attribute : attributeList) { Long key = null;
List<OsAccountAttribute> atList = null; if (optionalId.isPresent()) {
Optional<Long> optionalId = attribute.getHostId(); key = optionalId.get();
Long key = null;
if (optionalId.isPresent()) {
key = optionalId.get();
}
atList = idMap.get(key);
if (atList == null) {
atList = new ArrayList<>();
idMap.put(key, atList);
}
atList.add(attribute);
} }
// Add attribute lists to the hostMap atList = idMap.get(key);
for (Host host : hosts) {
List<OsAccountAttribute> atList = idMap.get(host.getHostId());
if (atList != null) {
hostMap.put(host, atList);
}
} if (atList == null) {
List<OsAccountAttribute> atList = idMap.get(null); atList = new ArrayList<>();
if (atList != null) { idMap.put(key, atList);
hostMap.put(null, atList);
} }
// Store both the host and the dataSource so that we get atList.add(attribute);
// all of the calls to the db done in the thread.
for (OsAccountInstance instance : account.getOsAccountInstances()) {
instanceMap.put(instance.getDataSource().getHost(), instance.getDataSource());
}
} else {
hostMap.put(null, attributeList);
} }
} }
// Add attribute lists to the hostMap
if (hosts != null) {
for (Host host : hosts) {
List<OsAccountAttribute> atList = idMap.get(host.getHostId());
hostMap.put(host, atList);
}
} else {
hostMap.put(null, attributeList);
}
List<OsAccountAttribute> atList = idMap.get(null);
if (atList != null) {
hostMap.put(null, atList);
}
// Store both the host and the dataSource so that we get
// all of the calls to the db done in the thread.
for (OsAccountInstance instance : account.getOsAccountInstances()) {
instanceMap.put(instance.getDataSource().getHost(), instance.getDataSource());
}
return new WorkerResults(hostMap, instanceMap, realm); return new WorkerResults(hostMap, instanceMap, realm);
} }