@@ -90,6 +90,7 @@ def _engine(self):
9090 # primitive) - stop cleanly instead of surfacing an internal traceback
9191 raise SqlmapDataException ("Esperanto could not establish reliable data extraction on this target (%s)" % ex )
9292 logger .info ("Esperanto identified the back-end SQL dialect: %s" % (esp .identify ().get ("product" ) or "unknown" ))
93+ logger .debug ("Esperanto dialect: %r" % esp .dialect )
9394 esp ._progress = lambda value : logger .info ("retrieved: %s" % _sanitize (value )) # live feedback (sanitized)
9495 self ._esp = esp
9596 self ._notesLogged = 0
@@ -125,9 +126,6 @@ def _scopeFor(self, table):
125126 self ._scopeCache [table ] = scope
126127 return scope
127128
128- def _db (self ):
129- return self ._scopeDb () or "<current>"
130-
131129 def getFingerprint (self ):
132130 # concise fingerprint only; the version banner is shown for --banner, not
133131 # printed unbidden on every run (and not re-extracted here)
@@ -146,6 +144,8 @@ def getCurrentUser(self):
146144 expr = self ._engine ().dialect .identity .get ("user" )
147145 if expr :
148146 logger .info ("fetching current user" )
147+ elif conf .getCurrentUser :
148+ logger .warning ("Esperanto cannot retrieve the current user on this back-end (no known expression)" )
149149 self ._identCache ["user" ] = self ._safeExtract (expr ) if expr else None
150150 kb .data .currentUser = self ._identCache ["user" ]
151151 return kb .data .currentUser
@@ -156,6 +156,8 @@ def getCurrentDb(self):
156156 expr = self ._engine ().dialect .identity .get ("database" )
157157 if expr :
158158 logger .info ("fetching current database" )
159+ elif conf .getCurrentDb :
160+ logger .warning ("Esperanto cannot retrieve the current database name on this back-end (no known expression)" )
159161 self ._identCache ["db" ] = self ._safeExtract (expr ) if expr else None
160162 kb .data .currentDb = self ._identCache ["db" ]
161163 return kb .data .currentDb
@@ -192,17 +194,18 @@ def getTables(self, bruteForce=None):
192194 # isn't polluted with every schema's tables (e.g. information_schema)
193195 db = conf .db or self .getCurrentDb ()
194196 lim = conf .limitStop or 100
197+ infoMsg = "fetching tables"
198+ if db :
199+ infoMsg += " for database '%s'" % db
200+ logger .info (infoMsg )
195201 names = self ._engine ().enumerate ("table" , limit = lim , schema = db ) or []
196202 if not names and not conf .db and db != "public" :
197203 # current schema empty (PG-family: login-user schema) -> tables usually
198204 # live in 'public'; broaden rather than report nothing
205+ logger .info ("no tables found, trying database 'public'" )
199206 pub = self ._engine ().enumerate ("table" , limit = lim , schema = "public" ) or []
200207 if pub :
201208 names , db = pub , "public"
202- infoMsg = "fetching tables"
203- if db :
204- infoMsg += " for database '%s'" % db
205- logger .info (infoMsg )
206209 kb .data .cachedTables = {db or "<current>" : names }
207210 self ._flushNotes ()
208211 return kb .data .cachedTables
@@ -225,7 +228,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None, dumpMod
225228 def getSchema (self ):
226229 esp = self ._engine ()
227230 # use the EFFECTIVE db that getTables() actually resolved (it may have broadened to
228- # 'public' when the current schema was empty) - recomputing _db() here would miss
231+ # 'public' when the current schema was empty) - recomputing the scope here would miss
229232 # that and look columns up in the wrong (empty) schema.
230233 tabmap = self .getTables ()
231234 effdb , tables = next (iter (tabmap .items ()), ("<current>" , []))
@@ -280,7 +283,7 @@ def dumpTable(self, foundData=None):
280283 values = [("NULL" if row [i ] is None else row [i ]) for row in result ["rows" ]]
281284 width = max ([len (name )] + [len (v ) for v in values ]) if values else len (name )
282285 table_data [name ] = {"length" : width , "values" : values }
283- table_data ["__infos__" ] = {"count" : len (result ["rows" ]), "table" : conf .tbl , "db" : self . _db () }
286+ table_data ["__infos__" ] = {"count" : len (result ["rows" ]), "table" : conf .tbl , "db" : db or "<current>" }
284287 if not result ["complete" ]:
285288 logger .warning ("Esperanto dump of '%s' may be incomplete" % conf .tbl )
286289 if not result .get ("exact" , True ): # coverage may be complete yet content inexact
0 commit comments