minor refactoring

This commit is contained in:
Miroslav Stampar 2012-05-03 22:34:18 +00:00
parent cc28f6db6b
commit 96299d3d5d
3 changed files with 7 additions and 6 deletions

View File

@ -3207,3 +3207,6 @@ def resetCookieJar(cookieJar):
errMsg += "cookies file ('%s')" % msg
raise sqlmapGenericException, errMsg
def prioritySortColumns(columns):
_ = lambda x: x and "id" in x.lower()
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)

View File

@ -19,6 +19,7 @@ from lib.core.common import dataToStdout
from lib.core.common import getUnicode
from lib.core.common import normalizeUnicode
from lib.core.common import openFile
from lib.core.common import prioritySortColumns
from lib.core.common import restoreDumpMarkedChars
from lib.core.common import safeCSValue
from lib.core.common import unsafeSQLIdentificatorNaming
@ -357,9 +358,7 @@ class Dump:
field = 1
fields = len(tableValues) - 1
columns = tableValues.keys()
_ = lambda x: x and "id" in x.lower()
columns = sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
columns = prioritySortColumns(tableValues.keys())
for column in columns:
if column != "__infos__":

View File

@ -26,6 +26,7 @@ from lib.core.common import isTechniqueAvailable
from lib.core.common import parsePasswordHash
from lib.core.common import parseSqliteTableSchema
from lib.core.common import popValue
from lib.core.common import prioritySortColumns
from lib.core.common import pushValue
from lib.core.common import randomStr
from lib.core.common import readInput
@ -1608,9 +1609,7 @@ class Enumeration:
else:
query = rootQuery.inband.query % (colString, conf.db, tbl)
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
_ = lambda x: x and "id" in x.lower()
orderby = sorted(sorted(colList, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)[0]
query = rootQuery.inband.query % (colString, conf.db, tbl, orderby)
query = rootQuery.inband.query % (colString, conf.db, tbl, prioritySortColumns(colList)[0])
else:
query = rootQuery.inband.query % (colString, conf.db, tbl)