Parse configuration file and save settings into the configuration advanced dictionary.
(configFile)
| 53 | logger.debug(debugMsg) |
| 54 | |
| 55 | def 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) |
no test coverage detected
searching dependent graphs…