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

Function saveConfig

lib/core/common.py:3565–3615  ·  view source on GitHub ↗

Saves conf to configuration filename

(conf, filename)

Source from the content-addressed store, hash-verified

3563 logger.debug(debugMsg)
3564
3565def saveConfig(conf, filename):
3566 """
3567 Saves conf to configuration filename
3568 """
3569
3570 config = UnicodeRawConfigParser()
3571 userOpts = {}
3572
3573 for family in optDict:
3574 userOpts[family] = []
3575
3576 for option, value in conf.items():
3577 for family, optionData in optDict.items():
3578 if option in optionData:
3579 userOpts[family].append((option, value, optionData[option]))
3580
3581 for family, optionData in userOpts.items():
3582 config.add_section(family)
3583
3584 optionData.sort()
3585
3586 for option, value, datatype in optionData:
3587 if datatype and isListLike(datatype):
3588 datatype = datatype[0]
3589
3590 if option in IGNORE_SAVE_OPTIONS:
3591 continue
3592
3593 if value is None:
3594 if datatype == OPTION_TYPE.BOOLEAN:
3595 value = "False"
3596 elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT):
3597 if option in defaults:
3598 value = str(defaults[option])
3599 else:
3600 value = '0'
3601 elif datatype == OPTION_TYPE.STRING:
3602 value = ""
3603
3604 if isinstance(value, six.string_types):
3605 value = value.replace("\n", "\n ")
3606
3607 config.set(family, option, value)
3608
3609 with openFile(filename, "wb") as f:
3610 try:
3611 config.write(f)
3612 except IOError as ex:
3613 errMsg = "something went wrong while trying "
3614 errMsg += "to write to the configuration file '%s' ('%s')" % (filename, getSafeExString(ex))
3615 raise SqlmapSystemException(errMsg)
3616
3617def initTechnique(technique=None):
3618 """

Callers 5

_export_configMethod · 0.90
_run_sqlmapMethod · 0.90
engine_startMethod · 0.90
runFunction · 0.90
_saveConfigFunction · 0.90

Calls 10

writeMethod · 0.95
openFileFunction · 0.85
itemsMethod · 0.80
isListLikeFunction · 0.70
getSafeExStringFunction · 0.70
appendMethod · 0.45
replaceMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…