MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / dbTableValues

Method dbTableValues

lib/core/dump.py:398–683  ·  view source on GitHub ↗
(self, tableValues)

Source from the content-addressed store, hash-verified

396 logger.error("unable to retrieve the number of entries for any table")
397
398 def dbTableValues(self, tableValues):
399 replication = None
400 rtable = None
401 dumpFP = None
402 appendToFile = False
403 warnFile = False
404
405 if tableValues is None:
406 return
407
408 db = tableValues["__infos__"]["db"]
409 if not db:
410 db = "All"
411 table = tableValues["__infos__"]["table"]
412
413 if conf.api:
414 self._write(tableValues, content_type=CONTENT_TYPE.DUMP_TABLE)
415
416 try:
417 dumpDbPath = os.path.join(conf.dumpPath, unsafeSQLIdentificatorNaming(db))
418 except UnicodeError:
419 try:
420 dumpDbPath = os.path.join(conf.dumpPath, normalizeUnicode(unsafeSQLIdentificatorNaming(db)))
421 except (UnicodeError, OSError):
422 tempDir = tempfile.mkdtemp(prefix="sqlmapdb")
423 warnMsg = "currently unable to use regular dump directory. "
424 warnMsg += "Using temporary directory '%s' instead" % tempDir
425 logger.warning(warnMsg)
426
427 dumpDbPath = tempDir
428
429 if conf.dumpFormat == DUMP_FORMAT.SQLITE:
430 replication = Replication(os.path.join(conf.dumpPath, "%s.sqlite3" % unsafeSQLIdentificatorNaming(db)))
431 elif conf.dumpFormat in (DUMP_FORMAT.CSV, DUMP_FORMAT.HTML):
432 if not os.path.isdir(dumpDbPath):
433 try:
434 os.makedirs(dumpDbPath)
435 except:
436 warnFile = True
437
438 _ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(db))
439 dumpDbPath = os.path.join(conf.dumpPath, "%s-%s" % (_, hashlib.md5(getBytes(db)).hexdigest()[:8]))
440
441 if not os.path.isdir(dumpDbPath):
442 try:
443 os.makedirs(dumpDbPath)
444 except Exception as ex:
445 tempDir = tempfile.mkdtemp(prefix="sqlmapdb")
446 warnMsg = "unable to create dump directory "
447 warnMsg += "'%s' (%s). " % (dumpDbPath, getSafeExString(ex))
448 warnMsg += "Using temporary directory '%s' instead" % tempDir
449 logger.warning(warnMsg)
450
451 dumpDbPath = tempDir
452
453 dumpFileName = conf.dumpFile or os.path.join(dumpDbPath, re.sub(r'[\\/]', UNSAFE_DUMP_FILEPATH_REPLACEMENT, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())))
454 if not checkFile(dumpFileName, False):
455 try:

Callers 3

dumpTableMethod · 0.80
dumpFoundColumnMethod · 0.80
dumpFoundTablesMethod · 0.80

Calls 15

_writeMethod · 0.95
createTableMethod · 0.95
normalizeUnicodeFunction · 0.90
ReplicationClass · 0.90
getBytesFunction · 0.90
getSafeExStringFunction · 0.90
checkFileFunction · 0.90
openFileFunction · 0.90
prioritySortColumnsFunction · 0.90
dataToDumpFileFunction · 0.90
getConsoleLengthFunction · 0.90

Tested by

no test coverage detected