Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3cd1596

Browse files
committed
more updates
1 parent 1da672e commit 3cd1596

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

lib/core/testing.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"""
2323

2424
import codecs
25+
import doctest
2526
import logging
2627
import os
2728
import re
@@ -41,13 +42,13 @@
4142
from lib.core.data import paths
4243
from lib.core.option import init
4344
from lib.core.option import __setVerbosity
45+
from lib.core.optiondict import optDict
4446
from lib.parse.cmdline import cmdLineParser
4547

4648
def smokeTest():
4749
"""
4850
This will run the basic smoke testing of a program
4951
"""
50-
import doctest
5152
retVal = True
5253
count, length = 0, 0
5354

@@ -88,6 +89,21 @@ def smokeTest():
8889

8990
return retVal
9091

92+
def adjustValueType(tagName, value):
93+
for family in optDict.keys():
94+
for name, type_ in optDict[family].items():
95+
if type(type_) == tuple:
96+
type_ = type_[0]
97+
if tagName == name:
98+
if type_ == "boolean":
99+
value = (value == "True")
100+
elif type_ == "integer":
101+
value = int(value)
102+
elif type_ == "float":
103+
value = float(value)
104+
break
105+
return value
106+
91107
def liveTest():
92108
"""
93109
This will run the test of a program against the live testing environment
@@ -106,7 +122,7 @@ def liveTest():
106122
for item in element:
107123
for child in item.childNodes:
108124
if child.nodeType == child.ELEMENT_NODE and child.hasAttribute("value"):
109-
global_[child.tagName] = child.getAttribute("value")
125+
global_[child.tagName] = adjustValueType(child.tagName, child.getAttribute("value"))
110126

111127
element = livetests.getElementsByTagName("vars")
112128
if element:
@@ -127,7 +143,8 @@ def liveTest():
127143
if case.getElementsByTagName("switches"):
128144
for child in case.getElementsByTagName("switches")[0].childNodes:
129145
if child.nodeType == child.ELEMENT_NODE and child.hasAttribute("value"):
130-
switches[child.tagName] = replaceVars(child.getAttribute("value"), vars_)
146+
value = replaceVars(child.getAttribute("value"), vars_)
147+
switches[child.tagName] = adjustValueType(child.tagName, value)
131148

132149
if case.getElementsByTagName("log"):
133150
for item in case.getElementsByTagName("log")[0].getElementsByTagName("item"):
@@ -163,11 +180,11 @@ def initCase(switches=None):
163180
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
164181
cmdLineOptions = cmdLineParser()
165182
cmdLineOptions.liveTest = cmdLineOptions.smokeTest = False
166-
cmdLineOptions.verbose = 0
167183

168184
if switches:
169185
for key, value in switches.items():
170-
conf[key] = value
186+
if key in cmdLineOptions.__dict__:
187+
cmdLineOptions.__dict__[key] = value
171188

172189
conf.sessionFile = None
173190
init(cmdLineOptions)

xml/livetests.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<root>
44
<global>
55
<ignoreProxy value="True"/>
6+
<verbose value="0"/>
67
</global>
78
<vars>
89
<host value="172.16.104.130"/>

0 commit comments

Comments
 (0)