old_console/correlation/constants.py
2024-11-02 14:12:45 +03:00

48 lines
1.6 KiB
Python

from enum import Enum
import redis
from django.conf import settings
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy
from django.db import models
from console.models import Vulnerability
from assets.models.assets import AssetManufacturer, OperatingSystem, AssetListGroup
from incident.models import IncidentRecommendations, IncidentEffect, IncidentCategory
EXPORT_TMP_PATH = '/tmp/export.json'
MEDIA_ROOT = getattr(settings, 'MEDIA_ROOT', 'media')
CORRELATOR_URL = getattr(settings, 'CORRELATOR_URL', 'http://localhost:5566')
STARTUP_UPDATE_NAME = "correlator_startup_tasks"
redis_instance = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
MODEL_NAME_MAPPER = {
'os': OperatingSystem,
'group': AssetListGroup,
'manufacturer': AssetManufacturer,
'vulnerabilities': Vulnerability,
'effects': IncidentEffect,
'close_recommendations': IncidentRecommendations,
'assigned_to': User,
'category': IncidentCategory
}
class Type(models.IntegerChoices):
system = 0, gettext_lazy("System")
user = 1, gettext_lazy("User")
class RuleParseErrors(Enum):
NAME_DESCRIPTION_ERROR = 1
FORMAT_ERROR = 2
class ActionType(models.TextChoices):
SYSLOG = "syslog", gettext_lazy("Syslog")
HTTP = "http", gettext_lazy("HTTP")
INCIDENT = "incident", gettext_lazy("Incident")
BASH = "bash", gettext_lazy("Bash")
EXECUTABLE = "exec", gettext_lazy("Run executable")
ASSET = "asset", gettext_lazy("New asset")
FIREWALL = "firewall", gettext_lazy("Firewall rule")