From bcf9fc6c6f57d7fda4510a3b79e3f0c1dea6b5c0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 16 Feb 2012 09:32:47 +0000 Subject: [PATCH] minor refactoring --- lib/core/common.py | 6 ++---- lib/core/settings.py | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index a4631cb31..957721ca3 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -61,7 +61,6 @@ from lib.core.convert import unicodeencode from lib.core.convert import urldecode from lib.core.convert import urlencode from lib.core.enums import DBMS -from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import HTTPHEADER from lib.core.enums import HTTPMETHOD from lib.core.enums import OS @@ -84,6 +83,7 @@ from lib.core.settings import DUMMY_USER_INJECTION from lib.core.settings import INFERENCE_UNKNOWN_CHAR from lib.core.settings import UNICODE_ENCODING from lib.core.settings import DBMS_DICT +from lib.core.settings import DBMS_DIRECTORY_DICT from lib.core.settings import DESCRIPTION from lib.core.settings import DUMMY_SQL_INJECTION_CHARS from lib.core.settings import NULL @@ -1813,9 +1813,7 @@ def getSPLSnippet(dbms, name, **variables): Returns content of SPL snippet located inside "procs" directory """ - _ = { DBMS.MSSQL: DBMS_DIRECTORY_NAME.MSSQL, DBMS.PGSQL: DBMS_DIRECTORY_NAME.PGSQL } - - filename = os.path.join(paths.SQLMAP_PROCS_PATH, _[dbms], "%s.txt" % name) + filename = os.path.join(paths.SQLMAP_PROCS_PATH, DBMS_DIRECTORY_DICT[dbms], "%s.txt" % name) checkFile(filename) retVal = readCachedFileContent(filename) diff --git a/lib/core/settings.py b/lib/core/settings.py index 1e4f0a5fe..5a9f4ca30 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -14,6 +14,7 @@ import sys from lib.core.enums import CUSTOM_LOGGING from lib.core.enums import DBMS +from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import PLACE from lib.core.revision import getRevisionNumber @@ -167,6 +168,8 @@ MAXDB_ALIASES = ( "maxdb", "sap maxdb", "sap db" ) SYBASE_ALIASES = ( "sybase", "sybase sql server" ) DB2_ALIASES = ( "db2", "ibm db2", "ibmdb2" ) +DBMS_DIRECTORY_DICT = dict((getattr(DBMS, _), getattr(DBMS_DIRECTORY_NAME, _)) for _ in dir(DBMS) if not _.startswith("_")) + SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES SUPPORTED_OS = ( "linux", "windows" )