from django.db import models from django.utils.translation import gettext_lazy from incident.models import Incident from ncircc.enums.notifications import NotificationCategoryEnum, EventTypeEnum, ActivityStatusEnum, TlpEnum, \ AffectedSystemCategoryEnum, NotificationStatusEnum, ImpactEffect class Notification(models.Model): """Modal with information notifications in NCIRCC.""" incident = models.ForeignKey( Incident, verbose_name=gettext_lazy('Incident'), null=True, on_delete=models.SET_NULL, unique=True) uuid = models.UUIDField(gettext_lazy('Incident uiid id in NCIRCC'), null=True, blank=True) # from NCIRCC update_time = models.DateTimeField(gettext_lazy('Update time'), null=True, blank=True) # from NCIRCC identifier = models.CharField(gettext_lazy('Incident identifier'), null=True, blank=True, max_length=127) # from NCIRCC category = models.CharField( gettext_lazy('Category'), choices=NotificationCategoryEnum.choices, default=NotificationCategoryEnum.INCIDENT.value, max_length=127, ) type = models.CharField( gettext_lazy('Event type'), choices=EventTypeEnum.choices, default=EventTypeEnum.DDOS.value, max_length=127, ) activity_status = models.CharField( gettext_lazy('Activity status'), choices=ActivityStatusEnum.choices, default=ActivityStatusEnum.TAKEN_ACTION.value, max_length=127, ) tlp = models.CharField( gettext_lazy('Privacy status'), choices=TlpEnum.choices, default=TlpEnum.GREEN.value, max_length=127 ) affected_system_name = models.CharField(gettext_lazy('Affected system name'), max_length=127) affected_system_category = models.CharField( gettext_lazy('Affected system category'), max_length=127, choices=AffectedSystemCategoryEnum.choices, default=AffectedSystemCategoryEnum.RESOURCE_NOT_CII.value, ) event_description = models.CharField(gettext_lazy('Short description of security event'), max_length=127) affected_system_connection = models.BooleanField(gettext_lazy('Affected system connection'), default=False) assistance = models.BooleanField(gettext_lazy('Assistance NCIRCC'), default=False) notification_status = models.CharField( gettext_lazy('Notification status'), max_length=127, choices=NotificationStatusEnum.choices, default=NotificationStatusEnum.CHECK_NCIRCC.value, ) # for NotificationCategoryEnum.VULNERABILITY vulnerability_id = models.CharField(gettext_lazy('Vulnerability id'), max_length=127, blank=True) product_category = models.CharField(gettext_lazy('Product Category'), max_length=127, blank=True) # for NotificationCategoryEnum.INCIDENT and NotificationCategoryEnum.ATTACK integrity_impact = models.CharField( gettext_lazy('Integrity impact'), max_length=127, choices=ImpactEffect.choices, default=ImpactEffect.NO.value, ) availability_impact = models.CharField( gettext_lazy('Availability impact'), max_length=127, choices=ImpactEffect.choices, default=ImpactEffect.NO.value, ) confidentiality_impact = models.CharField( gettext_lazy('Confidentiality impact'), max_length=127, choices=ImpactEffect.choices, default=ImpactEffect.NO.value, ) custom_impact = models.TextField(gettext_lazy('Custom impact'), blank=True) created = models.DateTimeField(gettext_lazy('Created'), auto_now_add=True) updated = models.DateTimeField(gettext_lazy('Updated'), auto_now=True) sending_time = models.DateTimeField(gettext_lazy('Sending time'), null=True, blank=True) # Sending time by clicking the button class Meta: verbose_name = gettext_lazy('Notification') verbose_name_plural = gettext_lazy('Notifications') def __str__(self) -> str: return self.identifier if self.identifier else str(self.id)