Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88f1110

Browse files
committed
adding a new (for now) hidden switch --test-filter for filtering tests by their name
1 parent fd9acfd commit 88f1110

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/controller/checks.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ def checkSqlInjection(place, parameter, value):
146146
logger.debug(debugMsg)
147147
continue
148148

149+
# Skip tests if title is not included by the given filter
150+
if conf.testFilter and not re.search(conf.testFilter, test.title, re.I):
151+
debugMsg = "skipping test '%s' because " % title
152+
debugMsg += "it's name is not included by the given filter"
153+
logger.debug(debugMsg)
154+
continue
155+
149156
# Skip DBMS-specific test if it does not match either the
150157
# previously identified or the user's provided DBMS (either
151158
# from program switch or from parsed error message(s))
@@ -160,14 +167,12 @@ def checkSqlInjection(place, parameter, value):
160167
debugMsg += "the back-end DBMS identified is "
161168
debugMsg += "%s" % injection.dbms
162169
logger.debug(debugMsg)
163-
164170
continue
165171

166172
if conf.dbms is not None and not intersect(conf.dbms.lower(), [value.lower() for value in arrayizeValue(dbms)]):
167173
debugMsg = "skipping test '%s' because " % title
168174
debugMsg += "the provided DBMS is %s" % conf.dbms
169175
logger.debug(debugMsg)
170-
171176
continue
172177

173178
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):
186191
debugMsg += "that the back-end DBMS could be "
187192
debugMsg += "%s" % Format.getErrorParsedDBMSes()
188193
logger.debug(debugMsg)
189-
190194
continue
191195

192196
# Skip test if it does not match the same SQL injection clause

lib/core/option.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,10 @@ def __cleanupOptions():
13291329
if conf.dbms:
13301330
conf.dbms = conf.dbms.capitalize()
13311331

1332+
if conf.testFilter:
1333+
if not any([char in conf.testFilter for char in ('.', ')', '(', ']', '[')]):
1334+
conf.testFilter = conf.testFilter.replace('*', '.*')
1335+
13321336
if conf.timeSec not in kb.explicitSettings:
13331337
if conf.tor:
13341338
conf.timeSec = 2 * conf.timeSec

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ def cmdLineParser():
591591
parser.add_option("--no-cast", dest="noCast", action="store_true",
592592
help=SUPPRESS_HELP)
593593

594+
parser.add_option("--test-filter", dest="testFilter",
595+
help=SUPPRESS_HELP)
596+
594597
parser.add_option_group(target)
595598
parser.add_option_group(request)
596599
parser.add_option_group(optimization)

0 commit comments

Comments
 (0)