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 itself
""" """
if not isinstance(value, (list, tuple, set)): if not isinstance(value, (list, tuple)):
value = [ value ] value = [ value ]
return value return value
@ -2592,7 +2592,7 @@ def unArrayizeValue(value):
itself itself
""" """
if isinstance(value, (list, tuple, set)): if isinstance(value, (list, tuple)):
value = value[0] if len(value) > 0 else None value = value[0] if len(value) > 0 else None
return value 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 isTechniqueAvailable
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -77,8 +78,7 @@ class Enumeration(GenericEnumeration):
rootQuery = queries[Backend.getIdentifiedDbms()].tables rootQuery = queries[Backend.getIdentifiedDbms()].tables
for db in dbs: for db in dbs:
if isinstance(db, (tuple, list)): db = unArrayizeValue(db)
db = db[0] if db else ""
randStr = randomStr() randStr = randomStr()
query = rootQuery.inband.query % (("'%s'" % db) if db != "USER" else 'USER') 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 isNumPosStrValue
from lib.core.common import isTechniqueAvailable from lib.core.common import isTechniqueAvailable
from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb 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: if any(isTechniqueAvailable(_) for _ in (PAYLOAD.TECHNIQUE.UNION, PAYLOAD.TECHNIQUE.ERROR)) or conf.direct:
for db in dbs: for db in dbs:
if isinstance(db, (tuple, list)): db = unArrayizeValue(db)
db = db[0] if db else ""
if conf.excludeSysDbs and db in self.excludeDbsList: if conf.excludeSysDbs and db in self.excludeDbsList:
infoMsg = "skipping system database '%s'" % db 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 isTechniqueAvailable
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -138,8 +139,7 @@ class Enumeration(GenericEnumeration):
rootQuery = queries[Backend.getIdentifiedDbms()].tables rootQuery = queries[Backend.getIdentifiedDbms()].tables
for db in dbs: for db in dbs:
if isinstance(db, (tuple, list)): db = unArrayizeValue(db)
db = db[0] if db else ""
for blind in blinds: for blind in blinds:
randStr = randomStr() randStr = randomStr()

View File

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