2222"""
2323
2424import codecs
25+ import doctest
2526import logging
2627import os
2728import re
4142from lib .core .data import paths
4243from lib .core .option import init
4344from lib .core .option import __setVerbosity
45+ from lib .core .optiondict import optDict
4446from lib .parse .cmdline import cmdLineParser
4547
4648def 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+
91107def 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 )
0 commit comments