Skip to content

Commit

Permalink
initial progress of group
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
pyth0n1c committed Feb 4, 2025
1 parent 3e2b421 commit ff372fb
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions contentctl/objects/mitre_attack_enrichment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations
from pydantic import BaseModel, Field, ConfigDict, HttpUrl, field_validator
from typing import List
from enum import StrEnum

import datetime
from enum import StrEnum
from typing import List

from pydantic import BaseModel, ConfigDict, Field, HttpUrl, field_validator

from contentctl.objects.annotated_types import MITRE_ATTACK_ID_TYPE


Expand Down Expand Up @@ -84,6 +87,13 @@ def standardize_contributors(cls, contributors: list[str] | None) -> list[str]:
return []
return contributors

def __lt__(self, other: MitreAttackGroup) -> bool:
if not isinstance(object, MitreAttackGroup):
raise Exception(
f"Cannot compare object of type MitreAttackGroup to object of type [{type(object).__name__}]"
)
return self.group < other.group


class MitreAttackEnrichment(BaseModel):
ConfigDict(extra="forbid")
Expand All @@ -96,3 +106,12 @@ class MitreAttackEnrichment(BaseModel):

def __hash__(self) -> int:
return id(self)

@staticmethod
def getUniqueGroups(groups: list[MitreAttackGroup]) -> list[MitreAttackGroup]:
group_set: set[MitreAttackGroup] = set()
for group in groups:
g = set(group)
group_set.update(g)

return sorted(group_set)

0 comments on commit ff372fb

Please sign in to comment.