Skip to content
Extraits de code Groupes Projets
Valider b41c82c8 rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

HTTP: remove Path only if Request

parent 1d6ba156
Branches main
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #61618 réussi
......@@ -70,17 +70,18 @@ def anonymize_http(http: HTTP) -> None:
http (scapy.HTTP): HTTP layer to anonymize
"""
# Remove request parameters
try:
path = http.getfieldval(HttpFields.PATH.value).decode(ENCODING)
http.setfieldval(HttpFields.PATH.value, path.split("?")[0].encode(ENCODING))
except AttributeError:
# HTTP packet does not contain the `Path` field
logger.warning(f"Field {HttpFields.PATH.value} not found in HTTP layer {http.summary()}")
pass
except UnicodeDecodeError:
# `Path` field is not encoded in UTF-8
logger.warning(f"Field {HttpFields.PATH.value} not UTF-8 encoded in HTTP layer {http.summary()}")
pass
if http.haslayer(HTTPRequest):
try:
path = http.getfieldval(HttpFields.PATH.value).decode(ENCODING)
http.setfieldval(HttpFields.PATH.value, path.split("?")[0].encode(ENCODING))
except AttributeError:
# HTTP packet does not contain the `Path` field
logger.warning(f"Field {HttpFields.PATH.value} not found in HTTP layer {http.summary()}")
pass
except UnicodeDecodeError:
# `Path` field is not encoded in UTF-8
logger.warning(f"Field {HttpFields.PATH.value} not UTF-8 encoded in HTTP layer {http.summary()}")
pass
# Remove all fields other than Method and Path
for field in http.fields.copy():
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter