GuardianUnivalle-Benito-Yucra 0.1.49__py3-none-any.whl → 0.1.50__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.

@@ -55,15 +55,16 @@ def analizar_comportamiento_cliente(datos):
55
55
  return "BAJA", descripcion
56
56
 
57
57
 
58
- def registrar_evento(tipo, descripcion, severidad="BAJA", extra=None):
58
+ def registrar_evento(tipo, descripcion, severidad="BAJA", usuario_id=None, extra=None):
59
59
  """
60
- Registra un evento en los logs (la BD será manejada por el backend Django).
60
+ Prepara un registro de auditoría (para luego guardarlo en BD desde Django).
61
61
  """
62
62
  try:
63
63
  registro = {
64
64
  "tipo": tipo,
65
65
  "descripcion": descripcion,
66
66
  "severidad": severidad,
67
+ "usuario_id": usuario_id, # <-- guardamos ID en lugar de FK
67
68
  "fecha": datetime.now().isoformat(),
68
69
  "extra": extra or {},
69
70
  }
@@ -92,20 +93,13 @@ class AuditoriaServidorMiddleware(MiddlewareMixin):
92
93
  "descripcion": descripcion,
93
94
  "severidad": severidad,
94
95
  "eventos_detectados": [],
96
+ "usuario_id": getattr(request.user, "id", None) # <-- si está autenticado
95
97
  }
96
98
 
97
99
  # Integrar información de ataques detectada por otros middlewares
98
- if hasattr(request, "sql_attack_info"):
99
- registro_base["eventos_detectados"].append(request.sql_attack_info)
100
-
101
- if hasattr(request, "xss_attack_info"):
102
- registro_base["eventos_detectados"].append(request.xss_attack_info)
103
-
104
- if hasattr(request, "csrf_attack_info"):
105
- registro_base["eventos_detectados"].append(request.csrf_attack_info)
106
-
107
- if hasattr(request, "dos_attack_info"):
108
- registro_base["eventos_detectados"].append(request.dos_attack_info)
100
+ for attr in ["sql_attack_info", "xss_attack_info", "csrf_attack_info", "dos_attack_info"]:
101
+ if hasattr(request, attr):
102
+ registro_base["eventos_detectados"].append(getattr(request, attr))
109
103
 
110
104
  # Si hubo algún evento sospechoso
111
105
  if registro_base["eventos_detectados"]:
@@ -113,6 +107,7 @@ class AuditoriaServidorMiddleware(MiddlewareMixin):
113
107
  tipo="ATAQUE_DETECTADO",
114
108
  descripcion="Se detectó comportamiento sospechoso en la solicitud",
115
109
  severidad="ALTA",
110
+ usuario_id=registro_base["usuario_id"],
116
111
  extra=registro_base,
117
112
  )
118
113
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GuardianUnivalle-Benito-Yucra
3
- Version: 0.1.49
3
+ Version: 0.1.50
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,6 +1,6 @@
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/auditoria_servidor.py,sha256=azBcGYRgX0icNrY-14vCbdy9SMZgjy503qPJaIupHPg,4622
3
+ GuardianUnivalle_Benito_Yucra/auditoria/auditoria_servidor.py,sha256=ZXyzegZb_iQI4ICzPBw2uJeco4LMYZ1wv12DuTnKb7M,4543
4
4
  GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py,sha256=NnKBOeRWkXVGaMBeQRYU528rWlaBDBPmTAzfji9n8fw,1135
5
5
  GuardianUnivalle_Benito_Yucra/criptografia/cifrado_aead.py,sha256=wfoRpaKvOqPbollNQsDNUNWClYJlXYTKTYvv0qcR6aI,962
6
6
  GuardianUnivalle_Benito_Yucra/criptografia/intercambio_claves.py,sha256=9djnlzb022hUhrDbQyWz7lWLbkn_vQZ4K7qar1FXYmo,829
@@ -14,8 +14,8 @@ GuardianUnivalle_Benito_Yucra/middleware_web/middleware_web.py,sha256=23pLLYqliU
14
14
  GuardianUnivalle_Benito_Yucra/mitigacion/limitador_peticion.py,sha256=ipMOebYhql-6mSyHs0ddYXOcXq9w8P_IXLlpiIqGncw,246
15
15
  GuardianUnivalle_Benito_Yucra/mitigacion/lista_bloqueo.py,sha256=6AYWII4mrmwCLHCvGTyoBxR4Oasr4raSHpFbVjqn7d8,193
16
16
  GuardianUnivalle_Benito_Yucra/puntuacion/puntuacion_amenaza.py,sha256=Wx5XfcII4oweLvZsTBEJ7kUc9pMpP5-36RfI5C5KJXo,561
17
- guardianunivalle_benito_yucra-0.1.49.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
18
- guardianunivalle_benito_yucra-0.1.49.dist-info/METADATA,sha256=yPQGstka38XBtdvH9FNE79DN1XCQQPRTeKM6mz2PJ3s,1893
19
- guardianunivalle_benito_yucra-0.1.49.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- guardianunivalle_benito_yucra-0.1.49.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
21
- guardianunivalle_benito_yucra-0.1.49.dist-info/RECORD,,
17
+ guardianunivalle_benito_yucra-0.1.50.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
18
+ guardianunivalle_benito_yucra-0.1.50.dist-info/METADATA,sha256=S1Slmtk8V-fzvKQqKOc-GvCcQ46C3DrDCPTlNQkATLw,1893
19
+ guardianunivalle_benito_yucra-0.1.50.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ guardianunivalle_benito_yucra-0.1.50.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
21
+ guardianunivalle_benito_yucra-0.1.50.dist-info/RECORD,,