From 2b15ad57c2d6e81a574d511fa939744a230bf072 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 24 Mar 2011 11:47:01 +0000 Subject: [PATCH] basic live tests against 3 major DBMSes --- lib/core/option.py | 8 +-- lib/core/testing.py | 12 +++-- xml/livetests.xml | 129 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 122 insertions(+), 27 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 13de9cfba..c62442f00 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1349,7 +1349,7 @@ def __setVerbosity(): elif conf.verbose >= 5: logger.setLevel(7) -def __mergeOptions(inputOptions): +def __mergeOptions(inputOptions, overrideOptions): """ Merge command line options with configuration file options. @@ -1367,7 +1367,7 @@ def __mergeOptions(inputOptions): for key, value in inputOptionsItems: if key not in conf or (conf[key] is False and value is True) or \ - value not in (None, False): + value not in (None, False) or overrideOptions: conf[key] = value def __setTrafficOutputFP(): @@ -1425,7 +1425,7 @@ def __basicOptionValidation(): errMsg = "value for --time-sec option must be an integer greater than 0" raise sqlmapSyntaxException, errMsg -def init(inputOptions=advancedDict()): +def init(inputOptions=advancedDict(), overrideOptions=False): """ Set attributes into both configuration and knowledge base singletons based upon command line and configuration file options. @@ -1433,7 +1433,7 @@ def init(inputOptions=advancedDict()): __setConfAttributes() __setKnowledgeBaseAttributes() - __mergeOptions(inputOptions) + __mergeOptions(inputOptions, overrideOptions) __setVerbosity() __saveCmdline() __setRequestFromFile() diff --git a/lib/core/testing.py b/lib/core/testing.py index 23a7fef94..75b1ab2b7 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -17,6 +17,7 @@ import tempfile import time from lib.controller.controller import start +from lib.core.common import beep from lib.core.common import clearConsoleLine from lib.core.common import dataToStdout from lib.core.common import getCompiledRegex @@ -74,6 +75,10 @@ def smokeTest(): return retVal def adjustValueType(tagName, value): + # as it's not part of optDict + if tagName == "technique": + value = int(value) + for family in optDict.keys(): for name, type_ in optDict[family].items(): if type(type_) == tuple: @@ -146,6 +151,7 @@ def liveTest(): logger.info("test passed") else: logger.error("test failed") + beep() retVal &= result dataToStdout("\n") @@ -169,7 +175,7 @@ def initCase(switches=None): cmdLineOptions.__dict__[key] = value conf.sessionFile = None - init(cmdLineOptions) + init(cmdLineOptions, True) __setVerbosity() def cleanCase(): @@ -194,7 +200,7 @@ def runCase(switches=None, log=None, session=None): ifile.close() for item in session: if item.startswith("r'") and item.endswith("'"): - if not re.search(item[2:-1], content): + if not re.search(item[2:-1], content, re.DOTALL): retVal = False break elif content.find(item) < 0: @@ -207,7 +213,7 @@ def runCase(switches=None, log=None, session=None): ifile.close() for item in log: if item.startswith("r'") and item.endswith("'"): - if not re.search(item[2:-1], content): + if not re.search(item[2:-1], content, re.DOTALL): retVal = False break elif content.find(item) < 0: diff --git a/xml/livetests.xml b/xml/livetests.xml index b5f6b9f1d..9e28d0927 100644 --- a/xml/livetests.xml +++ b/xml/livetests.xml @@ -3,44 +3,133 @@ + - - - - + - + + + + + + + + + + + + + - + - + + + - + + + + + - + + + + + + - + - - - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - -