Update for Issue #118

This commit is contained in:
Miroslav Stampar 2012-07-24 15:43:29 +02:00
parent f8c9868cb6
commit 922ea9d1f4
6 changed files with 15 additions and 11 deletions

View File

@ -137,8 +137,8 @@ def checkSqlInjection(place, parameter, value):
continue continue
# Skip tests if title is not included by the given filter # Skip tests if title is not included by the given filter
if conf.tstF: if conf.testFilter:
if not any(re.search(conf.tstF, str(item), re.I) for item in (test.title, test.vector,\ if not any(re.search(conf.testFilter, str(item), re.I) for item in (test.title, test.vector,\
test.details.dbms if "details" in test and "dbms" in test.details else "")): test.details.dbms if "details" in test and "dbms" in test.details else "")):
debugMsg = "skipping test '%s' because " % title debugMsg = "skipping test '%s' because " % title
debugMsg += "its name/vector/dbms is not included by the given filter" debugMsg += "its name/vector/dbms is not included by the given filter"
@ -478,7 +478,7 @@ def checkSqlInjection(place, parameter, value):
injection.dbms = Backend.setDbms(dValue) injection.dbms = Backend.setDbms(dValue)
else: else:
Backend.forceDbms(dValue[0], True) Backend.forceDbms(dValue[0], True)
elif dKey == "dbms_version" and injection.dbms_version is None and not conf.tstF: elif dKey == "dbms_version" and injection.dbms_version is None and not conf.testFilter:
injection.dbms_version = Backend.setVersion(dValue) injection.dbms_version = Backend.setVersion(dValue)
elif dKey == "os" and injection.os is None: elif dKey == "os" and injection.os is None:
injection.os = Backend.setOs(dValue) injection.os = Backend.setOs(dValue)

View File

@ -1330,9 +1330,9 @@ def __cleanupOptions():
if conf.dbms: if conf.dbms:
conf.dbms = conf.dbms.capitalize() conf.dbms = conf.dbms.capitalize()
if conf.tstF: if conf.testFilter:
if not any([char in conf.tstF for char in ('.', ')', '(', ']', '[')]): if not any([char in conf.testFilter for char in ('.', ')', '(', ']', '[')]):
conf.tstF = conf.tstF.replace('*', '.*') conf.testFilter = conf.testFilter.replace('*', '.*')
if conf.timeSec not in kb.explicitSettings: if conf.timeSec not in kb.explicitSettings:
if conf.tor: if conf.tor:

View File

@ -194,7 +194,7 @@ optDict = {
"mobile": "boolean", "mobile": "boolean",
"pageRank": "boolean", "pageRank": "boolean",
"smart": "boolean", "smart": "boolean",
"tstF": "string", "testFilter": "string",
"wizard": "boolean", "wizard": "boolean",
"verbose": "integer" "verbose": "integer"
}, },

View File

@ -519,3 +519,6 @@ BOLD_PATTERNS = ("' injectable", "might be injectable", "' is vulnerable", "is n
# Generic www root directory names # Generic www root directory names
GENERIC_DOC_ROOT_DIRECTORY_NAMES = ("htdocs", "wwwroot", "www") GENERIC_DOC_ROOT_DIRECTORY_NAMES = ("htdocs", "wwwroot", "www")
# Maximum length of a help part containing switch/option name(s)
MAX_HELP_OPTION_LENGTH = 18

View File

@ -18,6 +18,7 @@ from lib.core.data import logger
from lib.core.defaults import defaults from lib.core.defaults import defaults
from lib.core.settings import BASIC_HELP_ITEMS from lib.core.settings import BASIC_HELP_ITEMS
from lib.core.settings import IS_WIN from lib.core.settings import IS_WIN
from lib.core.settings import MAX_HELP_OPTION_LENGTH
from lib.core.settings import VERSION_STRING from lib.core.settings import VERSION_STRING
def cmdLineParser(): def cmdLineParser():
@ -629,7 +630,7 @@ def cmdLineParser():
action="store_true", action="store_true",
help="Conduct through tests only if positive heuristic(s)") help="Conduct through tests only if positive heuristic(s)")
miscellaneous.add_option("--test-filter", dest="tstF", miscellaneous.add_option("--test-filter", dest="testFilter",
help="Select tests by payloads and/or titles (e.g. ROW)") help="Select tests by payloads and/or titles (e.g. ROW)")
miscellaneous.add_option("--wizard", dest="wizard", miscellaneous.add_option("--wizard", dest="wizard",
@ -677,8 +678,8 @@ def cmdLineParser():
# Dirty hack to display longer options without breaking into two lines # Dirty hack to display longer options without breaking into two lines
def _(self, *args): def _(self, *args):
_ = parser.formatter._format_option_strings(*args) _ = parser.formatter._format_option_strings(*args)
if len(_) > 18: if len(_) > MAX_HELP_OPTION_LENGTH:
_ = "%.16s.." % _ _ = ("%%.%ds.." % (MAX_HELP_OPTION_LENGTH - parser.formatter.indent_increment)) % _
return _ return _
parser.formatter._format_option_strings = parser.formatter.format_option_strings parser.formatter._format_option_strings = parser.formatter.format_option_strings

View File

@ -669,7 +669,7 @@ pageRank = False
smart = False smart = False
# Select tests by payloads and/or titles (e.g. ROW) # Select tests by payloads and/or titles (e.g. ROW)
tstF = testFilter =
# Simple wizard interface for beginner users. # Simple wizard interface for beginner users.
# Valid: True or False # Valid: True or False