From b2dad63000a17fc1e7aa52e1ae2b9800497bf130 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 13 Jan 2012 22:00:34 +0000 Subject: [PATCH] some more refactoring --- lib/core/common.py | 4 ++-- plugins/dbms/maxdb/enumeration.py | 4 ++-- plugins/dbms/mssqlserver/enumeration.py | 4 ++-- plugins/dbms/sybase/enumeration.py | 4 ++-- plugins/generic/enumeration.py | 5 +---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 1272fb6ae..48300da3a 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -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 diff --git a/plugins/dbms/maxdb/enumeration.py b/plugins/dbms/maxdb/enumeration.py index 1f2b38130..621fb5293 100644 --- a/plugins/dbms/maxdb/enumeration.py +++ b/plugins/dbms/maxdb/enumeration.py @@ -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') diff --git a/plugins/dbms/mssqlserver/enumeration.py b/plugins/dbms/mssqlserver/enumeration.py index 589d63536..0e4cef3c3 100644 --- a/plugins/dbms/mssqlserver/enumeration.py +++ b/plugins/dbms/mssqlserver/enumeration.py @@ -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 diff --git a/plugins/dbms/sybase/enumeration.py b/plugins/dbms/sybase/enumeration.py index bb69935d0..79d126160 100644 --- a/plugins/dbms/sybase/enumeration.py +++ b/plugins/dbms/sybase/enumeration.py @@ -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() diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py index ec0b8da03..be11e3f24 100644 --- a/plugins/generic/enumeration.py +++ b/plugins/generic/enumeration.py @@ -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):