Skip to content

Commit d8dbaee

Browse files
committed
Fixing CI/CD errors
1 parent b154f08 commit d8dbaee

4 files changed

Lines changed: 40 additions & 3 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty import six
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.10.8.28"
23+
VERSION = "1.10.8.29"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

tests/test_configfile.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,27 @@ def test_saved_config_reads_back(self):
104104
handle, path = tempfile.mkstemp(suffix=".ini")
105105
os.close(handle)
106106

107+
# `conf` is the process-wide singleton every other test file shares, so this one saves and
108+
# restores the WHOLE of it. Clearing it (or leaving a key behind) is not a local mistake: an
109+
# emptied conf makes `conf.get("direct")` answer for the rest of the run, which silently turns
110+
# urlencode() into the identity function in test files that run later.
111+
saved = dict(conf)
112+
107113
try:
108114
conf.url = "http://127.0.0.1:1/?id=1"
109115
conf.commonTables = True
110116
conf.tablePrefix = "zzz"
111117
saveConfig(conf, path)
112118

113-
conf.clear()
119+
conf.url, conf.commonTables, conf.tablePrefix = None, False, "overwritten"
114120
configFileParser(path)
115121

116122
self.assertEqual(conf.url, "http://127.0.0.1:1/?id=1")
117123
self.assertTrue(conf.commonTables)
118124
self.assertEqual(conf.tablePrefix, "zzz")
119125
finally:
126+
conf.clear()
127+
conf.update(saved)
120128
os.unlink(path)
121129

122130

tests/test_target_parsing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,14 @@ def _cleanup_hashdb(self, path):
161161

162162
class TestRestoreMergedOptions(_TargetTestBase):
163163
def test_restores_each_option_from_mergedOptions(self):
164+
# conf is restored as carefully as mergedOptions: this leaves 'VAL_<opt>' in conf otherwise,
165+
# and conf.string / conf.textOnly are read by the shared page-comparison oracle - a stray
166+
# sentinel there makes every later boolean differential in the process answer false
164167
saved = {}
168+
savedConf = {}
165169
for opt in RESTORE_MERGED_OPTIONS:
166170
saved[opt] = mergedOptions.get(opt)
171+
savedConf[opt] = conf.get(opt)
167172
mergedOptions[opt] = "VAL_%s" % opt
168173
conf[opt] = "tampered"
169174
try:
@@ -174,6 +179,8 @@ def test_restores_each_option_from_mergedOptions(self):
174179
finally:
175180
for opt, v in saved.items():
176181
mergedOptions[opt] = v
182+
for opt, v in savedConf.items():
183+
conf[opt] = v
177184

178185

179186
class TestSetAuxOptions(_TargetTestBase):

tests/test_xslt.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,32 @@ def test_builders_accept_a_charset_override(self):
278278

279279
class SwitchWiringTest(unittest.TestCase):
280280
def test_switch_is_registered_and_mutually_exclusive(self):
281+
from lib.core.data import conf
282+
from lib.core.exception import SqlmapSyntaxException
281283
from lib.core.optiondict import optDict
284+
from lib.core.settings import NONSQL_TECHNIQUES
285+
282286
self.assertEqual(optDict["Techniques"].get("xslt"), "boolean")
283287

284-
self.assertIn('("--xslt", conf.xslt)', _source("lib", "core", "option.py"))
288+
# exclusivity used to be asserted by grepping option.py for a literal `("--xslt", conf.xslt)`
289+
# pair; the switches now come from one registry, so assert the PROPERTY instead of the spelling
290+
self.assertIn("xslt", NONSQL_TECHNIQUES)
291+
292+
saved = dict((_, conf.get(_)) for _ in NONSQL_TECHNIQUES)
293+
try:
294+
from lib.core.option import _basicOptionValidation
295+
296+
for _ in NONSQL_TECHNIQUES:
297+
conf[_] = False
298+
conf.xslt = conf.nosql = True
299+
try:
300+
_basicOptionValidation()
301+
except SqlmapSyntaxException as ex:
302+
self.assertIn("--xslt", str(ex))
303+
else:
304+
self.fail("'--xslt --nosql' was accepted")
305+
finally:
306+
conf.update(saved)
285307

286308
def test_controller_dispatches_the_scan(self):
287309
self.assertIn("from lib.techniques.xslt.inject import xsltScan", _source("lib", "controller", "controller.py"))

0 commit comments

Comments
 (0)