Skip to content

Commit

Permalink
Merge pull request #92 from center-for-threat-informed-defense/AF-127…
Browse files Browse the repository at this point in the history
…_text_trimming

AF-127 Text Trimming
  • Loading branch information
mikecarenzo committed Jul 28, 2023
2 parents 17bcc8f + 4197076 commit 733996d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/attack_flow_builder/src/assets/builder.config.publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
Property,
PropertyType,
RawEntries,
SemanticAnalyzer
SemanticAnalyzer,
StringProperty
} from "./scripts/BlockDiagram";


Expand Down Expand Up @@ -206,6 +207,11 @@ class AttackFlowPublisher extends DiagramPublisher {
node[key] = prop.toRawValue();
}
}

// Remove trailing whitespace on StringProperties
if (prop instanceof StringProperty && prop.isDefined()) {
node[key] = prop.toString().trim();
}
}
}

Expand Down Expand Up @@ -239,6 +245,11 @@ class AttackFlowPublisher extends DiagramPublisher {
this.mergeBasicListProperty(node, key, prop as ListProperty);
}
break;
case PropertyType.String: // Remove trailing whitespace on StringProperties
if (prop.isDefined()) {
node[key] = prop.toString().trim();
}
break;
default:
if(prop.isDefined()) {
node[key] = prop.toRawValue();
Expand Down Expand Up @@ -267,6 +278,11 @@ class AttackFlowPublisher extends DiagramPublisher {
throw new Error("Basic lists cannot contain lists.");
case PropertyType.Enum:
throw new Error("Basic lists cannot contain enums.");
case PropertyType.String: // Remove trailing whitespace on StringProperties
if(prop.isDefined()) {
node[key].push(prop.toString().trim());
}
break;
default:
if(prop.isDefined()) {
node[key].push(prop.toRawValue());
Expand Down Expand Up @@ -689,6 +705,7 @@ class AttackFlowPublisher extends DiagramPublisher {
flow[key] = prop
.toReferenceValue()!
.toString()
.trim()
.toLocaleLowerCase();
break;
default:
Expand Down Expand Up @@ -818,11 +835,12 @@ class AttackFlowPublisher extends DiagramPublisher {
author[key] = prop
.toReferenceValue()!
.toString()
.trim()
.toLocaleLowerCase();
break;
default:
if(prop.isDefined()) {
author[key] = prop.toRawValue()
author[key] = prop.toString().trim();
}
break;
}
Expand Down

0 comments on commit 733996d

Please sign in to comment.