Refactoring of obsolete switch/options cases

This commit is contained in:
Miroslav Stampar 2019-05-27 13:23:50 +02:00
parent 4857f36883
commit a25de423f2
4 changed files with 12 additions and 14 deletions

View File

@ -68,7 +68,7 @@ from lib.core.decorators import cachedmethod
from lib.core.defaults import defaults from lib.core.defaults import defaults
from lib.core.dicts import DBMS_DICT from lib.core.dicts import DBMS_DICT
from lib.core.dicts import DEFAULT_DOC_ROOTS from lib.core.dicts import DEFAULT_DOC_ROOTS
from lib.core.dicts import OLD_OPTIONS from lib.core.dicts import OBSOLETE_OPTIONS
from lib.core.dicts import SQL_STATEMENTS from lib.core.dicts import SQL_STATEMENTS
from lib.core.enums import ADJUST_TIME_DELAY from lib.core.enums import ADJUST_TIME_DELAY
from lib.core.enums import CONTENT_STATUS from lib.core.enums import CONTENT_STATUS
@ -4457,19 +4457,17 @@ def getHostHeader(url):
return retVal return retVal
def checkOldOptions(args): def checkObsoleteOptions(args):
""" """
Checks for deprecated/obsolete options Checks for obsolete options
""" """
for _ in args: for _ in args:
_ = _.split('=')[0].strip() _ = _.split('=')[0].strip()
if _ in OLD_OPTIONS: if _ in OBSOLETE_OPTIONS:
if OLD_OPTIONS[_]: errMsg = "switch/option '%s' is obsolete" % _
errMsg = "switch/option '%s' is deprecated" % _ if OBSOLETE_OPTIONS[_]:
errMsg += " (hint: %s)" % OLD_OPTIONS[_] errMsg += " (hint: %s)" % OBSOLETE_OPTIONS[_]
else:
errMsg = "switch/option '%s' is obsolete" % _
raise SqlmapSyntaxException(errMsg) raise SqlmapSyntaxException(errMsg)
def checkSystemEncoding(): def checkSystemEncoding():

View File

@ -280,7 +280,7 @@ POST_HINT_CONTENT_TYPES = {
POST_HINT.ARRAY_LIKE: "application/x-www-form-urlencoded; charset=utf-8", POST_HINT.ARRAY_LIKE: "application/x-www-form-urlencoded; charset=utf-8",
} }
OLD_OPTIONS = { OBSOLETE_OPTIONS = {
"--replicate": "use '--dump-format=SQLITE' instead", "--replicate": "use '--dump-format=SQLITE' instead",
"--no-unescape": "use '--no-escape' instead", "--no-unescape": "use '--no-escape' instead",
"--binary": "use '--binary-fields' instead", "--binary": "use '--binary-fields' instead",
@ -290,7 +290,7 @@ OLD_OPTIONS = {
"--purge-output": "use '--purge' instead", "--purge-output": "use '--purge' instead",
"--check-payload": None, "--check-payload": None,
"--check-waf": None, "--check-waf": None,
"--identify-waf": None, "--identify-waf": "functionality being done automatically",
"--pickled-options": "use '--api -c ...' instead", "--pickled-options": "use '--api -c ...' instead",
} }

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.5.145" VERSION = "1.3.5.146"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -17,7 +17,7 @@ from optparse import OptionGroup
from optparse import OptionParser from optparse import OptionParser
from optparse import SUPPRESS_HELP from optparse import SUPPRESS_HELP
from lib.core.common import checkOldOptions from lib.core.common import checkObsoleteOptions
from lib.core.common import checkSystemEncoding from lib.core.common import checkSystemEncoding
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import expandMnemonics from lib.core.common import expandMnemonics
@ -789,7 +789,7 @@ def cmdLineParser(argv=None):
_.append(getUnicode(arg, encoding=sys.stdin.encoding)) _.append(getUnicode(arg, encoding=sys.stdin.encoding))
argv = _ argv = _
checkOldOptions(argv) checkObsoleteOptions(argv)
prompt = "--sqlmap-shell" in argv prompt = "--sqlmap-shell" in argv