Skip to content

Commit

Permalink
Allowed compatibility with older AFB files, which is what caused the …
Browse files Browse the repository at this point in the history
…build to break.
  • Loading branch information
tleef42 committed Aug 19, 2023
1 parent bd19b4f commit 6117865
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/attack_flow_builder/src/assets/builder.config.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,25 @@ class AttackFlowValidator extends DiagramValidator {
*/
protected validateHash(id: string, hashes: ListProperty) {
const validKey = /^[a-zA-Z0-9_-]{3,250}$/;
for(let hash of hashes.value.values()) {
if(!hash.isDefined()) {
const hashDictionaryProps = hashes.value;

if(!hashDictionaryProps) {
// This is an older AFB file that does not have the Hash property updated to current version.
this.addWarning(id, "This AFB is outdated, please remake it in a new file.");
return;
}

for(let hashDictionary of hashDictionaryProps.values()) {
if(!hashDictionary.isDefined()) {
this.addError(id, "Hash Value cannot be empty.");
}
// Make sure hash_type is not empty.
let entries = hash.toRawValue()! as RawEntries;
let entries = hashDictionary.toRawValue()! as RawEntries;
if(!Object.fromEntries(entries).hash_type) {
this.addError(id, "Hash Type cannot be left empty.");
}

let key = hash.toString();
let key = hashDictionary.toString();
if (!validKey.test(key)) {
this.addError(id, "Invalid hash key.");
}
Expand Down

0 comments on commit 6117865

Please sign in to comment.