Some more dict refactorings

This commit is contained in:
Miroslav Stampar 2012-08-21 11:30:01 +02:00
parent 01f481c332
commit 1bcf5a6b88
6 changed files with 25 additions and 25 deletions

View File

@ -19,7 +19,7 @@ from lib.core.settings import MAXDB_ALIASES
from lib.core.settings import SYBASE_ALIASES from lib.core.settings import SYBASE_ALIASES
from lib.core.settings import DB2_ALIASES from lib.core.settings import DB2_ALIASES
firebirdTypes = { FIREBIRD_TYPES = {
"261":"BLOB", "261":"BLOB",
"14":"CHAR", "14":"CHAR",
"40":"CSTRING", "40":"CSTRING",
@ -36,7 +36,7 @@ firebirdTypes = {
"37":"VARCHAR" "37":"VARCHAR"
} }
sybaseTypes = { SYBASE_TYPES = {
"14":"floatn", "14":"floatn",
"8":"float", "8":"float",
"15":"datetimn", "15":"datetimn",
@ -67,7 +67,7 @@ sybaseTypes = {
"20":"image", "20":"image",
} }
mysqlPrivs = { MYSQL_PRIVS = {
1:"select_priv", 1:"select_priv",
2:"insert_priv", 2:"insert_priv",
3:"update_priv", 3:"update_priv",
@ -96,13 +96,13 @@ mysqlPrivs = {
26:"create_user_priv", 26:"create_user_priv",
} }
pgsqlPrivs = { PGSQL_PRIVS = {
1:"createdb", 1:"createdb",
2:"super", 2:"super",
3:"catupd", 3:"catupd",
} }
firebirdPrivs = { FIREBIRD_PRIVS = {
"S": "SELECT", "S": "SELECT",
"I": "INSERT", "I": "INSERT",
"U": "UPDATE", "U": "UPDATE",
@ -111,7 +111,7 @@ firebirdPrivs = {
"E": "EXECUTE" "E": "EXECUTE"
} }
db2Privs = { DB2_PRIVS = {
1: "CONTROLAUTH", 1: "CONTROLAUTH",
2: "ALTERAUTH", 2: "ALTERAUTH",
3: "DELETEAUTH", 3: "DELETEAUTH",
@ -122,7 +122,7 @@ db2Privs = {
8: "UPDATEAUTH" 8: "UPDATEAUTH"
} }
dumpReplacements = {" ": NULL, "": BLANK} DUMP_REPLACEMENTS = {" ": NULL, "": BLANK}
DBMS_DICT = { DBMS_DICT = {
DBMS.MSSQL: (MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"), DBMS.MSSQL: (MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"),

View File

@ -24,7 +24,7 @@ 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
from lib.core.data import logger from lib.core.data import logger
from lib.core.dicts import dumpReplacements from lib.core.dicts import DUMP_REPLACEMENTS
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.exception import sqlmapGenericException from lib.core.exception import sqlmapGenericException
from lib.core.exception import sqlmapValueException from lib.core.exception import sqlmapValueException
@ -444,7 +444,7 @@ class Dump:
value = u'' value = u''
else: else:
value = getUnicode(info["values"][i]) value = getUnicode(info["values"][i])
value = dumpReplacements.get(value, value) value = DUMP_REPLACEMENTS.get(value, value)
values.append(value) values.append(value)
maxlength = int(info["length"]) maxlength = int(info["length"])

View File

@ -15,7 +15,7 @@ from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import queries from lib.core.data import queries
from lib.core.dicts import sybaseTypes from lib.core.dicts import SYBASE_TYPES
from lib.core.enums import PAYLOAD from lib.core.enums import PAYLOAD
from lib.core.exception import sqlmapMissingMandatoryOptionException from lib.core.exception import sqlmapMissingMandatoryOptionException
from lib.core.exception import sqlmapNoneDataException from lib.core.exception import sqlmapNoneDataException

View File

@ -27,7 +27,7 @@ from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import paths from lib.core.data import paths
from lib.core.data import queries from lib.core.data import queries
from lib.core.dicts import firebirdTypes from lib.core.dicts import FIREBIRD_TYPES
from lib.core.enums import CHARSET_TYPE from lib.core.enums import CHARSET_TYPE
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.enums import EXPECTED from lib.core.enums import EXPECTED

View File

@ -27,7 +27,7 @@ from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import queries from lib.core.data import queries
from lib.core.dicts import dumpReplacements from lib.core.dicts import DUMP_REPLACEMENTS
from lib.core.enums import CHARSET_TYPE from lib.core.enums import CHARSET_TYPE
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.enums import EXPECTED from lib.core.enums import EXPECTED
@ -306,7 +306,7 @@ class Entries:
else: else:
colEntry = unArrayizeValue(entry[index]) if index < len(entry) else u'' colEntry = unArrayizeValue(entry[index]) if index < len(entry) else u''
_ = len(dumpReplacements.get(getUnicode(colEntry), getUnicode(colEntry))) _ = len(DUMP_REPLACEMENTS.get(getUnicode(colEntry), getUnicode(colEntry)))
maxLen = max(len(column), _) maxLen = max(len(column), _)
if maxLen > kb.data.dumpedTable[column]["length"]: if maxLen > kb.data.dumpedTable[column]["length"]:
@ -408,7 +408,7 @@ class Entries:
value = NULL if column in emptyColumns else inject.getValue(query, inband=False, error=False, dump=True) value = NULL if column in emptyColumns else inject.getValue(query, inband=False, error=False, dump=True)
_ = dumpReplacements.get(getUnicode(value), getUnicode(value)) _ = DUMP_REPLACEMENTS.get(getUnicode(value), getUnicode(value))
lengths[column] = max(lengths[column], len(_)) lengths[column] = max(lengths[column], len(_))
entries[column].append(value) entries[column].append(value)

View File

@ -26,10 +26,10 @@ from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import queries from lib.core.data import queries
from lib.core.dicts import mysqlPrivs from lib.core.dicts import MYSQL_PRIVS
from lib.core.dicts import pgsqlPrivs from lib.core.dicts import PGSQL_PRIVS
from lib.core.dicts import firebirdPrivs from lib.core.dicts import FIREBIRD_PRIVS
from lib.core.dicts import db2Privs from lib.core.dicts import DB2_PRIVS
from lib.core.enums import CHARSET_TYPE from lib.core.enums import CHARSET_TYPE
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.enums import EXPECTED from lib.core.enums import EXPECTED
@ -408,7 +408,7 @@ class Users:
# True, 0 otherwise # True, 0 otherwise
if Backend.isDbms(DBMS.PGSQL) and getUnicode(privilege).isdigit(): if Backend.isDbms(DBMS.PGSQL) and getUnicode(privilege).isdigit():
if int(privilege) == 1: if int(privilege) == 1:
privileges.add(pgsqlPrivs[count]) privileges.add(PGSQL_PRIVS[count])
# In MySQL >= 5.0 and Oracle we get the list # In MySQL >= 5.0 and Oracle we get the list
# of privileges as string # of privileges as string
@ -419,7 +419,7 @@ class Users:
# True, N otherwise # True, N otherwise
elif Backend.isDbms(DBMS.MYSQL) and not kb.data.has_information_schema: elif Backend.isDbms(DBMS.MYSQL) and not kb.data.has_information_schema:
if privilege.upper() == "Y": if privilege.upper() == "Y":
privileges.add(mysqlPrivs[count]) privileges.add(MYSQL_PRIVS[count])
# In DB2 we get Y or G if the privilege is # In DB2 we get Y or G if the privilege is
# True, N otherwise # True, N otherwise
@ -432,7 +432,7 @@ class Users:
for priv in privs: for priv in privs:
if priv.upper() in ("Y", "G"): if priv.upper() in ("Y", "G"):
for position, db2Priv in db2Privs.items(): for position, db2Priv in DB2_PRIVS.items():
if position == i: if position == i:
privilege += ", " + db2Priv privilege += ", " + db2Priv
@ -529,7 +529,7 @@ class Users:
for priv in privs: for priv in privs:
if priv.isdigit() and int(priv) == 1: if priv.isdigit() and int(priv) == 1:
for position, pgsqlPriv in pgsqlPrivs.items(): for position, pgsqlPriv in PGSQL_PRIVS.items():
if position == i: if position == i:
privileges.add(pgsqlPriv) privileges.add(pgsqlPriv)
@ -549,7 +549,7 @@ class Users:
for priv in privs: for priv in privs:
if priv.upper() == "Y": if priv.upper() == "Y":
for position, mysqlPriv in mysqlPrivs.items(): for position, mysqlPriv in MYSQL_PRIVS.items():
if position == i: if position == i:
privileges.add(mysqlPriv) privileges.add(mysqlPriv)
@ -557,7 +557,7 @@ class Users:
# In Firebird we get one letter for each privilege # In Firebird we get one letter for each privilege
elif Backend.isDbms(DBMS.FIREBIRD): elif Backend.isDbms(DBMS.FIREBIRD):
privileges.add(firebirdPrivs[privilege.strip()]) privileges.add(FIREBIRD_PRIVS[privilege.strip()])
# In DB2 we get Y or G if the privilege is # In DB2 we get Y or G if the privilege is
# True, N otherwise # True, N otherwise
@ -570,7 +570,7 @@ class Users:
for priv in privs: for priv in privs:
if priv.upper() in ("Y", "G"): if priv.upper() in ("Y", "G"):
for position, db2Priv in db2Privs.items(): for position, db2Priv in DB2_PRIVS.items():
if position == i: if position == i:
privilege += ", " + db2Priv privilege += ", " + db2Priv