Merge pull request #7378 from rcordovano/develop

7673 source code file reformatting
This commit is contained in:
Richard Cordovano 2021-10-25 09:24:56 -04:00 committed by GitHub
commit 003fdda95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 68 deletions

View File

@ -188,7 +188,7 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
switch (xryKey) { switch (xryKey) {
case TEL: case TEL:
case NUMBER: case NUMBER:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
@ -206,14 +206,14 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
// Although confusing, as these are also 'name spaces', it appears // Although confusing, as these are also 'name spaces', it appears
// later versions of XRY just made these standardized lines. // later versions of XRY just made these standardized lines.
case TO: case TO:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
calleeList.add(pair.getValue()); calleeList.add(pair.getValue());
break; break;
case FROM: case FROM:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
@ -221,15 +221,15 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
break; break;
case TIME: case TIME:
try { try {
//Tranform value to seconds since epoch //Tranform value to seconds since epoch
long dateTimeSinceEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); long dateTimeSinceEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue());
startTime = dateTimeSinceEpoch; startTime = dateTimeSinceEpoch;
} catch (DateTimeParseException ex) { } catch (DateTimeParseException ex) {
logger.log(Level.WARNING, String.format("[XRY DSP] Assumption" logger.log(Level.WARNING, String.format("[XRY DSP] Assumption"
+ " about the date time formatting of call logs is " + " about the date time formatting of call logs is "
+ "not right. Here is the value [ %s ]", pair.getValue()), ex); + "not right. Here is the value [ %s ]", pair.getValue()), ex);
} }
break; break;
case DIRECTION: case DIRECTION:
String directionString = pair.getValue().toLowerCase(); String directionString = pair.getValue().toLowerCase();
if (directionString.equals("incoming")) { if (directionString.equals("incoming")) {
@ -263,7 +263,6 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
// Make sure we have the required fields, otherwise the CommHelper will // Make sure we have the required fields, otherwise the CommHelper will
// complain about illegal arguments. // complain about illegal arguments.
// These are all the invalid combinations. // These are all the invalid combinations.
if (callerId == null && calleeList.isEmpty() if (callerId == null && calleeList.isEmpty()
|| direction == CommunicationDirection.INCOMING && callerId == null || direction == CommunicationDirection.INCOMING && callerId == null
@ -288,10 +287,10 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
// it would have been a valid combination. // it would have been a valid combination.
if (callerId != null) { if (callerId != null) {
try { try {
currentCase.getCommunicationsManager().createAccountFileInstance( currentCase.getCommunicationsManager().createAccountFileInstance(
Account.Type.PHONE, callerId, PARSER_NAME, parent); Account.Type.PHONE, callerId, PARSER_NAME, parent);
} catch (InvalidAccountIDException ex) { } catch (InvalidAccountIDException ex) {
logger.log(Level.WARNING, String.format("Invalid account identifier %s", callerId), ex); logger.log(Level.WARNING, String.format("Invalid account identifier %s", callerId), ex);
} }
otherAttributes.add(new BlackboardAttribute( otherAttributes.add(new BlackboardAttribute(
@ -301,13 +300,12 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser {
for (String phone : calleeList) { for (String phone : calleeList) {
try { try {
currentCase.getCommunicationsManager().createAccountFileInstance( currentCase.getCommunicationsManager().createAccountFileInstance(
Account.Type.PHONE, phone, PARSER_NAME, parent); Account.Type.PHONE, phone, PARSER_NAME, parent);
} catch (InvalidAccountIDException ex) { } catch (InvalidAccountIDException ex) {
logger.log(Level.WARNING, String.format("Invalid account identifier %s", phone), ex); logger.log(Level.WARNING, String.format("Invalid account identifier %s", phone), ex);
} }
otherAttributes.add(new BlackboardAttribute( otherAttributes.add(new BlackboardAttribute(
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER,
PARSER_NAME, phone)); PARSER_NAME, phone));

View File

@ -95,6 +95,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* Indicates if the display name of the XRY key is a recognized type. * Indicates if the display name of the XRY key is a recognized type.
* *
* @param name * @param name
*
* @return * @return
*/ */
public static boolean contains(String name) { public static boolean contains(String name) {
@ -114,6 +115,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* contains() before hand. * contains() before hand.
* *
* @param name * @param name
*
* @return * @return
*/ */
public static XryKey fromDisplayName(String name) { public static XryKey fromDisplayName(String name) {
@ -149,6 +151,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* type. * type.
* *
* @param xryNamespace * @param xryNamespace
*
* @return * @return
*/ */
public static boolean contains(String xryNamespace) { public static boolean contains(String xryNamespace) {
@ -169,6 +172,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* contains() before hand. * contains() before hand.
* *
* @param xryNamespace * @param xryNamespace
*
* @return * @return
*/ */
public static XryNamespace fromDisplayName(String xryNamespace) { public static XryNamespace fromDisplayName(String xryNamespace) {
@ -206,6 +210,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* Indicates if the display name of the XRY key is a recognized type. * Indicates if the display name of the XRY key is a recognized type.
* *
* @param name * @param name
*
* @return * @return
*/ */
public static boolean contains(String name) { public static boolean contains(String name) {
@ -225,6 +230,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
* contains() before hand. * contains() before hand.
* *
* @param name * @param name
*
* @return * @return
*/ */
public static XryMetaKey fromDisplayName(String name) { public static XryMetaKey fromDisplayName(String name) {
@ -253,11 +259,13 @@ final class XRYMessagesFileParser implements XRYFileParser {
* assumption is correct, otherwise an error will appear in the logs. * assumption is correct, otherwise an error will appear in the logs.
* *
* @param reader The XRYFileReader that reads XRY entities from the * @param reader The XRYFileReader that reads XRY entities from the
* Message-SMS report. * Message-SMS report.
* @param parent The parent Content to create artifacts from. * @param parent The parent Content to create artifacts from.
* @throws IOException If an I/O error is encountered during report reading *
* @throws IOException If an I/O error is encountered during report
* reading
* @throws TskCoreException If an error during artifact creation is * @throws TskCoreException If an error during artifact creation is
* encountered. * encountered.
*/ */
@Override @Override
public void parse(XRYFileReader reader, Content parent, SleuthkitCase currentCase) throws IOException, TskCoreException, BlackboardException { public void parse(XRYFileReader reader, Content parent, SleuthkitCase currentCase) throws IOException, TskCoreException, BlackboardException {
@ -287,7 +295,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
final String threadId = null; final String threadId = null;
final Collection<BlackboardAttribute> otherAttributes = new ArrayList<>(); final Collection<BlackboardAttribute> otherAttributes = new ArrayList<>();
for(XRYKeyValuePair pair : pairs) { for (XRYKeyValuePair pair : pairs) {
XryNamespace namespace = XryNamespace.NONE; XryNamespace namespace = XryNamespace.NONE;
if (XryNamespace.contains(pair.getNamespace())) { if (XryNamespace.contains(pair.getNamespace())) {
namespace = XryNamespace.fromDisplayName(pair.getNamespace()); namespace = XryNamespace.fromDisplayName(pair.getNamespace());
@ -298,14 +306,14 @@ final class XRYMessagesFileParser implements XRYFileParser {
switch (key) { switch (key) {
case TEL: case TEL:
case NUMBER: case NUMBER:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
// Apply namespace or direction // Apply namespace or direction
if(namespace == XryNamespace.FROM || direction == CommunicationDirection.INCOMING) { if (namespace == XryNamespace.FROM || direction == CommunicationDirection.INCOMING) {
senderId = pair.getValue(); senderId = pair.getValue();
} else if(namespace == XryNamespace.TO || direction == CommunicationDirection.OUTGOING) { } else if (namespace == XryNamespace.TO || direction == CommunicationDirection.OUTGOING) {
recipientIdsList.add(pair.getValue()); recipientIdsList.add(pair.getValue());
} else { } else {
try { try {
@ -316,21 +324,21 @@ final class XRYMessagesFileParser implements XRYFileParser {
} }
otherAttributes.add(new BlackboardAttribute( otherAttributes.add(new BlackboardAttribute(
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER,
PARSER_NAME, pair.getValue())); PARSER_NAME, pair.getValue()));
} }
break; break;
// Although confusing, as these are also 'name spaces', it appears // Although confusing, as these are also 'name spaces', it appears
// later versions of XRY just made these standardized lines. // later versions of XRY just made these standardized lines.
case FROM: case FROM:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
senderId = pair.getValue(); senderId = pair.getValue();
break; break;
case TO: case TO:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
@ -338,15 +346,15 @@ final class XRYMessagesFileParser implements XRYFileParser {
break; break;
case TIME: case TIME:
try { try {
//Tranform value to seconds since epoch //Tranform value to seconds since epoch
long dateTimeSinceInEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); long dateTimeSinceInEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue());
dateTime = dateTimeSinceInEpoch; dateTime = dateTimeSinceInEpoch;
} catch (DateTimeParseException ex) { } catch (DateTimeParseException ex) {
logger.log(Level.WARNING, String.format("[%s] Assumption" logger.log(Level.WARNING, String.format("[%s] Assumption"
+ " about the date time formatting of messages is " + " about the date time formatting of messages is "
+ "not right. Here is the pair [ %s ]", PARSER_NAME, pair), ex); + "not right. Here is the pair [ %s ]", PARSER_NAME, pair), ex);
} }
break; break;
case TYPE: case TYPE:
switch (normalizedValue) { switch (normalizedValue) {
case "incoming": case "incoming":
@ -406,7 +414,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
} }
break; break;
case SERVICE_CENTER: case SERVICE_CENTER:
if(!XRYUtils.isPhoneValid(pair.getValue())) { if (!XRYUtils.isPhoneValid(pair.getValue())) {
continue; continue;
} }
@ -429,16 +437,16 @@ final class XRYMessagesFileParser implements XRYFileParser {
} }
CommunicationArtifactsHelper helper = new CommunicationArtifactsHelper( CommunicationArtifactsHelper helper = new CommunicationArtifactsHelper(
currentCase, PARSER_NAME, parent, Account.Type.PHONE); currentCase, PARSER_NAME, parent, Account.Type.PHONE);
helper.addMessage(messageType, direction, senderId, recipientIdsList, helper.addMessage(messageType, direction, senderId, recipientIdsList,
dateTime, readStatus, subject, text, threadId, otherAttributes); dateTime, readStatus, subject, text, threadId, otherAttributes);
} }
} }
/** /**
* Extracts all pairs from the XRY Entity. This function * Extracts all pairs from the XRY Entity. This function will unify any
* will unify any segmented text, if need be. * segmented text, if need be.
*/ */
private List<XRYKeyValuePair> getXRYKeyValuePairs(String xryEntity, private List<XRYKeyValuePair> getXRYKeyValuePairs(String xryEntity,
XRYFileReader reader, Set<Integer> referenceValues) throws IOException { XRYFileReader reader, Set<Integer> referenceValues) throws IOException {
@ -508,10 +516,13 @@ final class XRYMessagesFileParser implements XRYFileParser {
* Builds up segmented message entities so that the text is unified for a * Builds up segmented message entities so that the text is unified for a
* single artifact. * single artifact.
* *
* @param reader File reader that is producing XRY entities. * @param reader File reader that is producing XRY entities.
* @param referenceNumbersSeen All known references numbers up until this point. * @param referenceNumbersSeen All known references numbers up until this
* @param xryEntity The source XRY entity. * point.
* @param xryEntity The source XRY entity.
*
* @return * @return
*
* @throws IOException * @throws IOException
*/ */
private String getSegmentedText(String[] xryEntity, XRYFileReader reader, private String getSegmentedText(String[] xryEntity, XRYFileReader reader,
@ -604,7 +615,8 @@ final class XRYMessagesFileParser implements XRYFileParser {
* Extracts the value of the XRY meta key, if any. * Extracts the value of the XRY meta key, if any.
* *
* @param xryLines XRY entity to extract from. * @param xryLines XRY entity to extract from.
* @param metaKey The key type to extract. * @param metaKey The key type to extract.
*
* @return * @return
*/ */
private Optional<Integer> getMetaKeyValue(String[] xryLines, XryMetaKey metaKey) { private Optional<Integer> getMetaKeyValue(String[] xryLines, XryMetaKey metaKey) {
@ -629,10 +641,12 @@ final class XRYMessagesFileParser implements XRYFileParser {
/** /**
* Extracts the ith XRY Key Value pair in the XRY Entity. * Extracts the ith XRY Key Value pair in the XRY Entity.
* *
* The total number of pairs can be determined via getCountOfKeyValuePairs(). * The total number of pairs can be determined via
* getCountOfKeyValuePairs().
* *
* @param xryLines XRY entity. * @param xryLines XRY entity.
* @param index The requested Key Value pair. * @param index The requested Key Value pair.
*
* @return * @return
*/ */
private Optional<XRYKeyValuePair> getKeyValuePairByIndex(String[] xryLines, int index) { private Optional<XRYKeyValuePair> getKeyValuePairByIndex(String[] xryLines, int index) {