MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / limitCondition

Method limitCondition

lib/core/agent.py:939–1010  ·  view source on GitHub ↗
(self, expression, dump=False)

Source from the content-addressed store, hash-verified

937 return unionQuery
938
939 def limitCondition(self, expression, dump=False):
940 startLimit = 0
941 stopLimit = None
942 limitCond = True
943
944 topLimit = re.search(r"TOP\s+([\d]+)\s+", expression, re.I)
945
946 limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)
947
948 if hasattr(queries[Backend.getIdentifiedDbms()].limitregexp, "query2"):
949 limitRegExp2 = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query2, expression, re.I)
950 else:
951 limitRegExp2 = None
952
953 if (limitRegExp or limitRegExp2) or (Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE) and topLimit):
954 if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.SQLITE, DBMS.H2):
955 limitGroupStart = queries[Backend.getIdentifiedDbms()].limitgroupstart.query
956 limitGroupStop = queries[Backend.getIdentifiedDbms()].limitgroupstop.query
957
958 if limitGroupStart.isdigit():
959 if limitRegExp:
960 startLimit = int(limitRegExp.group(int(limitGroupStart)))
961 stopLimit = limitRegExp.group(int(limitGroupStop))
962 elif limitRegExp2:
963 startLimit = 0
964 stopLimit = limitRegExp2.group(int(limitGroupStart))
965 limitCond = int(stopLimit) > 1
966
967 elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
968 if limitRegExp:
969 limitGroupStart = queries[Backend.getIdentifiedDbms()].limitgroupstart.query
970 limitGroupStop = queries[Backend.getIdentifiedDbms()].limitgroupstop.query
971
972 if limitGroupStart.isdigit():
973 startLimit = int(limitRegExp.group(int(limitGroupStart)))
974
975 stopLimit = limitRegExp.group(int(limitGroupStop))
976 limitCond = int(stopLimit) > 1
977 elif topLimit:
978 startLimit = 0
979 stopLimit = int(topLimit.group(1))
980 limitCond = int(stopLimit) > 1
981
982 elif Backend.isDbms(DBMS.ORACLE):
983 limitCond = False
984
985 # We assume that only queries NOT containing a "LIMIT #, 1"
986 # (or equivalent depending on the back-end DBMS) can return
987 # multiple entries
988 if limitCond:
989 if (limitRegExp or limitRegExp2) and stopLimit is not None:
990 stopLimit = int(stopLimit)
991
992 # From now on we need only the expression until the " LIMIT "
993 # (or equivalent, depending on the back-end DBMS) word
994 if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.SQLITE):
995 stopLimit += startLimit
996 if expression.find(queries[Backend.getIdentifiedDbms()].limitstring.query) > 0:

Callers 3

_goInferenceProxyFunction · 0.80
unionUseFunction · 0.80
errorUseFunction · 0.80

Calls 6

getIdentifiedDbmsMethod · 0.80
isDbmsMethod · 0.80
findMethod · 0.80
startMethod · 0.80
searchMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected