Skip to content

Commit b9d5883

Browse files
author
Wout Feys
committed
Use the new process_xml helper function
1 parent 06881de commit b9d5883

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

aikido_firewall/context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, context_obj=None, req=None, raw_body=None, source=None):
5454
self.user = None
5555
self.remote_address = get_ip_from_request(req["REMOTE_ADDR"], self.headers)
5656
self.parsed_userinput = {}
57-
self.xml = []
57+
self.xml = {}
5858

5959
def __reduce__(self):
6060
return (

aikido_firewall/sources/xml.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,9 @@
55
import copy
66
import importhook
77
from aikido_firewall.helpers.logging import logger
8-
from aikido_firewall.context import get_current_context
8+
from aikido_firewall.helpers.process_xml import process_xml
99

1010

11-
def process_xml(user_input, root_element):
12-
"""Extracts all attributes from the xml and adds them to context"""
13-
context = get_current_context()
14-
if not isinstance(context.body, str) or user_input != context.body:
15-
return
16-
17-
extracted_xml_attrs = dict()
18-
for el in root_element:
19-
for k, v in el.items():
20-
if not extracted_xml_attrs.get(k):
21-
extracted_xml_attrs[k] = set()
22-
extracted_xml_attrs[k].add(v)
23-
extracted_xml_attrs.update(set(el.items()))
24-
context.xml.append(extracted_xml_attrs)
25-
context.set_as_current_context()
26-
2711

2812
@importhook.on_import("xml.etree.ElementTree")
2913
def on_xml_import(eltree):

0 commit comments

Comments
 (0)