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
Aucune branche associée trouvée
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: ...@@ -70,17 +70,18 @@ def anonymize_http(http: HTTP) -> None:
http (scapy.HTTP): HTTP layer to anonymize http (scapy.HTTP): HTTP layer to anonymize
""" """
# Remove request parameters # Remove request parameters
try: if http.haslayer(HTTPRequest):
path = http.getfieldval(HttpFields.PATH.value).decode(ENCODING) try:
http.setfieldval(HttpFields.PATH.value, path.split("?")[0].encode(ENCODING)) path = http.getfieldval(HttpFields.PATH.value).decode(ENCODING)
except AttributeError: http.setfieldval(HttpFields.PATH.value, path.split("?")[0].encode(ENCODING))
# HTTP packet does not contain the `Path` field except AttributeError:
logger.warning(f"Field {HttpFields.PATH.value} not found in HTTP layer {http.summary()}") # HTTP packet does not contain the `Path` field
pass logger.warning(f"Field {HttpFields.PATH.value} not found in HTTP layer {http.summary()}")
except UnicodeDecodeError: pass
# `Path` field is not encoded in UTF-8 except UnicodeDecodeError:
logger.warning(f"Field {HttpFields.PATH.value} not UTF-8 encoded in HTTP layer {http.summary()}") # `Path` field is not encoded in UTF-8
pass 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 # Remove all fields other than Method and Path
for field in http.fields.copy(): 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