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

Function configFileParser

lib/parse/configfile.py:55–98  ·  view source on GitHub ↗

Parse configuration file and save settings into the configuration advanced dictionary.

(configFile)

Source from the content-addressed store, hash-verified

53 logger.debug(debugMsg)
54
55def configFileParser(configFile):
56 """
57 Parse configuration file and save settings into the configuration
58 advanced dictionary.
59 """
60
61 global config
62
63 debugMsg = "parsing configuration file"
64 logger.debug(debugMsg)
65
66 checkFile(configFile)
67 configFP = openFile(configFile, "rb")
68
69 try:
70 config = UnicodeRawConfigParser()
71 if hasattr(config, "read_file"):
72 config.read_file(configFP)
73 else:
74 config.readfp(configFP)
75 except Exception as ex:
76 errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % getSafeExString(ex)
77 raise SqlmapSyntaxException(errMsg)
78
79 if not config.has_section("Target"):
80 errMsg = "missing a mandatory section 'Target' in the configuration file"
81 raise SqlmapMissingMandatoryOptionException(errMsg)
82
83 mandatory = False
84
85 for option in ("direct", "url", "logFile", "bulkFile", "googleDork", "requestFile", "wizard"):
86 if config.has_option("Target", option) and config.get("Target", option) or cmdLineOptions.get(option):
87 mandatory = True
88 break
89
90 if not mandatory:
91 errMsg = "missing a mandatory option in the configuration file "
92 errMsg += "(direct, url, logFile, bulkFile, googleDork, requestFile or wizard)"
93 raise SqlmapMissingMandatoryOptionException(errMsg)
94
95 for family, optionData in optDict.items():
96 for option, datatype in optionData.items():
97 datatype = unArrayizeValue(datatype)
98 configFileProxy(family, option, datatype)

Callers 1

_mergeOptionsFunction · 0.90

Calls 11

checkFileFunction · 0.90
openFileFunction · 0.90
getSafeExStringFunction · 0.90
unArrayizeValueFunction · 0.90
configFileProxyFunction · 0.85
debugMethod · 0.80
itemsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…