some more refactoring

This commit is contained in:
Miroslav Stampar 2012-01-13 22:00:34 +00:00
parent 8e4b8d345f
commit b2dad63000
5 changed files with 9 additions and 12 deletions

View File

@ -2581,7 +2581,7 @@ def arrayizeValue(value):
itself
"""
if not isinstance(value, (list, tuple, set)):
if not isinstance(value, (list, tuple)):
value = [ value ]
return value
@ -2592,7 +2592,7 @@ def unArrayizeValue(value):
itself
"""
if isinstance(value, (list, tuple, set)):
if isinstance(value, (list, tuple)):
value = value[0] if len(value) > 0 else None
return value

View File

@ -11,6 +11,7 @@ from lib.core.common import Backend
from lib.core.common import isTechniqueAvailable
from lib.core.common import randomStr
from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf
from lib.core.data import kb
@ -77,8 +78,7 @@ class Enumeration(GenericEnumeration):
rootQuery = queries[Backend.getIdentifiedDbms()].tables
for db in dbs:
if isinstance(db, (tuple, list)):
db = db[0] if db else ""
db = unArrayizeValue(db)
randStr = randomStr()
query = rootQuery.inband.query % (("'%s'" % db) if db != "USER" else 'USER')

View File

@ -16,6 +16,7 @@ from lib.core.common import isNoneValue
from lib.core.common import isNumPosStrValue
from lib.core.common import isTechniqueAvailable
from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf
from lib.core.data import kb
@ -88,8 +89,7 @@ class Enumeration(GenericEnumeration):
if any(isTechniqueAvailable(_) for _ in (PAYLOAD.TECHNIQUE.UNION, PAYLOAD.TECHNIQUE.ERROR)) or conf.direct:
for db in dbs:
if isinstance(db, (tuple, list)):
db = db[0] if db else ""
db = unArrayizeValue(db)
if conf.excludeSysDbs and db in self.excludeDbsList:
infoMsg = "skipping system database '%s'" % db

View File

@ -12,6 +12,7 @@ from lib.core.common import filterPairValues
from lib.core.common import isTechniqueAvailable
from lib.core.common import randomStr
from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf
from lib.core.data import kb
@ -138,8 +139,7 @@ class Enumeration(GenericEnumeration):
rootQuery = queries[Backend.getIdentifiedDbms()].tables
for db in dbs:
if isinstance(db, (tuple, list)):
db = db[0] if db else ""
db = unArrayizeValue(db)
for blind in blinds:
randStr = randomStr()

View File

@ -897,10 +897,7 @@ class Enumeration:
value = map(lambda x: (dbs[0], x), value)
for db, table in filterPairValues(value):
if isinstance(db, (tuple, list)):
db = db[0] if db else ""
db = safeSQLIdentificatorNaming(db)
db = safeSQLIdentificatorNaming(unArrayizeValue(db))
table = safeSQLIdentificatorNaming(table, True)
if not kb.data.cachedTables.has_key(db):