Fixing CI/CD errors

This commit is contained in:
Miroslav Štampar
2026-08-12 00:17:57 +02:00
parent b154f084e0
commit d8dbaee0df
4 changed files with 40 additions and 3 deletions
+9 -1
View File
@@ -104,19 +104,27 @@ class TestConfigFileRoundTrip(unittest.TestCase):
handle, path = tempfile.mkstemp(suffix=".ini")
os.close(handle)
# `conf` is the process-wide singleton every other test file shares, so this one saves and
# restores the WHOLE of it. Clearing it (or leaving a key behind) is not a local mistake: an
# emptied conf makes `conf.get("direct")` answer for the rest of the run, which silently turns
# urlencode() into the identity function in test files that run later.
saved = dict(conf)
try:
conf.url = "http://127.0.0.1:1/?id=1"
conf.commonTables = True
conf.tablePrefix = "zzz"
saveConfig(conf, path)
conf.clear()
conf.url, conf.commonTables, conf.tablePrefix = None, False, "overwritten"
configFileParser(path)
self.assertEqual(conf.url, "http://127.0.0.1:1/?id=1")
self.assertTrue(conf.commonTables)
self.assertEqual(conf.tablePrefix, "zzz")
finally:
conf.clear()
conf.update(saved)
os.unlink(path)
+7
View File
@@ -161,9 +161,14 @@ class _TargetTestBase(unittest.TestCase):
class TestRestoreMergedOptions(_TargetTestBase):
def test_restores_each_option_from_mergedOptions(self):
# conf is restored as carefully as mergedOptions: this leaves 'VAL_<opt>' in conf otherwise,
# and conf.string / conf.textOnly are read by the shared page-comparison oracle - a stray
# sentinel there makes every later boolean differential in the process answer false
saved = {}
savedConf = {}
for opt in RESTORE_MERGED_OPTIONS:
saved[opt] = mergedOptions.get(opt)
savedConf[opt] = conf.get(opt)
mergedOptions[opt] = "VAL_%s" % opt
conf[opt] = "tampered"
try:
@@ -174,6 +179,8 @@ class TestRestoreMergedOptions(_TargetTestBase):
finally:
for opt, v in saved.items():
mergedOptions[opt] = v
for opt, v in savedConf.items():
conf[opt] = v
class TestSetAuxOptions(_TargetTestBase):
+23 -1
View File
@@ -278,10 +278,32 @@ class XQueryTierTest(unittest.TestCase):
class SwitchWiringTest(unittest.TestCase):
def test_switch_is_registered_and_mutually_exclusive(self):
from lib.core.data import conf
from lib.core.exception import SqlmapSyntaxException
from lib.core.optiondict import optDict
from lib.core.settings import NONSQL_TECHNIQUES
self.assertEqual(optDict["Techniques"].get("xslt"), "boolean")
self.assertIn('("--xslt", conf.xslt)', _source("lib", "core", "option.py"))
# exclusivity used to be asserted by grepping option.py for a literal `("--xslt", conf.xslt)`
# pair; the switches now come from one registry, so assert the PROPERTY instead of the spelling
self.assertIn("xslt", NONSQL_TECHNIQUES)
saved = dict((_, conf.get(_)) for _ in NONSQL_TECHNIQUES)
try:
from lib.core.option import _basicOptionValidation
for _ in NONSQL_TECHNIQUES:
conf[_] = False
conf.xslt = conf.nosql = True
try:
_basicOptionValidation()
except SqlmapSyntaxException as ex:
self.assertIn("--xslt", str(ex))
else:
self.fail("'--xslt --nosql' was accepted")
finally:
conf.update(saved)
def test_controller_dispatches_the_scan(self):
self.assertIn("from lib.techniques.xslt.inject import xsltScan", _source("lib", "controller", "controller.py"))