Skip to content
Snippets Groups Projects
Unverified Commit c5b06685 authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #1647 from eugene7646/email_errors_5575

Added string size sanity checks (5575)
parents cff9507b d521715d
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,10 @@ class TimelineEventArtifactTypeImpl extends TimelineEventTypeImpl {
private final TSKCoreCheckedFunction<BlackboardArtifact, String> medExtractor;
private final TSKCoreCheckedFunction<BlackboardArtifact, String> shortExtractor;
private final TSKCoreCheckedFunction<BlackboardArtifact, TimelineEventDescriptionWithTime> artifactParsingFunction;
private static final int MAX_SHORT_DESCRIPTION_LENGTH = 500;
private static final int MAX_MED_DESCRIPTION_LENGTH = 500;
private static final int MAX_FULL_DESCRIPTION_LENGTH = 1024;
TimelineEventArtifactTypeImpl(int typeID, String displayName,
TimelineEventType superType,
......@@ -130,8 +134,20 @@ TimelineEventDescriptionWithTime makeEventDescription(BlackboardArtifact artifac
//combine descriptions in standard way
String shortDescription = extractShortDescription(artifact);
if (shortDescription.length() > MAX_SHORT_DESCRIPTION_LENGTH) {
shortDescription = shortDescription.substring(0, MAX_SHORT_DESCRIPTION_LENGTH);
}
String medDescription = shortDescription + " : " + extractMedDescription(artifact);
if (medDescription.length() > MAX_MED_DESCRIPTION_LENGTH) {
medDescription = medDescription.substring(0, MAX_MED_DESCRIPTION_LENGTH);
}
String fullDescription = medDescription + " : " + extractFullDescription(artifact);
if (fullDescription.length() > MAX_FULL_DESCRIPTION_LENGTH) {
fullDescription = fullDescription.substring(0, MAX_FULL_DESCRIPTION_LENGTH);
}
return new TimelineEventDescriptionWithTime(timeAttribute.getValueLong(), shortDescription, medDescription, fullDescription);
}
......
......@@ -46,6 +46,7 @@
public interface TimelineEventType extends Comparable<TimelineEventType> {
static final int EMAIL_FULL_DESCRIPTION_LENGTH_MAX = 150;
static final int EMAIL_TO_FROM_LENGTH_MAX = 75;
String getDisplayName();
......@@ -298,9 +299,15 @@ public SortedSet<TimelineEventType> getSubTypes() {
new BlackboardArtifact.Type(TSK_EMAIL_MSG),
new Type(TSK_DATETIME_SENT),
artf -> {
final BlackboardAttribute emailFrom = getAttributeSafe(artf, new Type(TSK_EMAIL_FROM));
final BlackboardAttribute emailTo = getAttributeSafe(artf, new Type(TSK_EMAIL_TO));
return stringValueOf(emailFrom) + " to " + stringValueOf(emailTo); // NON-NLS
String emailFrom = stringValueOf(getAttributeSafe(artf, new Type(TSK_EMAIL_FROM)));
if (emailFrom.length() > EMAIL_TO_FROM_LENGTH_MAX) {
emailFrom = emailFrom.substring(0, EMAIL_TO_FROM_LENGTH_MAX);
}
String emailTo = stringValueOf(getAttributeSafe(artf, new Type(TSK_EMAIL_TO)));
if (emailTo.length() > EMAIL_TO_FROM_LENGTH_MAX) {
emailTo = emailTo.substring(0, EMAIL_TO_FROM_LENGTH_MAX);
}
return emailFrom + " to " + emailTo; // NON-NLS
},
new AttributeExtractor(new Type(TSK_SUBJECT)),
artf -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment