Skip to content

Commit b909d05

Browse files
committed
this is a quick fix and does not
account for duplicates in other string fields, like Mitre tags, references, etc. But this is still a good and helpful check
1 parent 226c7f8 commit b909d05

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pprint
1313
import uuid
1414
from abc import abstractmethod
15+
from collections import Counter
1516
from difflib import get_close_matches
1617
from functools import cached_property
1718
from typing import List, Optional, Tuple, Union
@@ -708,6 +709,15 @@ def mapNamesToSecurityContentObjects(
708709
"an error in the contentctl codebase which must be resolved."
709710
)
710711

712+
# Catch all for finding duplicates in mapped content
713+
if (
714+
len(duplicates := [name for name, count in Counter(v).items() if count > 1])
715+
> 0
716+
):
717+
raise ValueError(
718+
f"Duplicate {cls.__name__} ({duplicates}) found in list: {v}."
719+
)
720+
711721
mappedObjects: list[Self] = []
712722
mistyped_objects: list[SecurityContentObject_Abstract] = []
713723
missing_objects: list[str] = []

0 commit comments

Comments
 (0)