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

@@ -62,17 +62,33 @@ class SQLIDefenseMiddleware(MiddlewareMixin):
62
62
  def process_request(self, request):
63
63
  client_ip = get_client_ip(request)
64
64
  trusted_ips = getattr(settings, "SQLI_DEFENSE_TRUSTED_IPS", [])
65
+ trusted_domains = getattr(settings, "SQLI_DEFENSE_TRUSTED_DOMAINS", [])
65
66
 
67
+ # ✅ Si la IP está permitida → dejar pasar
66
68
  if client_ip in trusted_ips:
67
69
  return None
68
70
 
71
+ # ✅ Revisar el dominio de origen
72
+ origin = request.META.get("HTTP_ORIGIN", "")
73
+ referer = request.META.get("HTTP_REFERER", "")
74
+
75
+ # extraemos solo el host (sin protocolo http/https)
76
+ def get_domain(url):
77
+ return url.replace("http://", "").replace("https://", "").split("/")[0]
78
+
79
+ origin_domain = get_domain(origin) if origin else ""
80
+ referer_domain = get_domain(referer) if referer else ""
81
+
82
+ if origin_domain in trusted_domains or referer_domain in trusted_domains:
83
+ return None # → confiable, dejamos pasar
84
+
85
+ # 🔍 Analizamos payload
69
86
  text = extract_payload_text(request)
70
87
  if not text:
71
88
  return None
72
89
 
73
90
  flagged, descripcion = detect_sql_attack(text)
74
91
  if flagged:
75
- # Solo tipo SQL, descripción con los patrones detectados
76
92
  request.sql_attack_info = {
77
93
  "ip": client_ip,
78
94
  "tipos": ["SQL"],
@@ -84,5 +100,4 @@ class SQLIDefenseMiddleware(MiddlewareMixin):
84
100
  f"Ataque SQL detectado desde IP {client_ip}: {descripcion}, payload: {text}"
85
101
  )
86
102
 
87
- # No devolvemos JsonResponse, solo marcamos el ataque
88
103
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GuardianUnivalle-Benito-Yucra
3
- Version: 0.1.25
3
+ Version: 0.1.26
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
@@ -7,14 +7,14 @@ GuardianUnivalle_Benito_Yucra/criptografia/kdf.py,sha256=_sbepEY1qHEKga0ExrX2WRg
7
7
  GuardianUnivalle_Benito_Yucra/detectores/detector_csrf.py,sha256=EAYfLkHuxGC5rXSu4mZJ4yZDCbwBpTX8xZWGKz7i5wA,692
8
8
  GuardianUnivalle_Benito_Yucra/detectores/detector_dos.py,sha256=lMWmCw6nccCEnek53nVjpoBCeiBqLdrSXxqRuI7VP2I,696
9
9
  GuardianUnivalle_Benito_Yucra/detectores/detector_keylogger.py,sha256=rEDG-Q_R56OsG2ypfHVBK7erolYjdvATnAxB3yvPXts,729
10
- GuardianUnivalle_Benito_Yucra/detectores/detector_sql.py,sha256=b7pd4-CTH0FqW5-dwA6RA38Dls0bSBXKSLlmnKbLnbA,2982
10
+ GuardianUnivalle_Benito_Yucra/detectores/detector_sql.py,sha256=kOX-tVCSexUf4jvxM3jLl_jYBP_9YuF9-SQwLaLpAGg,3621
11
11
  GuardianUnivalle_Benito_Yucra/detectores/detector_xss.py,sha256=66V_xuxNOZEwluvWOT4-6pk5MJ3zWE1IwcVkBl7MZSg,719
12
12
  GuardianUnivalle_Benito_Yucra/middleware_web/middleware_web.py,sha256=23pLLYqliUoMrIC6ZEwz3hKXeDjWfHSm9vYPWGmDDik,495
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.25.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
- guardianunivalle_benito_yucra-0.1.25.dist-info/METADATA,sha256=tDabFGJJIV1ZgFbGRy-cx-pFw9ZHMVA9WZ9lmd0Sbb4,1893
18
- guardianunivalle_benito_yucra-0.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- guardianunivalle_benito_yucra-0.1.25.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
- guardianunivalle_benito_yucra-0.1.25.dist-info/RECORD,,
16
+ guardianunivalle_benito_yucra-0.1.26.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
+ guardianunivalle_benito_yucra-0.1.26.dist-info/METADATA,sha256=eTW0T-eW72Ycx5XPNt2VAWy0WgBV9bpY2FiSfPGzwKI,1893
18
+ guardianunivalle_benito_yucra-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ guardianunivalle_benito_yucra-0.1.26.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
+ guardianunivalle_benito_yucra-0.1.26.dist-info/RECORD,,