From a7366bf7107d2d091dbeef197aa6a5f15fb771ea Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 17 Apr 2011 21:39:00 +0000 Subject: [PATCH] SOAP refactoring --- lib/core/agent.py | 2 +- lib/core/common.py | 2 +- lib/core/convert.py | 3 ++- lib/core/enums.py | 1 + lib/core/target.py | 11 ++++++----- lib/request/connect.py | 11 ++++++++--- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 615b02eab..ce0c8027e 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -98,7 +98,7 @@ class Agent: newValue = self.cleanupPayload(newValue, origValue) - if "POSTxml" in conf.paramDict and place == PLACE.POST: + if place == PLACE.SOAP: root = ET.XML(paramString) iterator = root.getiterator(parameter) diff --git a/lib/core/common.py b/lib/core/common.py index da20d5715..594a31395 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -441,7 +441,7 @@ def paramToDict(place, parameters=None): if conf.parameters.has_key(place) and not parameters: parameters = conf.parameters[place] - if place != "POSTxml": + if place != PLACE.SOAP: parameters = parameters.replace(", ", ",") if place == PLACE.COOKIE: diff --git a/lib/core/convert.py b/lib/core/convert.py index b4873d23b..5bede6455 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -25,6 +25,7 @@ from extra.safe2bin.safe2bin import safecharencode from extra.safe2bin.safe2bin import safechardecode from lib.core.data import conf from lib.core.data import logger +from lib.core.enums import PLACE from lib.core.settings import UNICODE_ENCODING from lib.core.settings import URLENCODE_CHAR_LIMIT from lib.core.settings import URLENCODE_FAILSAFE_CHARS @@ -89,7 +90,7 @@ def urldecode(value, encoding=None): return result def urlencode(value, safe="%&=", convall=False, limit=False): - if conf.direct or "POSTxml" in conf.paramDict: + if conf.direct or PLACE.SOAP in conf.paramDict: return value count = 0 diff --git a/lib/core/enums.py b/lib/core/enums.py index 72feebf69..6562723e6 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -38,6 +38,7 @@ class DBMS: class PLACE: GET = "GET" POST = "POST" + SOAP = "SOAP" URI = "URI" COOKIE = "Cookie" UA = "User-Agent" diff --git a/lib/core/target.py b/lib/core/target.py index f345a88d0..cd776ad32 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -68,17 +68,18 @@ def __setRequestParams(): if conf.data: conf.data = conf.data.replace("\n", " ") - conf.parameters[PLACE.POST] = conf.data # Check if POST data is in xml syntax if re.match("[\n]*<(\?xml |soap\:|ns).*>", conf.data): - conf.paramDict["POSTxml"] = True - __paramDict = paramToDict("POSTxml", conf.data) + place = PLACE.SOAP else: - __paramDict = paramToDict(PLACE.POST, conf.data) + place = PLACE.POST + + conf.parameters[place] = conf.data + __paramDict = paramToDict(place, conf.data) if __paramDict: - conf.paramDict[PLACE.POST] = __paramDict + conf.paramDict[place] = __paramDict __testableParameters = True conf.method = HTTPMETHOD.POST diff --git a/lib/request/connect.py b/lib/request/connect.py index de136e4e8..9171ea813 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -149,9 +149,11 @@ class Connect: url = "%s?%s" % (url, get) requestMsg += "?%s" % get - if conf.method == HTTPMETHOD.POST: - if conf.parameters.has_key(PLACE.POST) and not post: - post = conf.parameters[PLACE.POST] + if conf.method == HTTPMETHOD.POST and not post: + for place in (PLACE.POST, PLACE.SOAP): + if conf.parameters.has_key(place): + post = conf.parameters[place] + break requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str @@ -466,6 +468,9 @@ class Connect: if PLACE.POST in conf.parameters: post = urlencode(conf.parameters[PLACE.POST] if place != PLACE.POST or not value else value) + if PLACE.SOAP in conf.parameters: + post = conf.parameters[PLACE.SOAP] if place != PLACE.SOAP or not value else value + if PLACE.COOKIE in conf.parameters: cookie = conf.parameters[PLACE.COOKIE] if place != PLACE.COOKIE or not value else value