GuardianUnivalle-Benito-Yucra 0.1.19__py3-none-any.whl → 0.1.20__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,4 +1,3 @@
1
- from django.http import JsonResponse
2
1
  from django.utils.deprecation import MiddlewareMixin
3
2
  from django.conf import settings
4
3
  import logging, re, json
@@ -10,7 +9,7 @@ if not logger.handlers:
10
9
  handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
11
10
  logger.addHandler(handler)
12
11
 
13
- # Patrones de ataque SQL
12
+ # 🔹 Patrones de ataque SQL
14
13
  PATTERNS = [
15
14
  (re.compile(r"\bunion\b\s+(all\s+)?\bselect\b", re.I), "UNION SELECT"),
16
15
  (
@@ -44,12 +43,12 @@ def extract_payload_text(request):
44
43
  return " ".join([p for p in parts if p])
45
44
 
46
45
 
47
- def detect_sqli_text(text):
48
- matches = []
49
- for patt, message in PATTERNS:
46
+ def detect_sql_attack(text):
47
+ descripcion = []
48
+ for patt, msg in PATTERNS:
50
49
  if patt.search(text):
51
- matches.append(message)
52
- return (len(matches) > 0, matches)
50
+ descripcion.append(msg)
51
+ return (len(descripcion) > 0, descripcion)
53
52
 
54
53
 
55
54
  def get_client_ip(request):
@@ -71,18 +70,19 @@ class SQLIDefenseMiddleware(MiddlewareMixin):
71
70
  if not text:
72
71
  return None
73
72
 
74
- flagged, matches = detect_sqli_text(text)
73
+ flagged, descripcion = detect_sql_attack(text)
75
74
  if flagged:
76
- # Guardamos los datos del ataque en el request
75
+ # Solo tipo SQL, descripción con los patrones detectados
77
76
  request.sql_attack_info = {
78
77
  "ip": client_ip,
79
- "tipos": matches,
78
+ "tipos": ["SQL"],
79
+ "descripcion": descripcion,
80
80
  "payload": text,
81
81
  }
82
82
 
83
83
  logger.warning(
84
- f"Ataque SQL detectado desde IP {client_ip}: {matches}, payload: {text}"
84
+ f"Ataque SQL detectado desde IP {client_ip}: {descripcion}, payload: {text}"
85
85
  )
86
86
 
87
- # 👉 Aquí ya NO devolvemos JsonResponse
87
+ # No devolvemos JsonResponse, solo marcamos el ataque
88
88
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GuardianUnivalle-Benito-Yucra
3
- Version: 0.1.19
3
+ Version: 0.1.20
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=qbYOc-Y1i_wmuYSY_skTa4j6nFaLAjEJ-p_AdIEjtf4,2930
10
+ GuardianUnivalle_Benito_Yucra/detectores/detector_sql.py,sha256=b7pd4-CTH0FqW5-dwA6RA38Dls0bSBXKSLlmnKbLnbA,2982
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.19.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
- guardianunivalle_benito_yucra-0.1.19.dist-info/METADATA,sha256=0yp93hYVTOMtAMMzYRideNMkcCmu0yPsKD8J9uxQdh4,1893
18
- guardianunivalle_benito_yucra-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- guardianunivalle_benito_yucra-0.1.19.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
- guardianunivalle_benito_yucra-0.1.19.dist-info/RECORD,,
16
+ guardianunivalle_benito_yucra-0.1.20.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
17
+ guardianunivalle_benito_yucra-0.1.20.dist-info/METADATA,sha256=SxkVycheSzn_Um1drF965h7QgSbDLy10ZIFq-tNKVas,1893
18
+ guardianunivalle_benito_yucra-0.1.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ guardianunivalle_benito_yucra-0.1.20.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
20
+ guardianunivalle_benito_yucra-0.1.20.dist-info/RECORD,,