Skip to content

Commit

Permalink
[backend] Add aliases deduplication on normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Dec 2, 2023
1 parent 13a5b4e commit 90ab7ef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opencti-platform/opencti-graphql/src/database/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,12 +1571,13 @@ const prepareAttributesForUpdate = (instance, elements) => {
return null;
}
}
// Aliases can't have the same name as entity name
// Aliases can't have the same name as entity name and an already existing normalized alias
if (input.key === ATTRIBUTE_ALIASES || input.key === ATTRIBUTE_ALIASES_OPENCTI) {
const filteredValues = input.value.filter((e) => normalizeName(e) !== normalizeName(instance.name));
const uniqAliases = R.uniqBy((e) => normalizeName(e), filteredValues);
return {
key: input.key,
value: filteredValues
value: uniqAliases
};
}
// No need to rework the input
Expand Down

0 comments on commit 90ab7ef

Please sign in to comment.