From eb1cda70656513f1ed401bf60b0b134d8d9bfad8 Mon Sep 17 00:00:00 2001
From: Miroslav Stampar <miroslav.stampar@gmail.com>
Date: Wed, 9 Mar 2011 12:06:32 +0000
Subject: [PATCH] minor refactoring (more consistent)

---
 lib/core/dicts.py              | 66 +++++++++++++++++-----------------
 plugins/generic/enumeration.py | 11 +++---
 2 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/lib/core/dicts.py b/lib/core/dicts.py
index d8c00794b..b7d0a21f1 100644
--- a/lib/core/dicts.py
+++ b/lib/core/dicts.py
@@ -55,40 +55,40 @@ sybaseTypes   = {
                     "20":"image",
                 }
 
-mysqlPrivs    = (
-                    ( 1, "select_priv" ),
-                    ( 2, "insert_priv" ),
-                    ( 3, "update_priv" ),
-                    ( 4, "delete_priv" ),
-                    ( 5, "create_priv" ),
-                    ( 6, "drop_priv" ),
-                    ( 7, "reload_priv" ),
-                    ( 8, "shutdown_priv" ),
-                    ( 9, "process_priv" ),
-                    ( 10, "file_priv" ),
-                    ( 11, "grant_priv" ),
-                    ( 12, "references_priv" ),
-                    ( 13, "index_priv" ),
-                    ( 14, "alter_priv" ),
-                    ( 15, "show_db_priv" ),
-                    ( 16, "super_priv" ),
-                    ( 17, "create_tmp_table_priv" ),
-                    ( 18, "lock_tables_priv" ),
-                    ( 19, "execute_priv" ),
-                    ( 20, "repl_slave_priv" ),
-                    ( 21, "repl_client_priv" ),
-                    ( 22, "create_view_priv" ),
-                    ( 23, "show_view_priv" ),
-                    ( 24, "create_routine_priv" ),
-                    ( 25, "alter_routine_priv" ),
-                    ( 26, "create_user_priv" ),
-                )
+mysqlPrivs    = {
+                    1:"select_priv",
+                    2:"insert_priv",
+                    3:"update_priv",
+                    4:"delete_priv",
+                    5:"create_priv",
+                    6:"drop_priv",
+                    7:"reload_priv",
+                    8:"shutdown_priv",
+                    9:"process_priv",
+                    10:"file_priv",
+                    11:"grant_priv",
+                    12:"references_priv",
+                    13:"index_priv",
+                    14:"alter_priv",
+                    15:"show_db_priv",
+                    16:"super_priv",
+                    17:"create_tmp_table_priv",
+                    18:"lock_tables_priv",
+                    19:"execute_priv",
+                    20:"repl_slave_priv",
+                    21:"repl_client_priv",
+                    22:"create_view_priv",
+                    23:"show_view_priv",
+                    24:"create_routine_priv",
+                    25:"alter_routine_priv",
+                    26:"create_user_priv",
+                }
 
-pgsqlPrivs    = (
-                    ( 1, "createdb" ),
-                    ( 2, "super" ),
-                    ( 3, "catupd" ),
-                )
+pgsqlPrivs    = {
+                    1:"createdb",
+                    2:"super",
+                    3:"catupd",
+                }
 
 firebirdPrivs = {
                     "S": "SELECT",
diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py
index ac3bf7d98..5a5d04022 100644
--- a/plugins/generic/enumeration.py
+++ b/plugins/generic/enumeration.py
@@ -463,9 +463,8 @@ class Enumeration:
                             # In PostgreSQL we get 1 if the privilege is
                             # True, 0 otherwise
                             if Backend.getIdentifiedDbms() == DBMS.PGSQL and getUnicode(privilege).isdigit():
-                                for position, pgsqlPriv in pgsqlPrivs:
-                                    if count == position and int(privilege) == 1:
-                                        privileges.add(pgsqlPriv)
+                                if int(privilege) == 1:
+                                    privileges.add(pgsqlPrivs[count])
 
                             # In MySQL >= 5.0 and Oracle we get the list
                             # of privileges as string
@@ -475,9 +474,9 @@ class Enumeration:
                             # In MySQL < 5.0 we get Y if the privilege is 
                             # True, N otherwise
                             elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
-                                for position, mysqlPriv in mysqlPrivs:
-                                    if count == position and privilege.upper() == "Y":
-                                        privileges.add(mysqlPriv)
+                                if privilege.upper() == "Y":
+                                    privileges.add(mysqlPrivs[count])
+                                        
 
                     if self.__isAdminFromPrivileges(privileges):
                         areAdmins.add(user)