GuardianUnivalle-Benito-Yucra 0.1.36__py3-none-any.whl → 0.1.37__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of GuardianUnivalle-Benito-Yucra might be problematic. Click here for more details.

@@ -1,8 +1,7 @@
1
+ import os
1
2
  import datetime
2
3
  import json
3
- import os
4
4
 
5
- # Archivo donde se guardarán los eventos
6
5
  LOG_FILE = "auditoria_guardian.log"
7
6
 
8
7
 
@@ -12,13 +11,6 @@ def registrar_evento(
12
11
  severidad: str = "MEDIA",
13
12
  extra: dict | None = None,
14
13
  ):
15
- """
16
- Registra un evento de auditoría en un archivo.
17
- :param tipo: Tipo de evento (DoS, CSRF, XSS, SQLi, etc.)
18
- :param descripcion: Descripción detallada del evento
19
- :param severidad: Nivel de severidad (BAJA, MEDIA, ALTA)
20
- :param extra: Datos adicionales opcionales
21
- """
22
14
  try:
23
15
  evento = {
24
16
  "fecha": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
@@ -28,8 +20,10 @@ def registrar_evento(
28
20
  "extra": extra or {},
29
21
  }
30
22
 
31
- # Asegurar que el archivo exista
32
- os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
23
+ # Crear carpeta solo si hay directorio en la ruta
24
+ log_dir = os.path.dirname(LOG_FILE)
25
+ if log_dir:
26
+ os.makedirs(log_dir, exist_ok=True)
33
27
 
34
28
  with open(LOG_FILE, "a", encoding="utf-8") as f:
35
29
  f.write(json.dumps(evento, ensure_ascii=False) + "\n")
@@ -1,23 +1,3 @@
1
- """
2
- Detector de ataques de tipo DoS (Denial of Service)
3
- ====================================================
4
-
5
- Este módulo forma parte del sistema de detección de amenazas.
6
- Detecta tasas de petición anómalas en base a límites configurables,
7
- captura datos del atacante (IP, agente, cabeceras)
8
- y registra los incidentes para su auditoría.
9
-
10
- Componentes:
11
- - DOSDefenseMiddleware: Middleware principal de detección.
12
- - detectar_dos(): Evalúa si la tasa supera el umbral permitido.
13
- - calcular_nivel_amenaza_dos(): Calcula la severidad proporcional.
14
- - registrar_evento(): Registra los incidentes en auditoría.
15
-
16
- Algoritmos relacionados:
17
- * Rate Limiting basado en ventana deslizante.
18
- * Cálculo de score: S_dos = w_dos * (tasa_peticion / limite)
19
- """
20
-
21
1
  from __future__ import annotations
22
2
  import time
23
3
  import logging
@@ -94,6 +74,7 @@ def detectar_dos(ip: str, tasa_peticion: int, limite: int = LIMITE_PETICIONES) -
94
74
  descripcion=f"Alta tasa de peticiones desde {ip}: {tasa_peticion} req/min (límite {limite})",
95
75
  severidad="ALTA",
96
76
  )
77
+
97
78
  limitar_peticion() # Acción de mitigación
98
79
  return True
99
80
  return False
@@ -164,3 +145,22 @@ S_dos = w_dos * (tasa_peticion / limite)
164
145
  S_dos = 0.6 * (150 / 100)
165
146
  donde w_dos es peso asignado a DoS y tasa_peticion / limite es la proporción de la tasa actual sobre el límite.
166
147
  """
148
+ """
149
+ Detector de ataques de tipo DoS (Denial of Service)
150
+ ====================================================
151
+
152
+ Este módulo forma parte del sistema de detección de amenazas.
153
+ Detecta tasas de petición anómalas en base a límites configurables,
154
+ captura datos del atacante (IP, agente, cabeceras)
155
+ y registra los incidentes para su auditoría.
156
+
157
+ Componentes:
158
+ - DOSDefenseMiddleware: Middleware principal de detección.
159
+ - detectar_dos(): Evalúa si la tasa supera el umbral permitido.
160
+ - calcular_nivel_amenaza_dos(): Calcula la severidad proporcional.
161
+ - registrar_evento(): Registra los incidentes en auditoría.
162
+
163
+ Algoritmos relacionados:
164
+ * Rate Limiting basado en ventana deslizante.
165
+ * Cálculo de score: S_dos = w_dos * (tasa_peticion / limite)
166
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GuardianUnivalle-Benito-Yucra
3
- Version: 0.1.36
3
+ Version: 0.1.37
4
4
  Summary: Middleware y detectores de seguridad (SQLi, XSS, CSRF, DoS, Keylogger) para Django/Flask
5
5
  Author-email: Andres Benito Calle Yucra <benitoandrescalle035@gmail.com>
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
1
  GuardianUnivalle_Benito_Yucra/__init__.py,sha256=lbIRb8fCFYfAdyJV6NsYVZJ5pKYSJZKhhK-En9g_1M8,762
2
2
  GuardianUnivalle_Benito_Yucra/utilidades.py,sha256=lFNVnlyTSYmQ1CqtmHx6aefK5uNw0wsMdHRQyxAIZy0,120
3
- GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py,sha256=D_N9HxjsREMRHozWy_40YOJYggigXq7N0JOxQrHSWWM,1407
3
+ GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py,sha256=NnKBOeRWkXVGaMBeQRYU528rWlaBDBPmTAzfji9n8fw,1135
4
4
  GuardianUnivalle_Benito_Yucra/criptografia/cifrado_aead.py,sha256=wfoRpaKvOqPbollNQsDNUNWClYJlXYTKTYvv0qcR6aI,962
5
5
  GuardianUnivalle_Benito_Yucra/criptografia/intercambio_claves.py,sha256=9djnlzb022hUhrDbQyWz7lWLbkn_vQZ4K7qar1FXYmo,829
6
6
  GuardianUnivalle_Benito_Yucra/criptografia/kdf.py,sha256=_sbepEY1qHEKga0ExrX2WRg1HeCPY5MC5CfXZWYyl-A,709
7
7
  GuardianUnivalle_Benito_Yucra/detectores/detector_csrf.py,sha256=wt9LRMG9XK4eSSmW91tlGmsJWfyk445b8-n2oxlXlwo,7893
8
- GuardianUnivalle_Benito_Yucra/detectores/detector_dos.py,sha256=KpsFnZvPmtKVgxR2Em_gIQvoho3sGOE_qQSWOEhts48,6163
8
+ GuardianUnivalle_Benito_Yucra/detectores/detector_dos.py,sha256=J3FjuJN15i-vx_q44re5RwujeFqjQDGm5r9NujxIlFc,6163
9
9
  GuardianUnivalle_Benito_Yucra/detectores/detector_keylogger.py,sha256=L5RQ0Sdgg7hTU1qkZYwt7AcDqtAzT6u-jwBGo7YWfsw,8078
10
10
  GuardianUnivalle_Benito_Yucra/detectores/detector_sql.py,sha256=o2IXqF3Nbsh5roPihyLal42iCzgxfyX3D6Ef-cxOpVo,6644
11
11
  GuardianUnivalle_Benito_Yucra/detectores/detector_xss.py,sha256=Ipw1XXBd1-SsOOhhl9joQGduTq0GhSa61TRTyASF3XE,6795
@@ -13,8 +13,8 @@ GuardianUnivalle_Benito_Yucra/middleware_web/middleware_web.py,sha256=23pLLYqliU
13
13
  GuardianUnivalle_Benito_Yucra/mitigacion/limitador_peticion.py,sha256=ipMOebYhql-6mSyHs0ddYXOcXq9w8P_IXLlpiIqGncw,246
14
14
  GuardianUnivalle_Benito_Yucra/mitigacion/lista_bloqueo.py,sha256=6AYWII4mrmwCLHCvGTyoBxR4Oasr4raSHpFbVjqn7d8,193
15
15
  GuardianUnivalle_Benito_Yucra/puntuacion/puntuacion_amenaza.py,sha256=Wx5XfcII4oweLvZsTBEJ7kUc9pMpP5-36RfI5C5KJXo,561
16
- guardianunivalle_benito_yucra-0.1.36.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
- guardianunivalle_benito_yucra-0.1.36.dist-info/METADATA,sha256=_k421TBz-SFWSQtlJ1dwWGNwkG3x7hyDfsPs2oChJ8s,1893
18
- guardianunivalle_benito_yucra-0.1.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- guardianunivalle_benito_yucra-0.1.36.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
- guardianunivalle_benito_yucra-0.1.36.dist-info/RECORD,,
16
+ guardianunivalle_benito_yucra-0.1.37.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
+ guardianunivalle_benito_yucra-0.1.37.dist-info/METADATA,sha256=qRwWENWOOMBUw9yy5z7otLbwv_Gi5sM42MTe7mPBWVY,1893
18
+ guardianunivalle_benito_yucra-0.1.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ guardianunivalle_benito_yucra-0.1.37.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
+ guardianunivalle_benito_yucra-0.1.37.dist-info/RECORD,,