diff --git a/lib/controller/checks.py b/lib/controller/checks.py index c3cc487a7..fa6aea1f7 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -146,6 +146,13 @@ def checkSqlInjection(place, parameter, value): logger.debug(debugMsg) continue + # Skip tests if title is not included by the given filter + if conf.testFilter and not re.search(conf.testFilter, test.title, re.I): + debugMsg = "skipping test '%s' because " % title + debugMsg += "it's name is not included by the given filter" + logger.debug(debugMsg) + continue + # Skip DBMS-specific test if it does not match either the # previously identified or the user's provided DBMS (either # from program switch or from parsed error message(s)) @@ -160,14 +167,12 @@ def checkSqlInjection(place, parameter, value): debugMsg += "the back-end DBMS identified is " debugMsg += "%s" % injection.dbms logger.debug(debugMsg) - continue if conf.dbms is not None and not intersect(conf.dbms.lower(), [value.lower() for value in arrayizeValue(dbms)]): debugMsg = "skipping test '%s' because " % title debugMsg += "the provided DBMS is %s" % conf.dbms logger.debug(debugMsg) - continue if len(Backend.getErrorParsedDBMSes()) > 0 and not intersect(dbms, Backend.getErrorParsedDBMSes()) and kb.skipOthersDbms is None: @@ -186,7 +191,6 @@ def checkSqlInjection(place, parameter, value): debugMsg += "that the back-end DBMS could be " debugMsg += "%s" % Format.getErrorParsedDBMSes() logger.debug(debugMsg) - continue # Skip test if it does not match the same SQL injection clause diff --git a/lib/core/option.py b/lib/core/option.py index d76ae49a5..ff1207fcc 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1329,6 +1329,10 @@ def __cleanupOptions(): if conf.dbms: conf.dbms = conf.dbms.capitalize() + if conf.testFilter: + if not any([char in conf.testFilter for char in ('.', ')', '(', ']', '[')]): + conf.testFilter = conf.testFilter.replace('*', '.*') + if conf.timeSec not in kb.explicitSettings: if conf.tor: conf.timeSec = 2 * conf.timeSec diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index bb1b03534..7910c0ede 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -591,6 +591,9 @@ def cmdLineParser(): parser.add_option("--no-cast", dest="noCast", action="store_true", help=SUPPRESS_HELP) + parser.add_option("--test-filter", dest="testFilter", + help=SUPPRESS_HELP) + parser.add_option_group(target) parser.add_option_group(request) parser.add_option_group(optimization)