@@ -388,19 +388,6 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
388388
389389 conf .db = safeSQLIdentificatorNaming (conf .db )
390390
391- if conf .col :
392- if Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
393- conf .col = conf .col .upper ()
394-
395- colList = conf .col .split ("," )
396- else :
397- colList = []
398-
399- for col in colList :
400- colList [colList .index (col )] = safeSQLIdentificatorNaming (col )
401-
402- colList = filter (None , colList )
403-
404391 if conf .tbl :
405392 if Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
406393 conf .tbl = conf .tbl .upper ()
@@ -440,7 +427,19 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
440427 logger .error (errMsg )
441428 bruteForce = True
442429
443- if bruteForce or colList :
430+ if bruteForce :
431+ if conf .col :
432+ if Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
433+ conf .col = conf .col .upper ()
434+
435+ colList = conf .col .split ("," )
436+ else :
437+ colList = []
438+
439+ for col in colList :
440+ colList [colList .index (col )] = safeSQLIdentificatorNaming (col )
441+
442+ colList = filter (None , colList )
444443 resumeAvailable = False
445444
446445 for tbl in tblList :
@@ -491,37 +490,17 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
491490
492491 return {conf .db : kb .data .cachedColumns [conf .db ]}
493492
494- infoMsg = "fetching columns "
495-
496- if len (colList ) > 0 :
497- if colTuple is None :
498- colConsider , colCondParam = self .likeOrExact ("column" )
499- else :
500- colConsider , colCondParam = colTuple
501- condQueryStr = "%%s%s" % colCondParam
502- condQuery = " AND (%s)" % " OR " .join (condQueryStr % (condition , unsafeSQLIdentificatorNaming (col )) for col in sorted (colList ))
503-
504- if colConsider == "1" :
505- infoMsg += "like '%s' " % ", " .join (unsafeSQLIdentificatorNaming (col ) for col in sorted (colList ))
506- else :
507- infoMsg += "'%s' " % ", " .join (unsafeSQLIdentificatorNaming (col ) for col in sorted (colList ))
508- else :
509- condQuery = ""
510-
511- infoMsg += "for table '%s' " % unsafeSQLIdentificatorNaming (tbl )
493+ infoMsg = "fetching columns for table '%s' " % unsafeSQLIdentificatorNaming (tbl )
512494 infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming (conf .db )
513495 logger .info (infoMsg )
514496
515497 if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
516498 query = rootQuery .inband .query % (unsafeSQLIdentificatorNaming (tbl ), unsafeSQLIdentificatorNaming (conf .db ))
517- query += condQuery
518499 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
519500 query = rootQuery .inband .query % unsafeSQLIdentificatorNaming (tbl .upper ())
520- query += condQuery
521501 elif Backend .isDbms (DBMS .MSSQL ):
522502 query = rootQuery .inband .query % (conf .db , conf .db , conf .db , conf .db ,
523503 conf .db , conf .db , conf .db , unsafeSQLIdentificatorNaming (tbl ).split ("." )[- 1 ])
524- query += condQuery .replace ("[DB]" , conf .db )
525504 elif Backend .isDbms (DBMS .SQLITE ):
526505 query = rootQuery .inband .query % tbl
527506
@@ -560,44 +539,19 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
560539
561540 return {conf .db : kb .data .cachedColumns [conf .db ]}
562541
563- infoMsg = "fetching columns "
564-
565- if len (colList ) > 0 :
566- if colTuple is None :
567- colConsider , colCondParam = self .likeOrExact ("column" )
568- else :
569- colConsider , colCondParam = colTuple
570- condQueryStr = "%%s%s" % colCondParam
571- condQuery = " AND (%s)" % " OR " .join (condQueryStr % (condition , unsafeSQLIdentificatorNaming (col )) for col in sorted (colList ))
572-
573- if colConsider == "1" :
574- infoMsg += "like '%s' " % ", " .join (unsafeSQLIdentificatorNaming (col ) for col in sorted (colList ))
575- else :
576- infoMsg += "'%s' " % ", " .join (unsafeSQLIdentificatorNaming (col ) for col in sorted (colList ))
577- else :
578- condQuery = ""
579-
580- infoMsg += "for table '%s' " % unsafeSQLIdentificatorNaming (tbl )
542+ infoMsg = "fetching columns for table '%s' " % unsafeSQLIdentificatorNaming (tbl )
581543 infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming (conf .db )
582544 logger .info (infoMsg )
583545
584546 if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
585547 query = rootQuery .blind .count % (unsafeSQLIdentificatorNaming (tbl ), unsafeSQLIdentificatorNaming (conf .db ))
586- query += condQuery
587-
588548 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
589549 query = rootQuery .blind .count % unsafeSQLIdentificatorNaming (tbl .upper ())
590- query += condQuery
591-
592550 elif Backend .isDbms (DBMS .MSSQL ):
593551 query = rootQuery .blind .count % (conf .db , conf .db , \
594552 unsafeSQLIdentificatorNaming (tbl ).split ("." )[- 1 ])
595- query += condQuery .replace ("[DB]" , conf .db )
596-
597553 elif Backend .isDbms (DBMS .FIREBIRD ):
598554 query = rootQuery .blind .count % (tbl )
599- query += condQuery
600-
601555 elif Backend .isDbms (DBMS .SQLITE ):
602556 query = rootQuery .blind .query % tbl
603557 value = inject .getValue (query , union = False , error = False )
@@ -620,19 +574,15 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
620574 for index in getLimitRange (count ):
621575 if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
622576 query = rootQuery .blind .query % (unsafeSQLIdentificatorNaming (tbl ), unsafeSQLIdentificatorNaming (conf .db ))
623- query += condQuery
624577 field = None
625578 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
626579 query = rootQuery .blind .query % unsafeSQLIdentificatorNaming (tbl .upper ())
627- query += condQuery
628580 field = None
629581 elif Backend .isDbms (DBMS .MSSQL ):
630582 query = rootQuery .blind .query .replace ("'%s'" , "'%s'" % unsafeSQLIdentificatorNaming (tbl ).split ("." )[- 1 ]).replace ("%s" , conf .db ).replace ("%d" , str (index ))
631- query += condQuery .replace ("[DB]" , conf .db )
632583 field = condition .replace ("[DB]" , conf .db )
633584 elif Backend .isDbms (DBMS .FIREBIRD ):
634585 query = rootQuery .blind .query % (tbl )
635- query += condQuery
636586 field = None
637587
638588 query = agent .limitQuery (index , query , field , field )
0 commit comments